From bae93b624d8d68ed2fe540c381a58b47082c1309 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期一, 26 十月 2026 16:28:28 +0800
Subject: [PATCH] feat(mes): 完善工艺路线管理功能

---
 src/views/mes/pro/route/data.ts |  144 +++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 125 insertions(+), 19 deletions(-)

diff --git a/src/views/mes/pro/route/data.ts b/src/views/mes/pro/route/data.ts
index f4bf910..1fc0695 100644
--- a/src/views/mes/pro/route/data.ts
+++ b/src/views/mes/pro/route/data.ts
@@ -19,12 +19,15 @@
 import { z } from '#/adapter/form';
 import { generateAutoCode } from '#/api/mes/md/autocode/record';
 import { getTemplatePage } from '#/api/mes/pro/processdesign/template';
+import { getWarehouseSimpleList } from '#/api/mes/wm/warehouse';
+import { getWarehouseAreaSimpleList } from '#/api/mes/wm/warehouse/area';
+import { getWarehouseLocationSimpleList } from '#/api/mes/wm/warehouse/location';
 import {
   MdItemSelect,
   MdProductBomSelect,
 } from '#/views/mes/md/item/components';
 
-import { RouteColorPicker } from './components';
+import { RouteColorPicker, RouteOutputAttribution } from './components';
 
 /** 琛ㄥ崟绫诲瀷 */
 export type FormType = 'create' | 'detail' | 'update';
@@ -167,7 +170,7 @@
       field: 'createTime',
       title: '鍒涘缓鏃堕棿',
       width: 180,
-      formatter: 'formatDate',
+      formatter: 'formatDateTime',
     },
     {
       title: '鎿嶄綔',
@@ -181,6 +184,7 @@
 /** 宸ヨ壓璺嚎宸ュ簭鏄庣粏琛ㄥ崟 */
 export function useRouteProcessFormSchema(
   processOptions: Array<{ label: string; value: number }>,
+  products: MesProRouteProductApi.RouteProduct[] = [],
 ): VbenFormSchema[] {
   return [
     {
@@ -231,36 +235,38 @@
     },
     {
       fieldName: 'yieldRate',
-      label: '鏀剁巼',
+      label: '宸ュ簭鏀剁巼',
       component: 'InputNumber',
+      help: '浜у嚭閲� 梅 鎶曞叆閲忥紱鏈~鍐欐寜 100% 鍙備笌鎺掍骇璁$畻銆�',
       componentProps: {
         class: '!w-full',
         min: 0.0001,
         max: 1,
         step: 0.01,
         precision: 4,
-        placeholder: '浜у嚭/鎶曞叆锛屽 0.98',
+        placeholder: '濡� 0.98锛�98%锛�',
       },
+      rules: z.number().min(0.0001).max(1).nullish(),
+    },
+    {
+      fieldName: 'outputs',
+      label: '鏈伐搴忎骇鍑�',
+      component: markRaw(RouteOutputAttribution),
+      componentProps: {
+        products,
+      },
+      formItemClass: 'col-span-2',
     },
     {
       fieldName: 'linkType',
       label: '涓庝笅閬撳伐搴忓叧绯�',
       component: 'Select',
-      help: () =>
-        h(
-          'div',
-          {
-            style:
-              'white-space: pre-line; max-width: 320px; line-height: 1.6;',
-          },
-          '0=寮�濮�-寮�濮�(SS)锛氭湰宸ュ簭寮�濮嬪悗锛屼笅閬撳伐搴忔墠鑳藉紑濮嬶紙鍙噸鍙犲苟琛屽紑宸ワ級\n1=缁撴潫-缁撴潫(FF)锛氫笅閬撳伐搴忓繀椤荤瓑鍒版湰宸ュ簭缁撴潫鎵嶈兘缁撴潫锛堝苟琛屼絾鍚屾瀹屽伐锛塡n2=寮�濮�-缁撴潫(SF)锛氭湰宸ュ簭寮�濮嬪悗锛屼笅閬撳伐搴忔墠鑳界粨鏉焅n3=缁撴潫-寮�濮�(FS)锛氭湰宸ュ簭缁撴潫鍚庯紝涓嬮亾宸ュ簭鎵嶈兘寮�濮嬶紙榛樿鍊硷級',
-        ),
       componentProps: {
         allowClear: true,
         options: getDictOptions(DICT_TYPE.MES_PRO_LINK_TYPE, 'number'),
         placeholder: '璇烽�夋嫨',
       },
-      rules: z.number().optional(),
+      rules: z.number().default(3),
     },
     {
       fieldName: 'colorCode',
@@ -284,6 +290,16 @@
       componentProps: {
         checkedChildren: '鏄�',
         unCheckedChildren: '鍚�',
+      },
+      rules: z.boolean().default(false),
+    },
+    {
+      fieldName: 'backflushFlag',
+      label: '鎶ュ伐鑷姩鎵f枡',
+      component: 'Switch',
+      componentProps: {
+        checkedChildren: '鑷姩',
+        unCheckedChildren: '鎵嬪姩',
       },
       rules: z.boolean().default(false),
     },
@@ -329,6 +345,25 @@
     { field: 'sort', title: '搴忓彿', width: 70, align: 'center', fixed: 'left' },
     { field: 'processCode', title: '宸ュ簭缂栫爜', width: 140, fixed: 'left' },
     { field: 'processName', title: '宸ュ簭鍚嶇О', width: 140, fixed: 'left' },
+    {
+      field: 'outputItemNames',
+      title: '鏈伐搴忎骇鍑�',
+      minWidth: 240,
+      formatter: ({ cellValue, row }) => {
+        const outputs = row.outputs ?? [];
+        if (!outputs.length) {
+          return cellValue ?? '';
+        }
+        return outputs
+          .map((output) => {
+            const name = output.itemName ?? output.itemCode ?? output.itemId;
+            return output.productId == null
+              ? `${name}锛堥�氱敤锛塦
+              : `${name}锛�${output.productName ?? output.productId}锛塦;
+          })
+          .join('銆�');
+      },
+    },
     { field: 'nextProcessName', title: '涓嬩竴閬撳伐搴�', width: 140 },
     {
       field: 'linkType',
@@ -357,6 +392,15 @@
         props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
       },
     },
+    {
+      field: 'backflushFlag',
+      title: '鑷姩鎵f枡',
+      width: 100,
+      cellRender: {
+        name: 'CellDict',
+        props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
+      },
+    },
     { field: 'prepareTime', title: '鍑嗗鏃堕棿(鍒�)', width: 110 },
     { field: 'waitTime', title: '绛夊緟鏃堕棿(鍒�)', width: 110 },
     {
@@ -378,11 +422,14 @@
 /** 宸ヨ壓璺嚎浜у搧鍒楄〃瀛楁 */
 export function useRouteProductGridColumns(): VxeTableGridOptions<MesProRouteProductApi.RouteProduct>['columns'] {
   return [
-    { field: 'itemCode', title: '浜у搧鐗╂枡缂栫爜', width: 150 },
-    { field: 'itemName', title: '浜у搧鐗╂枡鍚嶇О', width: 150 },
+    { field: 'itemCode', title: '浜у嚭缂栫爜', width: 150 },
+    { field: 'itemName', title: '浜у嚭鍚嶇О', width: 150 },
     { field: 'specification', title: '瑙勬牸鍨嬪彿', width: 150 },
     { field: 'unitName', title: '鍗曚綅', width: 80 },
     { field: 'quantity', title: '鐢熶骇鏁伴噺', width: 100 },
+    { field: 'warehouseName', title: '鎶ュ伐鍏ュ簱浠�', width: 140 },
+    { field: 'locationName', title: '鍏ュ簱搴撳尯', width: 120 },
+    { field: 'areaName', title: '鍏ュ簱搴撲綅', width: 120 },
     {
       field: 'productionTime',
       title: '鐢熶骇鐢ㄦ椂',
@@ -402,8 +449,8 @@
 /** 宸ヨ壓璺嚎浜у搧 BOM 鍒楄〃瀛楁 */
 export function useRouteProductBomGridColumns(): VxeTableGridOptions<MesProRouteProductBomApi.RouteProductBom>['columns'] {
   return [
-    { field: 'itemCode', title: 'BOM 鐗╂枡缂栫爜', width: 150 },
-    { field: 'itemName', title: 'BOM 鐗╂枡鍚嶇О', width: 150 },
+    { field: 'itemCode', title: '鎶曟枡缂栫爜', width: 150 },
+    { field: 'itemName', title: '鎶曟枡鍚嶇О', width: 150 },
     { field: 'specification', title: '瑙勬牸鍨嬪彿', width: 150 },
     { field: 'unitName', title: '鍗曚綅', width: 80 },
     { field: 'quantity', title: '鐢ㄦ枡姣斾緥', width: 100 },
@@ -420,6 +467,7 @@
 /** 宸ヨ壓璺嚎浜у搧琛ㄥ崟 */
 export function useRouteProductFormSchema(
   onItemChange?: (item: any) => void,
+  getFormApi?: () => VbenFormApi,
 ): VbenFormSchema[] {
   return [
     {
@@ -435,11 +483,12 @@
     // 浜у搧鐗╂枡锛氫娇鐢ㄤ笟鍔¤嚜瀹氫箟閫夋嫨鍣紝change 鍥炲~缂栫爜/鍚嶇О/瑙勬牸/鍗曚綅
     {
       fieldName: 'itemId',
-      label: '浜у搧',
+      label: '浜у嚭鐗╂枡',
       component: markRaw(MdItemSelect),
       componentProps: {
         onChange: onItemChange,
       },
+      help: '鍙�夋嫨涓绘暟鎹被鍨嬩负鎴愬搧鎴栧崐鎴愬搧鐨勭墿鏂欙紝涔熷吋瀹� MES 鎴愬搧/鍗婃垚鍝佸垎绫伙紱宸叉湁璺嚎浜у搧鍙户缁慨鏀逛粨浣嶃��',
       formItemClass: 'col-span-2',
       rules: 'selectRequired',
     },
@@ -455,6 +504,63 @@
       rules: z.number().default(1),
     },
     {
+      fieldName: 'warehouseId',
+      label: '鎶ュ伐浠撳簱',
+      component: 'ApiSelect',
+      componentProps: {
+        api: getWarehouseSimpleList,
+        labelField: 'name',
+        valueField: 'id',
+        placeholder: '璇烽�夋嫨鎶ュ伐浜у嚭浠撳簱',
+        onChange: async () => {
+          await getFormApi?.().setFieldValue('locationId', undefined);
+          await getFormApi?.().setFieldValue('areaId', undefined);
+        },
+      },
+      rules: 'selectRequired',
+    },
+    {
+      fieldName: 'locationId',
+      label: '鎶ュ伐搴撳尯',
+      component: 'Select',
+      dependencies: {
+        triggerFields: ['warehouseId'],
+        disabled: (values) => !values.warehouseId,
+        async componentProps(values) {
+          const options = values.warehouseId
+            ? await getWarehouseLocationSimpleList(values.warehouseId)
+            : [];
+          return {
+            fieldNames: { label: 'name', value: 'id' },
+            options,
+            placeholder: '璇烽�夋嫨鎶ュ伐浜у嚭搴撳尯',
+            onChange: async () => getFormApi?.().setFieldValue('areaId', undefined),
+          };
+        },
+      },
+      rules: 'selectRequired',
+    },
+    {
+      fieldName: 'areaId',
+      label: '鎶ュ伐搴撲綅',
+      component: 'Select',
+      dependencies: {
+        triggerFields: ['locationId'],
+        disabled: (values) => !values.locationId,
+        async componentProps(values) {
+          const options = values.locationId
+            ? await getWarehouseAreaSimpleList(values.locationId)
+            : [];
+          return {
+            fieldNames: { label: 'name', value: 'id' },
+            options,
+            placeholder: '璇烽�夋嫨鎶ュ伐浜у嚭搴撲綅',
+          };
+        },
+      },
+      rules: 'selectRequired',
+    },
+    {
       fieldName: 'productionTime',
       label: '鐢熶骇鐢ㄦ椂',
       component: 'InputNumber',

--
Gitblit v1.9.3