Преглед на файлове

修复日志填报的日期选择bug

iZaiZaiA преди 2 години
родител
ревизия
a275122f69
променени са 3 файла, в които са добавени 46 реда и са изтрити 16 реда
  1. 11 2
      src/views/data-fill/query.vue
  2. 29 10
      src/views/ledger/components/dateCalendar/index.vue
  3. 6 4
      src/views/ledger/components/table-form.vue

+ 11 - 2
src/views/data-fill/query.vue

@@ -145,8 +145,17 @@
         </div>
 
         <!--批量上报审批-->
-        <HcReportModal  title="批量上报审批" url="informationWriteQuery/batchTask" :show="showReportModal" :projectId="projectId" :contractId="contractId"
-                        :taskName="reportTaskName" :ids="reportIds" :addition="reportAddition" @hide="showReportModal = false" @finish="showReportFinish"/>
+        <HcReportModal  title="批量上报审批"
+                        url="informationWriteQuery/batchTask"
+                        :show="showReportModal"
+                        :projectId="projectId"
+                        :contractId="contractId"
+                        :taskName="reportTaskName"
+                        :ids="reportIds"
+                        :addition="reportAddition"
+                        @hide="showReportModal = false"
+                        @finish="showReportFinish"
+        />
     </div>
 </template>
 

+ 29 - 10
src/views/ledger/components/dateCalendar/index.vue

@@ -30,12 +30,17 @@
 import {nextTick, watch, ref} from "vue";
 import dayjs from "dayjs"
 import 'dayjs/locale/zh-cn'
+import {getObjNullValue} from "vue-utils-plus";
 dayjs.locale('zh-cn')
 const props = defineProps({
     ui: {
         type: String,
         default: ''
     },
+    recordDate: {
+        type: Object,
+        default: () => ({})
+    },
     dateData: {
         type: Array,
         default: () => ([])
@@ -56,9 +61,12 @@ const datesDay = ref([])        //日期数据
 const emit = defineEmits(['choice-date'])
 
 //监听
-watch(() => props.dateData, (dateData) => {
+watch(() => [
+    props.dateData,
+    props.recordDate,
+], ([dateData,recordDate]) => {
     selectedDatas.value = dateData
-    setCurDateData(dateData)
+    setCurDateData(dateData, recordDate)
 })
 
 //渲染完成
@@ -81,11 +89,11 @@ nextTick(()=> {
     }
     toPicker.value = toDayJs.format('YYYY-MM')
     emit('choice-date', isDayDateFormat(toDays.value))
-    setCurDateData(props.dateData)
+    setCurDateData(props.dateData, props.recordDate)
 })
 
 //处理设置的日期
-const setCurDateData = (dateData) => {
+const setCurDateData = (dateData, recordDate) => {
     let curData = [];
     for (let i = 0; i < dateData.length; i++) {
         let toDate = dayjs(dateData[i]).format("YYYY-MM-DD");
@@ -97,11 +105,16 @@ const setCurDateData = (dateData) => {
         })
     }
     curDateData.value = curData;
-    getDatesDay()
+    //判断是否选择了日期
+    if (getObjNullValue(recordDate)) {
+        getDatesDay(recordDate.year, recordDate.month)
+    } else {
+        getDatesDay()
+    }
 }
 
 //获取日期
-const getDatesDay = (year,month) => {
+const getDatesDay = (year, month) => {
     if (year && month) {
         let toDate = dayjs(year + '-' + month).format("YYYY-MM-DD");            //格式化一下先
         let days = dayjs(toDate).daysInMonth(); //天数
@@ -169,7 +182,10 @@ const prevMonthClick = () => {
     } else {
         months = month - 1;
     }
-    selectedDate.value = {year: years, month: months}
+    selectedDate.value = {
+        year: years,
+        month: months
+    }
     getDatesDay(years,months)
 }
 //下一月
@@ -183,7 +199,10 @@ const nextMonthClick = () => {
         years = year;
         months = month + 1;
     }
-    selectedDate.value = {year: years, month: months}
+    selectedDate.value = {
+        year: years,
+        month: months
+    }
     getDatesDay(years,months)
 }
 
@@ -192,7 +211,7 @@ const datesDayClick = (item) => {
     if (item.type !== 'excluded') {
         let {year,month} = selectedDate.value
         choiceDate.value = {year: year, month: month, date: item.key}
-        getDatesDay(year,month)
+        getDatesDay(year, month)
         backChoiceDate()
     }
 }
@@ -236,7 +255,7 @@ const isDayDateFormat = ({year, month, date}) => {
     }
     const choice = today.year + today.month + today.date
     const choices = `${today.year}-${today.month}-${today.date}`
-    return {date: today, choice, choices}
+    return {date: today, choice, choices, dates: {year, month, date}}
 }
 
 const zpadStart = (val, leng, pad) => {

+ 6 - 4
src/views/ledger/components/table-form.vue

@@ -25,7 +25,7 @@
                 </el-scrollbar>
             </div>
             <div class="hc-right-pian-box hc-flex-column">
-                <DateCalendar :dateData="dateData" @choice-date="dateCalendarChoice"/>
+                <DateCalendar :recordDate="recordDates" :dateData="dateData" @choice-date="dateCalendarChoice"/>
                 <el-alert title="蓝色代表当天已填写过日志" type="warning" show-icon/>
                 <div class="my-4" v-if="menuItem?.nodeType === 7 || menuItem?.nodeType === 11">
                     <el-button type="primary" hc-btn @click="showProcessModal">
@@ -176,17 +176,19 @@ const getQueryData = () => {
     const {excelId} = menuItem.value
     excelIdVal.value = excelId > 0 ? excelId + '' : ''
     const date = recordDate.value, time = recordTime.value
-    if (date && time) {
+    if (!getObjNullValue(date) && time) {
         getExcelBusinessData(date,time)
     }
 }
 
 //日期日历回调
 const recordTime = ref('')
-const recordDate = ref('')
-const dateCalendarChoice = ({date, choices}) => {
+const recordDate = ref({})
+const recordDates = ref({})
+const dateCalendarChoice = ({date, choices, dates}) => {
     recordTime.value = choices
     recordDate.value = date
+    recordDates.value = dates
     getExcelBusinessData(date,choices)
 }