From 37c7825ba84000caee76476cb734fec6e006569b Mon Sep 17 00:00:00 2001
From: 吴羡 <16976746+Xian-TT3@user.noreply.gitee.com>
Date: 星期六, 07 十一月 2026 13:38:11 +0800
Subject: [PATCH] feat: 完成好水川装箱、工单成本、留样与发货统计页面
---
src/views/wls/packages/data.ts | 77 +++++++++++++++++++++++++++++++++++++-
1 files changed, 75 insertions(+), 2 deletions(-)
diff --git a/src/views/wls/packages/data.ts b/src/views/wls/packages/data.ts
index 7876069..f734006 100644
--- a/src/views/wls/packages/data.ts
+++ b/src/views/wls/packages/data.ts
@@ -13,6 +13,7 @@
import { Button } from 'ant-design-vue';
import { generateAutoCode } from '#/api/mes/md/autocode/record';
+import { getItem } from '#/api/mes/md/item';
import { getSimpleUserList } from '#/api/system/user';
import { ErpSaleOrderSelect } from '#/views/erp/sale/order/components';
import { MdClientSelect } from '#/views/mes/md/client/components';
@@ -429,8 +430,36 @@
];
}
+/** 缁勮灏剧棰勮鏂囨锛氭暣闄ゆ椂鏄剧ず姣忕鏁伴噺骞舵爣璁版弧瑁� */
+function buildTailPreview(quantity?: number, boxQuantity?: number): string {
+ if (!quantity || quantity <= 0 || !boxQuantity || boxQuantity <= 0) {
+ return '杈撳叆瑁呯鏁伴噺鍚庤嚜鍔ㄨ绠�';
+ }
+ const boxCount = Math.ceil(quantity / boxQuantity - 1e-9);
+ const tail = Number((quantity - (boxCount - 1) * boxQuantity).toFixed(2));
+ const full = Math.abs(tail - boxQuantity) < 1e-6;
+ return `棰勮瑁� ${boxCount} 绠憋紝灏剧 ${full ? boxQuantity : tail} 浠�${
+ full ? '锛堟弧瑁咃級' : ''
+ }`;
+}
+
+/** 鍒锋柊瑁呯棰勮锛堟寜琛ㄥ崟涓殑瑁呯鏁伴噺涓庢瘡绠辨暟閲忓疄鏃惰绠楋級 */
+export async function refreshTailPreview(formApi?: VbenFormApi) {
+ if (!formApi) {
+ return;
+ }
+ const values = (await formApi.getValues()) as {
+ boxQuantity?: number;
+ quantity?: number;
+ };
+ await formApi.setFieldValue(
+ 'tailPreview',
+ buildTailPreview(values.quantity, values.boxQuantity),
+ );
+}
+
/** 瑁呯鏄庣粏鐨勮〃鍗� */
-export function useLineFormSchema(): VbenFormSchema[] {
+export function useLineFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
return [
{
fieldName: 'workOrderId',
@@ -438,6 +467,16 @@
component: markRaw(ProWorkOrderSelect),
componentProps: {
placeholder: '璇烽�夋嫨鐢熶骇璁㈠崟',
+ // 閫夋嫨鐢熶骇璁㈠崟鍚庯紝鑷姩甯﹀嚭璇ヨ鍗曠殑浜у搧鐗╂枡
+ onChange: async (order?: { productId?: number }) => {
+ await formApi?.setFieldValue('itemId', order?.productId);
+ // 甯﹀嚭浜у搧鐗╂枡鐨勬瘡绠辨暟閲忥紝鐢ㄤ簬璁$畻灏剧
+ const item = order?.productId
+ ? await getItem(order.productId).catch(() => undefined)
+ : undefined;
+ await formApi?.setFieldValue('boxQuantity', item?.boxQuantity);
+ await refreshTailPreview(formApi);
+ },
},
rules: 'selectRequired',
},
@@ -446,9 +485,19 @@
label: '浜у搧鐗╂枡',
component: markRaw(MdItemSelect),
componentProps: {
- placeholder: '璇烽�夋嫨浜у搧鐗╂枡',
+ disabled: true,
+ placeholder: '閫夋嫨鐢熶骇璁㈠崟鍚庤嚜鍔ㄥ甫鍑�',
},
rules: 'selectRequired',
+ help: '鑷姩鍙栫敓浜ц鍗曠殑浜у搧锛屾棤闇�鎵嬪姩閫夋嫨銆�',
+ },
+ {
+ fieldName: 'boxQuantity',
+ component: 'Input',
+ dependencies: {
+ triggerFields: [''],
+ show: () => false,
+ },
},
{
fieldName: 'quantity',
@@ -459,8 +508,21 @@
min: 0.01,
placeholder: '璇疯緭鍏ヨ绠辨暟閲�',
precision: 2,
+ onChange: () => {
+ refreshTailPreview(formApi);
+ },
},
rules: 'required',
+ },
+ {
+ fieldName: 'tailPreview',
+ label: '瑁呯棰勮',
+ component: 'Input',
+ formItemClass: 'col-span-2',
+ componentProps: {
+ disabled: true,
+ placeholder: '杈撳叆瑁呯鏁伴噺鍚庤嚜鍔ㄨ绠�',
+ },
},
{
fieldName: 'expireDate',
@@ -514,6 +576,17 @@
width: 100,
},
{
+ field: 'boxCount',
+ title: '绠辨暟',
+ width: 80,
+ },
+ {
+ field: 'tailBoxQuantity',
+ title: '灏剧鏁伴噺',
+ width: 110,
+ slots: { default: 'tailBoxQuantity' },
+ },
+ {
field: 'workOrderCode',
title: '鐢熶骇璁㈠崟缂栧彿',
minWidth: 140,
--
Gitblit v1.9.3