|
|
@@ -31,7 +31,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { queryAdjustment, removeAdjustment, saveAdjustment, sendMessage, getAdjustmentDetail, saveAdjustmentDetail } from '@/api/business/schedule'
|
|
|
+import { queryAdjustment, removeAdjustment, saveAdjustment, sendMessage, getStaffSchedule, saveStaffSchedule, getAdjustment, getAdjustmentDetail, saveAdjustmentDetail } from '@/api/business/schedule'
|
|
|
import { stateType } from '@/views/constants/schedule'
|
|
|
import ActionUtils from '@/utils/action'
|
|
|
import FixHeight from '@/mixins/height'
|
|
|
@@ -325,8 +325,12 @@ export default {
|
|
|
async handleAgree (key, data) {
|
|
|
// console.log(data)
|
|
|
data.status = (key === 'agree' ? this.isNextStep(data) : '已拒绝')
|
|
|
+ this.handleAccess(data)
|
|
|
saveAdjustment(data).then(() => {
|
|
|
ActionUtils.successMessage()
|
|
|
+ if (data.status === '已通过') {
|
|
|
+ this.handleAccess(data)
|
|
|
+ }
|
|
|
this.sendMsg(data) // 发送系统通知
|
|
|
this.search()
|
|
|
}).catch((e) => { console.error(e) })
|
|
|
@@ -343,12 +347,13 @@ export default {
|
|
|
const tableName = 't_adjustment'
|
|
|
let uparr = []
|
|
|
data.forEach((el) => {
|
|
|
+ el.status = key === 'massAgree' ? this.isNextStep(el) : '已拒绝'
|
|
|
uparr.push({
|
|
|
where: {
|
|
|
id_: el.id
|
|
|
},
|
|
|
param: {
|
|
|
- status: key === 'massAgree' ? this.isNextStep(el) : '已拒绝'
|
|
|
+ status: el.status
|
|
|
}
|
|
|
})
|
|
|
})
|
|
|
@@ -358,7 +363,12 @@ export default {
|
|
|
}
|
|
|
this.$common.request('update', updateParams).then(() => {
|
|
|
ActionUtils.successMessage()
|
|
|
- data.forEach((el) => { // 给每个申请单发通知
|
|
|
+ data.forEach(async (el) => { // 给每个申请单发通知
|
|
|
+ if (el.status === '已通过') {
|
|
|
+ // 获取子表数据
|
|
|
+ const response = await getAdjustment({ id: el.id })
|
|
|
+ this.handleAccess(response.data)
|
|
|
+ }
|
|
|
this.sendMsg(el)
|
|
|
})
|
|
|
this.search()
|
|
|
@@ -374,6 +384,42 @@ export default {
|
|
|
this.search()
|
|
|
}).catch((e) => { console.error(e) })
|
|
|
},
|
|
|
+ /**
|
|
|
+ * 处理已通过的申请单,修改排班数据
|
|
|
+ */
|
|
|
+ async handleAccess (data) {
|
|
|
+ if (data.adjustmentDetailPoList.length > 0) {
|
|
|
+ const scheduleId = data.scheduleId
|
|
|
+ const response = await getStaffSchedule({ id: scheduleId })
|
|
|
+ const submitData = response.data
|
|
|
+ const { staffScheduleDetailPoList, startDate } = response.data
|
|
|
+ data.adjustmentDetailPoList.forEach(async (el) => {
|
|
|
+ const userId = el.createBy
|
|
|
+ const partyId = el.party
|
|
|
+ const userResIndex = staffScheduleDetailPoList.findIndex(item => item.userId === userId) // 获取调班人的排班详情
|
|
|
+ const partyResIndex = staffScheduleDetailPoList.findIndex(item => item.userId === partyId) // 获取目标人的排班详情
|
|
|
+ // 修改调班人排班数据
|
|
|
+ const index = this.getDays(startDate, el.beforeDate) // 计算得出是d几天
|
|
|
+ staffScheduleDetailPoList[userResIndex][`d${index + 1}`] = staffScheduleDetailPoList[userResIndex][`d${index + 1}`].replace(el.beforeAdjust, el.afterAdjust)
|
|
|
+ // 修改目标人排班数据
|
|
|
+ const partyIndex = this.getDays(startDate, el.afterDate) // 计算得出是d几天
|
|
|
+ staffScheduleDetailPoList[partyResIndex][`d${partyIndex + 1}`] = staffScheduleDetailPoList[partyResIndex][`d${partyIndex + 1}`].replace(el.afterAdjust, el.beforeAdjust)
|
|
|
+ })
|
|
|
+ // 保存修改后的排班
|
|
|
+ submitData.staffScheduleDetailPoList = staffScheduleDetailPoList
|
|
|
+ saveStaffSchedule(submitData).then(() => {
|
|
|
+ console.log('排班已更新')
|
|
|
+ }).catch((err) => {
|
|
|
+ console.log(err)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getDays (start, end) { // 根据日期获取排序 d1、d2、d3...
|
|
|
+ if (!start || !end) {
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+ return Math.ceil((new Date(end) - new Date(start)) / (1000 * 60 * 60 * 24))
|
|
|
+ },
|
|
|
/**
|
|
|
* 行双击事件
|
|
|
*
|