From 91c82965b2d987452ca276e3a03b48c8dcda2ae9 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期三, 19 八月 2026 11:47:26 +0800
Subject: [PATCH] config(env): 更新生产环境配置和公司名称

---
 src/views/mes/pro/bagCode/index.vue |  273 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 273 insertions(+), 0 deletions(-)

diff --git a/src/views/mes/pro/bagCode/index.vue b/src/views/mes/pro/bagCode/index.vue
new file mode 100644
index 0000000..f4ffa22
--- /dev/null
+++ b/src/views/mes/pro/bagCode/index.vue
@@ -0,0 +1,273 @@
+<script lang="ts" setup>
+  import type { VxeTableGridOptions } from "#/adapter/vxe-table";
+  import type { MesProBagCodeApi } from "#/api/mes/pro/bagCode";
+
+  import { confirm, Page, useVbenModal } from "@vben/common-ui";
+  import { MesProBagCodeStatusEnum } from "@vben/constants";
+  import { downloadFileFromBlobPart } from "@vben/utils";
+
+  import { message } from "ant-design-vue";
+
+  import { ACTION_ICON, TableAction, useVbenVxeGrid } from "#/adapter/vxe-table";
+  import {
+    deleteBagCodesByUuid,
+    exportBagCodeExcel,
+    exportBagQr,
+    getBagCodePage,
+    unbindBagCodePallet,
+  } from "#/api/mes/pro/bagCode";
+  import { $t } from "#/locales";
+
+  import { useGridColumns, useGridFormSchema } from "./data";
+  import BindPalletModal from "./modules/bind-pallet.vue";
+  import GenerateModal from "./modules/generate-form.vue";
+  import QrTraceModal from "../components/qr-trace-modal.vue";
+
+  defineOptions({ name: "MesProBagCode" });
+
+  const [GenerateFormModal, generateFormModalApi] = useVbenModal({
+    connectedComponent: GenerateModal,
+    destroyOnClose: true,
+  });
+
+  const [BindPalletFormModal, bindPalletFormModalApi] = useVbenModal({
+    connectedComponent: BindPalletModal,
+    destroyOnClose: true,
+  });
+
+  const [QrTraceQueryModal, qrTraceQueryModalApi] = useVbenModal({
+    connectedComponent: QrTraceModal,
+    destroyOnClose: true,
+  });
+
+  /** 鍒锋柊琛ㄦ牸 */
+  function handleRefresh() {
+    gridApi.query();
+  }
+
+  /** 鐢熸垚鏁版嵁鍖� */
+  function handleGenerate() {
+    generateFormModalApi.open();
+  }
+
+  /** 鎵爜杩芥函 */
+  function handleTrace() {
+    qrTraceQueryModalApi.open();
+  }
+
+  /** 鏌ョ湅浜岀淮鐮侊紙琛屽唴棰勫~鐮佸�硷級 */
+  function handleViewQr(row: MesProBagCodeApi.BagCode) {
+    qrTraceQueryModalApi.setData({ code: row.code }).open();
+  }
+
+  /** 瀵煎嚭浜岀淮鐮� ZIP锛堟寜褰撳墠鏌ヨ鏉′欢鐨勭敓鎴愮粍/鎵规锛� */
+  async function handleExportQr() {
+    const values = await gridApi.formApi.getValues();
+    const params: { uuid?: string; batchId?: number } = {};
+    if (values.uuid) {
+      params.uuid = values.uuid;
+    }
+    if (values.batchId) {
+      params.batchId = values.batchId;
+    }
+    if (!params.uuid && !params.batchId) {
+      message.warning("璇峰厛鎸夌敓鎴愮粍鎴栨壒娆$瓫閫夊悗鍐嶅鍑轰簩缁寸爜");
+      return;
+    }
+    const data = await exportBagQr(params);
+    downloadFileFromBlobPart({ fileName: "琚嬬爜浜岀淮鐮�.zip", source: data });
+  }
+
+  /** 瀵煎嚭琚嬬爜 Excel锛堜氦浠樺嵃鍒凤級锛屽鍑哄悗琚嬬爜鐘舵�佸彉涓哄凡鍗板埛锛岄渶鍒锋柊鍒楄〃 */
+  async function handleExport() {
+    const data = await exportBagCodeExcel(await gridApi.formApi.getValues());
+    downloadFileFromBlobPart({ fileName: "琚嬬爜鏁版嵁鍖�.xls", source: data });
+    message.success("瀵煎嚭鎴愬姛锛屽鍑虹殑琚嬬爜宸叉爣璁颁负宸插嵃鍒�");
+    handleRefresh();
+  }
+
+  /** 鑾峰彇鍕鹃�夌殑琚嬬爜璁板綍 */
+  function getSelectedRecords(): MesProBagCodeApi.BagCode[] | undefined {
+    const records = gridApi.grid.getCheckboxRecords() as MesProBagCodeApi.BagCode[];
+    if (records.length === 0) {
+      message.warning("璇疯嚦灏戝嬀閫変竴鏉¤鐮佽褰�");
+      return undefined;
+    }
+    return records;
+  }
+
+  /** 鎵归噺缁戝畾鎵樼洏 */
+  function handleBindPallet() {
+    const records = getSelectedRecords();
+    if (!records) return;
+    const batchIds = new Set(records.map((record) => record.batchId));
+    if (batchIds.size > 1) {
+      message.warning("璇烽�夋嫨鍚屼竴鎵规涓嬬殑琚嬬爜杩涜缁戝畾");
+      return;
+    }
+    if (records.some((record) => record.palletId)) {
+      message.warning("鎵�閫夎鐮佷腑瀛樺湪宸茬粦瀹氭墭鐩樼殑璁板綍锛岃鍏堣В缁�");
+      return;
+    }
+    if (
+      records.some(
+        (record) => record.status === MesProBagCodeStatusEnum.CANCELED
+      )
+    ) {
+      message.warning("宸蹭綔搴熺殑琚嬬爜涓嶅厑璁哥粦瀹氭墭鐩�");
+      return;
+    }
+    const first = records[0]!;
+    bindPalletFormModalApi
+      .setData({
+        batchId: first.batchId,
+        batchCode: first.batchCode,
+        ids: records.map((record) => record.id!),
+      })
+      .open();
+  }
+
+  /** 鎵归噺瑙g粦鎵樼洏 */
+  async function handleUnbindPallet() {
+    const records = getSelectedRecords();
+    if (!records) return;
+    if (records.some((record) => !record.palletId)) {
+      message.warning("鎵�閫夎鐮佷腑瀛樺湪鏈粦瀹氭墭鐩樼殑璁板綍锛屾棤娉曡В缁�");
+      return;
+    }
+    const palletIds = new Set(records.map((record) => record.palletId));
+    if (palletIds.size > 1) {
+      message.warning("璇烽�夋嫨缁戝畾鍦ㄥ悓涓�鎵樼洏涓婄殑琚嬬爜杩涜瑙g粦");
+      return;
+    }
+    try {
+      await confirm(`纭瑙g粦鎵�閫� ${records.length} 鏉¤鐮佸悧锛焋);
+    } catch {
+      return;
+    }
+    await unbindBagCodePallet({
+      palletId: records[0]!.palletId!,
+      ids: records.map((record) => record.id!),
+    });
+    message.success($t("ui.actionMessage.operationSuccess"));
+    handleRefresh();
+  }
+
+  /** 鍒犻櫎琚嬬爜鐢熸垚缁勶紙鏁版嵁鍖咃級 */
+  async function handleDeleteGroup(row: MesProBagCodeApi.BagCode) {
+    await deleteBagCodesByUuid(row.uuid!);
+    message.success($t("ui.actionMessage.deleteSuccess", [row.uuid]));
+    handleRefresh();
+  }
+
+  const [Grid, gridApi] = useVbenVxeGrid({
+    formOptions: {
+      schema: useGridFormSchema(),
+    },
+    gridOptions: {
+      checkboxConfig: {
+        highlight: true,
+        reserve: true,
+      },
+      columns: useGridColumns(),
+      height: "auto",
+      keepSource: true,
+      proxyConfig: {
+        ajax: {
+          query: async ({ page }, formValues) => {
+            return await getBagCodePage({
+              pageNo: page.currentPage,
+              pageSize: page.pageSize,
+              ...formValues,
+            });
+          },
+        },
+      },
+      rowConfig: {
+        keyField: "id",
+        isHover: true,
+      },
+      showOverflow: true,
+      toolbarConfig: {
+        refresh: true,
+        search: true,
+      },
+    } as VxeTableGridOptions<MesProBagCodeApi.BagCode>,
+  });
+</script>
+
+<template>
+  <Page auto-content-height>
+    <GenerateFormModal @success="handleRefresh" />
+    <BindPalletFormModal @success="handleRefresh" />
+    <QrTraceQueryModal />
+    <Grid table-title="琚嬬爜鍒楄〃锛堜竴琚嬩竴鐮侊級">
+      <template #toolbar-tools>
+        <TableAction :actions="[
+            {
+              label: '鐢熸垚鏁版嵁鍖�',
+              type: 'primary',
+              icon: ACTION_ICON.ADD,
+              auth: ['mes:pro-bag-code:create'],
+              onClick: handleGenerate,
+            },
+            {
+              label: '缁戝畾鎵樼洏',
+              type: 'primary',
+              auth: ['mes:pro-bag-code:update'],
+              onClick: handleBindPallet,
+            },
+            {
+              label: '瑙g粦鎵樼洏',
+              auth: ['mes:pro-bag-code:update'],
+              onClick: handleUnbindPallet,
+            },
+            {
+              label: '鎵爜杩芥函',
+              icon: ACTION_ICON.SEARCH,
+              auth: ['mes:pro-bag-code:query'],
+              onClick: handleTrace,
+            },
+            {
+              label: '瀵煎嚭浜岀淮鐮�',
+              icon: ACTION_ICON.DOWNLOAD,
+              auth: ['mes:pro-bag-code:export'],
+              onClick: handleExportQr,
+            },
+            {
+              label: $t('ui.actionTitle.export'),
+              type: 'primary',
+              icon: ACTION_ICON.DOWNLOAD,
+              auth: ['mes:pro-bag-code:export'],
+              onClick: handleExport,
+            },
+          ]" />
+      </template>
+      <template #actions="{ row }">
+        <TableAction :actions="[
+            {
+              label: '鏌ョ湅浜岀淮鐮�',
+              type: 'link',
+              auth: ['mes:pro-bag-code:query'],
+              onClick: handleViewQr.bind(null, row),
+            },
+            {
+              label: $t('common.delete'),
+              type: 'link',
+              danger: true,
+              icon: ACTION_ICON.DELETE,
+              auth: ['mes:pro-bag-code:delete'],
+              ifShow:
+                row.status === MesProBagCodeStatusEnum.GENERATED &&
+                !row.palletId,
+              popConfirm: {
+                title:
+                  '鍒犻櫎灏嗙Щ闄よ琚嬬爜鎵�灞炵殑鏁翠釜鐢熸垚缁勶紙鏁版嵁鍖咃級锛岀‘璁ゅ垹闄ゅ悧锛�',
+                confirm: handleDeleteGroup.bind(null, row),
+              },
+            },
+          ]" />
+      </template>
+    </Grid>
+  </Page>
+</template>

--
Gitblit v1.9.3