|
|
|
@ -279,6 +279,7 @@
|
|
|
|
|
// 导入相关模块
|
|
|
|
|
import { ref, reactive, computed, onMounted, getCurrentInstance, toRefs, watch } from 'vue';
|
|
|
|
|
import { useRoute, useRouter } from 'vue-router';
|
|
|
|
|
import { ElMessageBox } from 'element-plus';
|
|
|
|
|
import { getDmsBillsFaultInstance, approveWorkOrder, confirmRepairResult } from '@/api/dms/dmsBillsFaultInstance';
|
|
|
|
|
import { addDmsFaultInstanceActivity } from '@/api/dms/dmsFaultInstanceActivity';
|
|
|
|
|
import { pageByTaskWait } from '@/api/workflow/task';
|
|
|
|
@ -509,7 +510,7 @@ const initializeFormData = () => {
|
|
|
|
|
form.repairer = workOrder.value?.repairer || '';
|
|
|
|
|
form.repairConfirm = workOrder.value?.repairConfirm || '';
|
|
|
|
|
form.componentsPartsId = workOrder.value?.componentsPartsId || '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果是审批阶段,设置默认审批状态
|
|
|
|
|
if (routeParams.value.type === 'approval' && !form.approveStatus) {
|
|
|
|
|
form.approveStatus = undefined; // 保持未选择状态,让用户必须选择
|
|
|
|
@ -595,18 +596,18 @@ const approvalVerifyOpen = async () => {
|
|
|
|
|
const valid = await processFormRef.value.validate();
|
|
|
|
|
if (valid) {
|
|
|
|
|
await proxy?.$modal.confirm('是否确认提交审批?');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buttonLoading.value = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 直接调用后端审批接口,后端会在同一事务中处理业务状态更新和工作流推进
|
|
|
|
|
const approveStatus = form.approveStatus;
|
|
|
|
|
const message = form.processHandleResolution || '';
|
|
|
|
|
|
|
|
|
|
await approveWorkOrder(form.repairInstanceId, approveStatus, message);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const statusText = approveStatus === '2' ? '通过' : '拒绝';
|
|
|
|
|
proxy?.$modal.msgSuccess(`审批${statusText}成功`);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 关闭页面返回
|
|
|
|
|
goBack();
|
|
|
|
|
}
|
|
|
|
@ -662,38 +663,49 @@ const submitCallback = async (approvalResult?: any) => {
|
|
|
|
|
// 主管确认处理
|
|
|
|
|
const handleConfirm = async () => {
|
|
|
|
|
try {
|
|
|
|
|
// 显示确认对话框
|
|
|
|
|
await proxy?.$modal.confirm('是否确认维修结果通过?\n通过:维修通过,工单完成\n退回:维修不通过,返回维修环节重新维修');
|
|
|
|
|
|
|
|
|
|
// 使用自定义按钮的确认对话框
|
|
|
|
|
const result = await ElMessageBox.confirm(
|
|
|
|
|
'请选择维修结果确认方式:\n• 通过:维修通过,工单完成\n• 退回:维修不通过,返回维修环节重新维修',
|
|
|
|
|
'主管确认',
|
|
|
|
|
{
|
|
|
|
|
confirmButtonText: '通过',
|
|
|
|
|
cancelButtonText: '退回',
|
|
|
|
|
type: 'warning',
|
|
|
|
|
distinguishCancelAndClose: true
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
buttonLoading.value = true;
|
|
|
|
|
|
|
|
|
|
// 用户点击确定,设置为确认通过
|
|
|
|
|
|
|
|
|
|
// 用户点击通过,设置为确认通过
|
|
|
|
|
form.repairConfirm = '1'; // 1表示确认通过
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 调用主管确认接口
|
|
|
|
|
await confirmRepairResult(form.repairInstanceId, form.repairConfirm);
|
|
|
|
|
proxy?.$modal.msgSuccess('确认通过完成');
|
|
|
|
|
goBack();
|
|
|
|
|
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
if (error === 'cancel' || error === 'close') {
|
|
|
|
|
// 用户点击取消,设置为确认不通过
|
|
|
|
|
|
|
|
|
|
} catch (action: any) {
|
|
|
|
|
if (action === 'cancel') {
|
|
|
|
|
// 用户点击退回,设置为确认不通过
|
|
|
|
|
try {
|
|
|
|
|
buttonLoading.value = true;
|
|
|
|
|
form.repairConfirm = '2'; // 2表示确认不通过
|
|
|
|
|
await confirmRepairResult(form.repairInstanceId, form.repairConfirm);
|
|
|
|
|
proxy?.$modal.msgSuccess('确认不通过完成');
|
|
|
|
|
proxy?.$modal.msgSuccess('退回维修环节完成');
|
|
|
|
|
goBack();
|
|
|
|
|
} catch (confirmError: any) {
|
|
|
|
|
console.error('确认不通过失败:', confirmError);
|
|
|
|
|
proxy?.$modal.msgError('确认不通过失败:' + (confirmError.message || '未知错误'));
|
|
|
|
|
console.error('退回操作失败:', confirmError);
|
|
|
|
|
proxy?.$modal.msgError('退回操作失败:' + (confirmError.message || '未知错误'));
|
|
|
|
|
} finally {
|
|
|
|
|
buttonLoading.value = false;
|
|
|
|
|
}
|
|
|
|
|
} else if (action === 'close') {
|
|
|
|
|
// 用户点击关闭按钮或按ESC键,不执行任何操作
|
|
|
|
|
console.log('用户取消了确认操作');
|
|
|
|
|
} else {
|
|
|
|
|
console.error('确认失败:', error);
|
|
|
|
|
proxy?.$modal.msgError('确认失败:' + (error.message || '未知错误'));
|
|
|
|
|
buttonLoading.value = false;
|
|
|
|
|
console.error('确认失败:', action);
|
|
|
|
|
proxy?.$modal.msgError('确认失败:' + (action.message || '未知错误'));
|
|
|
|
|
}
|
|
|
|
|
} finally {
|
|
|
|
|
if (form.repairConfirm === '1') {
|
|
|
|
@ -745,8 +757,8 @@ const setDynamicValidationRules = () => {
|
|
|
|
|
// 审批阶段:需要审批状态和处理意见
|
|
|
|
|
rules.approveStatus = [{ required: true, message: '审批状态不能为空', trigger: 'change' }];
|
|
|
|
|
rules.processHandleResolution = [{ required: true, message: '处理意见不能为空', trigger: 'blur' }];
|
|
|
|
|
} else if (workOrder.value?.billsStatus === '2' &&
|
|
|
|
|
workOrder.value?.approveStatus === '2' &&
|
|
|
|
|
} else if (workOrder.value?.billsStatus === '2' &&
|
|
|
|
|
workOrder.value?.approveStatus === '2' &&
|
|
|
|
|
workOrder.value?.repairConfirm === '0') {
|
|
|
|
|
// 主管确认阶段:需要确认结果和处理意见
|
|
|
|
|
rules.repairConfirm = [{ required: true, message: '维修结果不能为空', trigger: 'change' }];
|
|
|
|
|