|
|
@@ -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]
|