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/mes/pro/task/components/gantt-chart.vue | 120 ++++
src/views/wls/packages/modules/line-form.vue | 22
src/views/mes/qc/retentionsample/data.ts | 371 ++++++++++++++++
src/views/mes/pro/workorder/components/select.vue | 3
src/api/mes/md/vendor/index.ts | 108 ++--
src/views/mes/qc/retentionsample/modules/form.vue | 97 ++++
src/views/mes/pro/task/modules/schedule-form.vue | 11
src/views/wls/shipmentstatistics/index.vue | 52 ++
src/views/wls/packages/modules/sub-package-list.vue | 2
src/api/mes/wm/productsales/statistics/index.ts | 39 +
src/api/mes/wm/packages/line/index.ts | 3
src/views/wls/packages/modules/package-line-list.vue | 10
src/packages/constants/src/biz-mes-enum.ts | 1
src/views/mes/pro/workorder/data.ts | 32 +
src/views/mes/qc/retentionsample/index.vue | 140 ++++++
src/views/mes/pro/workorder/components/select-dialog.vue | 5
src/views/wls/packages/index.vue | 4
src/api/mes/pro/workorder/index.ts | 4
src/views/mes/md/item/data.ts | 18
src/views/mes/md/item/type/data.ts | 21
src/views/mes/md/vendor/data.ts | 31 -
src/api/mes/md/item/index.ts | 1
src/views/wls/shipmentstatistics/data.ts | 110 ++++
src/api/mes/wm/productsales/line/index.ts | 1
src/api/mes/md/item/type/index.ts | 1
src/views/wls/packages/data.ts | 77 +++
src/packages/constants/src/dict-enum.ts | 1
src/views/wls/productsales/data.ts | 5
src/api/mes/pro/mps/index.ts | 1
src/api/mes/qc/retention-sample/index.ts | 61 ++
30 files changed, 1,251 insertions(+), 101 deletions(-)
diff --git a/src/api/mes/md/item/index.ts b/src/api/mes/md/item/index.ts
index 6ad491e..22e991d 100644
--- a/src/api/mes/md/item/index.ts
+++ b/src/api/mes/md/item/index.ts
@@ -20,6 +20,7 @@
maxStock?: number; // 鏈�楂樺簱瀛橀噺
highValue?: boolean; // 鏄惁楂樺�肩墿鏂�
batchFlag?: boolean; // 鏄惁鍚敤鎵规绠$悊
+ boxQuantity?: number; // 姣忕鏁伴噺
remark?: string; // 澶囨敞
createTime?: Date; // 鍒涘缓鏃堕棿
}
diff --git a/src/api/mes/md/item/type/index.ts b/src/api/mes/md/item/type/index.ts
index 86dc13d..50b245c 100644
--- a/src/api/mes/md/item/type/index.ts
+++ b/src/api/mes/md/item/type/index.ts
@@ -8,6 +8,7 @@
code?: string; // 鍒嗙被缂栫爜
name?: string; // 鍒嗙被鍚嶇О
itemOrProduct?: string; // 鐗╂枡/浜у搧鏍囪瘑
+ finishedFlag?: boolean; // 鏄惁鎴愬搧鍒嗙被
sort?: number; // 鏄剧ず鎺掑簭
status?: number; // 鐘舵��
remark?: string; // 澶囨敞
diff --git a/src/api/mes/md/vendor/index.ts b/src/api/mes/md/vendor/index.ts
index e64845f..b33b27e 100644
--- a/src/api/mes/md/vendor/index.ts
+++ b/src/api/mes/md/vendor/index.ts
@@ -1,9 +1,10 @@
import type { PageParam, PageResult } from '@vben/request';
+import type { SrmSupplierApi } from '#/api/srm/supplier';
import { requestClient } from '#/api/request';
export namespace MesMdVendorApi {
- /** MES 渚涘簲鍟� */
+ /** MES 渚涘簲鍟嗭紙鏁版嵁鏉ユ簮锛歋RM 渚涘簲鍟嗘。妗堬級 */
export interface Vendor {
id?: number; // 渚涘簲鍟嗙紪鍙�
code?: string; // 渚涘簲鍟嗙紪鐮�
@@ -29,59 +30,66 @@
remark?: string; // 澶囨敞
createTime?: Date; // 鍒涘缓鏃堕棿
}
-
- /** 渚涘簲鍟嗗鍏ョ粨鏋� */
- export interface VendorImportRespVO {
- createCodes?: string[]; // 鏂板鎴愬姛鐨勪緵搴斿晢缂栫爜
- updateCodes?: string[]; // 鏇存柊鎴愬姛鐨勪緵搴斿晢缂栫爜
- failureCodes?: Record<string, string>; // 瀵煎叆澶辫触鐨勪緵搴斿晢缂栫爜鍙婂師鍥�
- }
}
-/** 鏌ヨ渚涘簲鍟嗗垎椤� */
-export function getVendorPage(params: PageParam) {
- return requestClient.get<PageResult<MesMdVendorApi.Vendor>>(
- '/mes/md-vendor/page',
- { params },
+/** SRM 渚涘簲鍟嗘。妗堣繑鍥炲瓧娈碉紙鍚墠绔被鍨嬪皻鏈0鏄庣殑绠�绉般�佸畼缃戯級 */
+interface SrmSupplierRow extends SrmSupplierApi.SupplierVO {
+ shortName?: string;
+ website?: string;
+}
+
+/** SRM 渚涘簲鍟嗗垎椤垫煡璇㈠弬鏁� */
+interface VendorPageParams extends PageParam {
+ code?: string;
+ name?: string;
+ status?: number;
+}
+
+function toVendor(supplier: SrmSupplierRow): MesMdVendorApi.Vendor {
+ return {
+ id: supplier.id,
+ code: supplier.code,
+ name: supplier.name,
+ nickname: supplier.shortName,
+ address: supplier.address,
+ website: supplier.website,
+ email: supplier.contactEmail,
+ telephone: supplier.contactMobile,
+ contact1Name: supplier.contactName,
+ contact1Telephone: supplier.contactMobile,
+ contact1Email: supplier.contactEmail,
+ creditCode: supplier.taxNo,
+ status: supplier.status,
+ remark: supplier.remark,
+ createTime: supplier.createTime ? new Date(supplier.createTime) : undefined,
+ };
+}
+
+/** 鏌ヨ渚涘簲鍟嗗垎椤碉紙璇诲彇 SRM 渚涘簲鍟嗘。妗堬級 */
+export async function getVendorPage(params: VendorPageParams) {
+ const page = await requestClient.get<PageResult<SrmSupplierRow>>(
+ '/srm/supplier/page',
+ {
+ params: {
+ pageNo: params.pageNo,
+ pageSize: params.pageSize,
+ code: params.code,
+ name: params.name,
+ status: params.status,
+ },
+ },
);
+ return {
+ list: page.list.map((supplier) => toVendor(supplier)),
+ total: page.total,
+ } as PageResult<MesMdVendorApi.Vendor>;
}
-/** 鏌ヨ渚涘簲鍟嗚鎯� */
-export function getVendor(id: number) {
- return requestClient.get<MesMdVendorApi.Vendor>(
- `/mes/md-vendor/get?id=${id}`,
+/** 鏌ヨ渚涘簲鍟嗚鎯咃紙璇诲彇 SRM 渚涘簲鍟嗘。妗堬級 */
+export async function getVendor(id: number) {
+ const supplier = await requestClient.get<SrmSupplierRow>(
+ '/srm/supplier/get',
+ { params: { id } },
);
-}
-
-/** 鏂板渚涘簲鍟� */
-export function createVendor(data: MesMdVendorApi.Vendor) {
- return requestClient.post('/mes/md-vendor/create', data);
-}
-
-/** 淇敼渚涘簲鍟� */
-export function updateVendor(data: MesMdVendorApi.Vendor) {
- return requestClient.put('/mes/md-vendor/update', data);
-}
-
-/** 鍒犻櫎渚涘簲鍟� */
-export function deleteVendor(id: number) {
- return requestClient.delete(`/mes/md-vendor/delete?id=${id}`);
-}
-
-/** 瀵煎嚭渚涘簲鍟� */
-export function exportVendor(params: any) {
- return requestClient.download('/mes/md-vendor/export-excel', { params });
-}
-
-/** 涓嬭浇渚涘簲鍟嗗鍏ユā鏉� */
-export function importVendorTemplate() {
- return requestClient.download('/mes/md-vendor/get-import-template');
-}
-
-/** 瀵煎叆渚涘簲鍟� */
-export function importVendor(file: File, updateSupport: boolean) {
- return requestClient.upload<MesMdVendorApi.VendorImportRespVO>(
- `/mes/md-vendor/import?updateSupport=${updateSupport}`,
- { file },
- );
+ return toVendor(supplier);
}
diff --git a/src/api/mes/pro/mps/index.ts b/src/api/mes/pro/mps/index.ts
index 652dbf8..d94e5ac 100644
--- a/src/api/mes/pro/mps/index.ts
+++ b/src/api/mes/pro/mps/index.ts
@@ -38,6 +38,7 @@
productId?: number;
clientId?: number;
status?: number;
+ workOrderId?: number;
requestDate?: number[];
}
diff --git a/src/api/mes/pro/workorder/index.ts b/src/api/mes/pro/workorder/index.ts
index 63dcc6e..c031c62 100644
--- a/src/api/mes/pro/workorder/index.ts
+++ b/src/api/mes/pro/workorder/index.ts
@@ -21,6 +21,9 @@
quantityProduced?: number; // 宸茬敓浜ф暟閲�
quantityChanged?: number; // 璋冩暣鏁伴噺
quantityScheduled?: number; // 宸叉帓浜ф暟閲�
+ packedQuantity?: number; // 宸茶绠辨暟閲�
+ packedBoxCount?: number; // 宸茶绠辩鏁�
+ packingStatus?: number; // 瑁呯鐘舵�侊細0=鏈绠� 1=閮ㄥ垎宸茶绠� 2=宸茶绠卞畬鎴�
clientId?: number; // 瀹㈡埛缂栧彿
clientName?: string; // 瀹㈡埛鍚嶇О
vendorId?: number; // 渚涘簲鍟嗙紪鍙�
@@ -52,6 +55,7 @@
clientId?: number;
status?: number;
type?: number;
+ packingStatus?: number;
requestDate?: number[];
}
}
diff --git a/src/api/mes/qc/retention-sample/index.ts b/src/api/mes/qc/retention-sample/index.ts
new file mode 100644
index 0000000..68365be
--- /dev/null
+++ b/src/api/mes/qc/retention-sample/index.ts
@@ -0,0 +1,61 @@
+import type { PageParam, PageResult } from '@vben/request';
+
+import { requestClient } from '#/api/request';
+
+export namespace MesQcRetentionSampleApi {
+ /** MES 鐣欐牱璁板綍 */
+ export interface RetentionSample {
+ id?: number;
+ code?: string;
+ workOrderId?: number;
+ workOrderCode?: string;
+ saleOrderId?: number;
+ saleOrderNo?: string;
+ productId?: number;
+ productCode?: string;
+ productName?: string;
+ productSpecification?: string;
+ batchCode?: string;
+ sampleQuantity?: number;
+ sampleDate?: string;
+ expiryDate?: string;
+ keeperUserId?: number;
+ keeperNickname?: string;
+ remark?: string;
+ createTime?: string;
+ }
+}
+
+/** 鏌ヨ鐣欐牱璁板綍鍒嗛〉 */
+export function getRetentionSamplePage(params: PageParam) {
+ return requestClient.get<PageResult<MesQcRetentionSampleApi.RetentionSample>>(
+ '/mes/qc/retention-sample/page',
+ { params },
+ );
+}
+
+/** 鏌ヨ鐣欐牱璁板綍璇︽儏 */
+export function getRetentionSample(id: number) {
+ return requestClient.get<MesQcRetentionSampleApi.RetentionSample>(
+ `/mes/qc/retention-sample/get?id=${id}`,
+ );
+}
+
+/** 鏂板鐣欐牱璁板綍 */
+export function createRetentionSample(
+ data: MesQcRetentionSampleApi.RetentionSample,
+) {
+ return requestClient.post('/mes/qc/retention-sample/create', data);
+}
+
+/** 淇敼鐣欐牱璁板綍 */
+export function updateRetentionSample(
+ data: MesQcRetentionSampleApi.RetentionSample,
+) {
+ return requestClient.put('/mes/qc/retention-sample/update', data);
+}
+
+/** 鍒犻櫎鐣欐牱璁板綍 */
+export function deleteRetentionSample(id: number) {
+ return requestClient.delete(`/mes/qc/retention-sample/delete?id=${id}`);
+}
diff --git a/src/api/mes/wm/packages/line/index.ts b/src/api/mes/wm/packages/line/index.ts
index d528d88..2b43733 100644
--- a/src/api/mes/wm/packages/line/index.ts
+++ b/src/api/mes/wm/packages/line/index.ts
@@ -14,6 +14,9 @@
specification?: string; // 瑙勬牸鍨嬪彿
unitMeasureName?: string; // 璁¢噺鍗曚綅鍚嶇О
quantity?: number; // 瑁呯鏁伴噺
+ boxCount?: number; // 绠辨暟
+ tailBoxQuantity?: number; // 灏剧鏁伴噺锛堟渶鍚庝竴绠卞疄闄呰鐨勬暟閲忥級
+ tailBoxFull?: boolean; // 灏剧鏄惁婊¤
workOrderId?: number; // 鐢熶骇璁㈠崟缂栧彿
workOrderCode?: string; // 鐢熶骇璁㈠崟缂栧彿
batchCode?: string; // 鎵规鍙�
diff --git a/src/api/mes/wm/productsales/line/index.ts b/src/api/mes/wm/productsales/line/index.ts
index 1f8e46a..729c023 100644
--- a/src/api/mes/wm/productsales/line/index.ts
+++ b/src/api/mes/wm/productsales/line/index.ts
@@ -15,6 +15,7 @@
specification?: string; // 瑙勬牸鍨嬪彿
unitMeasureName?: string; // 鍗曚綅
quantity?: number; // 鍑哄簱鏁伴噺
+ boxCount?: number; // 绠辨暟
pickedQuantity?: number; // 宸叉嫞璐ф暟閲�
batchId?: number; // 鎵规缂栧彿
batchCode?: string; // 鎵规鍙�
diff --git a/src/api/mes/wm/productsales/statistics/index.ts b/src/api/mes/wm/productsales/statistics/index.ts
new file mode 100644
index 0000000..b06f839
--- /dev/null
+++ b/src/api/mes/wm/productsales/statistics/index.ts
@@ -0,0 +1,39 @@
+import type { PageParam, PageResult } from '@vben/request';
+
+import { requestClient } from '#/api/request';
+
+export namespace MesWmProductSalesStatisticsApi {
+ /** MES 鍙戣揣缁熻 */
+ export interface Statistics {
+ id?: string; // 鍓嶇琛屼富閿紙瀹㈡埛+閿�鍞鍗曞彿+浜у搧锛�
+ clientId?: number; // 瀹㈡埛缂栧彿
+ clientName?: string; // 瀹㈡埛鍚嶇О
+ salesOrderCode?: string; // 閿�鍞鍗曠紪鍙�
+ itemId?: number; // 浜у搧缂栧彿
+ itemCode?: string; // 浜у搧缂栫爜
+ itemName?: string; // 浜у搧鍚嶇О
+ specification?: string; // 瑙勬牸鍨嬪彿
+ unitMeasureName?: string; // 鍗曚綅
+ totalQuantity?: number; // 鍑哄簱鎬绘暟閲�
+ totalBoxCount?: number; // 鎬荤鏁�
+ shipmentCount?: number; // 鍙戣揣娆℃暟
+ lastShipmentDate?: Date; // 鏈�鍚庡彂璐ф椂闂�
+ }
+
+ /** 鍙戣揣缁熻鍒嗛〉鏌ヨ鍙傛暟 */
+ export interface PageParams extends PageParam {
+ clientId?: number;
+ salesOrderCode?: string;
+ itemId?: number;
+ shipmentDate?: string[];
+ }
+}
+
+/** 鏌ヨ鍙戣揣缁熻鍒嗛〉 */
+export function getProductSalesStatisticsPage(
+ params: MesWmProductSalesStatisticsApi.PageParams,
+) {
+ return requestClient.get<
+ PageResult<MesWmProductSalesStatisticsApi.Statistics>
+ >('/mes/wm/product-sales/statistics-page', { params });
+}
diff --git a/src/packages/constants/src/biz-mes-enum.ts b/src/packages/constants/src/biz-mes-enum.ts
index 1aec909..1b54719 100644
--- a/src/packages/constants/src/biz-mes-enum.ts
+++ b/src/packages/constants/src/biz-mes-enum.ts
@@ -170,6 +170,7 @@
QC_IQC_VENDOR_BATCH_CODE: 'QC_IQC_VENDOR_BATCH_CODE',
QC_IPQC_CODE: 'QC_IPQC_CODE',
QC_OQC_CODE: 'QC_OQC_CODE',
+ QC_RETENTION_SAMPLE_CODE: 'QC_RETENTION_SAMPLE_CODE',
QC_RQC_CODE: 'QC_RQC_CODE',
QC_TEMPLATE_CODE: 'QC_TEMPLATE_CODE',
TM_TOOL_TYPE_CODE: 'TM_TOOL_TYPE_CODE',
diff --git a/src/packages/constants/src/dict-enum.ts b/src/packages/constants/src/dict-enum.ts
index 9324deb..809d189 100644
--- a/src/packages/constants/src/dict-enum.ts
+++ b/src/packages/constants/src/dict-enum.ts
@@ -242,6 +242,7 @@
MES_PRO_WORK_ORDER_STATUS: 'mes_pro_work_order_status', // MES 鐢熶骇宸ュ崟鐘舵��
ORDER_PRODUCTION_STATUS: 'order_production_status', // 鐢熶骇璁㈠崟鐘舵��
MES_PRO_WORK_ORDER_TYPE: 'mes_pro_work_order_type', // MES 宸ュ崟绫诲瀷
+ MES_PRO_WORK_ORDER_PACKING_STATUS: 'mes_pro_work_order_packing_status', // MES 宸ュ崟瑁呯鐘舵��
MES_PRO_WORK_ORDER_SOURCE_TYPE: 'mes_pro_work_order_source_type', // MES 宸ュ崟鏉ユ簮绫诲瀷
MES_PRO_TASK_STATUS: 'mes_pro_task_status', // MES 鐢熶骇浠诲姟鐘舵��
MES_PRO_FEEDBACK_STATUS: 'mes_pro_feedback_status', // MES 鐢熶骇鎶ュ伐鐘舵��
diff --git a/src/views/mes/md/item/data.ts b/src/views/mes/md/item/data.ts
index f477734..b4509e6 100644
--- a/src/views/mes/md/item/data.ts
+++ b/src/views/mes/md/item/data.ts
@@ -118,6 +118,18 @@
rules: z.number().default(CommonStatusEnum.DISABLE),
},
{
+ fieldName: 'boxQuantity',
+ label: '姣忕鏁伴噺',
+ component: 'InputNumber',
+ componentProps: {
+ class: '!w-full',
+ min: 0.01,
+ placeholder: '璇疯緭鍏ユ瘡绠辨暟閲�',
+ precision: 2,
+ },
+ help: '浠呮垚鍝侀渶瑕佸~鍐欙紝瑁呯涓庡彂璐ф椂鐢ㄤ簬鑷姩璁$畻绠辨暟銆�',
+ },
+ {
fieldName: 'highValue',
label: '楂樺�肩墿鏂�',
component: 'Switch',
@@ -288,6 +300,12 @@
align: 'center',
},
{
+ field: 'boxQuantity',
+ title: '姣忕鏁伴噺',
+ width: 100,
+ align: 'center',
+ },
+ {
field: 'itemTypeName',
title: '鐗╂枡鍒嗙被',
minWidth: 140,
diff --git a/src/views/mes/md/item/type/data.ts b/src/views/mes/md/item/type/data.ts
index 911080d..f5710a5 100644
--- a/src/views/mes/md/item/type/data.ts
+++ b/src/views/mes/md/item/type/data.ts
@@ -109,6 +109,17 @@
rules: z.string().default(MesItemOrProductEnum.ITEM.value),
},
{
+ fieldName: 'finishedFlag',
+ label: '鏄惁鎴愬搧鍒嗙被',
+ component: 'Switch',
+ componentProps: {
+ checkedChildren: '鏄�',
+ unCheckedChildren: '鍚�',
+ },
+ rules: z.boolean().default(false),
+ help: '璁句负鎴愬搧鍒嗙被鍚庯紝璇ュ垎绫讳笅鐨勭墿鏂欐墠鍏佽瑁呯銆�',
+ },
+ {
fieldName: 'sort',
label: '鏄剧ず鎺掑簭',
component: 'InputNumber',
@@ -194,6 +205,16 @@
},
},
{
+ field: 'finishedFlag',
+ title: '鎴愬搧鍒嗙被',
+ width: 110,
+ align: 'center',
+ cellRender: {
+ name: 'CellDict',
+ props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
+ },
+ },
+ {
field: 'sort',
title: '鎺掑簭',
width: 100,
diff --git a/src/views/mes/md/vendor/data.ts b/src/views/mes/md/vendor/data.ts
index 6a0bec1..37187e3 100644
--- a/src/views/mes/md/vendor/data.ts
+++ b/src/views/mes/md/vendor/data.ts
@@ -25,24 +25,6 @@
placeholder: '璇疯緭鍏ヤ緵搴斿晢鍚嶇О',
},
},
- {
- fieldName: 'nickname',
- label: '渚涘簲鍟嗙畝绉�',
- component: 'Input',
- componentProps: {
- allowClear: true,
- placeholder: '璇疯緭鍏ヤ緵搴斿晢绠�绉�',
- },
- },
- {
- fieldName: 'englishName',
- label: '鑻辨枃鍚嶇О',
- component: 'Input',
- componentProps: {
- allowClear: true,
- placeholder: '璇疯緭鍏ヨ嫳鏂囧悕绉�',
- },
- },
];
}
@@ -68,18 +50,9 @@
width: 120,
},
{
- field: 'level',
- title: '渚涘簲鍟嗙瓑绾�',
+ field: 'contact1Name',
+ title: '鑱旂郴浜�',
width: 120,
- cellRender: {
- name: 'CellDict',
- props: { type: DICT_TYPE.MES_VENDOR_LEVEL },
- },
- },
- {
- field: 'score',
- title: '渚涘簲鍟嗚瘎鍒�',
- width: 110,
},
{
field: 'telephone',
diff --git a/src/views/mes/pro/task/components/gantt-chart.vue b/src/views/mes/pro/task/components/gantt-chart.vue
index a6af9f1..0b750c6 100644
--- a/src/views/mes/pro/task/components/gantt-chart.vue
+++ b/src/views/mes/pro/task/components/gantt-chart.vue
@@ -157,6 +157,26 @@
ganttInited.value = true;
}
+/** 杞负鍚堟硶鏃ユ湡锛屾棤娉曡В鏋愭椂杩斿洖 null */
+function toValidDate(value: any): Date | null {
+ if (value === null || value === undefined || value === '') {
+ return null;
+ }
+ const date = value instanceof Date ? value : new Date(value);
+ return Number.isNaN(date.getTime()) ? null : date;
+}
+
+/** 琛ュ叏鐢樼壒鍥炬椂闀匡紙灏忔椂锛夛細缂哄け鎴栭潪娉曟椂鎸夎捣姝㈡椂闂磋绠� */
+function resolveDuration(item: any): number {
+ const duration = Number(item.duration);
+ if (Number.isFinite(duration) && duration > 0) {
+ return duration;
+ }
+ const hours =
+ (item.end_date.getTime() - item.start_date.getTime()) / 3_600_000;
+ return Math.max(hours, 1);
+}
+
/** 鍔犺浇鏁版嵁鍒扮敇鐗瑰浘 */
function loadData(tasks: any[]) {
if (!ganttInited.value) {
@@ -168,22 +188,93 @@
[BarcodeBizTypeEnum.WORKORDER]: 'project',
[BarcodeBizTypeEnum.TASK]: 'task',
};
- gantt.parse({
- data: tasks.map((item: any) => ({
- ...item,
- type: typeMap[item.type] || item.type,
- start_date: item.startDate ? new Date(item.startDate) : undefined,
- end_date: item.endDate ? new Date(item.endDate) : undefined,
- })),
- links: [],
+
+ // 浠诲姟琛岋細璧锋鏃堕棿涓嶅畬鏁寸殑涓嶈繘鐢樼壒鍥撅紝閬垮厤绗笁鏂瑰簱瑙f瀽绌烘棩鏈熸椂鎶ラ敊
+ const taskRows = tasks
+ .filter((item: any) => item.type !== BarcodeBizTypeEnum.WORKORDER)
+ .map((item: any) => {
+ const startDate = toValidDate(item.startDate);
+ const endDate = toValidDate(item.endDate);
+ if (!startDate || !endDate) {
+ return null;
+ }
+ return {
+ ...item,
+ type: typeMap[item.type] || item.type,
+ start_date: startDate,
+ end_date: endDate,
+ };
+ })
+ .filter(Boolean) as any[];
+
+ // 宸ュ崟琛岋細娌℃湁鑷韩鏃堕棿鏃剁敤瀛愪换鍔$殑鏈�鏃╁紑濮�/鏈�鏅氱粨鏉熻ˉ鍏紱娌℃湁浠讳綍鎺掍骇浠诲姟鐨勫伐鍗曚笉鏄剧ず
+ const tasksByParent = new Map<string, any[]>();
+ taskRows.forEach((row: any) => {
+ if (!row.parent) {
+ return;
+ }
+ const children = tasksByParent.get(row.parent) || [];
+ children.push(row);
+ tasksByParent.set(row.parent, children);
});
+ const projectRows = tasks
+ .filter((item: any) => item.type === BarcodeBizTypeEnum.WORKORDER)
+ .map((item: any) => {
+ const children = tasksByParent.get(item.id) || [];
+ let startDate = toValidDate(item.startDate);
+ let endDate = toValidDate(item.endDate);
+ if ((!startDate || !endDate) && children.length > 0) {
+ startDate = new Date(
+ Math.min(...children.map((child) => child.start_date.getTime())),
+ );
+ endDate = new Date(
+ Math.max(...children.map((child) => child.end_date.getTime())),
+ );
+ }
+ if (!startDate || !endDate) {
+ return null;
+ }
+ return {
+ ...item,
+ type: 'project',
+ start_date: startDate,
+ end_date: endDate,
+ };
+ })
+ .filter(Boolean) as any[];
+
+ const projectIds = new Set(projectRows.map((row: any) => row.id));
+ taskRows.forEach((row: any) => {
+ if (row.parent && !projectIds.has(row.parent)) {
+ delete row.parent;
+ }
+ });
+
+ const data = [...projectRows, ...taskRows].map((row: any) => ({
+ ...row,
+ duration: resolveDuration(row),
+ }));
+ if (data.length === 0) {
+ return;
+ }
+ try {
+ gantt.parse({ data, links: [] });
+ } catch (error) {
+ // 绗笁鏂瑰簱娓叉煋寮傚父鍙奖鍝嶇敇鐗瑰浘鑷韩锛屼笉鑳借鏁翠釜椤甸潰璺敱鍒囨崲澶辫触
+ console.error('鐢樼壒鍥炬暟鎹В鏋愬け璐ワ紝宸茶烦杩囨湰娆℃覆鏌�', error);
+ try {
+ gantt.clearAll();
+ } catch {
+ // 蹇界暐娓呯悊澶辫触
+ }
+ }
}
watch(
() => props.tasks,
(val) => {
- if (val?.length && ganttInited.value) {
- loadData(val);
+ if (ganttInited.value) {
+ loadData(val || []);
}
},
{ deep: true },
@@ -197,8 +288,15 @@
});
onBeforeUnmount(() => {
- if (ganttInited.value) {
+ if (!ganttInited.value) {
+ return;
+ }
+ try {
gantt.clearAll();
+ } catch {
+ // 绗笁鏂圭敇鐗瑰浘娓呯悊寮傚父涓嶅簲褰卞搷璺敱鍒囨崲
+ } finally {
+ ganttInited.value = false;
}
});
diff --git a/src/views/mes/pro/task/modules/schedule-form.vue b/src/views/mes/pro/task/modules/schedule-form.vue
index f459bfb..59c3b39 100644
--- a/src/views/mes/pro/task/modules/schedule-form.vue
+++ b/src/views/mes/pro/task/modules/schedule-form.vue
@@ -25,6 +25,9 @@
const currentRouteId = ref(0); // 褰撳墠宸ヨ壓璺嚎缂栧彿
const isReadonly = computed(() => formType.value === 'detail'); // 璇︽儏鎬佸彧璇�
+const canFinish = computed(
+ () => (workOrder.value?.quantityProduced ?? 0) > 0,
+); // 鏈変骇鍑烘墠鍏佽瀹屾垚
const getTitle = computed(() =>
formType.value === 'detail' ? '璁㈠崟璇︽儏' : '鐢熶骇鎺掍骇',
);
@@ -156,12 +159,18 @@
<div class="flex flex-auto items-center gap-2">
<template v-if="formType === 'schedule'">
<Popconfirm
- v-if="routeProcessList.length > 0"
+ v-if="routeProcessList.length > 0 && canFinish"
title="纭瑕佸畬鎴愯璁㈠崟鍚楋紵瀹屾垚鍚庤鍗曚笅鎵�鏈変换鍔″皢鏍囪涓哄凡瀹屾垚銆�"
@confirm="handleFinish"
>
<Button type="primary">瀹屾垚</Button>
</Popconfirm>
+ <span
+ v-else-if="routeProcessList.length > 0"
+ class="text-gray-400 text-sm"
+ >
+ 褰撳墠璁㈠崟宸茬敓浜ф暟閲忎负 0锛岃鍏堝畬鎴愭姤宸ュ悗鍐嶅畬鎴愯鍗�
+ </span>
<span v-else class="text-gray-400 text-sm">
褰撳墠璁㈠崟鏈厤缃伐搴忥紝璇峰厛鍦ㄥ伐鍗曚腑缁存姢宸ュ簭淇℃伅鍚庡啀瀹屾垚
</span>
diff --git a/src/views/mes/pro/workorder/components/select-dialog.vue b/src/views/mes/pro/workorder/components/select-dialog.vue
index 250ddd8..51e4a8a 100644
--- a/src/views/mes/pro/workorder/components/select-dialog.vue
+++ b/src/views/mes/pro/workorder/components/select-dialog.vue
@@ -19,11 +19,13 @@
const props = withDefaults(
defineProps<{
+ excludeStatuses?: number[];
status?: number;
type?: number;
checkMethod?: (row: MesProWorkOrderApi.WorkOrder) => boolean;
}>(),
{
+ excludeStatuses: undefined,
status: undefined,
type: undefined,
checkMethod: undefined,
@@ -151,6 +153,9 @@
...formValues,
...(props.status === undefined ? {} : { status: props.status }),
...(props.type === undefined ? {} : { type: props.type }),
+ ...(props.excludeStatuses === undefined
+ ? {}
+ : { excludeStatuses: props.excludeStatuses }),
});
},
},
diff --git a/src/views/mes/pro/workorder/components/select.vue b/src/views/mes/pro/workorder/components/select.vue
index 39dd494..167f73e 100644
--- a/src/views/mes/pro/workorder/components/select.vue
+++ b/src/views/mes/pro/workorder/components/select.vue
@@ -17,6 +17,7 @@
defineProps<{
allowClear?: boolean;
disabled?: boolean;
+ excludeStatuses?: number[];
modelValue?: number;
placeholder?: string;
status?: number;
@@ -26,6 +27,7 @@
{
allowClear: true,
disabled: false,
+ excludeStatuses: undefined,
modelValue: undefined,
placeholder: '璇烽�夋嫨璁㈠崟',
status: undefined,
@@ -142,6 +144,7 @@
ref="dialogRef"
:status="status"
:type="type"
+ :exclude-statuses="excludeStatuses"
:check-method="checkMethod"
@selected="handleSelected"
/>
diff --git a/src/views/mes/pro/workorder/data.ts b/src/views/mes/pro/workorder/data.ts
index cdc4573..74b3361 100644
--- a/src/views/mes/pro/workorder/data.ts
+++ b/src/views/mes/pro/workorder/data.ts
@@ -374,6 +374,19 @@
},
},
{
+ fieldName: 'packingStatus',
+ label: '瑁呯鐘舵��',
+ component: 'Select',
+ componentProps: {
+ allowClear: true,
+ options: getDictOptions(
+ DICT_TYPE.MES_PRO_WORK_ORDER_PACKING_STATUS,
+ 'number',
+ ),
+ placeholder: '璇烽�夋嫨瑁呯鐘舵��',
+ },
+ },
+ {
fieldName: 'requestDate',
label: '闇�姹傛棩鏈�',
component: 'RangePicker',
@@ -455,6 +468,25 @@
width: 100,
},
{
+ field: 'packedQuantity',
+ title: '宸茶绠辨暟閲�',
+ width: 110,
+ },
+ {
+ field: 'packedBoxCount',
+ title: '宸茶绠辩鏁�',
+ width: 110,
+ },
+ {
+ field: 'packingStatus',
+ title: '瑁呯鐘舵��',
+ width: 110,
+ cellRender: {
+ name: 'CellDict',
+ props: { type: DICT_TYPE.MES_PRO_WORK_ORDER_PACKING_STATUS },
+ },
+ },
+ {
field: 'clientName',
title: '瀹㈡埛鍚嶇О',
width: 120,
diff --git a/src/views/mes/qc/retentionsample/data.ts b/src/views/mes/qc/retentionsample/data.ts
new file mode 100644
index 0000000..9b67951
--- /dev/null
+++ b/src/views/mes/qc/retentionsample/data.ts
@@ -0,0 +1,371 @@
+import type { PageParam } from '@vben/request';
+
+import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+import type { MesProWorkOrderApi } from '#/api/mes/pro/workorder';
+import type { MesQcRetentionSampleApi } from '#/api/mes/qc/retention-sample';
+
+import { markRaw } from 'vue';
+
+import dayjs from 'dayjs';
+
+import { message } from 'ant-design-vue';
+
+import { getSaleOrder, getSaleOrderPage } from '#/api/erp/sale/order';
+import { getMpsPage } from '#/api/mes/pro/mps';
+import { getSimpleUserList } from '#/api/system/user';
+import { getDateRangePickerDefaultProps } from '#/utils';
+import { ErpSaleOrderSelect } from '#/views/erp/sale/order/components';
+import { MdItemSelect } from '#/views/mes/md/item/components';
+import { ProWorkOrderSelect } from '#/views/mes/pro/workorder/components';
+
+/** 鐣欐牱淇濆瓨鏃堕暱锛堟湀锛夛紝涓庡悗绔粯璁ゅ�间繚鎸佷竴鑷� */
+const RETENTION_MONTHS = 6;
+
+/** 鏍¢獙閿�鍞鍗曟槸鍚︾湡瀹炲瓨鍦紝杩斿洖瀛樺湪鐨勮鍗曠紪鍙� */
+async function resolveExistingSaleOrderId(id: number) {
+ const saleOrder = await getSaleOrder(id);
+ return saleOrder?.id;
+}
+
+/** 閫夋嫨宸ュ崟鍚庡甫鍑轰骇鍝併�佹壒娆′笌閿�鍞鍗� */
+async function handleWorkOrderChange(
+ item: MesProWorkOrderApi.WorkOrder | undefined,
+ formApi?: VbenFormApi,
+) {
+ if (!formApi) {
+ return;
+ }
+ await formApi.setFieldValue('productName', item?.productName ?? undefined);
+ await formApi.setFieldValue('batchCode', item?.batchCode ?? undefined);
+ let saleOrderId: number | undefined;
+ // 1. 瀹㈡埛璁㈠崟鏉ユ簮宸ュ崟锛氭寜鏉ユ簮鍗曞彿鑷姩鍖归厤閿�鍞鍗�
+ if (item?.orderSourceType === 1 && item.orderSourceCode) {
+ const params: PageParam & { no?: string } = {
+ no: item.orderSourceCode,
+ pageNo: 1,
+ pageSize: 1,
+ };
+ const page = await getSaleOrderPage(params);
+ saleOrderId = page.list?.[0]?.id;
+ }
+ // 2. MPS 涓嬪彂宸ュ崟锛氫互 MPS 璁板綍鐨勯攢鍞鍗曚负鍑嗭紙鍚堝苟涓嬪彂鍙兘瀵瑰簲澶氬紶锛�
+ if (item?.id) {
+ try {
+ const page = await getMpsPage({
+ pageNo: 1,
+ pageSize: 20,
+ workOrderId: item.id,
+ });
+ const mpsSaleOrders = new Map<number, string>();
+ for (const mps of page.list ?? []) {
+ if (mps.saleOrderId) {
+ mpsSaleOrders.set(
+ mps.saleOrderId,
+ mps.saleOrderNo || `ID=${mps.saleOrderId}`,
+ );
+ }
+ }
+ if (mpsSaleOrders.size === 1) {
+ const firstMpsSaleOrder = [...mpsSaleOrders.entries()][0];
+ if (firstMpsSaleOrder) {
+ const [mpsSaleOrderId, mpsSaleOrderNo] = firstMpsSaleOrder;
+ const existingId = await resolveExistingSaleOrderId(mpsSaleOrderId);
+ if (existingId) {
+ saleOrderId = existingId;
+ } else {
+ saleOrderId = undefined;
+ message.warning(
+ `璇ュ伐鍗曠敱 MPS 涓嬪彂锛屼絾 MPS 璁板綍鐨勯攢鍞鍗曘��${mpsSaleOrderNo}銆戯紙ID=${mpsSaleOrderId}锛夊湪绯荤粺涓笉瀛樺湪锛岃鍏堜慨姝� MPS 鏁版嵁鍚庡啀鐧昏鐣欐牱`,
+ );
+ }
+ }
+ } else if (mpsSaleOrders.size > 1) {
+ saleOrderId = undefined;
+ message.warning(
+ `璇ュ伐鍗曠敱 ${mpsSaleOrders.size} 寮犻攢鍞鍗曞悎骞朵笅鍙戯紝璇烽�夋嫨鏈鐣欐牱瀵瑰簲鐨勯攢鍞鍗昤,
+ );
+ }
+ } catch {
+ // MPS 鏌ヨ澶辫触锛堝鏃犳煡璇㈡潈闄愶級鏃朵笉闃绘柇宸ュ崟閫夋嫨锛屼繚瀛樻椂鐢卞悗绔厹搴曟牎楠�
+ }
+ }
+ await formApi.setFieldValue('saleOrderId', saleOrderId);
+}
+
+/** 鐣欐牱鏃ユ湡鍙樻洿鏃跺悓姝ュ埌鏈熸棩鏈� */
+function syncExpiryDate(value: string, formApi?: VbenFormApi) {
+ if (!formApi) {
+ return;
+ }
+ void formApi.setFieldValue(
+ 'expiryDate',
+ value ? dayjs(value).add(RETENTION_MONTHS, 'month').format('YYYY-MM-DD') : undefined,
+ );
+}
+
+/** 鏂板/淇敼鐨勮〃鍗� */
+export function useFormSchema(
+ formType: 'create' | 'update',
+ formApi?: VbenFormApi,
+): VbenFormSchema[] {
+ return [
+ {
+ fieldName: 'id',
+ component: 'Input',
+ dependencies: {
+ triggerFields: [''],
+ show: () => false,
+ },
+ },
+ {
+ fieldName: 'workOrderId',
+ label: '鐢熶骇宸ュ崟',
+ component: markRaw(ProWorkOrderSelect),
+ componentProps: {
+ disabled: formType === 'update',
+ excludeStatuses: [3],
+ placeholder: '璇烽�夋嫨鐢熶骇宸ュ崟',
+ onChange: (item: MesProWorkOrderApi.WorkOrder | undefined) =>
+ handleWorkOrderChange(item, formApi),
+ },
+ rules: 'selectRequired',
+ },
+ {
+ fieldName: 'productName',
+ label: '浜у搧鍚嶇О',
+ component: 'Input',
+ componentProps: {
+ disabled: true,
+ placeholder: '閫夋嫨宸ュ崟鍚庤嚜鍔ㄥ甫鍑�',
+ },
+ dependencies: {
+ triggerFields: ['workOrderId'],
+ show: (values) => !!values.workOrderId,
+ },
+ },
+ {
+ fieldName: 'batchCode',
+ label: '鐢熶骇鎵规鍙�',
+ component: 'Input',
+ componentProps: {
+ disabled: true,
+ placeholder: '閫夋嫨宸ュ崟鍚庤嚜鍔ㄥ甫鍑�',
+ },
+ dependencies: {
+ triggerFields: ['workOrderId'],
+ show: (values) => !!values.workOrderId,
+ },
+ },
+ {
+ fieldName: 'saleOrderId',
+ label: '閿�鍞鍗�',
+ component: markRaw(ErpSaleOrderSelect),
+ componentProps: {
+ placeholder: '搴撳瓨澶囪揣宸ュ崟鍙笉閫夛紱瀹㈡埛璁㈠崟宸ュ崟灏嗚嚜鍔ㄥ尮閰�',
+ },
+ },
+ {
+ fieldName: 'sampleQuantity',
+ label: '鐣欐牱鏁伴噺',
+ component: 'InputNumber',
+ componentProps: {
+ class: '!w-full',
+ min: 1,
+ placeholder: '璇疯緭鍏ョ暀鏍锋暟閲�',
+ precision: 0,
+ },
+ rules: 'required',
+ },
+ {
+ fieldName: 'sampleDate',
+ label: '鐣欐牱鏃ユ湡',
+ component: 'DatePicker',
+ componentProps: {
+ class: '!w-full',
+ format: 'YYYY-MM-DD',
+ placeholder: '璇烽�夋嫨鐣欐牱鏃ユ湡',
+ valueFormat: 'YYYY-MM-DD',
+ onChange: (value: string) => syncExpiryDate(value, formApi),
+ },
+ rules: 'required',
+ },
+ {
+ fieldName: 'expiryDate',
+ label: '鐣欐牱鍒版湡鏃ユ湡',
+ component: 'DatePicker',
+ componentProps: {
+ class: '!w-full',
+ disabled: true,
+ format: 'YYYY-MM-DD',
+ valueFormat: 'YYYY-MM-DD',
+ },
+ help: `鎸夌暀鏍锋棩鏈� + ${RETENTION_MONTHS} 涓湀鑷姩璁$畻`,
+ },
+ {
+ fieldName: 'keeperUserId',
+ label: '鐣欐牱浜�',
+ component: 'ApiSelect',
+ componentProps: {
+ allowClear: true,
+ api: getSimpleUserList,
+ labelField: 'nickname',
+ placeholder: '涓嶉�夊垯榛樿涓哄綋鍓嶇櫥褰曠敤鎴�',
+ showSearch: true,
+ optionFilterProp: 'label',
+ valueField: 'id',
+ },
+ },
+ {
+ fieldName: 'remark',
+ label: '澶囨敞',
+ component: 'Textarea',
+ formItemClass: 'col-span-2',
+ componentProps: {
+ placeholder: '璇疯緭鍏ュ娉�',
+ rows: 3,
+ },
+ },
+ ];
+}
+
+/** 鍒楄〃鐨勬悳绱㈣〃鍗� */
+export function useGridFormSchema(): VbenFormSchema[] {
+ return [
+ {
+ fieldName: 'code',
+ label: '鐣欐牱缂栧彿',
+ component: 'Input',
+ componentProps: {
+ allowClear: true,
+ placeholder: '璇疯緭鍏ョ暀鏍风紪鍙�',
+ },
+ },
+ {
+ fieldName: 'workOrderCode',
+ label: '鐢熶骇宸ュ崟缂栧彿',
+ component: 'Input',
+ componentProps: {
+ allowClear: true,
+ placeholder: '璇疯緭鍏ョ敓浜у伐鍗曠紪鍙�',
+ },
+ },
+ {
+ fieldName: 'saleOrderNo',
+ label: '閿�鍞鍗曞彿',
+ component: 'Input',
+ componentProps: {
+ allowClear: true,
+ placeholder: '璇疯緭鍏ラ攢鍞鍗曞彿',
+ },
+ },
+ {
+ fieldName: 'productId',
+ label: '浜у搧',
+ component: markRaw(MdItemSelect),
+ componentProps: {
+ placeholder: '璇烽�夋嫨浜у搧',
+ },
+ },
+ {
+ fieldName: 'batchCode',
+ label: '鐢熶骇鎵规鍙�',
+ component: 'Input',
+ componentProps: {
+ allowClear: true,
+ placeholder: '璇疯緭鍏ョ敓浜ф壒娆″彿',
+ },
+ },
+ {
+ fieldName: 'sampleDate',
+ label: '鐣欐牱鏃ユ湡',
+ component: 'RangePicker',
+ componentProps: {
+ ...getDateRangePickerDefaultProps(),
+ },
+ },
+ {
+ fieldName: 'expiryDate',
+ label: '鍒版湡鏃ユ湡',
+ component: 'RangePicker',
+ componentProps: {
+ ...getDateRangePickerDefaultProps(),
+ },
+ },
+ ];
+}
+
+/** 鍒楄〃鐨勫瓧娈� */
+export function useGridColumns(): VxeTableGridOptions<MesQcRetentionSampleApi.RetentionSample>['columns'] {
+ return [
+ {
+ field: 'code',
+ title: '鐣欐牱缂栧彿',
+ width: 160,
+ },
+ {
+ field: 'workOrderCode',
+ title: '鐢熶骇宸ュ崟缂栧彿',
+ width: 150,
+ },
+ {
+ field: 'saleOrderNo',
+ title: '閿�鍞鍗曞彿',
+ width: 150,
+ },
+ {
+ field: 'productCode',
+ title: '浜у搧缂栫爜',
+ width: 130,
+ },
+ {
+ field: 'productName',
+ title: '浜у搧鍚嶇О',
+ minWidth: 160,
+ },
+ {
+ field: 'batchCode',
+ title: '鐢熶骇鎵规鍙�',
+ width: 140,
+ },
+ {
+ field: 'sampleQuantity',
+ title: '鐣欐牱鏁伴噺',
+ width: 100,
+ },
+ {
+ field: 'sampleDate',
+ title: '鐣欐牱鏃ユ湡',
+ width: 120,
+ formatter: 'formatDate',
+ },
+ {
+ field: 'expiryDate',
+ title: '鍒版湡鏃ユ湡',
+ width: 120,
+ formatter: 'formatDate',
+ },
+ {
+ title: '鐣欐牱鐘舵��',
+ width: 100,
+ slots: { default: 'expiryStatus' },
+ },
+ {
+ field: 'keeperNickname',
+ title: '鐣欐牱浜�',
+ width: 100,
+ },
+ {
+ field: 'createTime',
+ title: '鍒涘缓鏃堕棿',
+ width: 180,
+ formatter: 'formatDate',
+ },
+ {
+ title: '鎿嶄綔',
+ width: 160,
+ fixed: 'right',
+ slots: { default: 'actions' },
+ },
+ ];
+}
diff --git a/src/views/mes/qc/retentionsample/index.vue b/src/views/mes/qc/retentionsample/index.vue
new file mode 100644
index 0000000..7a40884
--- /dev/null
+++ b/src/views/mes/qc/retentionsample/index.vue
@@ -0,0 +1,140 @@
+<script lang="ts" setup>
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+import type { MesQcRetentionSampleApi } from '#/api/mes/qc/retention-sample';
+
+import { Page, useVbenModal } from '@vben/common-ui';
+
+import { message, Tag } from 'ant-design-vue';
+import dayjs from 'dayjs';
+
+import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
+import {
+ deleteRetentionSample,
+ getRetentionSamplePage,
+} from '#/api/mes/qc/retention-sample';
+import { $t } from '#/locales';
+
+import { useGridColumns, useGridFormSchema } from './data';
+import Form from './modules/form.vue';
+
+defineOptions({ name: 'RetentionSampleIndex' });
+
+const [FormModal, formModalApi] = useVbenModal({
+ connectedComponent: Form,
+ destroyOnClose: true,
+});
+
+/** 鍒锋柊琛ㄦ牸 */
+function handleRefresh() {
+ gridApi.query();
+}
+
+/** 鍒涘缓 */
+function handleCreate() {
+ formModalApi.setData(null).open();
+}
+
+/** 缂栬緫 */
+function handleEdit(row: MesQcRetentionSampleApi.RetentionSample) {
+ formModalApi.setData(row).open();
+}
+
+/** 鍒犻櫎 */
+async function handleDelete(row: MesQcRetentionSampleApi.RetentionSample) {
+ const hideLoading = message.loading({
+ content: $t('ui.actionMessage.deleting', [row.code]),
+ duration: 0,
+ });
+ try {
+ await deleteRetentionSample(row.id!);
+ message.success($t('ui.actionMessage.deleteSuccess', [row.code]));
+ handleRefresh();
+ } finally {
+ hideLoading();
+ }
+}
+
+/** 鏄惁宸插埌鏈� */
+function isExpired(row: MesQcRetentionSampleApi.RetentionSample) {
+ return row.expiryDate ? dayjs(row.expiryDate).isBefore(dayjs(), 'day') : false;
+}
+
+const [Grid, gridApi] = useVbenVxeGrid({
+ formOptions: {
+ schema: useGridFormSchema(),
+ },
+ gridOptions: {
+ columns: useGridColumns(),
+ height: 'auto',
+ keepSource: true,
+ proxyConfig: {
+ ajax: {
+ query: async ({ page }, formValues) => {
+ return await getRetentionSamplePage({
+ pageNo: page.currentPage,
+ pageSize: page.pageSize,
+ ...formValues,
+ });
+ },
+ },
+ },
+ rowConfig: {
+ keyField: 'id',
+ isHover: true,
+ },
+ toolbarConfig: {
+ refresh: true,
+ search: true,
+ },
+ } as VxeTableGridOptions<MesQcRetentionSampleApi.RetentionSample>,
+});
+</script>
+
+<template>
+ <Page auto-content-height>
+ <FormModal @success="handleRefresh" />
+ <Grid table-title="鐣欐牱绠$悊">
+ <template #toolbar-tools>
+ <TableAction
+ :actions="[
+ {
+ label: $t('ui.actionTitle.create', ['鐣欐牱璁板綍']),
+ type: 'primary',
+ icon: ACTION_ICON.ADD,
+ auth: ['mes:qc-retention-sample:create'],
+ onClick: handleCreate,
+ },
+ ]"
+ />
+ </template>
+ <template #expiryStatus="{ row }">
+ <Tag v-if="isExpired(row)" color="red">宸插埌鏈�</Tag>
+ <Tag v-else color="green">鐣欐牱涓�</Tag>
+ </template>
+ <template #actions="{ row }">
+ <TableAction
+ :actions="[
+ {
+ label: $t('common.edit'),
+ type: 'link',
+ icon: ACTION_ICON.EDIT,
+ auth: ['mes:qc-retention-sample:update'],
+ onClick: handleEdit.bind(null, row),
+ },
+ {
+ label: $t('common.delete'),
+ type: 'link',
+ danger: true,
+ icon: ACTION_ICON.DELETE,
+ auth: ['mes:qc-retention-sample:delete'],
+ popConfirm: {
+ title: $t('ui.actionMessage.deleteConfirm', [row.code]),
+ confirm: handleDelete.bind(null, row),
+ },
+ },
+ ]"
+ />
+ </template>
+ </Grid>
+ </Page>
+</template>
diff --git a/src/views/mes/qc/retentionsample/modules/form.vue b/src/views/mes/qc/retentionsample/modules/form.vue
new file mode 100644
index 0000000..43fed70
--- /dev/null
+++ b/src/views/mes/qc/retentionsample/modules/form.vue
@@ -0,0 +1,97 @@
+<script lang="ts" setup>
+import type { MesQcRetentionSampleApi } from '#/api/mes/qc/retention-sample';
+
+import { computed, ref } from 'vue';
+
+import { useVbenModal } from '@vben/common-ui';
+
+import { message } from 'ant-design-vue';
+import dayjs from 'dayjs';
+
+import { useVbenForm } from '#/adapter/form';
+import {
+ createRetentionSample,
+ getRetentionSample,
+ updateRetentionSample,
+} from '#/api/mes/qc/retention-sample';
+import { $t } from '#/locales';
+
+import { useFormSchema } from '../data';
+
+defineOptions({ name: 'RetentionSampleForm' });
+
+const emit = defineEmits(['success']);
+const formData = ref<MesQcRetentionSampleApi.RetentionSample>();
+const getTitle = computed(() => {
+ return formData.value?.id
+ ? $t('ui.actionTitle.edit', ['鐣欐牱璁板綍'])
+ : $t('ui.actionTitle.create', ['鐣欐牱璁板綍']);
+});
+
+const [Form, formApi] = useVbenForm({
+ commonConfig: {
+ componentProps: {
+ class: 'w-full',
+ },
+ formItemClass: 'col-span-2',
+ labelWidth: 110,
+ },
+ layout: 'horizontal',
+ schema: [],
+ showDefaultActions: false,
+});
+
+const [Modal, modalApi] = useVbenModal({
+ async onConfirm() {
+ const { valid } = await formApi.validate();
+ if (!valid) {
+ return;
+ }
+ modalApi.lock();
+ const data =
+ (await formApi.getValues()) as MesQcRetentionSampleApi.RetentionSample;
+ try {
+ await (formData.value?.id
+ ? updateRetentionSample(data)
+ : createRetentionSample(data));
+ await modalApi.close();
+ emit('success');
+ message.success($t('ui.actionMessage.operationSuccess'));
+ } finally {
+ modalApi.unlock();
+ }
+ },
+ async onOpenChange(isOpen: boolean) {
+ if (!isOpen) {
+ formData.value = undefined;
+ return;
+ }
+ formData.value = undefined;
+ const data = modalApi.getData<MesQcRetentionSampleApi.RetentionSample>();
+ const isEdit = !!data?.id;
+ formApi.setState({ schema: useFormSchema(isEdit ? 'update' : 'create', formApi) });
+ await formApi.resetForm();
+ if (!isEdit) {
+ await formApi.setValues({
+ sampleDate: dayjs().format('YYYY-MM-DD'),
+ expiryDate: dayjs().add(6, 'month').format('YYYY-MM-DD'),
+ sampleQuantity: 2,
+ });
+ return;
+ }
+ modalApi.lock();
+ try {
+ formData.value = await getRetentionSample(data!.id!);
+ await formApi.setValues(formData.value);
+ } finally {
+ modalApi.unlock();
+ }
+ },
+});
+</script>
+
+<template>
+ <Modal :title="getTitle" class="w-3/5">
+ <Form class="mx-4" />
+ </Modal>
+</template>
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,
diff --git a/src/views/wls/packages/index.vue b/src/views/wls/packages/index.vue
index 6996fa8..ef0a124 100644
--- a/src/views/wls/packages/index.vue
+++ b/src/views/wls/packages/index.vue
@@ -137,7 +137,7 @@
type: 'link',
icon: ACTION_ICON.EDIT,
auth: ['mes:wm-package:update'],
- ifShow: row.status === MesWmPackageStatusEnum.PREPARE,
+ disabled: row.status !== MesWmPackageStatusEnum.PREPARE,
onClick: handleEdit.bind(null, row),
},
{
@@ -146,7 +146,7 @@
danger: true,
icon: ACTION_ICON.DELETE,
auth: ['mes:wm-package:delete'],
- ifShow: row.status === MesWmPackageStatusEnum.PREPARE,
+ disabled: row.status !== MesWmPackageStatusEnum.PREPARE,
popConfirm: {
title: $t('ui.actionMessage.deleteConfirm', [row.code]),
confirm: handleDelete.bind(null, row),
diff --git a/src/views/wls/packages/modules/line-form.vue b/src/views/wls/packages/modules/line-form.vue
index 93539ff..5411927 100644
--- a/src/views/wls/packages/modules/line-form.vue
+++ b/src/views/wls/packages/modules/line-form.vue
@@ -8,6 +8,7 @@
import { message } from 'ant-design-vue';
import { useVbenForm } from '#/adapter/form';
+import { getItem } from '#/api/mes/md/item';
import {
createPackageLine,
getPackageLine,
@@ -15,7 +16,7 @@
} from '#/api/mes/wm/packages/line';
import { $t } from '#/locales';
-import { useLineFormSchema } from '../data';
+import { refreshTailPreview, useLineFormSchema } from '../data';
const emit = defineEmits(['success']);
const formData = ref<MesWmPackageLineApi.PackageLine>();
@@ -35,7 +36,7 @@
labelWidth: 100,
},
layout: 'horizontal',
- schema: useLineFormSchema(),
+ schema: [],
showDefaultActions: false,
wrapperClass: 'grid-cols-2',
});
@@ -48,8 +49,14 @@
}
modalApi.lock();
// 鎻愪氦琛ㄥ崟
- const data = (await formApi.getValues()) as MesWmPackageLineApi.PackageLine;
+ const data = (await formApi.getValues()) as MesWmPackageLineApi.PackageLine & {
+ boxQuantity?: number;
+ tailPreview?: string;
+ };
data.packageId = packageId.value;
+ // 浠呯敤浜庨瑙堢殑瀛楁涓嶆彁浜�
+ delete data.boxQuantity;
+ delete data.tailPreview;
try {
await (formData.value?.id
? updatePackageLine({ ...data, id: formData.value.id })
@@ -70,6 +77,7 @@
// 鍔犺浇鏁版嵁
const data = modalApi.getData<{ id?: number; packageId: number }>();
packageId.value = data.packageId;
+ formApi.setState({ schema: useLineFormSchema(formApi) });
if (!data.id) {
return;
}
@@ -78,6 +86,14 @@
formData.value = await getPackageLine(data.id);
// 璁剧疆鍒� values
await formApi.setValues(formData.value);
+ // 甯﹀嚭姣忕鏁伴噺骞跺埛鏂板熬绠遍瑙�
+ if (formData.value.itemId) {
+ const item = await getItem(formData.value.itemId).catch(
+ () => undefined,
+ );
+ await formApi.setFieldValue('boxQuantity', item?.boxQuantity);
+ }
+ await refreshTailPreview(formApi);
} finally {
modalApi.unlock();
}
diff --git a/src/views/wls/packages/modules/package-line-list.vue b/src/views/wls/packages/modules/package-line-list.vue
index 14be505..ac977f1 100644
--- a/src/views/wls/packages/modules/package-line-list.vue
+++ b/src/views/wls/packages/modules/package-line-list.vue
@@ -103,6 +103,12 @@
]"
/>
</template>
+ <template #tailBoxQuantity="{ row }">
+ <span v-if="row.tailBoxQuantity !== undefined && row.tailBoxQuantity !== null">
+ {{ row.tailBoxQuantity }}{{ row.tailBoxFull ? '锛堟弧瑁咃級' : '' }}
+ </span>
+ <span v-else>鈥�</span>
+ </template>
<template #actions="{ row }">
<TableAction
:actions="[
@@ -110,7 +116,7 @@
label: $t('common.edit'),
type: 'link',
icon: ACTION_ICON.EDIT,
- ifShow: editable,
+ disabled: !editable,
onClick: handleEdit.bind(null, row),
},
{
@@ -118,7 +124,7 @@
type: 'link',
danger: true,
icon: ACTION_ICON.DELETE,
- ifShow: editable,
+ disabled: !editable,
popConfirm: {
title: $t('ui.actionMessage.deleteConfirm', [row.itemName]),
confirm: handleDelete.bind(null, row),
diff --git a/src/views/wls/packages/modules/sub-package-list.vue b/src/views/wls/packages/modules/sub-package-list.vue
index b35bc3d..f1c2452 100644
--- a/src/views/wls/packages/modules/sub-package-list.vue
+++ b/src/views/wls/packages/modules/sub-package-list.vue
@@ -112,7 +112,7 @@
type: 'link',
danger: true,
icon: ACTION_ICON.DELETE,
- ifShow: editable,
+ disabled: !editable,
popConfirm: {
title: '纭灏嗚瑁呯鍗曚粠瀛愮鍒楄〃涓Щ闄わ紵',
confirm: handleRemoveChild.bind(null, row),
diff --git a/src/views/wls/productsales/data.ts b/src/views/wls/productsales/data.ts
index 923946c..a4988a6 100644
--- a/src/views/wls/productsales/data.ts
+++ b/src/views/wls/productsales/data.ts
@@ -433,6 +433,11 @@
width: 100,
},
{
+ field: 'boxCount',
+ title: '绠辨暟',
+ width: 80,
+ },
+ {
field: 'batchCode',
title: '鎵规鍙�',
minWidth: 120,
diff --git a/src/views/wls/shipmentstatistics/data.ts b/src/views/wls/shipmentstatistics/data.ts
new file mode 100644
index 0000000..5e7c473
--- /dev/null
+++ b/src/views/wls/shipmentstatistics/data.ts
@@ -0,0 +1,110 @@
+import type { VbenFormSchema } from '#/adapter/form';
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+import type { MesWmProductSalesStatisticsApi } from '#/api/mes/wm/productsales/statistics';
+
+import { markRaw } from 'vue';
+
+import { getDateRangePickerDefaultProps } from '#/utils';
+import { MdClientSelect } from '#/views/mes/md/client/components';
+import { MdItemSelect } from '#/views/mes/md/item/components';
+
+/** 鍒楄〃鐨勬悳绱㈣〃鍗� */
+export function useGridFormSchema(): VbenFormSchema[] {
+ return [
+ {
+ fieldName: 'clientId',
+ label: '瀹㈡埛',
+ component: markRaw(MdClientSelect),
+ componentProps: {
+ placeholder: '璇烽�夋嫨瀹㈡埛',
+ },
+ },
+ {
+ fieldName: 'salesOrderCode',
+ label: '閿�鍞鍗曠紪鍙�',
+ component: 'Input',
+ componentProps: {
+ allowClear: true,
+ placeholder: '璇疯緭鍏ラ攢鍞鍗曠紪鍙�',
+ },
+ },
+ {
+ fieldName: 'itemId',
+ label: '浜у搧',
+ component: markRaw(MdItemSelect),
+ componentProps: {
+ placeholder: '璇烽�夋嫨浜у搧',
+ },
+ },
+ {
+ fieldName: 'shipmentDate',
+ label: '鍙戣揣鏃ユ湡',
+ component: 'RangePicker',
+ componentProps: {
+ ...getDateRangePickerDefaultProps(),
+ allowClear: true,
+ },
+ },
+ ];
+}
+
+/** 鍒楄〃鐨勫瓧娈� */
+export function useGridColumns(): VxeTableGridOptions<MesWmProductSalesStatisticsApi.Statistics>['columns'] {
+ return [
+ {
+ field: 'clientName',
+ title: '瀹㈡埛鍚嶇О',
+ minWidth: 140,
+ },
+ {
+ field: 'salesOrderCode',
+ title: '閿�鍞鍗曠紪鍙�',
+ minWidth: 160,
+ },
+ {
+ field: 'itemCode',
+ title: '浜у搧缂栫爜',
+ minWidth: 130,
+ },
+ {
+ field: 'itemName',
+ title: '浜у搧鍚嶇О',
+ minWidth: 160,
+ },
+ {
+ field: 'specification',
+ title: '瑙勬牸鍨嬪彿',
+ minWidth: 130,
+ },
+ {
+ field: 'unitMeasureName',
+ title: '鍗曚綅',
+ width: 90,
+ align: 'center',
+ },
+ {
+ field: 'totalQuantity',
+ title: '鍑哄簱鎬绘暟閲�',
+ width: 120,
+ align: 'right',
+ },
+ {
+ field: 'totalBoxCount',
+ title: '鎬荤鏁�',
+ width: 100,
+ align: 'right',
+ },
+ {
+ field: 'shipmentCount',
+ title: '鍙戣揣娆℃暟',
+ width: 100,
+ align: 'center',
+ },
+ {
+ field: 'lastShipmentDate',
+ title: '鏈�鍚庡彂璐ф椂闂�',
+ width: 180,
+ formatter: 'formatDate',
+ },
+ ];
+}
diff --git a/src/views/wls/shipmentstatistics/index.vue b/src/views/wls/shipmentstatistics/index.vue
new file mode 100644
index 0000000..3a4fb96
--- /dev/null
+++ b/src/views/wls/shipmentstatistics/index.vue
@@ -0,0 +1,52 @@
+<script lang="ts" setup>
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+import type { MesWmProductSalesStatisticsApi } from '#/api/mes/wm/productsales/statistics';
+
+import { Page } from '@vben/common-ui';
+
+import { useVbenVxeGrid } from '#/adapter/vxe-table';
+import { getProductSalesStatisticsPage } from '#/api/mes/wm/productsales/statistics';
+
+import { useGridColumns, useGridFormSchema } from './data';
+
+const [Grid] = useVbenVxeGrid({
+ formOptions: {
+ schema: useGridFormSchema(),
+ },
+ gridOptions: {
+ columns: useGridColumns(),
+ height: 'auto',
+ keepSource: true,
+ proxyConfig: {
+ ajax: {
+ query: async ({ page }, formValues) => {
+ const result = await getProductSalesStatisticsPage({
+ pageNo: page.currentPage,
+ pageSize: page.pageSize,
+ ...formValues,
+ });
+ result.list = result.list.map(row => ({
+ ...row,
+ id: `${row.clientId ?? ''}_${row.salesOrderCode ?? ''}_${row.itemId ?? ''}`,
+ }));
+ return result;
+ },
+ },
+ },
+ rowConfig: {
+ keyField: 'id',
+ isHover: true,
+ },
+ toolbarConfig: {
+ refresh: true,
+ search: true,
+ },
+ } as VxeTableGridOptions<MesWmProductSalesStatisticsApi.Statistics>,
+});
+</script>
+
+<template>
+ <Page auto-content-height>
+ <Grid table-title="鍙戣揣缁熻" />
+ </Page>
+</template>
--
Gitblit v1.9.3