diff --git a/src/views/modules/base/calendar.vue b/src/views/modules/base/calendar.vue index 754e4d0..b39a17d 100644 --- a/src/views/modules/base/calendar.vue +++ b/src/views/modules/base/calendar.vue @@ -165,13 +165,20 @@ - + + - + + @@ -226,29 +233,18 @@ align="center" width="30px"> - - - - - - - - - - - - - - - - + v-for="(item,index) in maintainColumnList2" :key="item.columnProp" + :prop="item.columnProp" + :header-align="item.headerAlign" + :align="item.align" + :min-width="item.width" + :vertical-align="'middle'" + :label="item.columnLabel" + :formatter="getSelections"> - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1208,33 +1218,29 @@ export default { this.dataList2 = data.rows }) }, - maintainCalendar() { + async maintainCalendar() { this.getSelectData(); this.maintainCalendarSearchData.calendarId = ''; this.maintainCalendarSearchData.calendarDesc = ''; this.maintainCalendarSearchData.startDate = this.GetDateStr(0); - this.maintainCalendarSearchData.endDate = this.GetDateStr(7); - this.refreshModel(); + this.maintainCalendarSearchData.endDate = this.GetDateStr(6); + await this.refreshModel(); this.maintainCalendarFlag = true; }, - refreshModel() { - this.getAll(); + async refreshModel() { + await this.getAll(); let mainData = { site: this.$store.state.user.site.toString(), calendarId: this.maintainCalendarSearchData.calendarId, calendarDesc: this.maintainCalendarSearchData.calendarDesc, } - getCalendarData(mainData).then(({data}) => { + await getCalendarData(mainData).then(({data}) => { let list = data.rows; if (list.length > 0) { for (let i = 0; i < list.length; i++) { - list[i].val0 = this.maintainCalendarSearchData.datetype; - list[i].val1 = this.maintainCalendarSearchData.datetype; - list[i].val2 = this.maintainCalendarSearchData.datetype; - list[i].val3 = this.maintainCalendarSearchData.datetype; - list[i].val4 = this.maintainCalendarSearchData.datetype; - list[i].val5 = this.maintainCalendarSearchData.datetype; - list[i].val6 = this.maintainCalendarSearchData.datetype; + for ( let f = 0; f < this.maintainColumnList2.length ; f++ ){ + list[i][this.maintainColumnList2[f].columnProp] = this.maintainCalendarSearchData.datetype; + } } } this.dataList3 = list; @@ -1274,8 +1280,33 @@ export default { var d = dd.getDate() < 10 ? "0" + dd.getDate() : dd.getDate();//获取当前几号,不足10补0 return y + "-" + m + "-" + d; }, - //获取区间所有时间并生成动态列 + // 2022-12-05 sxm 改 getAll() { + let days = this.dayjs(this.maintainCalendarSearchData.endDate).diff(this.maintainCalendarSearchData.startDate, 'day'); + if (days < 0 || days > 31) { + this.$message.warning('批量维护工作日历天数为 [1-31] 天, 切开始日期不能晚于结束日期!') + return; + } + let newColumn = [] + this.timeArray = [] + for (let i = 0; i <= days; i++) { + let columnProp = "val" + i; + let columnLabel = this.dayjs(this.maintainCalendarSearchData.startDate).add(i, 'day').format('YYYY-MM-DD') + let column = { + columnProp: columnProp, + headerAlign: 'center', + align: 'left', + width: '100px', + columnLabel: columnLabel, + value: '', + } + newColumn.push(column) + this.timeArray.push(columnLabel) + } + this.maintainColumnList2 = newColumn + }, + //获取区间所有时间并生成动态列 + getAll1() { let begin = this.maintainCalendarSearchData.startDate; var dd = new Date(begin); dd.setDate(dd.getDate() + 6);//获取AddDayCount天后的日期 @@ -1518,17 +1549,17 @@ export default { // 保存修改后的班次信息 updateWorkingCalendar() { this.workingCalendar.excepttime1 = parseInt(this.dayjs(this.workingCalendar.scheduledate + ' ' + this.workingCalendar.exceptexacttime1 + ':00').format('H')) - + parseFloat(this.dayjs(this.workingCalendar.scheduledate + ' ' + this.workingCalendar.exceptexacttime1 + ':00').format('mm'))/60 + + parseFloat(this.dayjs(this.workingCalendar.scheduledate + ' ' + this.workingCalendar.exceptexacttime1 + ':00').format('mm')) / 60 this.workingCalendar.excepttime2 = parseInt(this.dayjs(this.workingCalendar.scheduledate + ' ' + this.workingCalendar.exceptexacttime2 + ':00').format('H')) - + parseFloat(this.dayjs(this.workingCalendar.scheduledate + ' ' + this.workingCalendar.exceptexacttime2 + ':00').format('mm'))/60 + + parseFloat(this.dayjs(this.workingCalendar.scheduledate + ' ' + this.workingCalendar.exceptexacttime2 + ':00').format('mm')) / 60 this.workingCalendar.excepttime3 = parseInt(this.dayjs(this.workingCalendar.scheduledate + ' ' + this.workingCalendar.exceptexacttime3 + ':00').format('H')) - + parseFloat(this.dayjs(this.workingCalendar.scheduledate + ' ' + this.workingCalendar.exceptexacttime3 + ':00').format('mm'))/60 + + parseFloat(this.dayjs(this.workingCalendar.scheduledate + ' ' + this.workingCalendar.exceptexacttime3 + ':00').format('mm')) / 60 this.workingCalendar.excepttime4 = parseInt(this.dayjs(this.workingCalendar.scheduledate + ' ' + this.workingCalendar.exceptexacttime4 + ':00').format('H')) - + parseFloat(this.dayjs(this.workingCalendar.scheduledate + ' ' + this.workingCalendar.exceptexacttime4 + ':00').format('mm'))/60 + + parseFloat(this.dayjs(this.workingCalendar.scheduledate + ' ' + this.workingCalendar.exceptexacttime4 + ':00').format('mm')) / 60 this.workingCalendar.excepttime5 = parseInt(this.dayjs(this.workingCalendar.scheduledate + ' ' + this.workingCalendar.exceptexacttime5 + ':00').format('H')) - + parseFloat(this.dayjs(this.workingCalendar.scheduledate + ' ' + this.workingCalendar.exceptexacttime5 + ':00').format('mm'))/60 + + parseFloat(this.dayjs(this.workingCalendar.scheduledate + ' ' + this.workingCalendar.exceptexacttime5 + ':00').format('mm')) / 60 this.workingCalendar.excepttime6 = parseInt(this.dayjs(this.workingCalendar.scheduledate + ' ' + this.workingCalendar.exceptexacttime6 + ':00').format('H')) - + parseFloat(this.dayjs(this.workingCalendar.scheduledate + ' ' + this.workingCalendar.exceptexacttime6 + ':00').format('mm'))/60 + + parseFloat(this.dayjs(this.workingCalendar.scheduledate + ' ' + this.workingCalendar.exceptexacttime6 + ':00').format('mm')) / 60 updateWorkingCalendar(this.workingCalendar).then(({data}) => { if (data && data.code == 0) { this.$message.success(data.msg)