Procházet zdrojové kódy

调班申请修改为可以申请当天还没到打卡时间的班次

zhonghuizhen před 7 měsíci
rodič
revize
79b41fb721

+ 32 - 2
src/views/business/​scheduleManage/components/adjust-edit.vue

@@ -575,6 +575,7 @@ export default {
         params: [scheduleId]
         params: [scheduleId]
       }) // 获取当前审核状态中的申请单数据
       }) // 获取当前审核状态中的申请单数据
       self.blockList = self.getBlockResult(res.variables.data || [], 'default')
       self.blockList = self.getBlockResult(res.variables.data || [], 'default')
+      
       // 清除列表中被申请数据
       // 清除列表中被申请数据
       this.vaildExpireData(self.blockList)
       this.vaildExpireData(self.blockList)
     },
     },
@@ -624,6 +625,7 @@ export default {
             // 编辑新增状态初始化
             // 编辑新增状态初始化
             self.formData.adjustList = []
             self.formData.adjustList = []
           }
           }
+          
           if (this.params.action !== 'view') {
           if (this.params.action !== 'view') {
             self.getBlockAdjustRequest(self).then(() => {
             self.getBlockAdjustRequest(self).then(() => {
               // 获取被锁定的班次
               // 获取被锁定的班次
@@ -639,12 +641,14 @@ export default {
                 self.beforeDateList.length > 0 &&
                 self.beforeDateList.length > 0 &&
                 Object.keys(self.blockList).length > 0
                 Object.keys(self.blockList).length > 0
               ) {
               ) {
+                
                 // 过滤当前自己被占用的日期和班次
                 // 过滤当前自己被占用的日期和班次
                 self.beforeDateList = self.filterBlockList(
                 self.beforeDateList = self.filterBlockList(
                   self.blockList,
                   self.blockList,
                   self.beforeDateList,
                   self.beforeDateList,
                   filterid
                   filterid
                 )
                 )
+
               }
               }
             })
             })
           }
           }
@@ -946,11 +950,34 @@ export default {
     },
     },
     /*过滤今天之前的日期不可选 */
     /*过滤今天之前的日期不可选 */
     filterTodayList(dateList) {
     filterTodayList(dateList) {
+      
        // 将日期在今天之前的排班也锁定
        // 将日期在今天之前的排班也锁定
        dateList.forEach((el) => {
        dateList.forEach((el) => {
-           if (this.equalDate(el.value)) {
+          const today = this.$common.getDateNow()
+          const scheduleShift = this.scheduleInfo.scheduleShift // 班次时间
+          let pastBanCiArr = [] // 已到打卡时间的班次
+          scheduleShift.forEach((shift)=>{
+            const startTime = shift.dateRange[0].startTime
+            const now = this.$common.getDateNow(16).split(' ')[1]
+            if(startTime < now ){ //打卡时间已开始的班次,不允许再调班
+              pastBanCiArr.push(shift.alias)
+            }
+          })
+           if (this.equalDate(el.value) && el.value !== today) {
                el.disabled = true
                el.disabled = true
+           }else if(el.value === today){
+            let newBanCiArr = []
+              el.banci.split(',').forEach((item)=>{
+                if(!pastBanCiArr.includes(item)){ // 过滤掉已到打卡时间的班次
+                  newBanCiArr.push(item)
+                }
+              })
+              el.banci = newBanCiArr.join(',')
+              if(el.banci === ''){ // 如果今天的班次都已到打卡时间,则禁用今天
+                el.disabled = true
+              }
            }
            }
+
       })
       })
       return dateList
       return dateList
     },
     },
@@ -971,6 +998,7 @@ export default {
           dateList[index].value === el.value &&
           dateList[index].value === el.value &&
           dateList[index].disabled !== true
           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))
@@ -978,7 +1006,7 @@ export default {
             // 包含被锁定班次
             // 包含被锁定班次
             // dateList[index].banci = dateList[index].banci.replace(el.banci, '')
             // dateList[index].banci = dateList[index].banci.replace(el.banci, '')
             arr2.forEach((item) => {
             arr2.forEach((item) => {
-              // 替换班次为空
+              // 替换班次为空
               const index = arr1.indexOf(item)
               const index = arr1.indexOf(item)
               if (index !== -1) {
               if (index !== -1) {
                 arr1[index] = ''
                 arr1[index] = ''
@@ -994,6 +1022,7 @@ export default {
           }
           }
         }
         }
       })
       })
+      
       console.log('已过滤日期班次:', dateList)
       console.log('已过滤日期班次:', dateList)
       return dateList
       return dateList
     },
     },
@@ -1170,6 +1199,7 @@ export default {
         Object.keys(this.blockList).length > 0 &&
         Object.keys(this.blockList).length > 0 &&
         this.params.action !== 'view'
         this.params.action !== 'view'
       ) {
       ) {
+        
         // 过滤当前目标人被占用的日期和班次
         // 过滤当前目标人被占用的日期和班次
         this.afterDateList = this.filterBlockList(
         this.afterDateList = this.filterBlockList(
           this.blockList,
           this.blockList,