Showing
1 changed file
with
5 additions
and
6 deletions
... | ... | @@ -30,7 +30,7 @@ |
30 | 30 | import { ref, computed } from 'vue'; |
31 | 31 | import { useDrawerInner, BasicDrawer } from '/@/components/Drawer/index'; |
32 | 32 | import { useForm, BasicForm } from '/@/components/Form/index'; |
33 | - import { formSchema } from '../config/config.data.ts'; | |
33 | + import { formSchema } from '../config/config.data'; | |
34 | 34 | import { Card, Tag } from 'ant-design-vue'; |
35 | 35 | import { createOrEditTransformScriptApi } from '/@/api/device/TransformScriptApi'; |
36 | 36 | import { useMessage } from '/@/hooks/web/useMessage'; |
... | ... | @@ -53,7 +53,7 @@ |
53 | 53 | setFieldsValue(data.record); |
54 | 54 | } |
55 | 55 | }); |
56 | - const [registerForm, { getFieldsValue, setFieldsValue, resetFields }] = useForm({ | |
56 | + const [registerForm, { validate, setFieldsValue, resetFields }] = useForm({ | |
57 | 57 | showActionButtonGroup: false, |
58 | 58 | colProps: { span: 24 }, |
59 | 59 | schemas: formSchema, |
... | ... | @@ -84,9 +84,10 @@ |
84 | 84 | emit('isStatus', { status: 1, jsCode }); |
85 | 85 | }; |
86 | 86 | const handleSubmit = async () => { |
87 | - setDrawerProps({ confirmLoading: true }); | |
88 | - const fieldsValue = getFieldsValue(); | |
89 | 87 | try { |
88 | + setDrawerProps({ confirmLoading: true }); | |
89 | + const fieldsValue = await validate(); | |
90 | + if (!fieldsValue) return; | |
90 | 91 | await createOrEditTransformScriptApi({ |
91 | 92 | configuration: { |
92 | 93 | jsScript: aceEditor.value.getValue(), |
... | ... | @@ -99,8 +100,6 @@ |
99 | 100 | const { createMessage } = useMessage(); |
100 | 101 | createMessage.success('保存成功'); |
101 | 102 | } catch (e) { |
102 | - const { createMessage } = useMessage(); | |
103 | - createMessage.success('保存失败'); | |
104 | 103 | } finally { |
105 | 104 | setTimeout(() => { |
106 | 105 | setDrawerProps({ confirmLoading: false }); | ... | ... |