From cd1f2d9605c2e208bb7e70f5d3bc83b45a9ec8a6 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期四, 18 六月 2026 15:16:53 +0800
Subject: [PATCH] feat: 产品规格带出产品大类

---
 src/views/salesManagement/salesLedger/components/ProcessFlowConfigSelectDialog.vue |   92 ++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 84 insertions(+), 8 deletions(-)

diff --git a/src/views/salesManagement/salesLedger/components/ProcessFlowConfigSelectDialog.vue b/src/views/salesManagement/salesLedger/components/ProcessFlowConfigSelectDialog.vue
index f3c33b5..606d86c 100644
--- a/src/views/salesManagement/salesLedger/components/ProcessFlowConfigSelectDialog.vue
+++ b/src/views/salesManagement/salesLedger/components/ProcessFlowConfigSelectDialog.vue
@@ -8,10 +8,14 @@
   >
     <el-row :gutter="20">
       <el-col :span="24">
-        <div style="font-weight: 600; margin-bottom: 8px;">閰嶇疆</div>
-        <div style="font-size: 12px; margin-bottom: 8px;">
-          <span v-if="boundRouteName" style="color: #67c23a;">宸茬粦瀹氾細{{ boundRouteName }}</span>
-          <span v-else style="color: #e6a23c;">鏈粦瀹�</span>
+        <div class="dialog-topbar">
+          <div>
+            <div style="font-weight: 600; margin-bottom: 8px;">閰嶇疆</div>
+            <div style="font-size: 12px; margin-bottom: 8px;">
+              <span v-if="boundRouteName" style="color: #67c23a;">宸茬粦瀹氾細{{ boundRouteName }}</span>
+              <span v-else style="color: #e6a23c;">鏈粦瀹�</span>
+            </div>
+          </div>
         </div>
         <el-select
           v-model="selectedRouteId"
@@ -33,7 +37,7 @@
 
         <div style="font-weight: 600; margin-bottom: 8px;">姝ラ棰勮</div>
         <div style="font-size: 12px; color: #909399; margin-bottom: 10px;">
-          鏍规嵁鎵�閫夐厤缃睍绀烘祦绋嬪浘
+          鏍规嵁鎵�閫夐厤缃睍绀烘祦绋嬪浘锛屽嬀閫夎〃绀鸿宸ュ簭宸插畬鎴�
         </div>
       </el-col>
 
@@ -46,8 +50,16 @@
             class="process-diagram-segment"
           >
             <div class="process-diagram-node">
+              <el-checkbox
+                v-model="step.isCompleted"
+                class="process-diagram-checkbox"
+                @change="() => handleStepCompletedChange(step)"
+              />
               <div class="process-diagram-index">{{ idx + 1 }}</div>
               <div class="process-diagram-name">{{ step.processName }}</div>
+              <div class="process-diagram-status" :class="{ 'is-done': Number(step.isCompleted) === 1 }">
+                {{ Number(step.isCompleted) === 1 ? "宸插畬鎴�" : "鏈畬鎴�" }}
+              </div>
             </div>
             <div v-if="idx < steps.length - 1" class="process-diagram-arrow">鈫�</div>
           </div>
@@ -79,6 +91,8 @@
   visible: { type: Boolean, default: false },
   // 鎵撳紑寮圭獥鏃剁殑鍥炴樉锛氳嫢涓氬姟宸茬粦瀹氬伐鑹鸿矾绾垮垯浼犲叆璇� routeId锛涘惁鍒欓粯璁ゅ睍绀哄垪琛ㄧ涓�鏉�
   defaultRouteId: { type: [Number, String, null], default: null },
+  // 鎵撳紑寮圭獥鏃剁殑宸ュ簭瀹屾垚璁板綍鍥炴樉
+  defaultRecordList: { type: Array, default: () => [] },
   // 椤甸潰鎻愮ず锛氳鍗曞凡缁戝畾鐨勫伐鑹鸿矾绾垮悕绉�
   boundRouteName: { type: String, default: "" },
 });
@@ -103,9 +117,11 @@
   if (!Array.isArray(list)) return [];
   return list.map((s, idx) => ({
     stepId: s.stepId ?? s.id ?? null,
+    processRouteItemId: s.processRouteItemId ?? s.process_route_item_id ?? s.id ?? null,
     processId: s.processId ?? s.process_id ?? s.id ?? null,
     processName: s.processName ?? s.process_name ?? s.name ?? "",
     sortNo: s.sortNo ?? idx + 1,
+    isCompleted: Boolean(Number(s.isCompleted ?? s.completed ?? 0)),
   }));
 };
 
@@ -116,6 +132,27 @@
     processRouteName: r.processRouteName ?? r.routeName ?? r.name ?? "",
     isDefault: Boolean(r.isDefault),
   }));
+};
+
+const applyRecordListToSteps = (stepList, recordList) => {
+  if (!Array.isArray(stepList) || stepList.length === 0) return stepList;
+  if (!Array.isArray(recordList) || recordList.length === 0) return stepList;
+
+  const recordMap = new Map(
+    recordList
+      .filter((item) => item && item.processRouteItemId !== null && item.processRouteItemId !== undefined)
+      .map((item) => [String(item.processRouteItemId), item])
+  );
+
+  return stepList.map((step) => {
+    const matched = recordMap.get(String(step.processRouteItemId));
+    if (!matched) return step;
+    return {
+      ...step,
+      isCompleted: Boolean(Number(matched.isCompleted ?? 0)),
+      completedTime: matched.completedTime ?? matched.completed_time ?? null,
+    };
+  });
 };
 
 const fetchRouteList = async () => {
@@ -132,7 +169,12 @@
   }
   const res = await salesProcessFlowConfigItemList(routeId);
   const raw = res?.data ?? res ?? [];
-  steps.value = normalizeStepsFromApi(raw);
+  const normalizedSteps = normalizeStepsFromApi(raw);
+  if (String(routeId) === String(props.defaultRouteId)) {
+    steps.value = applyRecordListToSteps(normalizedSteps, props.defaultRecordList);
+    return;
+  }
+  steps.value = normalizedSteps;
 };
 
 watch(
@@ -163,6 +205,10 @@
   await fetchRouteSteps(selectedRouteId.value);
 };
 
+const handleStepCompletedChange = (step) => {
+  step.isCompleted = Boolean(step.isCompleted);
+};
+
 const handleClose = () => {
   emit("update:visible", false);
   saving.value = false;
@@ -176,7 +222,13 @@
   }
   saving.value = true;
   try {
-    emit("confirm", selectedRouteId.value);
+    emit("confirm", {
+      routeId: selectedRouteId.value,
+      recordList: steps.value.map((step) => ({
+        processRouteItemId: step.processRouteItemId,
+        isCompleted: Number(step.isCompleted ?? 0),
+      })),
+    });
   } catch (e) {
     proxy?.$modal?.msgError?.("纭澶辫触锛岃绋嶅悗閲嶈瘯");
   } finally {
@@ -213,6 +265,13 @@
   padding: 10px 12px;
   margin-right: 10px;
   box-sizing: border-box;
+  position: relative;
+}
+
+.process-diagram-checkbox {
+  position: absolute;
+  top: 8px;
+  right: 8px;
 }
 
 .process-diagram-index {
@@ -228,6 +287,17 @@
   white-space: nowrap;
   overflow: hidden;
   text-overflow: ellipsis;
+}
+
+.process-diagram-status {
+  margin-top: 4px;
+  font-size: 12px;
+  color: #909399;
+}
+
+.process-diagram-status.is-done {
+  color: #67c23a;
+  font-weight: 600;
 }
 
 .process-diagram-arrow {
@@ -251,5 +321,11 @@
   justify-content: flex-end;
   gap: 10px;
 }
-</style>
 
+.dialog-topbar {
+  display: flex;
+  justify-content: space-between;
+  align-items: flex-start;
+  gap: 16px;
+}
+</style>

--
Gitblit v1.9.3