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

考勤功能-排班调整:限制一天最多可选择三个班次

zhonghuizhen пре 1 година
родитељ
комит
3810c0034c

+ 12 - 1
src/views/business/​scheduleManage/components/adjust-edit.vue

@@ -599,8 +599,19 @@ export default {
                 } else if (duplicateElements.length === 0 && type === 'before') {
                 } else if (duplicateElements.length === 0 && type === 'before') {
                     return false
                     return false
                 }
                 }
-
             }
             }
+            /*
+            // 判断班次不能大于3个
+            if (row.afterShiftList.length > 3) {
+                this.$message.warning('调班后【' + row.afterDate + '】班次大于3个!')
+                // row.afterAdjust = []
+                return true
+            }
+            if ((row.beforeShiftList.length + row.afterAdjust.length - row.beforeAdjust.length) > 3) {
+                this.$message.warning('调班后【' + row.beforeDate + '】班次大于3个!')
+                row.beforeAdjust = []
+                return true
+            }*/
         },
         },
         rowValidate (row, index) { // 行必填检验
         rowValidate (row, index) { // 行必填检验
             if (!row.beforeDate) {
             if (!row.beforeDate) {

+ 4 - 0
src/views/business/​scheduleManage/components/context-menu.vue

@@ -87,6 +87,10 @@ export default {
     methods: {
     methods: {
         handleSubmit () {
         handleSubmit () {
             const selected = this.viewType === 'users' ? this.shiftList.filter(i => this.selectedShift.includes(i.alias)) : this.shiftList.filter(i => this.selectedShift.includes(i.userName))
             const selected = this.viewType === 'users' ? this.shiftList.filter(i => this.selectedShift.includes(i.alias)) : this.shiftList.filter(i => this.selectedShift.includes(i.userName))
+            if (selected.length > 3) {
+                this.$message.warning('不能超过三个班次!')
+                return
+            }
             this.$emit('select', { selected, params: this.params })
             this.$emit('select', { selected, params: this.params })
             this.$emit('close')
             this.$emit('close')
         }
         }

+ 15 - 5
src/views/business/​scheduleManage/edit.vue

@@ -615,7 +615,7 @@ export default {
             //     scheduleContent.style.paddingLeft = '0px'
             //     scheduleContent.style.paddingLeft = '0px'
             // }
             // }
         },
         },
-        getScheduleList (self) { // 获取选择排班下拉的选项
+        getScheduleList (self, flag) { // 获取选择排班下拉的选项
             const { first, second } = this.$store.getters.level || {}
             const { first, second } = this.$store.getters.level || {}
             const params = {
             const params = {
                 parameters: [{
                 parameters: [{
@@ -630,13 +630,16 @@ export default {
             }
             }
             queryStaffSchedule(params).then((res) => {
             queryStaffSchedule(params).then((res) => {
                 const scheduleList = res.data.dataResult || []
                 const scheduleList = res.data.dataResult || []
-                self.scheduleOptions = scheduleList
+                if (flag) {
+                    self.scheduleOptions = scheduleList.filter(s => s.id !== self.formData.id) // 历史排班选项数据
+                } else {
+                    self.scheduleOptions = scheduleList// 历史排班选项数据
+                }
             })
             })
         },
         },
         loadData () {
         loadData () {
             this.loading = true
             this.loading = true
             const self = this
             const self = this
-            this.getScheduleList(self)
             // 获取配置数据
             // 获取配置数据
             queryScheduleConfig({
             queryScheduleConfig({
                 parameters: [],
                 parameters: [],
@@ -653,6 +656,7 @@ export default {
                 self.configOptions.forEach((el) => {
                 self.configOptions.forEach((el) => {
                     el.options = el.options.filter(obj => obj.diDian === (second || first))
                     el.options = el.options.filter(obj => obj.diDian === (second || first))
                 })
                 })
+                self.getScheduleList(self, false)
                 // console.log(this.configOptions)
                 // console.log(this.configOptions)
                 if (self.$utils.isEmpty(self.pageParams.id)) {
                 if (self.$utils.isEmpty(self.pageParams.id)) {
                     self.loading = false
                     self.loading = false
@@ -685,6 +689,7 @@ export default {
                         return d.type === 'allday' ? '全天' : `当天 ${d.startTime}至${d.isSecondDay === 'Y' ? '第二天' : '当天'} ${d.endTime}`
                         return d.type === 'allday' ? '全天' : `当天 ${d.startTime}至${d.isSecondDay === 'Y' ? '第二天' : '当天'} ${d.endTime}`
                     })
                     })
                 }))
                 }))
+                self.getScheduleList(self, true)
                 console.log('formData', self.formData)
                 console.log('formData', self.formData)
                 self.scheduleData = self.transformScheduleData(records, overview, temp)
                 self.scheduleData = self.transformScheduleData(records, overview, temp)
                 self.responseData = { ...self.responseData, records, overview, temp }
                 self.responseData = { ...self.responseData, records, overview, temp }
@@ -1019,7 +1024,7 @@ export default {
             const self = this
             const self = this
             if (val) {
             if (val) {
                 await getStaffSchedule({ id: val }).then((res) => {
                 await getStaffSchedule({ id: val }).then((res) => {
-                    const { staffScheduleDetailPoList: records, title, endDate, startDate, overview, config,type } = res.data
+                    const { staffScheduleDetailPoList: records, title, endDate, startDate, overview, config, type } = res.data
                     const temp = config ? JSON.parse(config) : {}
                     const temp = config ? JSON.parse(config) : {}
                     self.responseData = res.data
                     self.responseData = res.data
                     self.formData = {
                     self.formData = {
@@ -1041,6 +1046,11 @@ export default {
                             return d.type === 'allday' ? '全天' : (`当天 ${d.startTime}` + ' 至 ' + `${d.isSecondDay === 'Y' ? '第二天' : '当天'} ${d.endTime}`)
                             return d.type === 'allday' ? '全天' : (`当天 ${d.startTime}` + ' 至 ' + `${d.isSecondDay === 'Y' ? '第二天' : '当天'} ${d.endTime}`)
                         })
                         })
                     }))
                     }))
+                    // 把子表数据的id和parentid去除
+                    records.forEach((item) => {
+                        item.id = ''
+                        item.parentId = ''
+                    })
                     console.log('formData', self.formData)
                     console.log('formData', self.formData)
                     self.scheduleData = self.transformScheduleData(records, overview, temp)
                     self.scheduleData = self.transformScheduleData(records, overview, temp)
                     self.responseData = { ...self.responseData, records, overview, temp }
                     self.responseData = { ...self.responseData, records, overview, temp }
@@ -1164,7 +1174,7 @@ export default {
                 diDian: second || first,
                 diDian: second || first,
                 title,
                 title,
                 oldScheduleId,
                 oldScheduleId,
-                status: type ? '已发布' : '未发布',
+                status: type ? '已发布' : (this.formData.status ? this.formData.status : '未发布'),
                 startDate: dateRange[0],
                 startDate: dateRange[0],
                 endDate: dateRange[1],
                 endDate: dateRange[1],
                 type: scheduleType,
                 type: scheduleType,