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-template/formConfigUtils.js |   30 ++++++++++++++++++++++++++----
 1 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/src/views/officeProcessAutomation/ApproveManage/approve-template/formConfigUtils.js b/src/views/officeProcessAutomation/ApproveManage/approve-template/formConfigUtils.js
index 733f463..c1f66bd 100644
--- a/src/views/officeProcessAutomation/ApproveManage/approve-template/formConfigUtils.js
+++ b/src/views/officeProcessAutomation/ApproveManage/approve-template/formConfigUtils.js
@@ -1,3 +1,12 @@
+import { mapAttachmentsFromApi } from "./approveTemplateConstants.js";
+import {
+  isDynamicOptionSource,
+  SELECT_OPTION_SOURCE,
+  selectOptionSourceLabel,
+} from "./selectOptionSource.js";
+
+export { selectOptionSourceLabel };
+
 /** 濉姤椤圭被鍨嬶紙涓庡鎵规彁浜ら〉 field.type 涓�鑷达級 */
 export const FORM_FIELD_TYPE_OPTIONS = [
   { value: "text", label: "鍗曡鏂囨湰" },
@@ -67,6 +76,7 @@
     min: 0,
     precision: 0,
     defaultValue: "",
+    optionSource: SELECT_OPTION_SOURCE.STATIC,
     options: [{ label: "", value: "" }],
   };
 }
@@ -154,6 +164,7 @@
     min: f.min ?? 0,
     precision: f.precision ?? 0,
     defaultValue: normalizeDefaultValueFromApi(f),
+    optionSource: f.optionSource || SELECT_OPTION_SOURCE.STATIC,
     options: (f.options || []).length
       ? f.options.map((o) => ({ label: o.label || "", value: o.value ?? "" }))
       : [{ label: "", value: "" }],
@@ -180,9 +191,13 @@
       item.precision = f.precision ?? 0;
     }
     if (item.type === "select") {
-      item.options = (f.options || [])
-        .filter((o) => (o.label || "").trim() || o.value !== "" && o.value != null)
-        .map((o) => ({ label: (o.label || "").trim(), value: o.value }));
+      const source = f.optionSource || SELECT_OPTION_SOURCE.STATIC;
+      item.optionSource = source;
+      if (!isDynamicOptionSource(source)) {
+        item.options = (f.options || [])
+          .filter((o) => (o.label || "").trim() || (o.value !== "" && o.value != null))
+          .map((o) => ({ label: (o.label || "").trim(), value: o.value }));
+      }
     }
     if (hasDefaultValue(f)) {
       item.defaultValue =
@@ -223,6 +238,8 @@
     if (keys.has(key)) return { ok: false, message: `瀛楁鏍囪瘑銆�${key}銆嶉噸澶嶏紝璇蜂慨鏀筦 };
     keys.add(key);
     if (f.type === "select") {
+      const source = f.optionSource || SELECT_OPTION_SOURCE.STATIC;
+      if (isDynamicOptionSource(source)) continue;
       const opts = (f.options || []).filter((o) => (o.label || "").trim() && o.value !== "" && o.value != null);
       if (!opts.length) return { ok: false, message: `璇蜂负銆�${label}銆嶉厤缃嚦灏戜竴涓笅鎷夐�夐」` };
     }
@@ -241,13 +258,16 @@
     return dv.length === 2 ? `${dv[0]} ~ ${dv[1]}` : "鈥�";
   }
   if (field?.type === "select") {
+    if (isDynamicOptionSource(field.optionSource)) {
+      return `${selectOptionSourceLabel(field.optionSource)}锛�${String(dv)}`;
+    }
     const opt = (field.options || []).find((o) => String(o.value) === String(dv));
     return opt?.label || String(dv);
   }
   return String(dv);
 }
 
-/** 灏嗗悗绔ā鏉胯杞负鎻愪氦椤垫ā鏉跨粨鏋勶紙鍚� fields 榛樿鍊硷級 */
+/** 灏嗗悗绔ā鏉胯杞负鎻愪氦椤垫ā鏉跨粨鏋勶紙鍚� fields 榛樿鍊笺�侀檮浠讹級 */
 export function buildSubmitTemplateFromRow(row) {
   const cfg = parseFormConfigToData(row?.formConfig);
   const fields = (cfg.fields || []).map(({ _uid, ...rest }) => ({
@@ -260,6 +280,7 @@
     min: rest.min,
     precision: rest.precision,
     defaultValue: rest.defaultValue,
+    optionSource: rest.optionSource,
     options: rest.options,
   }));
   return {
@@ -269,6 +290,7 @@
     summaryPlaceholder: cfg.summaryPlaceholder || "",
     approvalMode: cfg.approvalMode || "parallel",
     fields,
+    storageBlobDTOs: mapAttachmentsFromApi(row),
   };
 }
 

--
Gitblit v1.9.3