From 08bb5d242135e2c1f0fc17d2b5f7ae548275a3a2 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期五, 28 八月 2026 17:15:33 +0800
Subject: [PATCH] feat(mes): 实现临时码预生成和补录功能
---
src/views/mes/pro/bagCode/index.vue | 126 ++++++++++++++++++++++++++++++++++++++++-
1 files changed, 122 insertions(+), 4 deletions(-)
diff --git a/src/views/mes/pro/bagCode/index.vue b/src/views/mes/pro/bagCode/index.vue
index f4ffa22..58621ab 100644
--- a/src/views/mes/pro/bagCode/index.vue
+++ b/src/views/mes/pro/bagCode/index.vue
@@ -6,7 +6,7 @@
import { MesProBagCodeStatusEnum } from "@vben/constants";
import { downloadFileFromBlobPart } from "@vben/utils";
- import { message } from "ant-design-vue";
+ import { message, Modal } from "ant-design-vue";
import { ACTION_ICON, TableAction, useVbenVxeGrid } from "#/adapter/vxe-table";
import {
@@ -14,13 +14,16 @@
exportBagCodeExcel,
exportBagQr,
getBagCodePage,
+ bindBagCodeBatch,
unbindBagCodePallet,
} from "#/api/mes/pro/bagCode";
import { $t } from "#/locales";
import { useGridColumns, useGridFormSchema } from "./data";
+ import BindBatchModal from "./modules/bind-batch.vue";
import BindPalletModal from "./modules/bind-pallet.vue";
import GenerateModal from "./modules/generate-form.vue";
+ import ReplaceModal from "./modules/replace-form.vue";
import QrTraceModal from "../components/qr-trace-modal.vue";
defineOptions({ name: "MesProBagCode" });
@@ -30,8 +33,18 @@
destroyOnClose: true,
});
+ const [BindBatchFormModal, bindBatchFormModalApi] = useVbenModal({
+ connectedComponent: BindBatchModal,
+ destroyOnClose: true,
+ });
+
const [BindPalletFormModal, bindPalletFormModalApi] = useVbenModal({
connectedComponent: BindPalletModal,
+ destroyOnClose: true,
+ });
+
+ const [ReplaceFormModal, replaceFormModalApi] = useVbenModal({
+ connectedComponent: ReplaceModal,
destroyOnClose: true,
});
@@ -48,6 +61,12 @@
/** 鐢熸垚鏁版嵁鍖� */
function handleGenerate() {
generateFormModalApi.open();
+ }
+
+ /** 鏇挎崲鎴愬姛鍚庡睍绀虹粨鏋滃苟鍒锋柊鍒楄〃 */
+ function handleReplaceSuccess(result: MesProBagCodeApi.ReplaceResult) {
+ showReplaceResult(result);
+ handleRefresh();
}
/** 鎵爜杩芥函 */
@@ -88,18 +107,103 @@
/** 鑾峰彇鍕鹃�夌殑琚嬬爜璁板綍 */
function getSelectedRecords(): MesProBagCodeApi.BagCode[] | undefined {
- const records = gridApi.grid.getCheckboxRecords() as MesProBagCodeApi.BagCode[];
- if (records.length === 0) {
+ const records = [
+ ...(gridApi.grid.getCheckboxReserveRecords?.() ?? []),
+ ...(gridApi.grid.getCheckboxRecords?.() ?? []),
+ ] as MesProBagCodeApi.BagCode[];
+ const uniqueRecords = [
+ ...new Map(records.map((record) => [record.id, record])).values(),
+ ];
+ if (uniqueRecords.length === 0) {
message.warning("璇疯嚦灏戝嬀閫変竴鏉¤鐮佽褰�");
return undefined;
}
- return records;
+ return uniqueRecords;
+ }
+
+ /** 灞曠ず鏇挎崲缁撴灉 */
+ function showReplaceResult(result: MesProBagCodeApi.ReplaceResult) {
+ const items = result.items ?? [];
+ const content = items.length
+ ? items
+ .map(
+ (item) =>
+ `${item.oldCode ?? "-"} 鈫� ${item.newCode ?? "-"}${
+ item.newPalletCode ? `锛堟墭鐩橈細${item.newPalletCode}锛塦 : ""
+ }`,
+ )
+ .join("\n")
+ : "鏇挎崲鏄庣粏鏆傛棤";
+ Modal.success({
+ title: "鐮存崯琚嬬爜鏇挎崲鎴愬姛",
+ content: `鎵规锛�${result.batchCode ?? "-"}\n鏇挎崲鏁伴噺锛�${
+ result.count ?? items.length
+ }\n${content}`,
+ centered: true,
+ });
+ }
+
+ /** 鎵归噺鏇挎崲鐮存崯琚嬬爜 */
+ async function handleReplace() {
+ const records = getSelectedRecords();
+ if (!records) return;
+ if (records.length > 200) {
+ message.warning("鍗曟鏈�澶氭浛鎹� 200 涓鐮�");
+ return;
+ }
+ const batchIds = new Set(records.map((record) => record.batchId));
+ if (batchIds.size > 1 || !records[0]?.batchId) {
+ message.warning("璇烽�夋嫨鍚屼竴鎵规涓嬬殑琚嬬爜杩涜鏇挎崲");
+ return;
+ }
+ if (
+ records.some(
+ (record) =>
+ record.status !== MesProBagCodeStatusEnum.GENERATED &&
+ record.status !== MesProBagCodeStatusEnum.PRINTED,
+ )
+ ) {
+ message.warning("浠呭凡鐢熸垚鎴栧凡瀵煎嚭鍗板埛鐨勮鐮佸厑璁告浛鎹�");
+ return;
+ }
+ if (records.some((record) => !record.id)) {
+ message.warning("鎵�閫夎鐮佺己灏戠紪鍙凤紝鏃犳硶鏇挎崲");
+ return;
+ }
+ try {
+ await confirm(`纭浣滃簾鎵�閫� ${records.length} 涓鐮佸苟鐢熸垚绛夐噺鏂扮爜鍚楋紵`);
+ } catch {
+ return;
+ }
+ const first = records[0]!;
+ replaceFormModalApi
+ .setData({
+ batchId: first.batchId!,
+ batchCode: first.batchCode,
+ ids: records.map((record) => record.id!),
+ })
+ .open();
+ }
+
+ /** 鎵归噺褰曞叆鐢熶骇鎵规 */
+ function handleBindBatch() {
+ const records = getSelectedRecords();
+ if (!records) return;
+ if (records.some((record) => record.status !== MesProBagCodeStatusEnum.GENERATED || record.batchId)) {
+ message.warning("璇烽�夋嫨鏈綍鍏ユ壒娆′笖鐘舵�佷负宸茬敓鎴愮殑琚嬬爜");
+ return;
+ }
+ bindBatchFormModalApi.setData({ ids: records.map((record) => record.id!) }).open();
}
/** 鎵归噺缁戝畾鎵樼洏 */
function handleBindPallet() {
const records = getSelectedRecords();
if (!records) return;
+ if (records.some((record) => !record.batchId)) {
+ message.warning("璇峰厛褰曞叆鐢熶骇鎵规锛屽啀缁戝畾鎵樼洏");
+ return;
+ }
const batchIds = new Set(records.map((record) => record.batchId));
if (batchIds.size > 1) {
message.warning("璇烽�夋嫨鍚屼竴鎵规涓嬬殑琚嬬爜杩涜缁戝畾");
@@ -199,7 +303,9 @@
<template>
<Page auto-content-height>
<GenerateFormModal @success="handleRefresh" />
+ <BindBatchFormModal @success="handleRefresh" />
<BindPalletFormModal @success="handleRefresh" />
+ <ReplaceFormModal @success="handleReplaceSuccess" />
<QrTraceQueryModal />
<Grid table-title="琚嬬爜鍒楄〃锛堜竴琚嬩竴鐮侊級">
<template #toolbar-tools>
@@ -212,12 +318,24 @@
onClick: handleGenerate,
},
{
+ label: '褰曞叆鎵规',
+ type: 'primary',
+ auth: ['mes:pro-bag-code:update'],
+ onClick: handleBindBatch,
+ },
+ {
label: '缁戝畾鎵樼洏',
type: 'primary',
auth: ['mes:pro-bag-code:update'],
onClick: handleBindPallet,
},
{
+ label: '鐮存崯鏇挎崲',
+ type: 'primary',
+ auth: ['mes:pro-bag-code:replace'],
+ onClick: handleReplace,
+ },
+ {
label: '瑙g粦鎵樼洏',
auth: ['mes:pro-bag-code:update'],
onClick: handleUnbindPallet,
--
Gitblit v1.9.3