From 4762afb6cb043a3e539ed7ec8da5bde997bfaf65 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期五, 29 五月 2026 11:51:41 +0800
Subject: [PATCH] 英泽防锈 1.车辆管理页面开发联调

---
 src/views/officeProcessAutomation/ApproveManage/approve-template/formConfigUtils.js |   84 ++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 80 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..f18c0d2 100644
--- a/src/views/officeProcessAutomation/ApproveManage/approve-template/formConfigUtils.js
+++ b/src/views/officeProcessAutomation/ApproveManage/approve-template/formConfigUtils.js
@@ -1,9 +1,19 @@
+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: "鍗曡鏂囨湰" },
   { value: "textarea", label: "澶氳鏂囨湰" },
   { value: "number", label: "鏁板瓧" },
   { value: "date", label: "鏃ユ湡" },
+  { value: "datetime", label: "鏃ユ湡鏃堕棿" },
   { value: "datetimerange", label: "鏃ユ湡鏃堕棿鑼冨洿" },
   { value: "select", label: "涓嬫媺閫夋嫨" },
 ];
@@ -50,6 +60,56 @@
       { key: "dateRange", label: "璇峰亣鏃堕棿", type: "datetimerange", required: true },
     ],
   },
+  {
+    key: "vehicle",
+    label: "杞﹁締瀹℃壒",
+    summaryPlaceholder: "璇峰~鍐欒溅杈嗕娇鐢ㄧ敵璇蜂俊鎭�",
+    fields: [
+      { key: "vehicleNo", label: "杞︾墝鍙�", type: "select", required: true, optionSource: "vehicle_list", placeholder: "璇烽�夋嫨杞﹁締" },
+      { key: "driver", label: "椹鹃┒鍛�", type: "text", required: true },
+      { key: "purpose", label: "鐢ㄨ溅浜嬬敱", type: "textarea", required: true, rows: 2 },
+      { key: "useDateRange", label: "杞﹁締浣跨敤鏃堕棿", type: "datetimerange", required: true },
+      { key: "destination", label: "鐩殑鍦�", type: "text", required: true },
+      { key: "passengers", label: "涔樿溅浜烘暟", type: "number", required: false, min: 1, precision: 0 },
+      { key: "startMileage", label: "璧峰鍏噷鏁�", type: "number", required: true, min: 0, precision: 1 },
+      { key: "startMileagePhoto", label: "璧峰鍏噷鏁扮収鐗�", type: "image", required: false },
+      { key: "estimatedEndMileage", label: "棰勮缁撴潫鍏噷鏁�", type: "number", required: false, min: 0, precision: 1 },
+      { key: "remark", label: "澶囨敞", type: "textarea", required: false, rows: 2 },
+    ],
+  },
+  {
+    key: "vehicle_return",
+    label: "杞﹁締杩樿溅瀹℃壒",
+    summaryPlaceholder: "璇峰~鍐欒溅杈嗚繕杞︿俊鎭�",
+    fields: [
+      { key: "vehicleNo", label: "杞︾墝鍙�", type: "select", required: true, optionSource: "vehicle_list", placeholder: "璇烽�夋嫨杞﹁締" },
+      { key: "driver", label: "椹鹃┒鍛�", type: "text", required: true },
+      { key: "originalApprovalNo", label: "鍘熷鎵瑰崟鍙�", type: "text", required: true },
+      { key: "returnDate", label: "杩樿溅鏃ユ湡", type: "date", required: true },
+      { key: "endMileage", label: "缁撴潫鍏噷鏁�", type: "number", required: true, min: 0, precision: 1 },
+      { key: "endMileagePhoto", label: "缁撴潫鍏噷鏁扮収鐗�", type: "image", required: false },
+      { key: "actualMileage", label: "瀹為檯琛岄┒鍏噷鏁�", type: "number", required: false, min: 0, precision: 1 },
+      { key: "extendDays", label: "寤舵湡澶╂暟", type: "number", required: false, min: 0, precision: 0 },
+      { key: "extendReason", label: "寤舵湡鍘熷洜", type: "textarea", required: false, rows: 2 },
+      { key: "vehicleStatus", label: "杞﹁締鐘舵��", type: "select", required: true, options: [{ label: "瀹屽ソ", value: "good" }, { label: "杞诲井鎹熷潖", value: "minor_damage" }, { label: "闇�瑕佺淮淇�", value: "need_repair" }] },
+      { key: "remark", label: "澶囨敞", type: "textarea", required: false, rows: 2 },
+    ],
+  },
+  {
+    key: "vehicle_extend",
+    label: "杞﹁締寤舵湡瀹℃壒",
+    summaryPlaceholder: "杞﹁締鍒版湡鍚庣敵璇峰欢鏈熶娇鐢�",
+    fields: [
+      { key: "vehicleNo", label: "杞︾墝鍙�", type: "select", required: true, optionSource: "vehicle_list", placeholder: "璇烽�夋嫨杞﹁締" },
+      { key: "driver", label: "椹鹃┒鍛�", type: "text", required: true },
+      { key: "originalApprovalNo", label: "鍘熷鎵瑰崟鍙�", type: "text", required: true },
+      { key: "originalEndDate", label: "鍘熷埌鏈熸棩鏈�", type: "date", required: true },
+      { key: "extendDays", label: "寤舵湡澶╂暟", type: "number", required: true, min: 1, precision: 0 },
+      { key: "newEndDate", label: "鏂板埌鏈熸棩鏈�", type: "date", required: true },
+      { key: "extendReason", label: "寤舵湡鍘熷洜", type: "textarea", required: true, rows: 3 },
+      { key: "remark", label: "澶囨敞", type: "textarea", required: false, rows: 2 },
+    ],
+  },
 ];
 
 function newFieldUid() {
@@ -67,6 +127,7 @@
     min: 0,
     precision: 0,
     defaultValue: "",
+    optionSource: SELECT_OPTION_SOURCE.STATIC,
     options: [{ label: "", value: "" }],
   };
 }
@@ -78,6 +139,7 @@
   if (dv === undefined || dv === null || dv === "") {
     if (type === "number") return undefined;
     if (type === "datetimerange") return [];
+    if (type === "datetime") return "";
     return "";
   }
   if (type === "number") {
@@ -96,6 +158,7 @@
   if (dv === undefined || dv === null) return false;
   if (type === "number") return dv !== "" && !Number.isNaN(Number(dv));
   if (type === "datetimerange") return Array.isArray(dv) && dv.length === 2;
+  if (type === "datetime") return String(dv).trim() !== "";
   if (type === "select") return dv !== "";
   return String(dv).trim() !== "";
 }
@@ -133,6 +196,7 @@
   if (f.defaultValue === undefined || f.defaultValue === null) {
     if (type === "number") return undefined;
     if (type === "datetimerange") return [];
+    if (type === "datetime") return "";
     return "";
   }
   if (type === "datetimerange" && Array.isArray(f.defaultValue)) {
@@ -154,6 +218,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 +245,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 +292,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 +312,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 +334,7 @@
     min: rest.min,
     precision: rest.precision,
     defaultValue: rest.defaultValue,
+    optionSource: rest.optionSource,
     options: rest.options,
   }));
   return {
@@ -269,6 +344,7 @@
     summaryPlaceholder: cfg.summaryPlaceholder || "",
     approvalMode: cfg.approvalMode || "parallel",
     fields,
+    storageBlobDTOs: mapAttachmentsFromApi(row),
   };
 }
 

--
Gitblit v1.9.3