|
|
@ -327,7 +327,7 @@ export default { |
|
|
this.titleCon = isAttendanceMode ? '考勤修改' : this.labels.componentTitle;//重置标题 |
|
|
this.titleCon = isAttendanceMode ? '考勤修改' : this.labels.componentTitle;//重置标题 |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 加载操作员列表 |
|
|
|
|
|
|
|
|
// 加载操作员列表(只查询在岗人员 is_on_duty = 'Y') |
|
|
loadOperatorList() { |
|
|
loadOperatorList() { |
|
|
if (!this.currentSchedule.orderNo || !this.currentSchedule.seqNo) { |
|
|
if (!this.currentSchedule.orderNo || !this.currentSchedule.seqNo) { |
|
|
return; |
|
|
return; |
|
|
@ -337,7 +337,7 @@ export default { |
|
|
orderNo: this.currentSchedule.orderNo, |
|
|
orderNo: this.currentSchedule.orderNo, |
|
|
itemNo: this.currentSchedule.itemNo, |
|
|
itemNo: this.currentSchedule.itemNo, |
|
|
seqNo: this.currentSchedule.seqNo, |
|
|
seqNo: this.currentSchedule.seqNo, |
|
|
isOnDuty: 'Y' |
|
|
|
|
|
|
|
|
isOnDuty: 'Y' // 只查询在岗人员 |
|
|
}; |
|
|
}; |
|
|
getOperatorList2(params).then(({ data }) => { |
|
|
getOperatorList2(params).then(({ data }) => { |
|
|
if (data && data.code === 0) { |
|
|
if (data && data.code === 0) { |
|
|
@ -408,20 +408,30 @@ export default { |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 更新单行操作员时间(下岗) |
|
|
|
|
|
|
|
|
// 下岗操作 |
|
|
updateOperatorTime(row) { |
|
|
updateOperatorTime(row) { |
|
|
// 校验时间 |
|
|
|
|
|
const validateResult = this.validateOperatorTime(row); |
|
|
|
|
|
if (!validateResult.valid) { |
|
|
|
|
|
this.$message.error(validateResult.message); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.$confirm('确定更新该操作员的上下岗时间吗?', '提示', { |
|
|
|
|
|
|
|
|
this.$confirm('确定让该操作员下岗吗?', '提示', { |
|
|
confirmButtonText: '确定', |
|
|
confirmButtonText: '确定', |
|
|
cancelButtonText: '取消', |
|
|
cancelButtonText: '取消', |
|
|
type: 'warning' |
|
|
type: 'warning' |
|
|
}).then(() => { |
|
|
}).then(() => { |
|
|
|
|
|
// 如果用户没有选择下岗时间,使用当前时间 |
|
|
|
|
|
let offDutyTime = row.offDutyTime; |
|
|
|
|
|
if (!offDutyTime) { |
|
|
|
|
|
const now = new Date(); |
|
|
|
|
|
offDutyTime = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')} ${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}:${String(now.getSeconds()).padStart(2, '0')}`; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 校验下岗时间不能早于上岗时间 |
|
|
|
|
|
if (row.onDutyTime && offDutyTime) { |
|
|
|
|
|
const onDuty = new Date(row.onDutyTime); |
|
|
|
|
|
const offDuty = new Date(offDutyTime); |
|
|
|
|
|
if (offDuty < onDuty) { |
|
|
|
|
|
this.$message.error('下岗时间不能早于上岗时间!'); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const params = { |
|
|
const params = { |
|
|
id: row.id, |
|
|
id: row.id, |
|
|
site: this.$store.state.user.site, |
|
|
site: this.$store.state.user.site, |
|
|
@ -429,20 +439,19 @@ export default { |
|
|
itemNo: this.currentSchedule.itemNo, |
|
|
itemNo: this.currentSchedule.itemNo, |
|
|
seqNo: this.currentSchedule.seqNo, |
|
|
seqNo: this.currentSchedule.seqNo, |
|
|
operator: row.operator, |
|
|
operator: row.operator, |
|
|
onDutyTime: row.onDutyTime, |
|
|
|
|
|
offDutyTime: row.offDutyTime |
|
|
|
|
|
|
|
|
offDutyTime: offDutyTime |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
updateOperatorTime(params).then(({ data }) => { |
|
|
|
|
|
|
|
|
removeOperatorOnDuty(params).then(({ data }) => { |
|
|
if (data && data.code === 0) { |
|
|
if (data && data.code === 0) { |
|
|
this.$message.success('操作员时间更新成功!'); |
|
|
|
|
|
|
|
|
this.$message.success('操作员下岗成功!'); |
|
|
// 刷新列表 |
|
|
// 刷新列表 |
|
|
this.loadOperatorList(); |
|
|
this.loadOperatorList(); |
|
|
} else { |
|
|
} else { |
|
|
this.$message.error(data.msg || '操作员时间更新失败!'); |
|
|
|
|
|
|
|
|
this.$message.error(data.msg || '操作员下岗失败!'); |
|
|
} |
|
|
} |
|
|
}).catch(() => { |
|
|
}).catch(() => { |
|
|
this.$message.error('操作员时间更新失败!'); |
|
|
|
|
|
|
|
|
this.$message.error('操作员下岗失败!'); |
|
|
}); |
|
|
}); |
|
|
}).catch(() => { |
|
|
}).catch(() => { |
|
|
// 取消操作 |
|
|
// 取消操作 |
|
|
@ -451,9 +460,9 @@ export default { |
|
|
|
|
|
|
|
|
// 校验操作员时间 |
|
|
// 校验操作员时间 |
|
|
validateOperatorTime(row) { |
|
|
validateOperatorTime(row) { |
|
|
// 允许上岗时间为空(跳过校验) |
|
|
|
|
|
|
|
|
// 上岗时间不能为空 |
|
|
if (!row.onDutyTime) { |
|
|
if (!row.onDutyTime) { |
|
|
return { valid: true }; |
|
|
|
|
|
|
|
|
return { valid: false, message: '上岗时间不能为空!' }; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const now = new Date(); |
|
|
const now = new Date(); |
|
|
@ -533,38 +542,62 @@ export default { |
|
|
|
|
|
|
|
|
// 批量更新操作员时间(返回Promise) |
|
|
// 批量更新操作员时间(返回Promise) |
|
|
batchUpdateOperatorTimeSync() { |
|
|
batchUpdateOperatorTimeSync() { |
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
|
|
|
|
return new Promise(async (resolve, reject) => { |
|
|
// 如果列表为空,直接返回 |
|
|
// 如果列表为空,直接返回 |
|
|
if (!this.operatorList || this.operatorList.length === 0) { |
|
|
if (!this.operatorList || this.operatorList.length === 0) { |
|
|
resolve(); |
|
|
resolve(); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 校验所有行的时间 |
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
// 分为两组:需要下岗的 和 只需要更新上岗时间的 |
|
|
|
|
|
const offDutyList = []; // 需要下岗的 |
|
|
|
|
|
const updateOnDutyList = []; // 只更新上岗时间的 |
|
|
|
|
|
|
|
|
for (let i = 0; i < this.operatorList.length; i++) { |
|
|
for (let i = 0; i < this.operatorList.length; i++) { |
|
|
const row = this.operatorList[i]; |
|
|
const row = this.operatorList[i]; |
|
|
const validateResult = this.validateOperatorTime(row); |
|
|
|
|
|
if (!validateResult.valid) { |
|
|
|
|
|
this.$message.error(`第 ${i + 1} 行:${validateResult.message}`); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 上岗时间不能为空 |
|
|
|
|
|
if (!row.onDutyTime) { |
|
|
|
|
|
this.$message.error(`第 ${i + 1} 行:上岗时间不能为空!`); |
|
|
reject(); |
|
|
reject(); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (row.offDutyTime) { |
|
|
|
|
|
// 有下岗时间,需要校验并执行下岗操作 |
|
|
|
|
|
const onDuty = new Date(row.onDutyTime); |
|
|
|
|
|
const offDuty = new Date(row.offDutyTime); |
|
|
|
|
|
|
|
|
|
|
|
if (offDuty < onDuty) { |
|
|
|
|
|
this.$message.error(`第 ${i + 1} 行:下岗时间不能早于上岗时间!`); |
|
|
|
|
|
reject(); |
|
|
|
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 准备批量更新的数据 |
|
|
|
|
|
const operatorListData = this.operatorList.map(row => ({ |
|
|
|
|
|
|
|
|
offDutyList.push({ |
|
|
id: row.id, |
|
|
id: row.id, |
|
|
operator: row.operator, |
|
|
operator: row.operator, |
|
|
onDutyTime: row.onDutyTime, |
|
|
|
|
|
offDutyTime: row.offDutyTime |
|
|
offDutyTime: row.offDutyTime |
|
|
})); |
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 没有下岗时间,只更新上岗时间 |
|
|
|
|
|
updateOnDutyList.push({ |
|
|
|
|
|
id: row.id, |
|
|
|
|
|
operator: row.operator, |
|
|
|
|
|
onDutyTime: row.onDutyTime |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 调用后端批量处理 |
|
|
const params = { |
|
|
const params = { |
|
|
site: this.$store.state.user.site, |
|
|
site: this.$store.state.user.site, |
|
|
orderNo: this.currentSchedule.orderNo, |
|
|
orderNo: this.currentSchedule.orderNo, |
|
|
itemNo: this.currentSchedule.itemNo, |
|
|
itemNo: this.currentSchedule.itemNo, |
|
|
seqNo: this.currentSchedule.seqNo, |
|
|
seqNo: this.currentSchedule.seqNo, |
|
|
operatorList: operatorListData |
|
|
|
|
|
|
|
|
offDutyList: offDutyList, |
|
|
|
|
|
updateOnDutyList: updateOnDutyList |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
batchUpdateOperatorTime(params).then(({ data }) => { |
|
|
batchUpdateOperatorTime(params).then(({ data }) => { |
|
|
@ -581,6 +614,10 @@ export default { |
|
|
this.$message.error('考勤信息批量更新失败!'); |
|
|
this.$message.error('考勤信息批量更新失败!'); |
|
|
reject(); |
|
|
reject(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
this.$message.error('批量更新操作员时间失败!'); |
|
|
|
|
|
reject(error); |
|
|
|
|
|
} |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|