Commit a2bfd451f9c49294db3ebd75bdc5eac34e00dcb7
Merge branch 'fix/DEFECT-1478' into 'main_dev'
fix: 修改布尔类型没有缩放因子 See merge request yunteng/thingskit-front!792
Showing
2 changed files
with
28 additions
and
7 deletions
1 | <script lang="ts" setup> | 1 | <script lang="ts" setup> |
2 | import { Button } from 'ant-design-vue'; | 2 | import { Button } from 'ant-design-vue'; |
3 | - import { nextTick, ref, watch } from 'vue'; | 3 | + import { nextTick, ref, unref, watch } from 'vue'; |
4 | import { BasicForm, useForm } from '/@/components/Form'; | 4 | import { BasicForm, useForm } from '/@/components/Form'; |
5 | import { BasicModal } from '/@/components/Modal'; | 5 | import { BasicModal } from '/@/components/Modal'; |
6 | import { PlusCircleOutlined } from '@ant-design/icons-vue'; | 6 | import { PlusCircleOutlined } from '@ant-design/icons-vue'; |
7 | - import { formSchemas } from './config'; | 7 | + import { FormFieldsEnum, formSchemas } from './config'; |
8 | + import { DataTypeEnum } from '../StructForm/config'; | ||
8 | const show = ref(false); | 9 | const show = ref(false); |
9 | 10 | ||
10 | const props = withDefaults( | 11 | const props = withDefaults( |
11 | defineProps<{ | 12 | defineProps<{ |
12 | value?: object; | 13 | value?: object; |
13 | disabled?: boolean; | 14 | disabled?: boolean; |
15 | + dataType?: DataTypeEnum; | ||
14 | }>(), | 16 | }>(), |
15 | { | 17 | { |
16 | value: () => ({}), | 18 | value: () => ({}), |
17 | } | 19 | } |
18 | ); | 20 | ); |
19 | 21 | ||
22 | + const dataType = ref(props.dataType); //获取数据类型 | ||
23 | + | ||
20 | const emit = defineEmits(['update:value']); | 24 | const emit = defineEmits(['update:value']); |
21 | 25 | ||
22 | - const [registerForm, { setFieldsValue, getFieldsValue, setProps, validate, resetFields }] = | ||
23 | - useForm({ | ||
24 | - schemas: formSchemas, | ||
25 | - showActionButtonGroup: false, | ||
26 | - }); | 26 | + const [ |
27 | + registerForm, | ||
28 | + { setFieldsValue, getFieldsValue, setProps, validate, resetFields, updateSchema }, | ||
29 | + ] = useForm({ | ||
30 | + schemas: formSchemas, | ||
31 | + showActionButtonGroup: false, | ||
32 | + }); | ||
27 | 33 | ||
28 | const handleClick = async () => { | 34 | const handleClick = async () => { |
29 | show.value = true; | 35 | show.value = true; |
@@ -41,6 +47,16 @@ | @@ -41,6 +47,16 @@ | ||
41 | }; | 47 | }; |
42 | 48 | ||
43 | watch( | 49 | watch( |
50 | + () => props.dataType, | ||
51 | + (value) => { | ||
52 | + dataType.value = value; | ||
53 | + updateSchema([ | ||
54 | + { field: FormFieldsEnum.ZOOM_FACTOR, ifShow: unref(dataType) == 'BOOL' ? false : true }, | ||
55 | + ]); | ||
56 | + } | ||
57 | + ); | ||
58 | + | ||
59 | + watch( | ||
44 | () => props.value, | 60 | () => props.value, |
45 | (value) => { | 61 | (value) => { |
46 | setFieldsValue(value); | 62 | setFieldsValue(value); |
@@ -285,6 +285,11 @@ export const formSchemas = (hasStructForm: boolean, isTcp = false): FormSchema[] | @@ -285,6 +285,11 @@ export const formSchemas = (hasStructForm: boolean, isTcp = false): FormSchema[] | ||
285 | colProps: { | 285 | colProps: { |
286 | span: 16, | 286 | span: 16, |
287 | }, | 287 | }, |
288 | + componentProps: ({ formModel }) => { | ||
289 | + return { | ||
290 | + dataType: formModel[FormField.TYPE], | ||
291 | + }; | ||
292 | + }, | ||
288 | }, | 293 | }, |
289 | { | 294 | { |
290 | field: FormField.ACCESS_MODE, | 295 | field: FormField.ACCESS_MODE, |