11 小时以前 08bb5d242135e2c1f0fc17d2b5f7ae548275a3a2
src/views/mes/pro/bagCode/modules/generate-form.vue
@@ -3,33 +3,18 @@
  import type { MesProBagCodeApi } from "#/api/mes/pro/bagCode";
  import { useVbenModal } from "@vben/common-ui";
  import { MesProBatchStatusEnum } from "@vben/constants";
  import { message } from "ant-design-vue";
  import { useVbenForm } from "#/adapter/form";
  import { generateBagCodes } from "#/api/mes/pro/bagCode";
  import { getBatchSimpleList } from "#/api/mes/pro/batch";
  defineOptions({ name: "MesProBagCodeGenerateForm" });
  const emit = defineEmits(["success"]);
  /** 构建表单(批次下拉选项由外部加载注入) */
  function buildSchema(batchOptions: { label: string; value: number }[]): VbenFormSchema[] {
  function buildSchema(): VbenFormSchema[] {
    return [
      {
        fieldName: "batchId",
        label: "生产批次",
        component: "Select",
        componentProps: {
          options: batchOptions,
          optionFilterProp: "label",
          placeholder: "请选择生产中的批次",
          showSearch: true,
        },
        rules: "selectRequired",
      },
      {
        fieldName: "count",
        label: "生成袋数",
@@ -86,17 +71,7 @@
      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) });
        await formApi.setState({ schema: buildSchema() });
      } finally {
        modalApi.unlock();
      }