zhonghuizhen 1 год назад
Родитель
Сommit
8665d6ffaf

+ 2 - 1
src/views/business/​scheduleManage/adjust.vue

@@ -95,7 +95,8 @@ export default {
                     // effect: 'display',
                     // effect: 'display',
                     actions: [
                     actions: [
                         { key: 'edit', label: '编辑', type: 'primary', icon: 'ibps-icon-edit', hidden: function (row) { return row.status !== '已暂存' && row.status !== '已取消' } },
                         { key: 'edit', label: '编辑', type: 'primary', icon: 'ibps-icon-edit', hidden: function (row) { return row.status !== '已暂存' && row.status !== '已取消' } },
-                        { key: 'cancel', label: '取消', type: 'danger', icon: 'ibps-icon-cancel', hidden: function (row) { return row.status !== '待审核' } },
+                        { key: 'cancel', label: '取消', type: 'danger', icon: 'ibps-icon-cancel', hidden: function (row) { return !(row.status === '待审核' && row.createBy === this.$store.getters.userId) } },
+                        { key: 'edit', label: '再次申请', type: 'primary', icon: 'ibps-icon-edit', hidden: function (row) { return row.status !== '已拒绝' } },
                         { key: 'detail', label: '详情', type: 'primary', icon: 'ibps-icon-list-alt' }
                         { key: 'detail', label: '详情', type: 'primary', icon: 'ibps-icon-list-alt' }
                     ]
                     ]
                 }
                 }

+ 32 - 4
src/views/business/​scheduleManage/adjustVerify.vue

@@ -248,10 +248,10 @@ export default {
                 return false
                 return false
             }
             }
             // 当前用户是未审批的审批人 展示
             // 当前用户是未审批的审批人 展示
-            if (row.executor.includes(userId) && row.status !== '待审批') {
+            if (row.executor.includes(userId) && row.status === '待审批') {
                 return false
                 return false
             }
             }
-            return false
+            return true
         },
         },
         /**
         /**
          * 处理分页事件
          * 处理分页事件
@@ -291,10 +291,10 @@ export default {
                     break
                     break
                 */
                 */
                 case 'massAgree':
                 case 'massAgree':
-                    this.handleMassAgree(command, data)
+                    this.handleMassAgree(command, data, selection)
                     break
                     break
                 case 'massDisagree':
                 case 'massDisagree':
-                    this.handleMassAgree(command, data)
+                    this.handleMassAgree(command, data, selection)
                     break
                     break
                 case 'agree':
                 case 'agree':
                     this.handleAgree(command, data)
                     this.handleAgree(command, data)
@@ -509,6 +509,34 @@ export default {
                 this.search()
                 this.search()
             }).catch((e) => { console.error(e) })
             }).catch((e) => { console.error(e) })
         },
         },
+        /**
+         * 批量处理同意/不同意
+         */
+        async handleMassAgree (key, data, selection) {
+            if (!data || data.length < 1) {
+                ActionUtils.warning('请选择数据!')
+                return
+            }
+            let flag = []
+            data = data.filter((row, index) => {
+                if (this.showAgreeBtn(row)) {
+                    flag.push(index + 1)
+                    return false
+                }
+                return true
+            })
+            if (flag.length > 0) {
+                this.$message.warning('所选数据中【序号:' + flag.join(',') + '】您无权限处理或已结束审核审批!')
+                return
+            }
+            if (key === 'massAgree') {
+                this.updateMassData(key, data)
+            } else {
+                this.ismass = true
+                this.currentRejectData = data
+                this.rejectdialogVisible = true
+            }
+        },
         /**
         /**
          * 处理删除
          * 处理删除
          */
          */

+ 126 - 31
src/views/business/​scheduleManage/components/adjust-edit.vue

@@ -154,7 +154,9 @@
                                 :disabled="readonly"
                                 :disabled="readonly"
                                 multiple
                                 multiple
                                 filterable
                                 filterable
+                                multiple-limit="3"
                                 :placeholder=" readonly ? '' : '请选择调班班次'"
                                 :placeholder=" readonly ? '' : '请选择调班班次'"
+                                @change="vaildBanci($event, scope.row, scope.$index)"
                             >
                             >
                                 <el-option
                                 <el-option
                                     v-for="item in scope.row.beforeShiftList"
                                     v-for="item in scope.row.beforeShiftList"
@@ -191,7 +193,6 @@
                         </template>
                         </template>
                     </el-table-column>
                     </el-table-column>
                     <el-table-column
                     <el-table-column
-                        v-if= "reScheduleValue!=='paiban'"
                         prop="afterDate"
                         prop="afterDate"
                         label="目标日期"
                         label="目标日期"
                         width="150"
                         width="150"
@@ -207,9 +208,10 @@
                         <template slot-scope="scope">
                         <template slot-scope="scope">
                             <el-select
                             <el-select
                                 v-model="scope.row.afterDate"
                                 v-model="scope.row.afterDate"
-                                :disabled="readonly || reScheduleValue==='paiban'"
+                                :disabled="readonly"
                                 :placeholder=" readonly ? '' : '请选择目标日期'"
                                 :placeholder=" readonly ? '' : '请选择目标日期'"
                                 @change="handleDateChange($event, scope.$index, 'afterShiftList')"
                                 @change="handleDateChange($event, scope.$index, 'afterShiftList')"
+                                @visible-change="(visible) => {getPaiBanDate(visible,scope.$index)}"
                             >
                             >
                                 <el-option
                                 <el-option
                                     v-for="item in afterDateList"
                                     v-for="item in afterDateList"
@@ -240,8 +242,9 @@
                                 :disabled="readonly"
                                 :disabled="readonly"
                                 multiple
                                 multiple
                                 filterable
                                 filterable
+                                multiple-limit="3"
                                 :placeholder=" readonly ? '' : '请选择目标班次'"
                                 :placeholder=" readonly ? '' : '请选择目标班次'"
-                                @visible-change="(visible) => {getPaiBanBanci(visible,scope.$index)}"
+                                @change="vaildBanci($event, scope.row, scope.$index)"
                             >
                             >
                                 <el-option
                                 <el-option
                                     v-for="item in scope.row.afterShiftList"
                                     v-for="item in scope.row.afterShiftList"
@@ -264,8 +267,6 @@
 <script>
 <script>
 // import {  } from '@/views/constants/schedule'
 // import {  } from '@/views/constants/schedule'
 import { getAdjustment, saveAdjustment, queryStaffSchedule, getStaffSchedule, sendMessage } from '@/api/business/schedule'
 import { getAdjustment, saveAdjustment, queryStaffSchedule, getStaffSchedule, sendMessage } from '@/api/business/schedule'
-import { queryDataById } from '@/api/platform/data/dataTemplate'
-
 export default {
 export default {
     props: {
     props: {
         visible: {
         visible: {
@@ -322,15 +323,6 @@ export default {
             pickerOptions: {}
             pickerOptions: {}
         }
         }
     },
     },
-    computed: {
-        /*
-        beforeShiftList () {
-            return []
-        },
-        afterShiftList () {
-            return []
-        }*/
-    },
     watch: {
     watch: {
         visible: {
         visible: {
             handler (val, oldVal) {
             handler (val, oldVal) {
@@ -364,7 +356,7 @@ export default {
             }
             }
             // 初始化表单数据的方法
             // 初始化表单数据的方法
             const initializeFormData = (data) => {
             const initializeFormData = (data) => {
-                const { scheduleId, reason, executor, executeDate, adjustmentDetailPoList } = data || {}
+                const { scheduleId, reason, status, rejectReason, executor, executeDate, adjustmentDetailPoList } = data || {}
                 this.reScheduleValue = data.type
                 this.reScheduleValue = data.type
                 // this.reScheduleValue = 'paiban'
                 // this.reScheduleValue = 'paiban'
                 self.formData = {
                 self.formData = {
@@ -375,7 +367,7 @@ export default {
                         beforeAdjust: i.beforeAdjust ? i.beforeAdjust.split(',') : [],
                         beforeAdjust: i.beforeAdjust ? i.beforeAdjust.split(',') : [],
                         afterAdjust: i.afterAdjust ? i.afterAdjust.split(',') : [],
                         afterAdjust: i.afterAdjust ? i.afterAdjust.split(',') : [],
                         beforeShiftList: self.handleDateInit(i.beforeDate, index, 'beforeShiftList', i.createBy, i.beforeAdjust),
                         beforeShiftList: self.handleDateInit(i.beforeDate, index, 'beforeShiftList', i.createBy, i.beforeAdjust),
-                        afterShiftList: this.reScheduleValue === 'paiban' ? self.getPaiBanBanci(true, index, i.afterAdjust.split(',')) : self.handleDateInit(i.afterDate, index, 'afterShiftList', i.party, i.afterAdjust)
+                        afterShiftList: self.handleDateInit(i.afterDate, index, 'afterShiftList', i.party, i.afterAdjust)
                     }))
                     }))
                 }
                 }
                 console.log('formData', self.formData)
                 console.log('formData', self.formData)
@@ -426,7 +418,7 @@ export default {
                     value: s.id
                     value: s.id
                 }))
                 }))
                 if (this.params.action !== 'view') {
                 if (this.params.action !== 'view') {
-                    await self.handleScheduleChange(id)
+                    self.handleScheduleChange(id)
                 }
                 }
             })
             })
         },
         },
@@ -494,7 +486,82 @@ export default {
             //     }
             //     }
             // }
             // }
         },
         },
-        rowValidate (row, index) {
+        /** 校验数据中有无日期过期或班次被锁定数据,有则清空该条数据
+         *
+         * @param dateList 已经过滤的数据
+         */
+        vaildExpireData (dateList) {
+            this.formData.adjustList.forEach((adjustItem) => {
+                const beforeDateObj = dateList.find((date) => date.value === adjustItem.beforeDate)
+                const afterDateObj = dateList.find((date) => date.value === adjustItem.afterDate)
+                if (beforeDateObj && beforeDateObj.disabled) {
+                    this.$message.warning('调班日期【' + adjustItem.beforeDate + '】已过期或已被申请,请重新选择')
+                    adjustItem.beforeDate = ''
+                    adjustItem.beforeAdjust = []
+                } else if (afterDateObj && afterDateObj.disabled) {
+                    this.$message.warning('目标日期【' + adjustItem.afterDate + '】已过期或已被申请,请重新选择')
+                    adjustItem.afterDate = ''
+                    adjustItem.afterAdjust = []
+                } else {
+                    // 校验beforeAdjust中的数据是否在对应dateList数据的banci中
+                    adjustItem.beforeAdjust.forEach((banciValue) => {
+                        const beforeDateMatch = dateList.find((date) => date.value === adjustItem.beforeDate && date.banci.includes(banciValue))
+                        if (beforeDateMatch) {
+                            this.$message.warning('调班班次【' + banciValue + '】已被申请,请重新选择')
+                            adjustItem.beforeAdjust = adjustItem.beforeAdjust.filter(item => item !== banciValue)
+                        }
+                    })
+
+                    // 校验afterAdjust中的数据是否在对应dateList数据的banci中
+                    adjustItem.afterAdjust.forEach((banciValue) => {
+                        const afterDateMatch = dateList.find((date) => date.value === adjustItem.afterDate && date.banci.includes(banciValue))
+                        if (afterDateMatch) {
+                            this.$message.warning('目标班次【' + banciValue + '】已被申请,请重新选择')
+                            adjustItem.afterAdjust = adjustItem.afterAdjust.filter(item => item !== banciValue)
+                        }
+                    })
+                }
+            })
+        },
+        vaildBanci (chooseArr, row) {
+            // 校验调班那天是否有重复班次
+            if (this.reScheduleValue === 'diaoban' && chooseArr.length > 0) {
+                const duplicateElements = [] // 用户重复班次数组
+                row.afterAdjust.some(element => {
+                    if (row.beforeShiftList.find(item => item.alias === element)) {
+                        duplicateElements.push(element)
+                    }
+                })
+                if (duplicateElements.length > 0) { // 用户当天有目标班次 不能换
+                    const val = duplicateElements.map(el => {
+                        const nameObj = this.scheduleInfo.scheduleShift.find(obj => obj.alias === el)
+                        return nameObj?.name
+                    }).filter(Boolean).join(', ')
+                    // 把该重复元素从目标班次删除
+                    row.afterAdjust = row.afterAdjust.filter(item => !duplicateElements.includes(item))
+                    this.$message.warning(row.afterDate + '您已有【' + val + '】班次,不能作为目标班次!')
+                    return true
+                }
+                const partyElements = []// 目标人员重复班次数组
+                row.beforeAdjust.some(element => {
+                    if (row.afterShiftList.find(item => item.alias === element)) {
+                        partyElements.push(element)
+                    }
+                    return false
+                })
+                if (partyElements.length > 0) { // 目标人员有重复班次 也不能换
+                    const val = partyElements.map(el => {
+                        const nameObj = this.scheduleInfo.scheduleShift.find(obj => obj.alias === el)
+                        return nameObj?.name
+                    }).filter(Boolean).join(', ')
+                    // 把该重复元素从目标班次删除
+                    row.beforeAdjust = row.beforeAdjust.filter(item => !partyElements.includes(item))
+                    this.$message.warning(row.afterDate + '目标人员已有【' + val + '】班次,不能作为调班班次!')
+                    return true
+                }
+            }
+        },
+        rowValidate (row, index) { // 行必填检验
             if (!row.beforeDate) {
             if (!row.beforeDate) {
                 this.$message.warning(`第${index}行` + '调班日期未选择!')
                 this.$message.warning(`第${index}行` + '调班日期未选择!')
                 return true
                 return true
@@ -503,7 +570,7 @@ export default {
                 this.$message.warning(`第${index}行` + '调班班次未选择!')
                 this.$message.warning(`第${index}行` + '调班班次未选择!')
                 return true
                 return true
             }
             }
-            if (this.reScheduleValue === 'diaoban') { // 排班变更目标日期目标人员不用填
+            if (this.reScheduleValue === 'diaoban') { // 排班变更目标人员不用填
                 if (!row.afterDate) {
                 if (!row.afterDate) {
                     this.$message.warning(`第${index}行` + '目标人员未选择!')
                     this.$message.warning(`第${index}行` + '目标人员未选择!')
                     return true
                     return true
@@ -512,10 +579,10 @@ export default {
                     this.$message.warning(`第${index}行` + '目标日期未选择!')
                     this.$message.warning(`第${index}行` + '目标日期未选择!')
                     return true
                     return true
                 }
                 }
-            }
-            if (row.afterAdjust.length < 1) {
-                this.$message.warning(`第${index}行` + '目标班次未选择!')
-                return true
+                if (row.afterAdjust.length < 1) {
+                    this.$message.warning(`第${index}行` + '目标班次未选择!')
+                    return true
+                }
             }
             }
         },
         },
         initDateOptions (startDateStr, obj) { // 初始化日期下拉数据
         initDateOptions (startDateStr, obj) { // 初始化日期下拉数据
@@ -588,6 +655,7 @@ export default {
                 }
                 }
             })
             })
             console.log('已过滤日期班次:', dateList)
             console.log('已过滤日期班次:', dateList)
+            this.vaildExpireData(dateList) // 检验有无过期数据
             return dateList
             return dateList
         },
         },
         getBlockResult (data, type) {
         getBlockResult (data, type) {
@@ -676,6 +744,12 @@ export default {
                 // 获取所选日期对应数据
                 // 获取所选日期对应数据
                 let selectObj = this.beforeDateList.filter(item => item.value === val) // 调班人自己的数据
                 let selectObj = this.beforeDateList.filter(item => item.value === val) // 调班人自己的数据
                 if (type === 'afterShiftList') {
                 if (type === 'afterShiftList') {
+                    if (this.reScheduleValue === 'paiban') { // 排班变更模式下 日期 班次初始化为全部日期班次
+                        this.afterDateList = this.getDateArray(this.scheduleInfo.startDate, this.scheduleInfo.endDate)
+                        const shiftArr = this.scheduleInfo.scheduleShift
+                        shiftArr.push({})
+                        return shiftArr
+                    }
                     this.handlePartyChange(userid, this.formData.adjustList[index], index, 'init')
                     this.handlePartyChange(userid, this.formData.adjustList[index], index, 'init')
                     selectObj = this.afterDateList.filter(item => item.value === val) // 目标人员数据
                     selectObj = this.afterDateList.filter(item => item.value === val) // 目标人员数据
                 }
                 }
@@ -724,15 +798,12 @@ export default {
                 this.handleDateChange(row.afterDate, index, 'afterShiftList')
                 this.handleDateChange(row.afterDate, index, 'afterShiftList')
             }
             }
         },
         },
-        getPaiBanBanci (visible, index, afterAdjust) { // 排班变更方式,班次全部可选,目标人员和日期不可选
+        getPaiBanDate (visible, index, afterAdjust) { // 排班变更方式,日期全部可选,目标人员不可选
             if (this.reScheduleValue === 'paiban' && visible === true) {
             if (this.reScheduleValue === 'paiban' && visible === true) {
-                this.formData.adjustList[index]['afterShiftList'] = this.scheduleInfo.scheduleShift
-                if (afterAdjust) {
-                    this.formData.adjustList[index]['afterAdjust'] = afterAdjust
-                    return this.formData.adjustList[index]['afterShiftList']
-                }
-            } else {
-                return
+                const startDate = this.scheduleInfo.startDate
+                const endDate = this.scheduleInfo.endDate
+                const datearr = this.getDateArray(startDate, endDate)
+                this.afterDateList = datearr
             }
             }
         },
         },
         handleFormAction ({ key }) {
         handleFormAction ({ key }) {
@@ -953,6 +1024,30 @@ 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))
         },
         },
+        /** 返回一个从开始日期到结束日期的日期数组(今天之前的不可用)
+         * @param startDate
+         * @param endDate
+         */
+        getDateArray (startDate, endDate) {
+            const dateArray = []
+            const start = new Date(startDate)
+            const end = new Date(endDate)
+            const currentDateNow = new Date() // 获取当前日期
+            const aliasList = this.scheduleInfo.scheduleShift.map(item => item.alias)
+            const banci = aliasList.join(',')
+            for (let currentDate = start; currentDate <= end; currentDate.setDate(currentDate.getDate() + 1)) {
+                const dateObj = {
+                    banci: banci + ',休息',
+                    disabled: currentDate < currentDateNow, // 修改此处判断,若日期小于当前日期则设为disabled:true,
+                    key: `d${currentDate.getDate()}`,
+                    label: currentDate.toISOString().split('T')[0],
+                    value: currentDate.toISOString().split('T')[0]
+                }
+                dateArray.push(dateObj)
+            }
+
+            return dateArray
+        },
         equalDate (dateStr) { // 比较传参是否在今天日期之前,是则返回true
         equalDate (dateStr) { // 比较传参是否在今天日期之前,是则返回true
             // 获取今天的日期,只保留年月日部分
             // 获取今天的日期,只保留年月日部分
             const today = new Date()
             const today = new Date()