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/pallet/modules/generate-form.vue |  125 +++++++++++++++--------------------------
 1 files changed, 47 insertions(+), 78 deletions(-)

diff --git a/src/views/mes/pro/pallet/modules/generate-form.vue b/src/views/mes/pro/pallet/modules/generate-form.vue
index c34f952..e094e17 100644
--- a/src/views/mes/pro/pallet/modules/generate-form.vue
+++ b/src/views/mes/pro/pallet/modules/generate-form.vue
@@ -1,69 +1,16 @@
 <script lang="ts" setup>
   import type { VbenFormSchema } from "#/adapter/form";
-  import type { MesProPalletApi } from "#/api/mes/pro/pallet";
 
   import { useVbenModal } from "@vben/common-ui";
-  import { MesProBatchStatusEnum } from "@vben/constants";
 
   import { message } from "ant-design-vue";
 
   import { useVbenForm } from "#/adapter/form";
-  import { getBatchSimpleList } from "#/api/mes/pro/batch";
-  import { batchCreatePallet } from "#/api/mes/pro/pallet";
+  import { preGeneratePallet } from "#/api/mes/pro/pallet";
 
   defineOptions({ name: "MesProPalletGenerateForm" });
 
   const emit = defineEmits(["success"]);
-
-  /** 鏋勫缓琛ㄥ崟锛堟壒娆′笅鎷夐�夐」鐢卞閮ㄥ姞杞芥敞鍏ワ級 */
-  function buildSchema(batchOptions: { label: string; value: number }[]): VbenFormSchema[] {
-    return [
-      {
-        fieldName: "batchId",
-        label: "鐢熶骇鎵规",
-        component: "Select",
-        componentProps: {
-          options: batchOptions,
-          optionFilterProp: "label",
-          placeholder: "璇烽�夋嫨鐢熶骇涓殑鎵规",
-          showSearch: true,
-        },
-        rules: "selectRequired",
-      },
-      {
-        fieldName: "count",
-        label: "鐢熸垚鏁伴噺",
-        component: "InputNumber",
-        componentProps: {
-          class: "!w-full",
-          min: 1,
-          placeholder: "璇疯緭鍏ラ渶瑕佺敓鎴愮殑鎵樼洏鏁伴噺",
-          precision: 0,
-        },
-        rules: "required",
-      },
-      {
-        fieldName: "capacity",
-        label: "鍙琚嬫暟",
-        component: "InputNumber",
-        componentProps: {
-          class: "!w-full",
-          min: 1,
-          placeholder: "璇疯緭鍏ユ瘡鎵樼洏鍙琚嬫暟锛堣/鎵樼洏锛�",
-          precision: 0,
-        },
-      },
-      {
-        fieldName: "remark",
-        label: "澶囨敞",
-        component: "Textarea",
-        componentProps: {
-          placeholder: "璇疯緭鍏ュ娉�",
-          rows: 2,
-        },
-      },
-    ];
-  }
 
   const [Form, formApi] = useVbenForm({
     commonConfig: {
@@ -83,40 +30,62 @@
       if (!valid) return;
       modalApi.lock();
       try {
-        const values =
-          (await formApi.getValues()) as MesProPalletApi.BatchCreateParams;
-        const ids = await batchCreatePallet(values);
-        message.success(`宸叉垚鍔熺敓鎴� ${ids.length} 涓墭鐩樼爜`);
-        emit("success");
+        const values = await formApi.getValues();
+        const result = await preGeneratePallet({
+          count: values.count,
+          capacity: values.capacity,
+          remark: values.remark,
+        });
+        message.success(`宸茬敓鎴� ${result.length} 涓复鏃舵墭鐩樼爜`);
+        emit("success", result);
         await modalApi.close();
       } finally {
         modalApi.unlock();
       }
     },
-    async onOpenChange(isOpen: boolean) {
+    onOpenChange(isOpen: boolean) {
       if (!isOpen) return;
-      modalApi.lock();
-      try {
-        // 浠呯敓浜т腑鐨勬壒娆″厑璁哥敓鎴愭墭鐩樼爜
-        const batches = await getBatchSimpleList();
-        const options = batches
-          .filter(
-            (batch) => batch.status === MesProBatchStatusEnum.PRODUCING
-          )
-          .map((batch) => ({
-            label: batch.code!,
-            value: batch.id!,
-          }));
-        await formApi.setState({ schema: buildSchema(options) });
-      } finally {
-        modalApi.unlock();
-      }
+      const schema: VbenFormSchema[] = [
+        {
+          fieldName: "count",
+          label: "鐢熸垚鏁伴噺",
+          component: "InputNumber",
+          componentProps: {
+            class: "!w-full",
+            min: 1,
+            placeholder: "璇疯緭鍏ラ渶瑕佺敓鎴愮殑鎵樼洏鏁伴噺",
+            precision: 0,
+          },
+          rules: "required",
+        },
+        {
+          fieldName: "capacity",
+          label: "鍙琚嬫暟",
+          component: "InputNumber",
+          componentProps: {
+            class: "!w-full",
+            min: 1,
+            placeholder: "璇疯緭鍏ユ瘡鎵樼洏鍙琚嬫暟锛堣/鎵樼洏锛�",
+            precision: 0,
+          },
+        },
+        {
+          fieldName: "remark",
+          label: "澶囨敞",
+          component: "Textarea",
+          componentProps: {
+            placeholder: "璇疯緭鍏ュ娉�",
+            rows: 2,
+          },
+        },
+      ];
+      formApi.setState({ schema });
     },
   });
 </script>
 
 <template>
-  <Modal title="鎵归噺鐢熸垚鎵樼洏鐮�" class="w-2/5">
+  <Modal title="棰勭敓鎴愭墭鐩樹簩缁寸爜" class="w-2/5">
     <Form class="mx-4" />
   </Modal>
-</template>
+</template>
\ No newline at end of file

--
Gitblit v1.9.3