|
|
|
@ -4,20 +4,7 @@
|
|
|
|
|
<el-card shadow="never">
|
|
|
|
|
<div style="display: flex; justify-content: space-between">
|
|
|
|
|
<div>
|
|
|
|
|
<el-button
|
|
|
|
|
v-if="submitButtonShow"
|
|
|
|
|
:loading="buttonLoading"
|
|
|
|
|
type="info"
|
|
|
|
|
@click="submitForm('draft')">
|
|
|
|
|
暂存
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button
|
|
|
|
|
v-if="submitButtonShow"
|
|
|
|
|
:loading="buttonLoading"
|
|
|
|
|
type="primary"
|
|
|
|
|
@click="submitForm('submit')">
|
|
|
|
|
提交
|
|
|
|
|
</el-button>
|
|
|
|
|
<!-- 移除提交按钮,Web端不再创建工单 -->
|
|
|
|
|
<el-button
|
|
|
|
|
v-if="approvalButtonShow"
|
|
|
|
|
:loading="buttonLoading"
|
|
|
|
@ -86,150 +73,84 @@
|
|
|
|
|
</el-form>
|
|
|
|
|
</el-card>
|
|
|
|
|
|
|
|
|
|
<!-- 当前步骤处理区域 -->
|
|
|
|
|
<!-- PDA端创建的工单详情(只读显示) -->
|
|
|
|
|
<el-card shadow="never">
|
|
|
|
|
<h4 class="form-header">{{ currentStepTitle }}</h4>
|
|
|
|
|
<h4 class="form-header">PDA端创建的工单详情(只读)</h4>
|
|
|
|
|
<el-form
|
|
|
|
|
ref="processFormRef"
|
|
|
|
|
v-loading="loading"
|
|
|
|
|
:disabled="routeParams.type === 'view'"
|
|
|
|
|
:model="form"
|
|
|
|
|
:rules="rules"
|
|
|
|
|
label-width="120px">
|
|
|
|
|
|
|
|
|
|
<el-row>
|
|
|
|
|
<!-- 第一步:故障报修信息 -->
|
|
|
|
|
<template v-if="currentStepOrder === 1">
|
|
|
|
|
<el-col :span="8">
|
|
|
|
|
<el-form-item label="故障类型" prop="faultType">
|
|
|
|
|
<el-select v-model="form.faultType" placeholder="请选择故障类型">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="dict in activity_fault_type"
|
|
|
|
|
:key="dict.value"
|
|
|
|
|
:label="dict.label"
|
|
|
|
|
:value="dict.value">
|
|
|
|
|
</el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="8">
|
|
|
|
|
<el-form-item label="维修类型" prop="repairType">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="form.repairType"
|
|
|
|
|
placeholder="请选择维修类型"
|
|
|
|
|
@change="updateOutsourcingValidation">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="dict in fault_repair_type"
|
|
|
|
|
:key="dict.value"
|
|
|
|
|
:label="dict.label"
|
|
|
|
|
:value="dict.value">
|
|
|
|
|
</el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="8">
|
|
|
|
|
<el-form-item label="外协单位" prop="outsourcingId">
|
|
|
|
|
<el-input v-model="form.outsourcingId" placeholder="请输入外协单位" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<el-form-item label="故障描述" prop="faultDescription">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="form.faultDescription"
|
|
|
|
|
type="textarea"
|
|
|
|
|
:rows="3"
|
|
|
|
|
placeholder="请输入故障描述" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<el-form-item label="涉及操作" prop="designOperations">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="form.designOperations"
|
|
|
|
|
type="textarea"
|
|
|
|
|
:rows="2"
|
|
|
|
|
placeholder="请输入涉及操作" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</template>
|
|
|
|
|
<!-- 故障报修信息(只读显示) -->
|
|
|
|
|
<el-col :span="8">
|
|
|
|
|
<el-form-item label="故障类型">
|
|
|
|
|
<el-input v-model="form.faultType" disabled />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="8">
|
|
|
|
|
<el-form-item label="维修类型">
|
|
|
|
|
<el-input v-model="form.repairType" disabled />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="8">
|
|
|
|
|
<el-form-item label="外协单位">
|
|
|
|
|
<el-input v-model="outsourcingName" disabled />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<el-form-item label="故障描述">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="form.faultDescription"
|
|
|
|
|
type="textarea"
|
|
|
|
|
:rows="3"
|
|
|
|
|
disabled />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<el-form-item label="涉及操作">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="form.designOperations"
|
|
|
|
|
type="textarea"
|
|
|
|
|
:rows="2"
|
|
|
|
|
disabled />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
|
|
|
|
|
<!-- 第二步:维修处理 -->
|
|
|
|
|
<template v-if="currentStepOrder === 2">
|
|
|
|
|
<el-col :span="8">
|
|
|
|
|
<el-form-item label="故障类型">
|
|
|
|
|
<el-input v-model="form.faultType" disabled />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="8">
|
|
|
|
|
<el-form-item label="维修类型">
|
|
|
|
|
<el-input v-model="form.repairType" disabled />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="8">
|
|
|
|
|
<el-form-item label="维修人" prop="repairer">
|
|
|
|
|
<el-input v-model="form.repairer" placeholder="请输入维修人" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<el-form-item label="检查后的故障判断" prop="checkedFault">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="form.checkedFault"
|
|
|
|
|
type="textarea"
|
|
|
|
|
:rows="3"
|
|
|
|
|
placeholder="请输入检查后的故障判断" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<el-form-item label="维修措施" prop="protectedMethod">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="form.protectedMethod"
|
|
|
|
|
type="textarea"
|
|
|
|
|
:rows="3"
|
|
|
|
|
placeholder="请输入维修措施" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<el-form-item label="维修内容" prop="repairContent">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="form.repairContent"
|
|
|
|
|
type="textarea"
|
|
|
|
|
:rows="4"
|
|
|
|
|
placeholder="请输入维修内容" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<!-- 第三步:维修确认 -->
|
|
|
|
|
<template v-if="currentStepOrder === 3">
|
|
|
|
|
<!-- 维修处理信息(只读显示) -->
|
|
|
|
|
<template v-if="form.repairer">
|
|
|
|
|
<el-col :span="8">
|
|
|
|
|
<el-form-item label="维修人">
|
|
|
|
|
<el-input v-model="form.repairer" disabled />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="8">
|
|
|
|
|
<el-form-item label="维修结果" prop="repairConfirm">
|
|
|
|
|
<el-select v-model="form.repairConfirm" placeholder="请选择维修结果">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="dict in fault_repair_confirm"
|
|
|
|
|
:key="dict.value"
|
|
|
|
|
:label="dict.label"
|
|
|
|
|
:value="dict.value">
|
|
|
|
|
</el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="8">
|
|
|
|
|
<el-form-item label="关联更换零部件" prop="componentsPartsId">
|
|
|
|
|
<el-input v-model="form.componentsPartsId" placeholder="请输入关联更换零部件内容" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<el-form-item label="维修内容">
|
|
|
|
|
<el-input v-model="form.repairContent" type="textarea" :rows="3" disabled />
|
|
|
|
|
<el-form-item label="检查后的故障判断">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="form.checkedFault"
|
|
|
|
|
type="textarea"
|
|
|
|
|
:rows="3"
|
|
|
|
|
disabled />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<el-form-item label="维修措施">
|
|
|
|
|
<el-input v-model="form.protectedMethod" type="textarea" :rows="3" disabled />
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="form.protectedMethod"
|
|
|
|
|
type="textarea"
|
|
|
|
|
:rows="3"
|
|
|
|
|
disabled />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
<el-form-item label="维修内容">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="form.repairContent"
|
|
|
|
|
type="textarea"
|
|
|
|
|
:rows="4"
|
|
|
|
|
disabled />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</template>
|
|
|
|
@ -249,7 +170,7 @@
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
|
|
|
|
|
<!-- 处理意见:除第一步外都需要 -->
|
|
|
|
|
<!-- 处理意见:审批时需要 -->
|
|
|
|
|
<el-col :span="24" v-if="needProcessResolution">
|
|
|
|
|
<el-form-item label="处理意见" prop="processHandleResolution">
|
|
|
|
|
<el-input
|
|
|
|
@ -277,12 +198,11 @@
|
|
|
|
|
|
|
|
|
|
<script setup name="FaultWorkOrderProcess" lang="ts">
|
|
|
|
|
// 导入相关模块
|
|
|
|
|
import { ref, reactive, computed, onMounted, getCurrentInstance, toRefs, watch } from 'vue';
|
|
|
|
|
import { ref, reactive, computed, onMounted, getCurrentInstance, toRefs } from 'vue';
|
|
|
|
|
import { useRoute, useRouter } from 'vue-router';
|
|
|
|
|
import { ElMessageBox, type FormInstance } from 'element-plus';
|
|
|
|
|
import type { ComponentInternalInstance } from 'vue';
|
|
|
|
|
import { getDmsBillsFaultInstance, approveWorkOrder, confirmRepairResult } from '@/api/dms/dmsBillsFaultInstance';
|
|
|
|
|
import { addDmsFaultInstanceActivity } from '@/api/dms/dmsFaultInstanceActivity';
|
|
|
|
|
import { pageByTaskWait } from '@/api/workflow/task';
|
|
|
|
|
import { getCurrentDateTime } from '@/utils/dateUtils';
|
|
|
|
|
import { getDmsBaseOutsourcingInfoList } from '@/api/dms/dmsBaseOutsourcingInfo';
|
|
|
|
|
import SubmitVerify from '@/views/dms/dmsFaultInstanceActivity/submitVerify.vue';
|
|
|
|
|
import ApprovalRecord from '@/components/Process/approvalRecord.vue';
|
|
|
|
@ -299,15 +219,14 @@ const routeParams = ref<Record<string, any>>({});
|
|
|
|
|
const workOrder = ref<any>({});
|
|
|
|
|
const workOrderStatusText = ref('');
|
|
|
|
|
const outsourceList = ref<any[]>([]);
|
|
|
|
|
const outsourcingName = ref('');
|
|
|
|
|
|
|
|
|
|
// 表单相关
|
|
|
|
|
const processFormRef = ref<ElFormInstance>();
|
|
|
|
|
const processFormRef = ref<FormInstance>();
|
|
|
|
|
const submitVerifyRef = ref<InstanceType<typeof SubmitVerify>>();
|
|
|
|
|
const approvalRecordRef = ref<InstanceType<typeof ApprovalRecord>>();
|
|
|
|
|
|
|
|
|
|
// 当前任务信息
|
|
|
|
|
const currentTask = ref<any>(null);
|
|
|
|
|
const currentStepOrder = ref(1);
|
|
|
|
|
// 任务变量
|
|
|
|
|
const taskVariables = ref<any>({});
|
|
|
|
|
|
|
|
|
|
// 表单数据
|
|
|
|
@ -325,7 +244,6 @@ const initFormData = {
|
|
|
|
|
repairConfirm: undefined,
|
|
|
|
|
componentsPartsId: undefined,
|
|
|
|
|
processHandleResolution: undefined,
|
|
|
|
|
processStepOrder: undefined,
|
|
|
|
|
approveStatus: undefined
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -333,68 +251,60 @@ const form = reactive({ ...initFormData });
|
|
|
|
|
|
|
|
|
|
// 表单验证规则
|
|
|
|
|
const rules = reactive({
|
|
|
|
|
faultType: [{ required: false, message: '故障类型不能为空', trigger: 'change' }],
|
|
|
|
|
faultDescription: [{ required: false, message: '故障描述不能为空', trigger: 'blur' }],
|
|
|
|
|
repairType: [{ required: false, message: '维修类型不能为空', trigger: 'change' }],
|
|
|
|
|
outsourcingId: [{ required: false, message: '外协单位不能为空', trigger: 'change' }],
|
|
|
|
|
repairer: [{ required: false, message: '维修人不能为空', trigger: 'blur' }],
|
|
|
|
|
checkedFault: [{ required: false, message: '检查后的故障判断不能为空', trigger: 'blur' }],
|
|
|
|
|
protectedMethod: [{ required: false, message: '维修措施不能为空', trigger: 'blur' }],
|
|
|
|
|
repairContent: [{ required: false, message: '维修内容不能为空', trigger: 'blur' }],
|
|
|
|
|
repairConfirm: [{ required: false, message: '维修结果不能为空', trigger: 'change' }],
|
|
|
|
|
processHandleResolution: [{ required: false, message: '处理意见不能为空', trigger: 'blur' }],
|
|
|
|
|
approveStatus: [{ required: false, message: '审批状态不能为空', trigger: 'change' }]
|
|
|
|
|
approveStatus: [{ required: false, message: '审批状态不能为空', trigger: 'change' }],
|
|
|
|
|
processHandleResolution: [{ required: false, message: '处理意见不能为空', trigger: 'blur' }]
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 计算属性
|
|
|
|
|
const needProcessResolution = computed(() => currentStepOrder.value > 1);
|
|
|
|
|
|
|
|
|
|
const currentStepName = computed(() => {
|
|
|
|
|
const stepNames = {
|
|
|
|
|
1: '故障报修',
|
|
|
|
|
2: '维修处理',
|
|
|
|
|
3: '维修确认'
|
|
|
|
|
};
|
|
|
|
|
return stepNames[currentStepOrder.value] || '处理工单';
|
|
|
|
|
const needProcessResolution = computed(() => {
|
|
|
|
|
return isApprovalStage.value || confirmButtonShow.value;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const currentStepTitle = computed(() => {
|
|
|
|
|
const stepTitles = {
|
|
|
|
|
1: '步骤1:故障报修(要求参数)',
|
|
|
|
|
2: '步骤2:维修处理(实际参数)',
|
|
|
|
|
3: '步骤3:维修确认'
|
|
|
|
|
};
|
|
|
|
|
return stepTitles[currentStepOrder.value] || '工单处理';
|
|
|
|
|
const currentStepName = computed(() => {
|
|
|
|
|
if (workOrder.value?.approveStatus === '1') {
|
|
|
|
|
return '审批工单';
|
|
|
|
|
}
|
|
|
|
|
return '处理工单';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const approvalButtonShow = computed(() => {
|
|
|
|
|
return routeParams.value.type === 'approval' && currentTask.value;
|
|
|
|
|
// 显示审批按钮的条件:工单审批状态为待审批(1)
|
|
|
|
|
return workOrder.value?.approveStatus === '1';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const confirmButtonShow = computed(() => {
|
|
|
|
|
// 显示确认按钮的条件:
|
|
|
|
|
// 1. 页面类型是confirm
|
|
|
|
|
// 2. 或者工单状态为维修完成(2)且确认状态为待确认(0)
|
|
|
|
|
// 3. 且审批状态为审批成功(2) - 只有审批通过的工单才能进行确认
|
|
|
|
|
return routeParams.value.type === 'confirm' ||
|
|
|
|
|
(workOrder.value?.billsStatus === '2' &&
|
|
|
|
|
workOrder.value?.repairConfirm === '0' &&
|
|
|
|
|
workOrder.value?.approveStatus === '2');
|
|
|
|
|
// 【调试信息】输出实际的字段值,帮助排查问题
|
|
|
|
|
console.log('主管确认按钮显示条件检查:', {
|
|
|
|
|
billsStatus: workOrder.value?.billsStatus,
|
|
|
|
|
billsStatusType: typeof workOrder.value?.billsStatus,
|
|
|
|
|
approveStatus: workOrder.value?.approveStatus,
|
|
|
|
|
approveStatusType: typeof workOrder.value?.approveStatus,
|
|
|
|
|
repairConfirm: workOrder.value?.repairConfirm,
|
|
|
|
|
repairConfirmType: typeof workOrder.value?.repairConfirm
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 显示主管确认按钮的条件:
|
|
|
|
|
// 工单状态为维修完成(2) && 审批状态为审批成功(2) && 确认状态为待确认(0)
|
|
|
|
|
// 【修复】使用字符串比较,并处理可能的数据类型问题
|
|
|
|
|
const billsStatusMatches = String(workOrder.value?.billsStatus) === '2';
|
|
|
|
|
const approveStatusMatches = String(workOrder.value?.approveStatus) === '2';
|
|
|
|
|
const repairConfirmMatches = String(workOrder.value?.repairConfirm) === '0';
|
|
|
|
|
|
|
|
|
|
const shouldShow = billsStatusMatches && approveStatusMatches && repairConfirmMatches;
|
|
|
|
|
|
|
|
|
|
console.log('主管确认按钮显示结果:', {
|
|
|
|
|
billsStatusMatches,
|
|
|
|
|
approveStatusMatches,
|
|
|
|
|
repairConfirmMatches,
|
|
|
|
|
shouldShow
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return shouldShow;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 是否为审批阶段
|
|
|
|
|
const isApprovalStage = computed(() => {
|
|
|
|
|
return routeParams.value.type === 'approval' && workOrder.value?.approveStatus === '1';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 提交按钮显示控制逻辑
|
|
|
|
|
const submitButtonShow = computed(() => {
|
|
|
|
|
return (
|
|
|
|
|
routeParams.value.type === 'add' ||
|
|
|
|
|
(routeParams.value.type === 'update' &&
|
|
|
|
|
workOrder.value?.billsStatus &&
|
|
|
|
|
(workOrder.value.billsStatus === 'draft' || workOrder.value.billsStatus === 'cancel' || workOrder.value.billsStatus === 'back'))
|
|
|
|
|
);
|
|
|
|
|
return workOrder.value?.approveStatus === '1';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 初始化
|
|
|
|
@ -409,11 +319,6 @@ onMounted(async () => {
|
|
|
|
|
// 获取外协单位列表
|
|
|
|
|
await getOutsourceList();
|
|
|
|
|
|
|
|
|
|
// 获取当前任务信息
|
|
|
|
|
if (routeParams.value.type === 'approval') {
|
|
|
|
|
await loadCurrentTask();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 初始化表单数据
|
|
|
|
|
initializeFormData();
|
|
|
|
|
|
|
|
|
@ -422,28 +327,19 @@ onMounted(async () => {
|
|
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('初始化失败:', error);
|
|
|
|
|
proxy?.$modal.msgError('加载数据失败');
|
|
|
|
|
(proxy as any)?.$modal.msgError('加载数据失败');
|
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 监听维修类型变化,动态更新外协单位验证规则
|
|
|
|
|
watch(() => form.repairType, (newValue) => {
|
|
|
|
|
updateOutsourcingValidation();
|
|
|
|
|
// 如果从外协类型改为其他类型,清空外协单位选择
|
|
|
|
|
if (newValue !== '2') {
|
|
|
|
|
form.outsourcingId = undefined;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 加载工单信息
|
|
|
|
|
const loadWorkOrderInfo = async () => {
|
|
|
|
|
// 从query参数获取businessId
|
|
|
|
|
const businessId = routeParams.value.id;
|
|
|
|
|
|
|
|
|
|
if (!businessId) {
|
|
|
|
|
proxy?.$modal.msgError('缺少工单ID参数');
|
|
|
|
|
(proxy as any)?.$modal.msgError('缺少工单ID参数');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -454,50 +350,10 @@ const loadWorkOrderInfo = async () => {
|
|
|
|
|
workOrderStatusText.value = getStatusText(workOrder.value.billsStatus || '');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 加载当前任务信息
|
|
|
|
|
const loadCurrentTask = async () => {
|
|
|
|
|
// 从query参数获取businessId和taskId
|
|
|
|
|
const businessId = routeParams.value.id;
|
|
|
|
|
const taskId = routeParams.value.taskId;
|
|
|
|
|
|
|
|
|
|
// 通过taskId或businessId获取当前任务
|
|
|
|
|
const taskRes = await pageByTaskWait({
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
flowCode: 'Fault01' // 故障维修流程代码
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const tasks = taskRes.rows.filter(task =>
|
|
|
|
|
task.businessId === businessId || task.id === taskId
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (tasks.length > 0) {
|
|
|
|
|
currentTask.value = tasks[0];
|
|
|
|
|
|
|
|
|
|
// 根据节点名称确定当前步骤
|
|
|
|
|
const nodeName = currentTask.value.nodeName;
|
|
|
|
|
if (nodeName === '故障报修') {
|
|
|
|
|
currentStepOrder.value = 1;
|
|
|
|
|
} else if (nodeName === '维修处理') {
|
|
|
|
|
currentStepOrder.value = 2;
|
|
|
|
|
} else if (nodeName === '维修确认') {
|
|
|
|
|
currentStepOrder.value = 3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 动态设置处理意见校验规则
|
|
|
|
|
if (needProcessResolution.value) {
|
|
|
|
|
rules.processHandleResolution = [
|
|
|
|
|
{ required: true, message: '处理意见不能为空', trigger: 'blur' }
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 初始化表单数据
|
|
|
|
|
const initializeFormData = () => {
|
|
|
|
|
// 基础信息从工单获取
|
|
|
|
|
form.repairInstanceId = workOrder.value?.repairInstanceId;
|
|
|
|
|
form.processStepOrder = currentStepOrder.value;
|
|
|
|
|
|
|
|
|
|
// 处理所有字段,确保没有undefined值
|
|
|
|
|
form.faultType = workOrder.value?.faultType || '';
|
|
|
|
@ -511,84 +367,19 @@ const initializeFormData = () => {
|
|
|
|
|
form.repairer = workOrder.value?.repairer || '';
|
|
|
|
|
form.repairConfirm = workOrder.value?.repairConfirm || '';
|
|
|
|
|
form.componentsPartsId = workOrder.value?.componentsPartsId || '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置外协单位名称
|
|
|
|
|
if (form.outsourcingId && outsourceList.value.length > 0) {
|
|
|
|
|
const outsourcing = outsourceList.value.find(item => item.outsourcingId === form.outsourcingId);
|
|
|
|
|
outsourcingName.value = outsourcing?.outsourcingName || '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 如果是审批阶段,设置默认审批状态
|
|
|
|
|
if (routeParams.value.type === 'approval' && !form.approveStatus) {
|
|
|
|
|
form.approveStatus = undefined; // 保持未选择状态,让用户必须选择
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 提交表单方法
|
|
|
|
|
const submitForm = async (status: string) => {
|
|
|
|
|
if (!processFormRef.value) return;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const valid = await processFormRef.value.validate();
|
|
|
|
|
if (valid) {
|
|
|
|
|
buttonLoading.value = true;
|
|
|
|
|
|
|
|
|
|
if (status === 'draft') {
|
|
|
|
|
// 暂存逻辑
|
|
|
|
|
await addDmsFaultInstanceActivity({
|
|
|
|
|
repairInstanceId: form.repairInstanceId,
|
|
|
|
|
faultType: form.faultType,
|
|
|
|
|
faultDescription: form.faultDescription,
|
|
|
|
|
designOperations: form.designOperations,
|
|
|
|
|
repairType: form.repairType,
|
|
|
|
|
outsourcingId: form.outsourcingId,
|
|
|
|
|
checkedFault: form.checkedFault || '',
|
|
|
|
|
repairContent: form.repairContent || '',
|
|
|
|
|
protectedMethod: form.protectedMethod || '',
|
|
|
|
|
repairer: form.repairer || '',
|
|
|
|
|
repairConfirm: form.repairConfirm,
|
|
|
|
|
componentsPartsId: form.componentsPartsId,
|
|
|
|
|
processHandleResolution: form.processHandleResolution || '',
|
|
|
|
|
processStepOrder: form.processStepOrder,
|
|
|
|
|
handleTime: getCurrentDateTime()
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
proxy?.$modal.msgSuccess('暂存成功');
|
|
|
|
|
goBack();
|
|
|
|
|
} else {
|
|
|
|
|
// 提交逻辑
|
|
|
|
|
// 准备任务变量
|
|
|
|
|
taskVariables.value = {
|
|
|
|
|
entity: {
|
|
|
|
|
repairInstanceId: form.repairInstanceId,
|
|
|
|
|
faultType: form.faultType,
|
|
|
|
|
faultDescription: form.faultDescription,
|
|
|
|
|
designOperations: form.designOperations,
|
|
|
|
|
repairType: form.repairType,
|
|
|
|
|
outsourcingId: form.outsourcingId,
|
|
|
|
|
checkedFault: form.checkedFault || '',
|
|
|
|
|
repairContent: form.repairContent || '',
|
|
|
|
|
protectedMethod: form.protectedMethod || '',
|
|
|
|
|
repairer: form.repairer || '',
|
|
|
|
|
repairConfirm: form.repairConfirm,
|
|
|
|
|
componentsPartsId: form.componentsPartsId,
|
|
|
|
|
processHandleResolution: form.processHandleResolution || '',
|
|
|
|
|
processStepOrder: form.processStepOrder
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 启动工作流或继续处理
|
|
|
|
|
if (routeParams.value.taskId) {
|
|
|
|
|
submitVerifyRef.value?.openDialog(routeParams.value.taskId);
|
|
|
|
|
} else {
|
|
|
|
|
// 处理新建状态的提交
|
|
|
|
|
proxy?.$modal.msgSuccess('提交成功');
|
|
|
|
|
goBack();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('提交失败:', error);
|
|
|
|
|
proxy?.$modal.msgError('提交失败');
|
|
|
|
|
} finally {
|
|
|
|
|
buttonLoading.value = false;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 审批处理
|
|
|
|
|
const approvalVerifyOpen = async () => {
|
|
|
|
|
if (!processFormRef.value) return;
|
|
|
|
@ -596,26 +387,26 @@ const approvalVerifyOpen = async () => {
|
|
|
|
|
try {
|
|
|
|
|
const valid = await processFormRef.value.validate();
|
|
|
|
|
if (valid) {
|
|
|
|
|
await proxy?.$modal.confirm('是否确认提交审批?');
|
|
|
|
|
|
|
|
|
|
await (proxy as any)?.$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}成功`);
|
|
|
|
|
|
|
|
|
|
(proxy as any)?.$modal.msgSuccess(`审批${statusText}成功`);
|
|
|
|
|
|
|
|
|
|
// 关闭页面返回
|
|
|
|
|
goBack();
|
|
|
|
|
}
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
if (error !== 'cancel' && error !== 'close') {
|
|
|
|
|
console.error('审批失败:', error);
|
|
|
|
|
proxy?.$modal.msgError('审批失败:' + (error.message || '未知错误'));
|
|
|
|
|
(proxy as any)?.$modal.msgError('审批失败:' + (error.message || '未知错误'));
|
|
|
|
|
}
|
|
|
|
|
} finally {
|
|
|
|
|
buttonLoading.value = false;
|
|
|
|
@ -629,50 +420,67 @@ const submitCallback = async (approvalResult?: any) => {
|
|
|
|
|
// 主管确认逻辑
|
|
|
|
|
const confirmResult = form.repairConfirm || '1'; // 默认确认通过
|
|
|
|
|
await confirmRepairResult(form.repairInstanceId, confirmResult);
|
|
|
|
|
proxy?.$modal.msgSuccess('确认完成');
|
|
|
|
|
} else {
|
|
|
|
|
// 保存工单实例活动记录
|
|
|
|
|
await addDmsFaultInstanceActivity({
|
|
|
|
|
repairInstanceId: form.repairInstanceId,
|
|
|
|
|
faultType: form.faultType,
|
|
|
|
|
faultDescription: form.faultDescription,
|
|
|
|
|
designOperations: form.designOperations,
|
|
|
|
|
repairType: form.repairType,
|
|
|
|
|
outsourcingId: form.outsourcingId,
|
|
|
|
|
checkedFault: form.checkedFault || '',
|
|
|
|
|
repairContent: form.repairContent || '',
|
|
|
|
|
protectedMethod: form.protectedMethod || '',
|
|
|
|
|
repairer: form.repairer || '',
|
|
|
|
|
repairConfirm: form.repairConfirm,
|
|
|
|
|
componentsPartsId: form.componentsPartsId,
|
|
|
|
|
processHandleResolution: form.processHandleResolution || '',
|
|
|
|
|
processStepOrder: form.processStepOrder,
|
|
|
|
|
handleTime: getCurrentDateTime()
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
proxy?.$modal.msgSuccess(`${currentStepName.value}完成`);
|
|
|
|
|
(proxy as any)?.$modal.msgSuccess('确认完成');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 关闭页面返回
|
|
|
|
|
goBack();
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
console.error('操作失败:', error);
|
|
|
|
|
proxy?.$modal.msgError('操作失败:' + (error.message || '未知错误'));
|
|
|
|
|
(proxy as any)?.$modal.msgError('操作失败:' + (error.message || '未知错误'));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 主管确认处理
|
|
|
|
|
const handleConfirm = async () => {
|
|
|
|
|
try {
|
|
|
|
|
// 设置确认结果
|
|
|
|
|
// 使用自定义按钮的确认对话框
|
|
|
|
|
const result = await ElMessageBox.confirm(
|
|
|
|
|
'请选择维修结果确认方式:\n• 通过:维修通过,工单完成\n• 退回:维修不通过,返回维修环节重新维修',
|
|
|
|
|
'主管确认',
|
|
|
|
|
{
|
|
|
|
|
confirmButtonText: '通过',
|
|
|
|
|
cancelButtonText: '退回',
|
|
|
|
|
type: 'warning',
|
|
|
|
|
distinguishCancelAndClose: true
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
buttonLoading.value = true;
|
|
|
|
|
|
|
|
|
|
// 用户点击通过,设置为确认通过
|
|
|
|
|
form.repairConfirm = '1'; // 1表示确认通过
|
|
|
|
|
|
|
|
|
|
// 调用审批处理方法(实际上是工作流处理)
|
|
|
|
|
await approvalVerifyOpen();
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
if (error !== 'cancel' && error !== 'close') {
|
|
|
|
|
console.error('确认失败:', error);
|
|
|
|
|
proxy?.$modal.msgError('确认失败:' + (error.message || '未知错误'));
|
|
|
|
|
// 调用主管确认接口
|
|
|
|
|
await confirmRepairResult(form.repairInstanceId, form.repairConfirm);
|
|
|
|
|
(proxy as any)?.$modal.msgSuccess('确认通过完成');
|
|
|
|
|
goBack();
|
|
|
|
|
|
|
|
|
|
} catch (action: any) {
|
|
|
|
|
if (action === 'cancel') {
|
|
|
|
|
// 用户点击退回,设置为确认不通过
|
|
|
|
|
try {
|
|
|
|
|
buttonLoading.value = true;
|
|
|
|
|
form.repairConfirm = '2'; // 2表示确认不通过
|
|
|
|
|
await confirmRepairResult(form.repairInstanceId, form.repairConfirm);
|
|
|
|
|
(proxy as any)?.$modal.msgSuccess('退回维修环节完成');
|
|
|
|
|
goBack();
|
|
|
|
|
} catch (confirmError: any) {
|
|
|
|
|
console.error('退回操作失败:', confirmError);
|
|
|
|
|
(proxy as any)?.$modal.msgError('退回操作失败:' + (confirmError.message || '未知错误'));
|
|
|
|
|
} finally {
|
|
|
|
|
buttonLoading.value = false;
|
|
|
|
|
}
|
|
|
|
|
} else if (action === 'close') {
|
|
|
|
|
// 用户点击关闭按钮或按ESC键,不执行任何操作
|
|
|
|
|
console.log('用户取消了确认操作');
|
|
|
|
|
} else {
|
|
|
|
|
console.error('确认失败:', action);
|
|
|
|
|
(proxy as any)?.$modal.msgError('确认失败:' + (action.message || '未知错误'));
|
|
|
|
|
}
|
|
|
|
|
} finally {
|
|
|
|
|
if (form.repairConfirm === '1') {
|
|
|
|
|
buttonLoading.value = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
@ -684,7 +492,7 @@ const handleApprovalRecord = () => {
|
|
|
|
|
|
|
|
|
|
// 返回
|
|
|
|
|
const goBack = () => {
|
|
|
|
|
proxy?.$tab.closePage(proxy?.$route);
|
|
|
|
|
(proxy as any)?.$tab.closePage((proxy as any)?.$route);
|
|
|
|
|
router.go(-1);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -698,16 +506,6 @@ const getOutsourceList = async () => {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 更新外协单位验证规则
|
|
|
|
|
const updateOutsourcingValidation = () => {
|
|
|
|
|
// 只有在非审批阶段且维修类型为外协时才设置为必填
|
|
|
|
|
if (routeParams.value.type !== 'approval' && form.repairType === '2') {
|
|
|
|
|
rules.outsourcingId = [{ required: true, message: '外协单位不能为空', trigger: 'change' }];
|
|
|
|
|
} else {
|
|
|
|
|
rules.outsourcingId = [{ required: false, message: '外协单位不能为空', trigger: 'change' }];
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 动态设置表单验证规则
|
|
|
|
|
const setDynamicValidationRules = () => {
|
|
|
|
|
// 重置所有规则为非必填
|
|
|
|
@ -715,44 +513,17 @@ const setDynamicValidationRules = () => {
|
|
|
|
|
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' }];
|
|
|
|
|
if (needProcessResolution.value) {
|
|
|
|
|
rules.processHandleResolution = [{ required: true, message: '处理意见不能为空', trigger: 'blur' }];
|
|
|
|
|
}
|
|
|
|
|
} else if (routeParams.value.type === 'confirm') {
|
|
|
|
|
// 确认阶段只需要确认结果和处理意见
|
|
|
|
|
rules.repairConfirm = [{ required: true, message: '维修结果不能为空', trigger: 'change' }];
|
|
|
|
|
rules.processHandleResolution = [{ required: true, message: '处理意见不能为空', trigger: 'blur' }];
|
|
|
|
|
} else {
|
|
|
|
|
// 新增或编辑模式,根据当前步骤设置验证规则
|
|
|
|
|
if (currentStepOrder.value === 1) {
|
|
|
|
|
// 第一步:故障报修
|
|
|
|
|
rules.faultType = [{ required: true, message: '故障类型不能为空', trigger: 'change' }];
|
|
|
|
|
rules.faultDescription = [{ required: true, message: '故障描述不能为空', trigger: 'blur' }];
|
|
|
|
|
rules.repairType = [{ required: true, message: '维修类型不能为空', trigger: 'change' }];
|
|
|
|
|
} else if (currentStepOrder.value === 2) {
|
|
|
|
|
// 第二步:维修处理
|
|
|
|
|
rules.repairer = [{ required: true, message: '维修人不能为空', trigger: 'blur' }];
|
|
|
|
|
rules.checkedFault = [{ required: true, message: '检查后的故障判断不能为空', trigger: 'blur' }];
|
|
|
|
|
rules.protectedMethod = [{ required: true, message: '维修措施不能为空', trigger: 'blur' }];
|
|
|
|
|
rules.repairContent = [{ required: true, message: '维修内容不能为空', trigger: 'blur' }];
|
|
|
|
|
if (needProcessResolution.value) {
|
|
|
|
|
rules.processHandleResolution = [{ required: true, message: '处理意见不能为空', trigger: 'blur' }];
|
|
|
|
|
}
|
|
|
|
|
} else if (currentStepOrder.value === 3) {
|
|
|
|
|
// 第三步:维修确认
|
|
|
|
|
rules.repairConfirm = [{ required: true, message: '维修结果不能为空', trigger: 'change' }];
|
|
|
|
|
if (needProcessResolution.value) {
|
|
|
|
|
rules.processHandleResolution = [{ required: true, message: '处理意见不能为空', trigger: 'blur' }];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (workOrder.value?.billsStatus === '2' &&
|
|
|
|
|
workOrder.value?.approveStatus === '2' &&
|
|
|
|
|
workOrder.value?.repairConfirm === '0') {
|
|
|
|
|
// 主管确认阶段:需要处理意见
|
|
|
|
|
rules.processHandleResolution = [{ required: true, message: '处理意见不能为空', trigger: 'blur' }];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 更新外协单位验证规则
|
|
|
|
|
updateOutsourcingValidation();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 工具函数
|
|
|
|
|