| | |
| | | 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: "生成袋数", |
| | |
| | | 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(); |
| | | } |