ChoiceMonthDialog.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <el-dialog title="设置当前工作月" v-model="formOpen" width="500px" append-to-body draggable @close="cancel">
  3. <el-form ref="dictRef" :model="form" label-width="100" size="small">
  4. <el-form-item label="对账工作月:">
  5. <el-date-picker v-model="dateRange" value-format="YYYY-MM-DD" type="monthrange"
  6. :disabled-date="disabledDateHandler" range-separator="-" format="YYYY年 第MM期" start-placeholder="开始日期"
  7. end-placeholder="结束日期" style="width: 240px;" @change="dateRangeChange" />
  8. </el-form-item>
  9. </el-form>
  10. <template #footer>
  11. <div class="dialog-footer">
  12. <el-button type="primary" icon="Finished" size="small" @click="submitForm">确 定</el-button>
  13. <el-button icon="close" size="small" @click="cancel">取 消</el-button>
  14. </div>
  15. </template>
  16. </el-dialog>
  17. </template>
  18. <script setup>
  19. // 获取所有有委托的月份
  20. import { getMonths } from "@/api/business/entrust/entrustOrder";
  21. import { ref } from "vue";
  22. const { proxy } = getCurrentInstance();
  23. const props = defineProps({
  24. getList: {
  25. type: Function,
  26. default: () => { },
  27. },
  28. setCurrentMonth: {
  29. type: Function,
  30. default: () => { },
  31. },
  32. });
  33. const emit = defineEmits(["confirm"]);
  34. const { getList } = toRefs(props);
  35. const currentMonth = ref(proxy.moment().format("YYYY-MM-01"));
  36. const entrustOrderId = ref(null)
  37. const dateRange = ref([])
  38. const formOpen = ref(false);
  39. const form = ref({});
  40. const months = ref([])
  41. // function submitForm() {
  42. // if (currentMonth.value == null || currentMonth.value == "") {
  43. // proxy.$modal.msgError("请选择月份!");
  44. // return;
  45. // }
  46. // initCurrentMonth({
  47. // year: currentMonth.value.substring(0, 4),
  48. // month: currentMonth.value.substring(5, 7),
  49. // }).then((response) => {
  50. // proxy.$modal.msgSuccess("设置完成!");
  51. // formOpen.value = false;
  52. // setCurrentMonth(proxy.moment().format("YYYY-MM-01"));
  53. // cancel();
  54. // getList.value();
  55. // });
  56. // }
  57. function submitForm() {
  58. if (dateRange.value === null || dateRange.value.length === 0) {
  59. proxy.$modal.msgError('请选择对账月份')
  60. return
  61. }
  62. emit('confirm', dateRange.value)
  63. cancel()
  64. }
  65. function disabledDateHandler(date) {
  66. const d = proxy.moment(date, 'YYYY-MM-DD').format('YYYY-MM-DD')
  67. console.log(d)
  68. // debugger
  69. // 判断是否在months 中
  70. if (months.value.includes(d)) {
  71. return false
  72. } else {
  73. return true
  74. }
  75. }
  76. function dateRangeChange(arg) {
  77. }
  78. function cancel() {
  79. formOpen.value = false;
  80. reset();
  81. }
  82. function open(options) {
  83. formOpen.value = true
  84. entrustOrderId.value = options
  85. getMonths(entrustOrderId.value).then(res => {
  86. months.value = res.data
  87. })
  88. }
  89. function reset() {
  90. dateRange.value = []
  91. }
  92. // 暴露给父组件的方法
  93. defineExpose({
  94. open,
  95. });
  96. </script>