2 天以前 46624ce480a3c14da21f39cc4ad5f7eecea2bb1e
src/views/mes/pro/batch/modules/form.vue
@@ -1,5 +1,5 @@
<script lang="ts" setup>
  import type { FormType } from "../data";
  import type { FormType, PalletOption } from "../data";
  import type { VxeTableGridOptions } from "#/adapter/vxe-table";
  import type { MesProBatchApi } from "#/api/mes/pro/batch";
@@ -21,6 +21,7 @@
    getBatch,
    updateBatch,
  } from "#/api/mes/pro/batch";
  import { getUnboundPalletList } from "#/api/mes/pro/pallet";
  import { $t } from "#/locales";
  import { UserSelect } from "#/views/system/user/components";
@@ -206,7 +207,20 @@
      }
      const data = modalApi.getData<{ formType: FormType; id?: number }>();
      formType.value = data.formType;
      formApi.setState({ schema: useFormSchema(formType.value) });
      // 新增/补录/编辑态加载未绑定批次的托盘,供「绑定托盘」多选下拉使用
      let palletOptions: PalletOption[] = [];
      if (formType.value !== "detail") {
        const pallets = await getUnboundPalletList();
        palletOptions = pallets.map((pallet) => ({
          label: `${pallet.tempCode ?? `托盘${pallet.id}`}(已装 ${pallet.bagCount ?? 0} 袋)`,
          value: pallet.id as number,
        }));
      }
      formApi.setState({ schema: useFormSchema(formType.value, palletOptions) });
      if (formType.value !== "detail") {
        // 清空上次打开时勾选的托盘,避免残留值误触发「批次进入生产中」
        await formApi.setFieldValue("palletIds", undefined);
      }
      // 根据表单态切换人员子表列
      workerGridApi.setGridOptions({
        columns: isEditable.value