From 5b248a9716688d8132cfb02b4ba0abecd4060b06 Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期三, 20 五月 2026 11:49:08 +0800
Subject: [PATCH] 审批模板流程化

---
 src/views/officeProcessAutomation/ApproveManage/approve-list/useApproveList.js |   61 +++++++++++-------------------
 1 files changed, 22 insertions(+), 39 deletions(-)

diff --git a/src/views/officeProcessAutomation/ApproveManage/approve-list/useApproveList.js b/src/views/officeProcessAutomation/ApproveManage/approve-list/useApproveList.js
index 4b8510a..27706b9 100644
--- a/src/views/officeProcessAutomation/ApproveManage/approve-list/useApproveList.js
+++ b/src/views/officeProcessAutomation/ApproveManage/approve-list/useApproveList.js
@@ -18,11 +18,13 @@
   fetchBusinessTypeOptions,
   formatDisplayTime,
   mapEnabledFromApi,
-  mapTemplateFromApi,
-  unwrapTemplateDetail,
   unwrapTemplateList,
 } from "../approve-template/approveTemplateConstants.js";
-import { buildSubmitTemplateFromRow } from "../approve-template/formConfigUtils.js";
+import {
+  buildFormPayloadRules,
+  buildTemplateBindingFromDetail,
+  validateTemplateBinding,
+} from "../approve-shared/approvalTemplateBindingUtils.js";
 import {
   APPROVAL_TYPE_OPTIONS,
   approvalStatusLabel,
@@ -37,7 +39,6 @@
   mapInstanceFromApi,
   mapSubmitTemplateCard,
   matchBusinessTypeValue,
-  validateSubmitFlowNodes,
   unwrapInstancePage,
 } from "./approveListConstants.js";
 
@@ -111,22 +112,10 @@
     return submitForm.formFieldDefs || [];
   });
 
-  const submitFormRules = computed(() => {
-    const rules = {
-      templateKey: [{ required: true, message: "璇烽�夋嫨瀹℃壒绫诲瀷", trigger: "change" }],
-    };
-    submitFormFields.value.forEach((f) => {
-      if (!f.required) return;
-      if (f.type === "number") {
-        rules[`formPayload.${f.key}`] = [{ required: true, message: `璇峰~鍐�${f.label}`, trigger: "blur" }];
-      } else if (f.type === "datetimerange") {
-        rules[`formPayload.${f.key}`] = [{ required: true, message: `璇烽�夋嫨${f.label}`, trigger: "change" }];
-      } else {
-        rules[`formPayload.${f.key}`] = [{ required: true, message: `璇峰~鍐�${f.label}`, trigger: "blur" }];
-      }
-    });
-    return rules;
-  });
+  const submitFormRules = computed(() => ({
+    templateKey: [{ required: true, message: "璇烽�夋嫨瀹℃壒绫诲瀷", trigger: "change" }],
+    ...buildFormPayloadRules(submitFormFields.value),
+  }));
 
   const tableColumn = ref([
     { label: "鐢宠浜虹紪鍙�", prop: "applicantNo", width: 110 },
@@ -291,18 +280,12 @@
     submitTemplatesLoading.value = true;
     try {
       const res = await getApprovalTemplateDetail(card.id);
-      const mapped = mapTemplateFromApi(unwrapTemplateDetail(res));
-      const tpl = {
-        ...buildSubmitTemplateFromRow(mapped),
-        templateId: mapped.id,
-      };
-      const base = createEmptySubmitForm(String(card.id), tpl, mapped.flowNodes);
+      const applied = buildTemplateBindingFromDetail(res);
       Object.assign(submitForm, {
-        ...base,
-        templateName: mapped.templateName || tpl.label || "",
-        businessType: mapped.businessType ?? card.businessType ?? selectedBusinessType.value,
-        templateSnapshot: tpl,
-        formFieldDefs: tpl.fields || [],
+        templateKey: String(card.id),
+        ...applied,
+        businessType:
+          applied.businessType ?? card.businessType ?? selectedBusinessType.value,
       });
       submitDialog.step = 3;
     } catch {
@@ -343,9 +326,9 @@
       return false;
     }
     if (!activeTemplate.value) return false;
-    const flowCheck = validateSubmitFlowNodes(submitForm.flowNodes);
-    if (!flowCheck.ok) {
-      ElMessage.warning(flowCheck.message);
+    const bindingCheck = validateTemplateBinding({ flowNodes: submitForm.flowNodes });
+    if (!bindingCheck.ok) {
+      ElMessage.warning(bindingCheck.message);
       return false;
     }
     if (!submitForm.templateId) {
@@ -360,7 +343,7 @@
           submitForm,
           activeTemplate: activeTemplate.value,
           userStore,
-          flowNodes: flowCheck.nodes,
+          flowNodes: bindingCheck.nodes,
         })
       );
       submitDialog.visible = false;
@@ -382,9 +365,9 @@
       return false;
     }
     if (!activeTemplate.value) return false;
-    const flowCheck = validateSubmitFlowNodes(submitForm.flowNodes);
-    if (!flowCheck.ok) {
-      ElMessage.warning(flowCheck.message);
+    const bindingCheck = validateTemplateBinding({ flowNodes: submitForm.flowNodes });
+    if (!bindingCheck.ok) {
+      ElMessage.warning(bindingCheck.message);
       return false;
     }
     if (!submitForm.instanceId) {
@@ -398,7 +381,7 @@
         buildInstanceDto({
           submitForm,
           activeTemplate: activeTemplate.value,
-          flowNodes: flowCheck.nodes,
+          flowNodes: bindingCheck.nodes,
           existingRow: submitEditRow.value,
         })
       );

--
Gitblit v1.9.3