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
| <script lang="ts" setup>
| import { ref } from 'vue';
|
| import { useVbenModal } from '@vben/common-ui';
|
| import { message } from 'ant-design-vue';
|
| import { useVbenForm } from '#/adapter/form';
| import { inspectPurchaseIn } from '#/api/erp/purchase/in';
| import { $t } from '#/locales';
|
| const emit = defineEmits(['success']);
| const purchaseInId = ref<number>();
|
| const [Form, formApi] = useVbenForm({
| commonConfig: {
| componentProps: {
| class: 'w-full',
| },
| labelWidth: 100,
| },
| wrapperClass: 'grid-cols-1',
| layout: 'horizontal',
| schema: [
| {
| fieldName: 'inspectionStatus',
| label: '验收状态',
| component: 'RadioGroup',
| componentProps: {
| options: [
| { label: '验收合格', value: 1 },
| { label: '验收不合格', value: 2 },
| ],
| buttonStyle: 'solid',
| optionType: 'button',
| },
| rules: 'required',
| },
| {
| fieldName: 'inspectionResult',
| label: '验收结果',
| component: 'Textarea',
| componentProps: {
| placeholder: '请输入验收结果',
| rows: 3,
| },
| },
| ],
| showDefaultActions: false,
| });
|
| const [Modal, modalApi] = useVbenModal({
| async onConfirm() {
| const { valid } = await formApi.validate();
| if (!valid) {
| return;
| }
| if (!purchaseInId.value) {
| message.error('入库单ID不存在');
| return;
| }
| modalApi.lock();
| const data = await formApi.getValues();
| try {
| await inspectPurchaseIn({
| id: purchaseInId.value,
| inspectionStatus: data.inspectionStatus,
| inspectionResult: data.inspectionResult,
| });
| await modalApi.close();
| emit('success');
| message.success('验收成功');
| } finally {
| modalApi.unlock();
| }
| },
| async onOpenChange(isOpen: boolean) {
| if (!isOpen) {
| purchaseInId.value = undefined;
| await formApi.resetForm();
| return;
| }
| const data = modalApi.getData<{ id: number }>();
| if (!data || !data.id) {
| return;
| }
| purchaseInId.value = data.id;
| // 默认选择验收合格
| await formApi.setValues({ inspectionStatus: 1 });
| },
| });
| </script>
|
| <template>
| <Modal title="采购入库验收" class="w-1/3">
| <Form class="mx-4" />
| </Modal>
| </template>
|
|