From 47bae1f938f915206e3934ea960aff975e5738c9 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期五, 12 六月 2026 16:09:49 +0800
Subject: [PATCH] feat(teachingDemo): 新增工艺路线与BOM教学演示模块

---
 src/views/officeProcessAutomation/ApproveManage/approve-template/useApproveTemplate.js |   42 +++++++++++++++++++++++++++++++++++-------
 1 files changed, 35 insertions(+), 7 deletions(-)

diff --git a/src/views/officeProcessAutomation/ApproveManage/approve-template/useApproveTemplate.js b/src/views/officeProcessAutomation/ApproveManage/approve-template/useApproveTemplate.js
index 0dbf2ca..79e96bc 100644
--- a/src/views/officeProcessAutomation/ApproveManage/approve-template/useApproveTemplate.js
+++ b/src/views/officeProcessAutomation/ApproveManage/approve-template/useApproveTemplate.js
@@ -3,17 +3,18 @@
   deleteApprovalTemplate,
   getApprovalTemplateDetail,
   listApprovalTemplatePage,
-  TEMPLATE_TYPE_CUSTOM,
+  TEMPLATE_TYPE_BUILTIN,
   updateApprovalTemplate,
 } from "@/api/officeProcessAutomation/approvalTemplate.js";
 import { Search } from "@element-plus/icons-vue";
 import { ElMessage, ElMessageBox } from "element-plus";
-import { reactive, ref } from "vue";
+import { computed, reactive, ref } from "vue";
 import {
   buildApprovalTemplateListParams,
   createEmptyTemplateForm,
   fetchBusinessTypeOptions,
   flowNodesSummary,
+  isBuiltinTemplate,
   mapTemplateFromApi,
   mapTemplateToApi,
   nodeSignModeLabel,
@@ -58,6 +59,10 @@
   const formDialog = reactive({ visible: false, title: "", mode: "add" });
   const form = reactive(createEmptyTemplateForm());
   const formRef = ref();
+
+  const isEditingBuiltin = computed(
+    () => formDialog.mode === "edit" && Number(form.templateType) === TEMPLATE_TYPE_BUILTIN
+  );
 
   async function loadTemplateTypeOptions() {
     try {
@@ -140,6 +145,7 @@
           name: "鍒犻櫎",
           type: "danger",
           link: true,
+          disabled: (row) => isBuiltinTemplate(row),
           clickFun: (row) => removeTemplate(row),
         },
       ],
@@ -186,26 +192,43 @@
       Object.assign(form, base);
       return;
     }
+    const formConfigData = JSON.parse(
+      JSON.stringify(row.formConfigData || parseFormConfigToData(row.formConfig))
+    );
+    const builtin = isBuiltinTemplate(row);
     Object.assign(form, {
       ...base,
       id: row.id,
       templateName: row.templateName || "",
       description: row.description || "",
+      templateType: row.templateType != null ? Number(row.templateType) : base.templateType,
       businessType: row.businessType ?? "",
       formConfig: row.formConfig || "",
-      formConfigData: JSON.parse(
-        JSON.stringify(row.formConfigData || parseFormConfigToData(row.formConfig))
-      ),
+      formConfigData,
+      lockedFormFieldUids: builtin
+        ? (formConfigData.fields || []).map((f) => f._uid).filter(Boolean)
+        : [],
       enabled: row.enabled !== false,
       flowNodes: JSON.parse(JSON.stringify(row.flowNodes || [base.flowNodes[0]])),
       storageBlobDTOs: JSON.parse(JSON.stringify(row.storageBlobDTOs || [])),
     });
   }
 
-  function openFormDialog(mode, row) {
+  async function openFormDialog(mode, row) {
     formDialog.mode = mode;
     formDialog.title = mode === "add" ? "鏂板缓瀹℃壒妯℃澘" : "缂栬緫瀹℃壒妯℃澘";
-    resetForm(mode === "edit" ? row : null);
+    if (mode === "edit" && row?.id) {
+      // 缂栬緫鏃跺厛鏌ヨ璇︽儏鑾峰彇瀹屾暣鏁版嵁锛堝寘鍚檮浠讹級
+      try {
+        const res = await getApprovalTemplateDetail(row.id);
+        const detailData = mapTemplateFromApi(unwrapTemplateDetail(res));
+        resetForm(detailData);
+      } catch {
+        resetForm(row);
+      }
+    } else {
+      resetForm(mode === "edit" ? row : null);
+    }
     formDialog.visible = true;
   }
 
@@ -258,6 +281,10 @@
   }
 
   async function removeTemplate(row) {
+    if (isBuiltinTemplate(row)) {
+      ElMessage.warning("绯荤粺鍐呯疆妯℃澘涓嶅厑璁稿垹闄�");
+      return;
+    }
     if (row?.id == null || row.id === "") {
       ElMessage.warning("鏃犳硶鍒犻櫎锛氱己灏戞ā鏉� ID");
       return;
@@ -304,6 +331,7 @@
     form,
     formRef,
     formRules,
+    isEditingBuiltin,
     detailDialog,
     detailRow,
     detailLoading,

--
Gitblit v1.9.3