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
| <template>
| <BasicDrawer
| v-bind="$attrs"
| @register="registerDrawer"
| showFooter
| :title="getTitle"
| width="800px"
| @ok="handleSubmit"
| >
| <BasicForm @register="registerForm" />
| </BasicDrawer>
| </template>
| <script lang="ts">
| import { defineComponent, ref, computed, unref } from 'vue';
| import { BasicForm, useForm } from '/@/components/Form/index';
| import { formSchema } from './smt_tool.data';
| import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
|
| import { getToolListByPage,SaveTool,DeleteTool } from '/@/api/tigerapi/mes/smt/tool';
|
| export default defineComponent({
| name: 'ToolDrawer',
| components: { BasicDrawer, BasicForm },
| emits: ['success', 'register'],
| setup(_, { emit }) {
| const isUpdate = ref(true);
| const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner((data) => {
| resetFields();
| setDrawerProps({ confirmLoading: false });
| isUpdate.value = !!data?.isUpdate;
| if (unref(isUpdate)) {
| setFieldsValue({
| ...data.record,
| });
| }
| });
| const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
| labelWidth: 120,
| schemas: formSchema,
| actionColOptions: {
| span: 24,
| },
| showActionButtonGroup: false,
| });
|
| const getTitle = computed(() => (!unref(isUpdate) ? '新增物料' : '编辑物料'));
|
| async function handleSubmit() {
| try {
| const values = await validate();
| setDrawerProps({ confirmLoading: true });
| // TODO custom api
| //保存物料
| const apiAction = SaveTool(values, unref(isUpdate),false);
| apiAction.then((action) => {
| if (action.IsSuccessed) {
| closeDrawer();
| emit('success');
| }
| });
| } finally {
| setDrawerProps({ confirmLoading: false });
| }
| }
|
| return {
| registerDrawer,
| registerForm,
| getTitle,
| handleSubmit,
| };
| },
| });
| </script>
|
|