Преглед изворни кода

修复task-2656,调班问题汇总

zhonghuizhen пре 1 година
родитељ
комит
3f7f6550d7

+ 21 - 5
src/views/business/​scheduleManage/adjustVerify.vue

@@ -73,7 +73,8 @@ export default {
                 toolbars: [
                 toolbars: [
                     { key: 'search', icon: 'ibps-icon-search', label: '查询', type: 'primary', hidden: false },
                     { key: 'search', icon: 'ibps-icon-search', label: '查询', type: 'primary', hidden: false },
                     { key: 'massAgree', icon: 'ibps-icon-check', label: '批量同意', type: 'success', hidden: false },
                     { key: 'massAgree', icon: 'ibps-icon-check', label: '批量同意', type: 'success', hidden: false },
-                    { key: 'massDisagree', icon: 'ibps-icon-close', label: '批量不同意', type: 'danger', hidden: false }
+                    { key: 'massDisagree', icon: 'ibps-icon-close', label: '批量不同意', type: 'danger', hidden: false },
+                    { key: 'remove', icon: 'ibps-icon-close', label: '删除', type: 'danger', hidden: !this.isRoleFilter() }
                 ],
                 ],
                 searchForm: {
                 searchForm: {
                     labelWidth: 80,
                     labelWidth: 80,
@@ -404,7 +405,8 @@ export default {
                             id_: data.id
                             id_: data.id
                         },
                         },
                         param: {
                         param: {
-                            status: data.status
+                            status: data.status,
+                            execute_date_: data.status === ('已通过' || '已拒绝') ? this.getTimeNow() : ''
                         }
                         }
                     }]
                     }]
             }
             }
@@ -420,7 +422,8 @@ export default {
                                 party_: userId
                                 party_: userId
                             },
                             },
                             param: {
                             param: {
-                                status_: key === 'agree' ? '已通过' : '已拒绝'
+                                status_: key === 'agree' ? '已通过' : '已拒绝',
+                                audit_time_: data.status === ('已通过' || '已拒绝') ? this.getTimeNow() : ''
                             }
                             }
                         }]
                         }]
                 }
                 }
@@ -468,7 +471,8 @@ export default {
                         id_: el.id
                         id_: el.id
                     },
                     },
                     param: {
                     param: {
-                        status: el.status
+                        status: el.status,
+                        execute_date_: el.status === ('已通过' || '已拒绝') ? this.getTimeNow() : ''
                     }
                     }
                 })
                 })
                 sonuparr.push({
                 sonuparr.push({
@@ -477,7 +481,8 @@ export default {
                         party_: userId
                         party_: userId
                     },
                     },
                     param: {
                     param: {
-                        status_: key === 'massAgree' ? '已通过' : '已拒绝'
+                        status_: key === 'massAgree' ? '已通过' : '已拒绝',
+                        audit_time_: el.status === ('已通过' || '已拒绝') ? this.getTimeNow() : ''
                     }
                     }
                 })
                 })
             })
             })
@@ -552,6 +557,17 @@ export default {
             }
             }
             return Math.ceil((new Date(end) - new Date(start)) / (1000 * 60 * 60 * 24))
             return Math.ceil((new Date(end) - new Date(start)) / (1000 * 60 * 60 * 24))
         },
         },
+        getTimeNow () {
+            const currentDate = new Date()
+            const year = currentDate.getFullYear()
+            const month = (currentDate.getMonth() + 1).toString().padStart(2, '0')
+            const day = currentDate.getDate().toString().padStart(2, '0')
+            const hours = currentDate.getHours().toString().padStart(2, '0')
+            const minutes = currentDate.getMinutes().toString().padStart(2, '0')
+            // 拼接
+            const formattedDateTime = `${year}-${month}-${day} ${hours}:${minutes}`
+            return formattedDateTime
+        },
         /**
         /**
          * 行双击事件
          * 行双击事件
          *
          *

+ 76 - 39
src/views/business/​scheduleManage/components/adjust-edit.vue

@@ -52,6 +52,7 @@
                     filterable
                     filterable
                     clearable
                     clearable
                     :placeholder=" readonly ? '' : '请选择排班'"
                     :placeholder=" readonly ? '' : '请选择排班'"
+                    @clear="clearSchedule"
                     @change="handleScheduleChange"
                     @change="handleScheduleChange"
                 >
                 >
                     <el-option
                     <el-option
@@ -354,6 +355,9 @@ export default {
                 await self.getScheduleList(self)
                 await self.getScheduleList(self)
             } else {
             } else {
                 await self.getScheduleInfo(scheduleId, self)
                 await self.getScheduleInfo(scheduleId, self)
+                if (self.params.action === 'edit') { // 编辑时获取排版列表
+                    await self.getScheduleList(self)
+                }
             }
             }
             if (self.$utils.isEmpty(id)) {
             if (self.$utils.isEmpty(id)) {
                 return
                 return
@@ -421,7 +425,9 @@ export default {
                     label: s.title,
                     label: s.title,
                     value: s.id
                     value: s.id
                 }))
                 }))
-                await self.handleScheduleChange(id)
+                if (this.params.action !== 'view') {
+                    await self.handleScheduleChange(id)
+                }
             })
             })
         },
         },
         async getBlockAdjustRequest (self) { // 获取锁定班次
         async getBlockAdjustRequest (self) { // 获取锁定班次
@@ -430,48 +436,53 @@ export default {
             const res = await self.$common.request('sql', sql) // 获取当前审核状态中的申请单数据
             const res = await self.$common.request('sql', sql) // 获取当前审核状态中的申请单数据
             self.blockList = self.getBlockResult(res.variables.data || [], 'default')
             self.blockList = self.getBlockResult(res.variables.data || [], 'default')
         },
         },
+        clearSchedule () { // 清空操作 清空排班数据
+            this.formData.adjustList = []
+        },
         async handleScheduleChange (val) { // 排班改变刷新数据
         async handleScheduleChange (val) { // 排班改变刷新数据
             const self = this
             const self = this
-            await getStaffSchedule({ id: val }).then((res) => {
-                const schedule = res.data
-                if (self.$utils.isEmpty(schedule)) {
-                    return self.$message.error('数据有误!所选排班不存在!')
-                }
-                const config = schedule.config ? JSON.parse(schedule.config) : {}
-                self.scheduleInfo = {
-                    id: schedule.id,
-                    startDate: schedule.startDate,
-                    endDate: schedule.endDate,
-                    scheduleShift: config.scheduleShift,
-                    scheduleStaff: self.userList.filter(u => config.scheduleStaff.includes(u.userId) && u.userId !== self.userId),
-                    shiftList: schedule.staffScheduleDetailPoList,
-                    executor: JSON.stringify(config.approver) || ''
-                }
-                self.currentShift = self.scheduleInfo.shiftList.find(s => s.userId === self.userId) // 当前排班中我的排版表
-                if (!self.currentShift) {
-                    return self.$message.warning('所选排班中未含有您的信息,请重新选择!')
-                }
-                self.$set(self, 'pickerOptions', {
-                    disableDate: (time) => {
-                        const startDate = new Date(schedule.startDate)
-                        const endDate = new Date(schedule.endDate)
-                        return time < startDate || time > endDate
+            if (val) {
+                await getStaffSchedule({ id: val }).then((res) => {
+                    const schedule = res.data
+                    if (self.$utils.isEmpty(schedule)) {
+                        return self.$message.error('数据有误!所选排班不存在!')
                     }
                     }
-                })
-                if (self.formData.adjustList.length < 1) { // 编辑新增状态初始化
-                    self.formData.adjustList = []
-                }
-                if (this.params.action !== 'view') {
-                    self.getBlockAdjustRequest(self).then(() => { // 获取被锁定的班次
-                        self.beforeDateList = self.initDateOptions(schedule.startDate, self.currentShift)
-                        const filterid = self.$store.getters.userId || ''
-                        if (self.beforeDateList.length > 0 && Object.keys(self.blockList).length > 0) {
-                            // 过滤当前自己被占用的日期和班次
-                            self.beforeDateList = self.filterBlockList(self.blockList, self.beforeDateList, filterid)
+                    const config = schedule.config ? JSON.parse(schedule.config) : {}
+                    self.scheduleInfo = {
+                        id: schedule.id,
+                        startDate: schedule.startDate,
+                        endDate: schedule.endDate,
+                        scheduleShift: config.scheduleShift,
+                        scheduleStaff: self.userList.filter(u => config.scheduleStaff.includes(u.userId) && u.userId !== self.userId),
+                        shiftList: schedule.staffScheduleDetailPoList,
+                        executor: JSON.stringify(config.approver) || ''
+                    }
+                    self.currentShift = self.scheduleInfo.shiftList.find(s => s.userId === self.userId) // 当前排班中我的排版表
+                    if (!self.currentShift) {
+                        return self.$message.warning('所选排班中未含有您的信息,请重新选择!')
+                    }
+                    self.$set(self, 'pickerOptions', {
+                        disableDate: (time) => {
+                            const startDate = new Date(schedule.startDate)
+                            const endDate = new Date(schedule.endDate)
+                            return time < startDate || time > endDate
                         }
                         }
                     })
                     })
-                }
-            })
+                    if (self.formData.adjustList.length < 1) { // 编辑新增状态初始化
+                        self.formData.adjustList = []
+                    }
+                    if (this.params.action !== 'view') {
+                        self.getBlockAdjustRequest(self).then(() => { // 获取被锁定的班次
+                            self.beforeDateList = self.initDateOptions(schedule.startDate, self.currentShift)
+                            const filterid = self.$store.getters.userId || ''
+                            if (self.beforeDateList.length > 0 && Object.keys(self.blockList).length > 0) {
+                                // 过滤当前自己被占用的日期和班次
+                                self.beforeDateList = self.filterBlockList(self.blockList, self.beforeDateList, filterid)
+                            }
+                        })
+                    }
+                })
+            }
 
 
             // this.scheduleList.find(i => i.id === val)
             // this.scheduleList.find(i => i.id === val)
             // this.pickerOptions = {
             // this.pickerOptions = {
@@ -538,12 +549,24 @@ export default {
             })
             })
             return result
             return result
         },
         },
+        /**
+         * 过滤锁定班次,返回被过滤后的排班van数据
+         * @param bList  锁定班次数组
+         * @param dateList 需要过滤的用户数组
+         * @param filterid 需要过滤的用户id
+         */
         filterBlockList (bList, dateList, filterid) { // 根据锁定数据,过滤当前列表
         filterBlockList (bList, dateList, filterid) { // 根据锁定数据,过滤当前列表
             const filterBList = bList[filterid] || []
             const filterBList = bList[filterid] || []
             const { startDate } = this.scheduleInfo
             const { startDate } = this.scheduleInfo
+            // 将日期在今天之前的排班也锁定
+            dateList.forEach((el) => {
+                if (this.equalDate(el.value)) {
+                    el.disabled = true
+                }
+            })
             filterBList.forEach((el) => {
             filterBList.forEach((el) => {
                 const index = this.getDays(startDate, el.value)
                 const index = this.getDays(startDate, el.value)
-                if (dateList[index].value === el.value) {
+                if (dateList[index].value === el.value && dateList[index].disabled !== true) {
                     const arr1 = dateList[index].banci.split(',')
                     const arr1 = dateList[index].banci.split(',')
                     const arr2 = el.banci.split(',')
                     const arr2 = el.banci.split(',')
                     const result = arr2.some(item => arr1.includes(item))
                     const result = arr2.some(item => arr1.includes(item))
@@ -930,6 +953,20 @@ export default {
         handleSelectionChange (v) {
         handleSelectionChange (v) {
             this.selectionIndex = v.map(item => this.formData.adjustList.indexOf(item))
             this.selectionIndex = v.map(item => this.formData.adjustList.indexOf(item))
         },
         },
+        equalDate (dateStr) { // 比较传参是否在今天日期之前,是则返回true
+            // 获取今天的日期,只保留年月日部分
+            const today = new Date()
+            today.setHours(0, 0, 0, 0)
+            // 要比较的日期字符串
+            // 将日期字符串解析为日期对象
+            const dateObj = new Date(dateStr.split('-')[0], parseInt(dateStr.split('-')[1]) - 1, dateStr.split('-')[2])
+            // 进行比较
+            if (dateObj >= today) {
+                return false
+            } else {
+                return true
+            }
+        },
         handleRemove (removeIndex, type) {
         handleRemove (removeIndex, type) {
             const self = this
             const self = this
             let indexList = []
             let indexList = []