refactor(dms): 优化故障工单审批和确认逻辑

- 修复审批按钮显示逻辑,改为根据工单审批状态控制
- 优化确认按钮显示逻辑,明确主管确认条件
- 移除路由类型对任务加载的影响
- 重构主管确认流程,增加用户交互和错误处理
- 调整验证规则设置,根据工单状态动态调整
master
zangchenhao 3 weeks ago
parent 34fed01699
commit f45939995c

@ -368,23 +368,21 @@ const currentStepTitle = computed(() => {
}); });
const approvalButtonShow = computed(() => { const approvalButtonShow = computed(() => {
return routeParams.value.type === 'approval' && currentTask.value; // (1)
return workOrder.value?.approveStatus === '1';
}); });
const confirmButtonShow = computed(() => { const confirmButtonShow = computed(() => {
// //
// 1. confirm // (2) && (2) && (0)
// 2. (2)(0) return workOrder.value?.billsStatus === '2' &&
// 3. (2) - workOrder.value?.approveStatus === '2' &&
return routeParams.value.type === 'confirm' || workOrder.value?.repairConfirm === '0';
(workOrder.value?.billsStatus === '2' &&
workOrder.value?.repairConfirm === '0' &&
workOrder.value?.approveStatus === '2');
}); });
// //
const isApprovalStage = computed(() => { const isApprovalStage = computed(() => {
return routeParams.value.type === 'approval' && workOrder.value?.approveStatus === '1'; return workOrder.value?.approveStatus === '1';
}); });
// //
@ -410,7 +408,7 @@ onMounted(async () => {
await getOutsourceList(); await getOutsourceList();
// //
if (routeParams.value.type === 'approval') { if (routeParams.value.type === 'approval' || routeParams.value.type === 'confirm') {
await loadCurrentTask(); await loadCurrentTask();
} }
@ -664,15 +662,42 @@ const submitCallback = async (approvalResult?: any) => {
// //
const handleConfirm = async () => { const handleConfirm = async () => {
try { try {
// //
await proxy?.$modal.confirm('是否确认维修结果通过?\n通过维修通过工单完成\n退回维修不通过返回维修环节重新维修');
buttonLoading.value = true;
//
form.repairConfirm = '1'; // 1 form.repairConfirm = '1'; // 1
// //
await approvalVerifyOpen(); await confirmRepairResult(form.repairInstanceId, form.repairConfirm);
proxy?.$modal.msgSuccess('确认通过完成');
goBack();
} catch (error: any) { } catch (error: any) {
if (error !== 'cancel' && error !== 'close') { if (error === 'cancel' || error === 'close') {
//
try {
buttonLoading.value = true;
form.repairConfirm = '2'; // 2
await confirmRepairResult(form.repairInstanceId, form.repairConfirm);
proxy?.$modal.msgSuccess('确认不通过完成');
goBack();
} catch (confirmError: any) {
console.error('确认不通过失败:', confirmError);
proxy?.$modal.msgError('确认不通过失败:' + (confirmError.message || '未知错误'));
} finally {
buttonLoading.value = false;
}
} else {
console.error('确认失败:', error); console.error('确认失败:', error);
proxy?.$modal.msgError('确认失败:' + (error.message || '未知错误')); proxy?.$modal.msgError('确认失败:' + (error.message || '未知错误'));
buttonLoading.value = false;
}
} finally {
if (form.repairConfirm === '1') {
buttonLoading.value = false;
} }
} }
}; };
@ -715,18 +740,18 @@ const setDynamicValidationRules = () => {
rules[key] = [{ required: false, message: rules[key][0].message, trigger: rules[key][0].trigger }]; rules[key] = [{ required: false, message: rules[key][0].message, trigger: rules[key][0].trigger }];
}); });
// //
if (routeParams.value.type === 'approval') { if (workOrder.value?.approveStatus === '1') {
// //
rules.approveStatus = [{ required: true, message: '审批状态不能为空', trigger: 'change' }]; rules.approveStatus = [{ required: true, message: '审批状态不能为空', trigger: 'change' }];
if (needProcessResolution.value) {
rules.processHandleResolution = [{ required: true, message: '处理意见不能为空', trigger: 'blur' }]; rules.processHandleResolution = [{ required: true, message: '处理意见不能为空', trigger: 'blur' }];
} } else if (workOrder.value?.billsStatus === '2' &&
} else if (routeParams.value.type === 'confirm') { workOrder.value?.approveStatus === '2' &&
// workOrder.value?.repairConfirm === '0') {
//
rules.repairConfirm = [{ required: true, message: '维修结果不能为空', trigger: 'change' }]; rules.repairConfirm = [{ required: true, message: '维修结果不能为空', trigger: 'change' }];
rules.processHandleResolution = [{ required: true, message: '处理意见不能为空', trigger: 'blur' }]; rules.processHandleResolution = [{ required: true, message: '处理意见不能为空', trigger: 'blur' }];
} else { } else if (routeParams.value.type === 'add' || routeParams.value.type === 'update') {
// //
if (currentStepOrder.value === 1) { if (currentStepOrder.value === 1) {
// //

Loading…
Cancel
Save