Bläddra i källkod

修复排班调班:不显示班次详情、排版变更无审批人逻辑调整、排版变更班次重复、列表排版变更应隐藏审核人等问题

zhonghuizhen 1 år sedan
förälder
incheckning
f45321d170

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

@@ -22,7 +22,7 @@
             </template>
             <template slot="partys" slot-scope="scope">
                 <span v-for="party in scope.row.partys" :key="party.value">
-                    <span :class="getTagClass(party)" class="el-tag el-tag--small el-tag--light" style="margin-left: 5px;">{{ party.label }}</span>
+                    <span v-if="party.value !== scope.row.createBy" :class="getTagClass(party)" class="el-tag el-tag--small el-tag--light" style="margin-left: 5px;">{{ party.label }}</span>
                 </span>
             </template>
         </ibps-crud>

+ 11 - 6
src/views/business/​scheduleManage/adjustVerify.vue

@@ -21,7 +21,7 @@
             </template>
             <template slot="partys" slot-scope="scope">
                 <span v-for="party in scope.row.partys" :key="party.value">
-                    <span :class="getTagClass(party)" class="el-tag el-tag--small el-tag--light" style="margin-left: 5px;">{{ party.label }}</span>
+                    <span v-if="party.value !== scope.row.createBy" :class="getTagClass(party)" class="el-tag el-tag--small el-tag--light" style="margin-left: 5px;">{{ party.label }}</span>
                 </span>
             </template>
         </ibps-crud>
@@ -632,11 +632,16 @@ export default {
                         // 排版变更
                         const index = this.getDays(startDate, el.afterDate) // 计算得出是d几天
                         const partyIndex = this.getDays(startDate, el.beforeDate) // 计算得出是d几天
-                        if (staffScheduleDetailPoList[userResIndex][`d${index + 1}`] !== '') {
-                            staffScheduleDetailPoList[userResIndex][`d${index + 1}`] = staffScheduleDetailPoList[userResIndex][`d${index + 1}`].concat(',' + el.afterAdjust) // 申请人目标日期改变
-                        } else {
-                            staffScheduleDetailPoList[userResIndex][`d${index + 1}`] = el.afterAdjust
-                        }
+                        const afterAdjustArr = el.afterAdjust.split(',')
+                        afterAdjustArr.forEach((item) => {
+                            if (!staffScheduleDetailPoList[userResIndex][`d${index + 1}`].includes(item)) { // 排班原本不包含的班次才加进去 避免重复
+                                if (staffScheduleDetailPoList[userResIndex][`d${index + 1}`] !== '') {
+                                    staffScheduleDetailPoList[userResIndex][`d${index + 1}`] = staffScheduleDetailPoList[userResIndex][`d${index + 1}`].concat(',' + item) // 申请人目标日期改变
+                                } else {
+                                    staffScheduleDetailPoList[userResIndex][`d${index + 1}`] = item
+                                }
+                            }
+                        })
                         const beforeAdjustList = el.beforeAdjust.split(',')
                         beforeAdjustList.forEach((item, i) => {
                             if (i === (beforeAdjustList.length - 1)) {

+ 63 - 18
src/views/business/​scheduleManage/components/adjust-edit.vue

@@ -289,11 +289,7 @@
 
 <script>
 // import {  } from '@/views/constants/schedule'
-import { getAdjustment, saveAdjustment, queryStaffSchedule, getStaffSchedule, sendMessage } from '@/api/business/schedule'
-import { queryDataById } from '@/api/platform/data/dataTemplate'
-import { status } from '@/api/platform/job/scheduler';
-import { reject } from 'lodash';
-
+import { getAdjustment, saveAdjustment, queryStaffSchedule, getStaffSchedule, sendMessage, saveStaffSchedule } from '@/api/business/schedule'
 export default {
     props: {
         visible: {
@@ -320,6 +316,7 @@ export default {
             maxHeight: document.body.clientHeight - 438 + 'px',
             dialogVisible: this.visible,
             formLabelWidth: '110px',
+            getAdjustmentData: null,
             formData: {
                 scheduleId: '',
                 reason: '',
@@ -404,9 +401,10 @@ export default {
             }
             self.loading = true
             try {
-                const res = await getAdjustment({ id: self.params.id })
-                if (res.data) {
-                    initializeFormData(res.data)
+                // const res = await getAdjustment({ id: self.params.id })
+                this.getAdjustmentData = await getAdjustment({ id: self.params.id })
+                if (this.getAdjustmentData.data) {
+                    initializeFormData(this.getAdjustmentData.data)
                 }
             } catch (error) {
                 console.error('加载排班配置失败', error)
@@ -415,8 +413,12 @@ export default {
             }
         },
         getScheduleList (self) { // 获取排班下拉的列表
+            const { first, second } = this.$store.getters.level || {}
             const params = {
-                parameters: [],
+                parameters: [{
+                    key: 'Q^di_dian_^S',
+                    value: second || first
+                }],
                 requestPage: {
                     pageNo: 1,
                     limit: 99999
@@ -907,6 +909,7 @@ export default {
                 const { first, second } = this.$store.getters.level || {}
                 const { scheduleId, reason, adjustList, rejectReason } = this.formData || {}
                 let statusVal = '已暂存'
+                const executorVal = this.scheduleInfo.executor.replace(/\[|\]|\"/g, '').replace(/,/g, ',') || ''
                 if (key === 'tempSave') { // 暂存
                 } else { // 提交
                     // 对最后一行进行行校验
@@ -917,7 +920,7 @@ export default {
                     if (this.rowValidate(this.formData.adjustList[this.formData.adjustList.length - 1], this.formData.adjustList.length)) {
                         return
                     }
-                    statusVal = adjustList.some((i) => { return this.$utils.isNotEmpty(i.party) && this.reScheduleValue !== 'paiban' }) ? '待审核' : '待审批'
+                    statusVal = adjustList.some((i) => { return this.$utils.isNotEmpty(i.party) && this.reScheduleValue !== 'paiban' }) ? '待审核' : (executorVal === '' ? '已通过' : '待审批')
                 }
                 // return
                 const submitData = {
@@ -937,7 +940,7 @@ export default {
                     executeDate: '',
                     "type": "string",
                     */
-                    executor: this.scheduleInfo.executor.replace(/\[|\]|\"/g, '').replace(/,/g, ',') || '',
+                    executor: executorVal,
                     // type: this.reScheduleValue,
                     adjustmentDetailPoList: adjustList.map(i => ({
                         recordId: i.recordId,
@@ -956,10 +959,11 @@ export default {
         },
         // 提交数据
         submitForm (data) {
-            saveAdjustment(data).then(res => {
-                this.$message.success(`${this.params.action === 'edit' ? '提交' : '申请'}成功`)
-                this.closeDialog()
-                this.$emit('refresh')
+            const self = this
+            saveAdjustment(data).then(async (res) => {
+                self.$message.success(`${self.params.action === 'edit' ? '提交' : '申请'}成功`)
+                self.closeDialog()
+                self.$emit('refresh')
                 // 提交后通知审核人、审批人
                 if (data.status === '待审核') {
                     const partyArray = data.adjustmentDetailPoList.map(obj => obj.party)
@@ -971,9 +975,49 @@ export default {
                     executorList.forEach(el => {
                         sendMessage(data, el)
                     })
+                } else if (data.status === '已通过') { // 通过申请修改排班数据(只有排版变更且无排版审批人才可能在提交时变为已通过)
+                    self.handleAccess(self)
                 }
             })
         },
+        /**
+         * 处理已通过的申请单,修改排班数据
+         */
+        async handleAccess (self) {
+            const response = await getStaffSchedule({ id: self.formData.scheduleId })
+            const submitData = response.data
+            const { staffScheduleDetailPoList, startDate } = response.data
+            self.formData.adjustList.forEach(async (el) => {
+                const userId = this.$store.getters.userId || ''
+                const userResIndex = staffScheduleDetailPoList.findIndex(item => item.userId === userId) // 获取调班人的排班详情
+                // 排版变更
+                const index = this.getDays(startDate, el.afterDate) // 计算得出是d几天
+                const partyIndex = this.getDays(startDate, el.beforeDate) // 计算得出是d几天
+                el.afterAdjust.forEach((item) => {
+                    if (!staffScheduleDetailPoList[userResIndex][`d${index + 1}`].includes(item)) { // 排班原本不包含的班次才加进去 避免重复
+                        if (staffScheduleDetailPoList[userResIndex][`d${index + 1}`] !== '') {
+                            staffScheduleDetailPoList[userResIndex][`d${index + 1}`] = staffScheduleDetailPoList[userResIndex][`d${index + 1}`].concat(',' + item) // 申请人目标日期改变
+                        } else {
+                            staffScheduleDetailPoList[userResIndex][`d${index + 1}`] = item
+                        }
+                    }
+                })
+                el.beforeAdjust.forEach((item, i) => {
+                    if (i === (el.beforeAdjust.length - 1)) {
+                        staffScheduleDetailPoList[userResIndex][`d${partyIndex + 1}`] = staffScheduleDetailPoList[userResIndex][`d${partyIndex + 1}`].replace(item, '') // 申请人申请日期除去原来的班次
+                    } else { // 当不在最后一项时,把附带的逗号也除去
+                        staffScheduleDetailPoList[userResIndex][`d${partyIndex + 1}`] = staffScheduleDetailPoList[userResIndex][`d${partyIndex + 1}`].replace(item + ',', '') // 申请人申请日期除去原来的班次和逗号
+                    }
+                })
+            })
+            // 保存修改后的排班
+            // submitData.staffScheduleDetailPoList = staffScheduleDetailPoList
+            saveStaffSchedule(submitData).then(() => {
+                console.log('排班已更新')
+            }).catch((err) => {
+                console.log(err)
+            })
+        },
         handleAddParam () {
             // 把前面填写的行加入班次日期锁定
             if (this.formData.adjustList.length > 0) {
@@ -1075,18 +1119,19 @@ export default {
         /** 返回一个从开始日期到结束日期的日期数组(今天之前的不可用)
          * @param startDate
          * @param endDate
-         */
+         * */
         getDateArray (startDate, endDate) {
             const dateArray = []
             const start = new Date(startDate)
             const end = new Date(endDate)
-            const currentDateNow = new Date() // 获取当前日期
+            // 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,
+                    disabled: false,
+                    // currentDate < currentDateNow, // 修改此处判断,若日期小于当前日期则设为disabled:true,
                     key: `d${currentDate.getDate()}`,
                     label: currentDate.toISOString().split('T')[0],
                     value: currentDate.toISOString().split('T')[0]

+ 10 - 9
src/views/system/dashboard/components/util.js

@@ -165,7 +165,6 @@ export function buildComponent (name, column, preview, vm) {
                 this.$nextTick(async () => {
                     this.fetchData()
                     this.scheduleData = await this.getScheduleData()
-
                 })
             },
             methods: {
@@ -589,7 +588,8 @@ export function buildComponent (name, column, preview, vm) {
                     return Math.ceil((new Date(end) - new Date(start)) / (1000 * 60 * 60 * 24))
                 },
                 getScheduleData () {
-                    const sql = `select a.*, b.title_,b.type_, b.start_date_, b.end_date_, b.config_, b.overview_ from t_schedule_detail a, t_schedule b where a.parent_id_ = b.id_ and a.user_id_ = '${this.userId}'`
+                    const { first, second } = this.$store.getters.level || {}
+                    const sql = `select a.*, b.title_,b.type_, b.start_date_, b.end_date_, b.config_, b.overview_ from t_schedule_detail a, t_schedule b where a.parent_id_ = b.id_ and b.di_dian_ = '${second || first}' and a.user_id_ = '${this.userId}'`
                     return new Promise((resolve, reject) => {
                         this.$common.request('sql', sql).then(res => {
                             const { data = [] } = res.variables || {}
@@ -611,9 +611,8 @@ export function buildComponent (name, column, preview, vm) {
                                             const t = scheduleShift.find(i => i.alias === s)
                                             eventList.push({
                                                 scheduleName: item.title_ ? item.title_ : '', // 排班表名字
-                                                scheduleTypeLabel: scheduleTypeLabel, // 排班类型
-                                                scheduleCreateBy: scheduleCreateBy, // 排班创建人
-                                                color: t ? t.color : '',
+                                                scheduleTypeLabel: scheduleTypeLabel || '', // 排班类型
+                                                scheduleCreateBy: scheduleCreateBy || '', // 排班创建人
                                                 content: t.dateRange.map(d => {
                                                     return d.type === 'allday' ? '全天' : (`当天 ${d.startTime}` + ' 至 ' + `${d.isSecondDay === 'Y' ? '第二天' : '当天'} ${d.endTime}`)
                                                 }).join('\n'),
@@ -622,7 +621,9 @@ export function buildComponent (name, column, preview, vm) {
                                                 end: date,
                                                 jieShuShiJian: date,
                                                 zhuangTai: '',
-                                                id: i
+                                                id: i,
+                                                bcolor: t.color,
+                                                ...t
                                             })
                                         })
                                     }
@@ -637,7 +638,7 @@ export function buildComponent (name, column, preview, vm) {
                         })
                     })
                 },
-                handleScheduleEventClick (param) {
+                handleScheduleEventClick (param) { // 排班点击事件
                     this.$emit(
                         'open',
                         'banci',
@@ -670,8 +671,8 @@ export function buildComponent (name, column, preview, vm) {
                             // right: 'dayGridMonth,timeGridWeek,timeGridDay'
                             // end: 'prev,next,today,month,agendaWeek,agendaDay,listWeek'
                         },
-                        events: this.scheduleData, // 日程数组
-                        eventClick: this.handleScheduleEventClick, // 日程点击信息展示
+                        events: this.scheduleData, // 排班数组
+                        eventClick: this.handleScheduleEventClick, // 排班点击信息展示
                         scheduleShift: this.scheduleShift
                     }
                     this.$emit('action-event', 'mySchedule', scheduleConfig)

+ 3 - 1
src/views/system/homepage/components/banciDialog.vue

@@ -30,7 +30,7 @@
                 </div>
                 <div>
                     <strong class="label">对应颜色:</strong>
-                    <div :style="{ background: banci.color, height: '20px', width: '50px', display: 'inline-block' }"></div>
+                    <div :style="{ background: banci.bcolor, height: '20px', width: '50px', display: 'inline-block' }"></div>
                 </div>
                 <div>
                     <strong class="label">时间段:</strong>
@@ -114,10 +114,12 @@ export default {
           align-items: center;
          .position-list {
               display: flex;
+              flex-wrap: wrap;
               list-style: none;
               padding-left: 0;
               li {
                   margin-right: 10px;
+                  margin-top: 10px;
               }
           }
       }

+ 1 - 5
src/views/system/homepage/index.vue

@@ -670,11 +670,7 @@ export default {
                     break
                 case 'banci':
                 {
-                    const filterObj = events.filter(item => item.alias === clickId)
-                    this.banciInfo = filterObj[0]
-                    this.banciInfo.scheduleCreateBy = dateArr.scheduleCreateBy
-                    this.banciInfo.scheduleName = dateArr.scheduleName
-                    this.banciInfo.scheduleTypeLabel = dateArr.scheduleTypeLabel
+                    this.banciInfo = dateArr
                     this.banciDialogVisible = true
                     break
                 }