From ee7ac8df8bce38add1f75baf876b49de94b9e00a Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期五, 16 十月 2026 17:58:33 +0800
Subject: [PATCH] feat(mes): 赋码管理绑定托盘支持未录入批次的袋码
---
src/views/wls/salesnotice/data.ts | 185 ++++++++++++++++++++++++++-------------------
1 files changed, 106 insertions(+), 79 deletions(-)
diff --git a/src/views/wls/salesnotice/data.ts b/src/views/wls/salesnotice/data.ts
index fcadf3c..dc2d2a7 100644
--- a/src/views/wls/salesnotice/data.ts
+++ b/src/views/wls/salesnotice/data.ts
@@ -8,23 +8,26 @@
import {
DICT_TYPE,
MesAutoCodeRuleCode,
- MesWmSalesNoticeOutStatusEnum,
+ MesWmWarehouseTypeEnum,
} from '@vben/constants';
-import { Button, Tag } from 'ant-design-vue';
+import { Button } from 'ant-design-vue';
import { z } from '#/adapter/form';
import { generateAutoCode } from '#/api/mes/md/autocode/record';
-import { ErpSaleOrderSelect } from '#/views/erp/sale/order/components';
-import { MdClientSelect } from '#/views/mes/md/client/components';
-import { MdItemSelect } from '#/views/mes/md/item/components';
+import CrmCustomerSelect from '#/components/crm-customer-select.vue';
+import {
+ getStockSummaryByBatch,
+ getStockSummaryByItem,
+ type MesWmMaterialStockApi,
+} from '#/api/mes/wm/materialstock';
/** 琛ㄥ崟绫诲瀷 */
-export type FormType = 'create' | 'detail' | 'finish' | 'update';
+export type FormType = 'create' | 'detail' | 'update';
-/** 琛ㄥ崟澶撮儴鏄惁鍙锛堣鎯呫�佹墽琛屽嚭搴撴�侊級 */
+/** 琛ㄥ崟澶撮儴鏄惁鍙锛堣鎯呮�侊級 */
function isHeaderReadonly(formType: FormType): boolean {
- return formType === 'detail' || formType === 'finish';
+ return formType === 'detail';
}
/** 鏂板/淇敼鐨勮〃鍗� */
@@ -84,44 +87,11 @@
rules: 'required',
},
{
- fieldName: 'saleOrderId',
- label: '閿�鍞鍗�',
- component: markRaw(ErpSaleOrderSelect),
- componentProps: {
- placeholder: '璇烽�夋嫨閿�鍞鍗�',
- // 閫夋嫨閿�鍞鍗曞悗锛岃嚜鍔ㄥ洖濉鎴蜂俊鎭�
- onChange: (item: any) => {
- if (item?.customerId && formApi) {
- formApi.setFieldValue('clientId', item.customerId);
- formApi.setFieldValue('clientName', item.customerName);
- }
- },
- },
- },
- {
- fieldName: 'clientName',
- label: '',
- component: 'Input',
- dependencies: {
- triggerFields: [''],
- show: () => false,
- },
- },
- {
fieldName: 'clientId',
label: '瀹㈡埛',
- component: markRaw(MdClientSelect),
+ component: markRaw(CrmCustomerSelect),
componentProps: {
placeholder: '璇烽�夋嫨瀹㈡埛',
- disabled: true,
- },
- dependencies: {
- triggerFields: ['clientName'],
- componentProps: (values) => ({
- placeholder: '璇烽�夋嫨瀹㈡埛',
- disabled: true,
- clientName: values.clientName as string,
- }),
},
rules: 'selectRequired',
},
@@ -133,7 +103,7 @@
class: '!w-full',
format: 'YYYY-MM-DD',
placeholder: '璇烽�夋嫨鍙戣揣鏃ユ湡',
- valueFormat: 'x',
+ valueFormat: 'YYYY-MM-DD',
},
rules: 'required',
},
@@ -196,18 +166,9 @@
},
},
{
- fieldName: 'salesOrderCode',
- label: '閿�鍞鍗曠紪鍙�',
- component: 'Input',
- componentProps: {
- allowClear: true,
- placeholder: '璇疯緭鍏ラ攢鍞鍗曠紪鍙�',
- },
- },
- {
fieldName: 'clientId',
label: '瀹㈡埛',
- component: markRaw(MdClientSelect),
+ component: markRaw(CrmCustomerSelect),
componentProps: {
placeholder: '璇烽�夋嫨瀹㈡埛',
},
@@ -228,11 +189,6 @@
field: 'name',
title: '閫氱煡鍗曞悕绉�',
minWidth: 150,
- },
- {
- field: 'salesOrderCode',
- title: '閿�鍞鍗曠紪鍙�',
- minWidth: 140,
},
{
field: 'clientName',
@@ -273,20 +229,7 @@
field: 'outStatus',
title: '鍑哄簱鐘舵��',
minWidth: 100,
- cellRender: {
- name: 'CellTag',
- props: {
- formatter: ({ row }: { row: MesWmSalesNoticeApi.SalesNotice }) => {
- const statusMap: Record<number, { color: string; label: string }> = {
- [MesWmSalesNoticeOutStatusEnum.NONE]: { color: 'default', label: '鏈嚭搴�' },
- [MesWmSalesNoticeOutStatusEnum.PARTIAL]: { color: 'warning', label: '閮ㄥ垎鍑哄簱' },
- [MesWmSalesNoticeOutStatusEnum.ALL]: { color: 'success', label: '鍏ㄩ儴鍑哄簱' },
- };
- const status = statusMap[row.outStatus ?? MesWmSalesNoticeOutStatusEnum.NONE];
- return { color: status?.color, label: status?.label ?? '鏈嚭搴�' };
- },
- },
- },
+ slots: { default: 'outStatus' },
},
{
title: '鎿嶄綔',
@@ -381,15 +324,98 @@
];
}
-/** 閫氱煡鍗曡鏂板/淇敼鐨勮〃鍗� */
+/** 姝e紡搴擄紙鍚堟牸搴撳簱瀛橈紝stockState = 20锛夋湁搴撳瓨鐨勭墿鏂欓�夐」 */
+export async function loadQualifiedStockItemOptions(): Promise<
+ { label: string; value: number }[]
+> {
+ const list = await getStockSummaryByItem({
+ stockState: 20,
+ warehouseType: MesWmWarehouseTypeEnum.QUALIFIED,
+ });
+ return list.map((item: MesWmMaterialStockApi.MaterialStockSummary) => ({
+ label: [item.itemName, item.itemCode, `搴撳瓨 ${item.totalQuantity}`]
+ .filter(Boolean)
+ .join(' '),
+ value: item.itemId as number,
+ }));
+}
+
+/** 鎸囧畾鐗╂枡鐨勬寮忓簱瀛樻壒娆¢�夐」 */
+export async function loadQualifiedStockBatchOptions(
+ itemId: number,
+): Promise<{ label: string; value: number }[]> {
+ const list = await getStockSummaryByBatch({
+ stockState: 20,
+ itemId,
+ warehouseType: MesWmWarehouseTypeEnum.QUALIFIED,
+ });
+ return list.map((item: MesWmMaterialStockApi.MaterialStockSummary) => ({
+ label: [item.batchCode, `搴撳瓨 ${item.totalQuantity}`].filter(Boolean).join(' '),
+ value: item.batchId as number,
+ }));
+}
+
+/**
+ * 鍙彂璐ф暟閲忥細鎵�閫夌墿鏂�/鎵规鐨勬寮忓簱瀛橈紙stockState = 20锛夋眹鎬汇��
+ *
+ * 鎸囧畾鎵规鏃剁簿纭埌璇ユ壒娆★紝鍚﹀垯杩斿洖鐗╂枡鍏ㄩ儴姝e紡搴撳瓨銆�
+ */
+export async function loadAvailableQuantity(
+ itemId?: number,
+ batchId?: number,
+): Promise<number> {
+ if (!itemId) {
+ return 0;
+ }
+ if (batchId) {
+ const list = await getStockSummaryByBatch({
+ stockState: 20,
+ itemId,
+ warehouseType: MesWmWarehouseTypeEnum.QUALIFIED,
+ });
+ return list.find((item) => item.batchId === batchId)?.totalQuantity ?? 0;
+ }
+ const list = await getStockSummaryByItem({
+ stockState: 20,
+ itemId,
+ warehouseType: MesWmWarehouseTypeEnum.QUALIFIED,
+ });
+ return list.find((item) => item.itemId === itemId)?.totalQuantity ?? 0;
+}
+
+/**
+ * 閫氱煡鍗曡鏂板/淇敼鐨勮〃鍗曘��
+ *
+ * 鐗╂枡銆佹壒娆″潎浠庢寮忓簱搴撳瓨锛坰tockState = 20锛変腑閫夋嫨锛�
+ * 鎵规閫夐」闅忕墿鏂欒仈鍔ㄥ姞杞斤紝鍙敤搴撳瓨涓嶈冻鐢卞悗绔繚瀛樻椂鏍¢獙銆�
+ */
export function useLineFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'itemId',
label: '鐗╂枡',
- component: markRaw(MdItemSelect),
+ component: 'Select',
componentProps: {
- placeholder: '璇烽�夋嫨鐗╂枡',
+ allowClear: true,
+ filterOption: true,
+ optionFilterProp: 'label',
+ options: [],
+ placeholder: '璇烽�夋嫨鐗╂枡锛堜粎姝e紡搴撳簱瀛橈級',
+ showSearch: true,
+ },
+ rules: 'selectRequired',
+ },
+ {
+ fieldName: 'batchId',
+ label: '鎵规',
+ component: 'Select',
+ componentProps: {
+ allowClear: true,
+ filterOption: true,
+ optionFilterProp: 'label',
+ options: [],
+ placeholder: '璇烽�夋嫨鎵规锛堜粎姝e紡搴撳簱瀛橈級',
+ showSearch: true,
},
rules: 'selectRequired',
},
@@ -400,17 +426,18 @@
componentProps: {
class: '!w-full',
min: 0.01,
- placeholder: '璇疯緭鍏ュ彂璐ф暟閲�',
+ placeholder: '璇疯緭鍏ュ彂璐ф暟閲忥紙涓嶅彲瓒呰繃姝e紡搴撳瓨锛�',
precision: 2,
},
rules: 'required',
},
{
- fieldName: 'batchCode',
- label: '鎵规鍙�',
+ fieldName: 'availableQuantity',
+ label: '鍙彂璐ф暟閲�',
component: 'Input',
componentProps: {
- placeholder: '璇疯緭鍏ユ壒娆″彿',
+ disabled: true,
+ placeholder: '閫夋嫨鐗╂枡/鎵规鍚庤嚜鍔ㄥ甫鍑�',
},
},
{
--
Gitblit v1.9.3