From 6ebcfebf58fe23ea401de1050b15ba85e41763a9 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期六, 17 十月 2026 18:36:52 +0800
Subject: [PATCH] feat(wls): 仓储物流单据跨模块关联字段改为手工填写

---
 src/views/wls/returnissue/data.ts |  132 ++++++++++++++++++++++++-------------------
 1 files changed, 73 insertions(+), 59 deletions(-)

diff --git a/src/views/wls/returnissue/data.ts b/src/views/wls/returnissue/data.ts
index 6dfc81f..ff3033b 100644
--- a/src/views/wls/returnissue/data.ts
+++ b/src/views/wls/returnissue/data.ts
@@ -1,26 +1,21 @@
 锘縤mport type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
 import type { VxeTableGridOptions } from '#/adapter/vxe-table';
 import type { MesWmMaterialStockApi } from '#/api/mes/wm/materialstock';
+import type { MesWmProductIssueLineApi } from '#/api/mes/wm/productissue/line';
 import type { MesWmReturnIssueApi } from '#/api/mes/wm/returnissue';
 import type { MesWmReturnIssueDetailApi } from '#/api/mes/wm/returnissue/detail';
 import type { MesWmReturnIssueLineApi } from '#/api/mes/wm/returnissue/line';
 
 import { h, markRaw } from 'vue';
 
-import {
-  DICT_TYPE,
-  MesAutoCodeRuleCode,
-  MesProWorkOrderStatusEnum,
-} from '../../../packages/constants/src';
-import { getDictOptions } from '../../../packages/effects/hooks/src';
+import { DICT_TYPE, MesAutoCodeRuleCode } from '@vben/constants';
+import { getDictOptions } from '@vben/hooks';
 
 import { Button } from 'ant-design-vue';
 
 import { z } from '#/adapter/form';
 import { generateAutoCode } from '#/api/mes/md/autocode/record';
-import { MdItemSelect } from '#/views/mes/md/item/components';
-import { MdWorkstationSelect } from '#/views/mes/md/workstation/components';
-import { ProWorkOrderSelect } from '#/views/mes/pro/workorder/components';
+import { WmProductIssueLineSelect } from '#/views/wls/productissue/components';
 import { WmMaterialStockSelect } from '#/views/wls/materialstock/components';
 import {
   WmWarehouseAreaSelect,
@@ -104,20 +99,21 @@
       rules: 'required',
     },
     {
-      fieldName: 'workOrderId',
-      label: '鐢熶骇璁㈠崟',
-      component: markRaw(ProWorkOrderSelect),
+      fieldName: 'workOrderCode',
+      label: '鐢熶骇璁㈠崟鍙�',
+      component: 'Input',
       componentProps: {
-        status: MesProWorkOrderStatusEnum.CONFIRMED,
+        disabled: isHeaderReadonly(formType),
+        placeholder: '璇疯緭鍏ョ敓浜ц鍗曞彿',
       },
-      rules: 'selectRequired',
     },
     {
-      fieldName: 'workstationId',
+      fieldName: 'workstationName',
       label: '宸ヤ綔绔�',
-      component: markRaw(MdWorkstationSelect),
+      component: 'Input',
       componentProps: {
-        placeholder: '璇烽�夋嫨宸ヤ綔绔�',
+        disabled: isHeaderReadonly(formType),
+        placeholder: '璇疯緭鍏ュ伐浣滅珯鍚嶇О',
       },
     },
     {
@@ -126,10 +122,10 @@
       component: 'DatePicker',
       componentProps: {
         class: '!w-full',
-        format: 'YYYY-MM-DD HH:mm:ss',
+        format: 'YYYY-MM-DD',
         placeholder: '璇烽�夋嫨閫�鏂欐棩鏈�',
-        showTime: true,
-        valueFormat: 'x',
+        showTime: false,
+        valueFormat: 'YYYY-MM-DD HH:mm:ss',
       },
     },
     {
@@ -167,11 +163,12 @@
       },
     },
     {
-      fieldName: 'workOrderId',
-      label: '鐢熶骇璁㈠崟',
-      component: markRaw(ProWorkOrderSelect),
+      fieldName: 'workOrderCode',
+      label: '鐢熶骇璁㈠崟鍙�',
+      component: 'Input',
       componentProps: {
-        placeholder: '璇烽�夋嫨鐢熶骇璁㈠崟',
+        allowClear: true,
+        placeholder: '璇疯緭鍏ョ敓浜ц鍗曞彿',
       },
     },
     {
@@ -224,7 +221,7 @@
       field: 'returnDate',
       title: '閫�鏂欐棩鏈�',
       width: 180,
-      formatter: 'formatDateTime',
+      formatter: 'formatDate',
     },
     {
       field: 'status',
@@ -317,24 +314,29 @@
 }
 
 /** 閫�鏂欏崟琛屾柊澧�/淇敼鐨勮〃鍗� */
-export function useLineFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
+export function useLineFormSchema(
+  formApi?: VbenFormApi,
+  workOrderId?: number,
+): VbenFormSchema[] {
   return [
     {
-      fieldName: 'materialStockId',
-      label: '搴撳瓨璁板綍',
-      component: markRaw(WmMaterialStockSelect),
+      fieldName: 'issueLineId',
+      label: '棰嗘枡璁板綍',
+      component: markRaw(WmProductIssueLineSelect),
       componentProps: {
-        // 閫夋嫨搴撳瓨璁板綍鍚庯紝鑷姩鍥炲~鐗╂枡/鎵规/鏁伴噺
-        onChange: async (stock?: MesWmMaterialStockApi.MaterialStock) => {
+        workOrderId,
+        onChange: async (line?: MesWmProductIssueLineApi.ProductIssueLine) => {
           await formApi?.setValues({
-            batchCode: stock?.batchCode,
-            batchId: stock?.batchId,
-            itemId: stock?.itemId,
-            quantity: stock?.quantity,
-            quantityMax: stock?.quantity,
+            batchCode: line?.batchCode,
+            batchId: line?.batchId,
+            itemId: line?.itemId,
+            materialDisplayName: line
+              ? [line.itemName, line.specification].filter(Boolean).join(' | ')
+              : undefined,
+            quantity: line?.quantity,
+            quantityMax: line?.quantity,
           });
         },
-        virtualFilter: 'only',
       },
       rules: 'selectRequired',
     },
@@ -376,10 +378,19 @@
     },
     {
       fieldName: 'itemId',
+      component: 'Input',
+      dependencies: {
+        triggerFields: [''],
+        show: () => false,
+      },
+    },
+    {
+      fieldName: 'materialDisplayName',
       label: '鐗╂枡',
-      component: markRaw(MdItemSelect),
+      component: 'Input',
       componentProps: {
         disabled: true,
+        placeholder: '閫夋嫨棰嗘枡璁板綍鍚庤嚜鍔ㄥ甫鍑�',
       },
     },
     {
@@ -388,7 +399,7 @@
       component: 'Input',
       componentProps: {
         disabled: true,
-        placeholder: '閫夋嫨搴撳瓨鍚庤嚜鍔ㄥ甫鍑�',
+        placeholder: '閫夋嫨棰嗘枡璁板綍鍚庤嚜鍔ㄥ甫鍑�',
       },
     },
     {
@@ -460,28 +471,37 @@
     },
     {
       fieldName: 'itemId',
+      component: 'Input',
+      dependencies: {
+        triggerFields: [''],
+        show: () => false,
+      },
+    },
+    {
+      fieldName: 'materialDisplayName',
       label: '鐗╂枡',
-      component: markRaw(MdItemSelect),
+      component: 'Input',
       componentProps: {
         disabled: true,
+        placeholder: '閫夋嫨搴撳瓨鍚庤嚜鍔ㄥ甫鍑�',
       },
-      rules: 'selectRequired',
     },
     {
       fieldName: 'materialStockId',
       label: '搴撳瓨璁板綍',
       component: markRaw(WmMaterialStockSelect),
       componentProps: {
-        // 閫夋嫨搴撳瓨璁板綍鍚庯紝鑷姩鍥炲~浠撳簱/搴撳尯/搴撲綅/鎵规/鏁伴噺
+        // 閫夋嫨搴撳瓨璁板綍鍚庯紝鑷姩鍥炲~鐗╂枡/鎵规/鏁伴噺锛堜笉鍐嶅甫鍏ヤ粨搴撲俊鎭級
         onChange: async (stock?: MesWmMaterialStockApi.MaterialStock) => {
           await formApi?.setValues({
-            areaId: stock?.areaId,
             batchCode: stock?.batchCode,
             batchId: stock?.batchId,
-            locationId: stock?.locationId,
+            itemId: stock?.itemId,
+            materialDisplayName: stock
+              ? [stock.itemName, stock.specification].filter(Boolean).join(' | ')
+              : undefined,
             quantity: stock?.quantity,
             quantityMax: stock?.quantity,
-            warehouseId: stock?.warehouseId,
           });
         },
         virtualFilter: 'only',
@@ -519,38 +539,32 @@
     },
     {
       fieldName: 'warehouseId',
-      label: '鍏ュ簱浠撳簱',
+      label: '涓婃灦鐩爣浠撳簱',
       component: markRaw(WmWarehouseSelect),
-      componentProps: {
-        disabled: true,
-      },
+      // componentProps: {
+      //   excludeCodes: ['WIP_VIRTUAL_WAREHOUSE'],
+      // },
     },
     {
       fieldName: 'locationId',
-      label: '搴撳尯',
+      label: '涓婃灦鐩爣搴撳尯',
       component: markRaw(WmWarehouseLocationSelect),
-      componentProps: {
-        disabled: true,
-      },
       dependencies: {
         triggerFields: ['warehouseId'],
         componentProps: (values) => ({
-          disabled: true,
+          disabled: !values.warehouseId,
           warehouseId: values.warehouseId,
         }),
       },
     },
     {
       fieldName: 'areaId',
-      label: '搴撲綅',
+      label: '涓婃灦鐩爣搴撲綅',
       component: markRaw(WmWarehouseAreaSelect),
-      componentProps: {
-        disabled: true,
-      },
       dependencies: {
         triggerFields: ['locationId'],
         componentProps: (values) => ({
-          disabled: true,
+          disabled: !values.locationId,
           locationId: values.locationId,
         }),
       },

--
Gitblit v1.9.3