From 21599300cc73ff7384b74cc5e4ac2cbd82bdc293 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期三, 28 十月 2026 18:34:29 +0800
Subject: [PATCH] feat(wls): 更新销售退货功能支持关联销售出库单
---
src/views/wls/returnsales/data.ts | 153 +++++++++++++++++++++++++++++++++++++-------------
1 files changed, 112 insertions(+), 41 deletions(-)
diff --git a/src/views/wls/returnsales/data.ts b/src/views/wls/returnsales/data.ts
index c45c5f9..4824d5f 100644
--- a/src/views/wls/returnsales/data.ts
+++ b/src/views/wls/returnsales/data.ts
@@ -11,16 +11,20 @@
import { Button } from 'ant-design-vue';
-import { z } from '#/adapter/form';
import CrmCustomerSelect from '#/components/crm-customer-select.vue';
import { generateAutoCode } from '#/api/mes/md/autocode/record';
-import { MdItemSelect } from '#/views/mes/md/item/components';
+import { MdmItemSelect } from '#/views/basicData/mdm/components';
import { WmBatchSelect } from '#/views/wls/batch/components';
import {
WmWarehouseAreaSelect,
WmWarehouseLocationSelect,
WmWarehouseSelect,
} from '#/views/wls/warehouse/components';
+
+import {
+ WmReturnSalesProductSalesLineSelect,
+ WmReturnSalesProductSalesSelect,
+} from './components';
/** 琛ㄥ崟绫诲瀷 */
export type FormType = 'create' | 'detail' | 'finish' | 'stock' | 'update';
@@ -85,6 +89,20 @@
placeholder: '璇疯緭鍏ラ��璐у崟鍚嶇О',
},
rules: 'required',
+ },
+ {
+ fieldName: 'productSalesId',
+ label: '閿�鍞嚭搴撳崟',
+ component: markRaw(WmReturnSalesProductSalesSelect),
+ componentProps: {
+ disabled: isHeaderReadonly(formType),
+ // 閫夋嫨鍑哄簱鍗曞悗鑷姩甯﹀嚭瀹㈡埛
+ onChange: async (
+ productSales?: MesWmReturnSalesApi.ReturnableProductSales,
+ ) => {
+ await formApi?.setFieldValue('clientId', productSales?.clientId);
+ },
+ },
},
{
fieldName: 'clientId',
@@ -188,6 +206,11 @@
minWidth: 150,
},
{
+ field: 'productSalesCode',
+ title: '閿�鍞嚭搴撳崟鍙�',
+ minWidth: 160,
+ },
+ {
field: 'clientCode',
title: '瀹㈡埛缂栫爜',
minWidth: 120,
@@ -248,12 +271,12 @@
minWidth: 140,
},
{
- field: 'specification',
+ field: 'itemSpecification',
title: '瑙勬牸鍨嬪彿',
minWidth: 120,
},
{
- field: 'unitMeasureName',
+ field: 'itemUnit',
title: '鍗曚綅',
width: 80,
},
@@ -266,24 +289,6 @@
field: 'batchCode',
title: '鎵规鍙�',
minWidth: 120,
- },
- {
- field: 'rqcCheckFlag',
- title: '鏄惁闇�瑕佽川妫�',
- width: 120,
- cellRender: {
- name: 'CellDict',
- props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
- },
- },
- {
- field: 'qualityStatus',
- title: '璐ㄩ噺鐘舵��',
- width: 100,
- cellRender: {
- name: 'CellDict',
- props: { type: DICT_TYPE.MES_WM_QUALITY_STATUS },
- },
},
...(editable || stockable
? [
@@ -299,28 +304,52 @@
}
/** 閫�璐у崟琛屾柊澧�/淇敼鐨勮〃鍗� */
-export function useLineFormSchema(clientId?: number): VbenFormSchema[] {
+export function useLineFormSchema(
+ options: { clientId?: number; productSalesId?: number } = {},
+ formApi?: VbenFormApi,
+): VbenFormSchema[] {
+ const { clientId, productSalesId } = options;
+ const hasProductSales = !!productSalesId; // 鍏宠仈浜嗛攢鍞嚭搴撳崟鏃讹紝鐗╂枡/鎵规鐢卞嚭搴撹甯﹀叆
return [
+ {
+ fieldName: 'productSalesLineId',
+ label: '鍑哄簱琛�',
+ component: markRaw(WmReturnSalesProductSalesLineSelect),
+ componentProps: {
+ // 閫夋嫨鍑哄簱琛屽悗鑷姩甯﹀叆鐗╂枡銆佹壒娆′笌鍙��鏁伴噺
+ onChange: async (
+ line?: MesWmReturnSalesApi.ReturnableProductSalesLine,
+ ) => {
+ await formApi?.setValues({
+ batchCode: line?.batchCode,
+ itemId: line?.itemId,
+ quantity: line?.returnableQuantity,
+ returnableQuantity: line?.returnableQuantity,
+ });
+ },
+ productSalesId,
+ },
+ rules: hasProductSales ? 'selectRequired' : undefined,
+ dependencies: {
+ triggerFields: [''],
+ if: () => hasProductSales,
+ },
+ },
{
fieldName: 'itemId',
label: '鐗╂枡',
- component: markRaw(MdItemSelect),
+ component: markRaw(MdmItemSelect),
componentProps: {
placeholder: '璇烽�夋嫨鐗╂枡',
},
rules: 'selectRequired',
- },
- {
- fieldName: 'quantity',
- label: '閫�璐ф暟閲�',
- component: 'InputNumber',
- componentProps: {
- class: '!w-full',
- min: 0,
- placeholder: '璇疯緭鍏ラ��璐ф暟閲�',
- precision: 2,
+ dependencies: {
+ triggerFields: ['productSalesLineId'],
+ componentProps: (values) => ({
+ disabled: hasProductSales || !!values.productSalesLineId,
+ placeholder: '璇烽�夋嫨鐗╂枡',
+ }),
},
- rules: 'required',
},
{
fieldName: 'batchId',
@@ -333,6 +362,7 @@
},
dependencies: {
triggerFields: ['itemId'],
+ if: () => !hasProductSales,
componentProps: (values) => ({
clientId,
disabled: true,
@@ -342,10 +372,50 @@
},
},
{
- fieldName: 'rqcCheckFlag',
- label: '闇�瑕佽川妫�',
- component: 'Switch',
- rules: z.boolean().default(false),
+ fieldName: 'batchCode',
+ label: '鎵规鍙�',
+ component: 'Input',
+ componentProps: {
+ disabled: true,
+ placeholder: '鐢卞嚭搴撹甯﹀叆',
+ },
+ dependencies: {
+ triggerFields: [''],
+ if: () => hasProductSales,
+ },
+ },
+ {
+ fieldName: 'returnableQuantity',
+ label: '鍙��鏁伴噺',
+ component: 'Input',
+ componentProps: {
+ disabled: true,
+ placeholder: '閫夋嫨鍑哄簱琛屽悗鑷姩甯﹀嚭',
+ },
+ dependencies: {
+ triggerFields: [''],
+ if: () => hasProductSales,
+ },
+ },
+ {
+ fieldName: 'quantity',
+ label: '閫�璐ф暟閲�',
+ component: 'InputNumber',
+ componentProps: {
+ class: '!w-full',
+ min: 0,
+ placeholder: '璇疯緭鍏ラ��璐ф暟閲�',
+ precision: 2,
+ },
+ rules: 'required',
+ dependencies: {
+ triggerFields: ['returnableQuantity'],
+ componentProps: (values) => ({
+ max: hasProductSales
+ ? (values.returnableQuantity as number | undefined)
+ : undefined,
+ }),
+ },
},
{
fieldName: 'remark',
@@ -409,7 +479,7 @@
{
fieldName: 'itemId',
label: '鐗╂枡',
- component: markRaw(MdItemSelect),
+ component: markRaw(MdmItemSelect),
componentProps: {
disabled: true,
},
@@ -471,7 +541,8 @@
label: '鎵规鍙�',
component: 'Input',
componentProps: {
- placeholder: '璇疯緭鍏ユ壒娆″彿',
+ disabled: true,
+ placeholder: '鐢遍��璐ц甯﹀叆',
},
},
{
--
Gitblit v1.9.3