|
|
|
@ -4,6 +4,20 @@
|
|
|
|
|
<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>
|
|
|
|
|
<el-button
|
|
|
|
|
v-if="approvalButtonShow"
|
|
|
|
|
:loading="buttonLoading"
|
|
|
|
@ -112,7 +126,8 @@ import {
|
|
|
|
|
DmsBillsInspectInstanceActivityForm
|
|
|
|
|
} from '@/api/dms/dmsBillsInspectInstanceActivity/types';
|
|
|
|
|
import { getDmsBillsInspectInstance } from '@/api/dms/dmsBillsInspectInstance';
|
|
|
|
|
import { getCurrentTask } from '@/api/workflow/task';
|
|
|
|
|
import { pageByTaskWait } from '@/api/workflow/task';
|
|
|
|
|
import { getCurrentDateTime } from '@/utils/dateUtils';
|
|
|
|
|
import SubmitVerify from '@/components/Process/submitVerify.vue';
|
|
|
|
|
import ApprovalRecord from '@/components/Process/approvalRecord.vue';
|
|
|
|
|
|
|
|
|
@ -121,30 +136,32 @@ const { inspect_status } = toRefs<any>(proxy?.useDict('inspect_status'));
|
|
|
|
|
const route = useRoute();
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
|
|
// 基础数据
|
|
|
|
|
const loading = ref(true);
|
|
|
|
|
const buttonLoading = ref(false);
|
|
|
|
|
const routeParams = ref<Record<string, any>>({});
|
|
|
|
|
const workOrder = ref<any>({});
|
|
|
|
|
const workOrderStatusText = ref('');
|
|
|
|
|
|
|
|
|
|
// 表单引用
|
|
|
|
|
const processFormRef = ref<FormInstance>();
|
|
|
|
|
const submitVerifyRef = ref<InstanceType<typeof SubmitVerify>>();
|
|
|
|
|
const approvalRecordRef = ref<InstanceType<typeof ApprovalRecord>>();
|
|
|
|
|
|
|
|
|
|
// 基础数据
|
|
|
|
|
const loading = ref(false);
|
|
|
|
|
const buttonLoading = ref(false);
|
|
|
|
|
const workOrder = ref<any>({});
|
|
|
|
|
const workOrderStatusText = ref('');
|
|
|
|
|
// 当前任务信息
|
|
|
|
|
const currentTask = ref<any>(null);
|
|
|
|
|
const taskVariables = ref<any>({});
|
|
|
|
|
|
|
|
|
|
// 路由参数
|
|
|
|
|
const routeParams = computed(() => route.query);
|
|
|
|
|
|
|
|
|
|
// 表单数据
|
|
|
|
|
const form = reactive<Partial<DmsBillsInspectInstanceActivityForm>>({
|
|
|
|
|
inspectInstanceId: routeParams.value.id,
|
|
|
|
|
const initFormData = {
|
|
|
|
|
inspectInstanceId: undefined,
|
|
|
|
|
inspectRouteId: undefined,
|
|
|
|
|
deviceAmount: undefined,
|
|
|
|
|
performer: undefined,
|
|
|
|
|
processHandleResolution: undefined
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const form = reactive<Partial<DmsBillsInspectInstanceActivityForm>>({ ...initFormData });
|
|
|
|
|
|
|
|
|
|
// 表单验证规则
|
|
|
|
|
const rules = reactive<FormRules>({
|
|
|
|
@ -173,9 +190,21 @@ const needProcessResolution = computed(() => {
|
|
|
|
|
return routeParams.value.type === 'approval';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 新增:提交按钮显示控制逻辑
|
|
|
|
|
const submitButtonShow = computed(() => {
|
|
|
|
|
return (
|
|
|
|
|
routeParams.value.type === 'add' ||
|
|
|
|
|
(routeParams.value.type === 'update' &&
|
|
|
|
|
workOrder.value.inspectStatus &&
|
|
|
|
|
(workOrder.value.inspectStatus === 'draft' || workOrder.value.inspectStatus === 'cancel' || workOrder.value.inspectStatus === 'back'))
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 初始化
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
routeParams.value = route.query;
|
|
|
|
|
loading.value = true;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// 获取工单信息
|
|
|
|
|
await loadWorkOrderInfo();
|
|
|
|
@ -219,10 +248,29 @@ const loadWorkOrderInfo = async () => {
|
|
|
|
|
// 加载当前任务信息
|
|
|
|
|
const loadCurrentTask = async () => {
|
|
|
|
|
try {
|
|
|
|
|
const businessId = routeParams.value.id;
|
|
|
|
|
const taskId = routeParams.value.taskId;
|
|
|
|
|
if (taskId) {
|
|
|
|
|
const res = await getCurrentTask(taskId);
|
|
|
|
|
currentTask.value = res.data;
|
|
|
|
|
|
|
|
|
|
// 通过taskId或businessId获取当前任务
|
|
|
|
|
const taskRes = await pageByTaskWait({
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
flowCode: 'Inspect01' // 巡检流程代码
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const tasks = taskRes.rows.filter(task =>
|
|
|
|
|
task.businessId === businessId || task.id === taskId
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (tasks.length > 0) {
|
|
|
|
|
currentTask.value = tasks[0];
|
|
|
|
|
|
|
|
|
|
// 动态设置处理意见校验规则
|
|
|
|
|
if (needProcessResolution.value) {
|
|
|
|
|
rules.processHandleResolution = [
|
|
|
|
|
{ required: true, message: '处理意见不能为空', trigger: 'blur' }
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('获取任务信息失败:', error);
|
|
|
|
@ -236,10 +284,58 @@ const initializeFormData = () => {
|
|
|
|
|
form.inspectRouteId = workOrder.value.inspectRouteId;
|
|
|
|
|
form.deviceAmount = workOrder.value.deviceAmount;
|
|
|
|
|
form.performer = workOrder.value.performer;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 新增:提交表单方法
|
|
|
|
|
const submitForm = async (status: string) => {
|
|
|
|
|
if (!processFormRef.value) return;
|
|
|
|
|
|
|
|
|
|
// 如果是审批模式,需要处理意见
|
|
|
|
|
if (routeParams.value.type === 'approval') {
|
|
|
|
|
rules.processHandleResolution = [{ required: true, message: "处理意见不能为空", trigger: "blur" }];
|
|
|
|
|
try {
|
|
|
|
|
const valid = await processFormRef.value.validate();
|
|
|
|
|
if (valid) {
|
|
|
|
|
buttonLoading.value = true;
|
|
|
|
|
|
|
|
|
|
if (status === 'draft') {
|
|
|
|
|
// 暂存逻辑
|
|
|
|
|
await addDmsBillsInspectInstanceActivity({
|
|
|
|
|
inspectInstanceId: form.inspectInstanceId,
|
|
|
|
|
inspectRouteId: form.inspectRouteId,
|
|
|
|
|
deviceAmount: form.deviceAmount,
|
|
|
|
|
performer: form.performer,
|
|
|
|
|
processHandleResolution: form.processHandleResolution || '',
|
|
|
|
|
handleTime: getCurrentDateTime()
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
proxy?.$modal.msgSuccess('暂存成功');
|
|
|
|
|
goBack();
|
|
|
|
|
} else {
|
|
|
|
|
// 提交逻辑
|
|
|
|
|
// 准备任务变量
|
|
|
|
|
taskVariables.value = {
|
|
|
|
|
entity: {
|
|
|
|
|
inspectInstanceId: form.inspectInstanceId,
|
|
|
|
|
inspectRouteId: form.inspectRouteId,
|
|
|
|
|
deviceAmount: form.deviceAmount,
|
|
|
|
|
performer: form.performer,
|
|
|
|
|
processHandleResolution: form.processHandleResolution || ''
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 启动工作流或继续处理
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -265,7 +361,7 @@ const approvalVerifyOpen = async () => {
|
|
|
|
|
submitVerifyRef.value?.openDialog(routeParams.value.taskId);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
proxy?.$modal.msgError('表单验证失败');
|
|
|
|
|
proxy?.$modal.msgError('表单验证失败,请检查输入项');
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -278,17 +374,6 @@ const handleApprovalRecord = () => {
|
|
|
|
|
const submitCallback = async () => {
|
|
|
|
|
try {
|
|
|
|
|
// 保存工单实例活动记录
|
|
|
|
|
const getCurrentDateTime = () => {
|
|
|
|
|
const now = new Date();
|
|
|
|
|
const year = now.getFullYear();
|
|
|
|
|
const month = (now.getMonth() + 1).toString().padStart(2, '0');
|
|
|
|
|
const day = now.getDate().toString().padStart(2, '0');
|
|
|
|
|
const hours = now.getHours().toString().padStart(2, '0');
|
|
|
|
|
const minutes = now.getMinutes().toString().padStart(2, '0');
|
|
|
|
|
const seconds = now.getSeconds().toString().padStart(2, '0');
|
|
|
|
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
await addDmsBillsInspectInstanceActivity({
|
|
|
|
|
inspectInstanceId: form.inspectInstanceId,
|
|
|
|
|
inspectRouteId: form.inspectRouteId,
|
|
|
|
@ -311,7 +396,7 @@ const submitCallback = async () => {
|
|
|
|
|
// 返回
|
|
|
|
|
const goBack = () => {
|
|
|
|
|
proxy?.$tab.closePage(proxy?.$route);
|
|
|
|
|
proxy?.$router.go(-1);
|
|
|
|
|
router.go(-1);
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|