1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
| <script lang="ts" setup>
| import type { VbenFormSchema } from "#/adapter/form";
|
| import { markRaw } from "vue";
|
| import { useVbenModal } from "@vben/common-ui";
|
| import { message } from "ant-design-vue";
|
| import { useVbenForm } from "#/adapter/form";
| import { generateRawBagCodes } from "#/api/mes/pro/bagCode";
| import { MdmItemSelect } from "#/views/basicData/mdm/components";
|
| defineOptions({ name: "MesProBagCodeRawGenerateForm" });
|
| const emit = defineEmits(["success"]);
|
| const schema: VbenFormSchema[] = [
| {
| fieldName: "itemId",
| label: "品种",
| component: markRaw(MdmItemSelect),
| componentProps: {
| placeholder: "请选择品种(产品品种)",
| },
| rules: "selectRequired",
| },
| {
| fieldName: "count",
| label: "袋码数量",
| component: "InputNumber",
| componentProps: {
| class: "!w-full",
| min: 1,
| placeholder: "请输入需要生成的袋码数量",
| precision: 0,
| },
| rules: "required",
| },
| {
| fieldName: "remark",
| label: "备注",
| component: "Textarea",
| componentProps: {
| placeholder: "请输入备注",
| rows: 2,
| },
| },
| ];
|
| const [Form, formApi] = useVbenForm({
| commonConfig: {
| componentProps: {
| class: "w-full",
| },
| labelWidth: 100,
| },
| layout: "horizontal",
| schema,
| showDefaultActions: false,
| });
|
| const [Modal, modalApi] = useVbenModal({
| async onConfirm() {
| const { valid } = await formApi.validate();
| if (!valid) return;
| modalApi.lock();
| try {
| const values = await formApi.getValues();
| const result = await generateRawBagCodes({
| itemId: values.itemId,
| count: values.count,
| remark: values.remark,
| });
| message.success(`已成功生成 ${result.totalCount} 条原始袋码`);
| emit("success");
| await modalApi.close();
| } finally {
| modalApi.unlock();
| }
| },
| async onOpenChange(isOpen: boolean) {
| if (!isOpen) return;
| await formApi.setValues({
| itemId: undefined,
| count: undefined,
| remark: undefined,
| });
| },
| });
| </script>
|
| <template>
| <Modal title="生成原始袋码" class="w-2/5">
| <Form class="mx-4" />
| <div class="mx-4 mb-2 rounded bg-gray-50 px-3 py-2 text-sm text-gray-500">
| 原始袋码仅需选择品种并输入数量,不换算计量单位类型、不生成托盘;后续可正常录入批次或绑定托盘
| </div>
| </Modal>
| </template>
|
|