|
|
@@ -355,7 +355,7 @@
|
|
|
|
|
|
<script>
|
|
|
import { cycleOptions, scheduleType, scheduleColumn } from '../../constants/schedule'
|
|
|
-import { queryScheduleConfig, getStaffSchedule, saveStaffSchedule } from '@/api/business/schedule'
|
|
|
+import { queryScheduleConfig, getStaffSchedule, saveStaffSchedule, saveAdjustment } from '@/api/business/schedule'
|
|
|
import request from '@/utils/request'
|
|
|
import { SYSTEM_URL } from '@/api/baseUrl'
|
|
|
import { previewFile } from '@/api/platform/file/attachment'
|
|
|
@@ -421,7 +421,7 @@ export default {
|
|
|
{ key: 'next', icon: 'el-icon-d-arrow-right', label: '下一步', type: 'primary', steps: '1,2', show: true },
|
|
|
{ key: 'changeView', icon: 'el-icon-set-up', label: '切换视图', type: 'primary', steps: '2', show: true },
|
|
|
// { key: 'history', icon: 'el-icon-time', label: '排班历史', type: 'info', steps: '2,3' },
|
|
|
- { key: 'record', icon: 'el-icon-tickets', label: '修改记录', type: 'warning', steps: '2,3', show: (!this.readonly) },
|
|
|
+ { key: 'record', icon: 'el-icon-tickets', label: '修改记录', type: 'warning', steps: '2,3', show: true },
|
|
|
{ key: 'export', icon: 'el-icon-download', label: '导出', type: 'primary', steps: '2,3', show: true },
|
|
|
{ key: 'reset', icon: 'el-icon-refresh', label: '重置', type: 'warning', steps: '2', show: (!this.readonly) },
|
|
|
// { key: 'edit', icon: 'el-icon-edit', label: '编辑', type: 'primary', steps: '2,3' },
|
|
|
@@ -595,6 +595,7 @@ export default {
|
|
|
}))
|
|
|
console.log('formData', this.formData)
|
|
|
this.scheduleData = this.transformScheduleData(records, overview, temp)
|
|
|
+ this.responseData = { ...this.responseData, records, overview, temp }
|
|
|
console.log('scheduleData', this.scheduleData)
|
|
|
this.loading = false
|
|
|
this.userNameList = this.ordinateList.map(item => ({ // 存起user对应id和name
|
|
|
@@ -995,6 +996,8 @@ export default {
|
|
|
this.closeDialog()
|
|
|
this.$emit('callback')
|
|
|
}
|
|
|
+ // 增加一条调班申请记录,用于查看排班管理员修改历史。
|
|
|
+ this.submitAdjust(submitData)
|
|
|
}).catch(() => {
|
|
|
this.loading = false
|
|
|
})
|
|
|
@@ -1191,6 +1194,61 @@ export default {
|
|
|
}
|
|
|
this.resetShiftSetting()
|
|
|
},
|
|
|
+ /** 获取排班变化描述 */
|
|
|
+ getOverViews (responseData, newData) {
|
|
|
+ const oldData = responseData.staffScheduleDetailPoList
|
|
|
+ const result = []
|
|
|
+ // 遍历newData
|
|
|
+ newData.forEach((newItem, i) => {
|
|
|
+ // 比较每个人班次的数量变化
|
|
|
+ if (newItem.statistics !== oldData[i].statistics) {
|
|
|
+ const newStatistics = JSON.parse(newItem.statistics) || []
|
|
|
+ const oldStatistics = JSON.parse(oldData[i].statistics) || []
|
|
|
+ const changes = []
|
|
|
+ // 比较每个人班次的数量变化
|
|
|
+ for (const shift in newStatistics) {
|
|
|
+ const newCount = newStatistics[shift] || 0
|
|
|
+ const oldCount = oldStatistics[shift] || 0
|
|
|
+ const shiftName = this.formData.scheduleShift.find(item => item.alias === shift)?.name
|
|
|
+ if (newCount > oldCount) {
|
|
|
+ changes.push(`${shiftName}增加了` + (newCount - oldCount) + '班次')
|
|
|
+ } else if (newCount < oldCount) {
|
|
|
+ changes.push(`${shiftName}减少了` + (oldCount - newCount) + '班次')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // oldStatistics中有的项而newStatistics中没有的项
|
|
|
+ for (const oldShift in oldStatistics) {
|
|
|
+ if (!newStatistics.hasOwnProperty(oldShift)) {
|
|
|
+ const shiftName = this.formData.scheduleShift.find(item => item.alias === oldShift)?.name
|
|
|
+ const oldCount = oldStatistics[oldShift] || 0
|
|
|
+ changes.push(`${shiftName}减少了` + oldCount + '班次')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 如果有班次变化,将其与userId记录到结果中
|
|
|
+ if (changes.length > 0) {
|
|
|
+ const userNameObj = this.userNameList.filter(item => item.userId === newItem.userId)
|
|
|
+ const perOverView = userNameObj[0]?.userName + changes.join(',')
|
|
|
+ result.push(perOverView)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return '排班管理员调整如下:' + result.join('。')
|
|
|
+ },
|
|
|
+ // 提交调班申请数据
|
|
|
+ submitAdjust (submitData) {
|
|
|
+ const overView = this.getOverViews(this.responseData, submitData.staffScheduleDetailPoList)
|
|
|
+ const { first, second } = this.$store.getters.level || {}
|
|
|
+ const adjustData = {
|
|
|
+ scheduleId: submitData.id,
|
|
|
+ reason: '排班管理员调整排班',
|
|
|
+ diDian: second || first,
|
|
|
+ overview: overView,
|
|
|
+ status: '已通过',
|
|
|
+ updateTime: Date.now(),
|
|
|
+ adjustmentDetailPoList: []
|
|
|
+ }
|
|
|
+ saveAdjustment(adjustData)
|
|
|
+ },
|
|
|
closeDialog () {
|
|
|
this.$emit('close', false)
|
|
|
}
|