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 | 1 | <script lang="ts" setup> |
| 2 | 2 | import { Button } from 'ant-design-vue'; |
| 3 | - import { nextTick, ref, watch } from 'vue'; | |
| 3 | + import { nextTick, ref, unref, watch } from 'vue'; | |
| 4 | 4 | import { BasicForm, useForm } from '/@/components/Form'; |
| 5 | 5 | import { BasicModal } from '/@/components/Modal'; |
| 6 | 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 | 9 | const show = ref(false); |
| 9 | 10 | |
| 10 | 11 | const props = withDefaults( |
| 11 | 12 | defineProps<{ |
| 12 | 13 | value?: object; |
| 13 | 14 | disabled?: boolean; |
| 15 | + dataType?: DataTypeEnum; | |
| 14 | 16 | }>(), |
| 15 | 17 | { |
| 16 | 18 | value: () => ({}), |
| 17 | 19 | } |
| 18 | 20 | ); |
| 19 | 21 | |
| 22 | + const dataType = ref(props.dataType); //获取数据类型 | |
| 23 | + | |
| 20 | 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 | 34 | const handleClick = async () => { |
| 29 | 35 | show.value = true; |
| ... | ... | @@ -41,6 +47,16 @@ |
| 41 | 47 | }; |
| 42 | 48 | |
| 43 | 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 | 60 | () => props.value, |
| 45 | 61 | (value) => { |
| 46 | 62 | setFieldsValue(value); | ... | ... |
| ... | ... | @@ -285,6 +285,11 @@ export const formSchemas = (hasStructForm: boolean, isTcp = false): FormSchema[] |
| 285 | 285 | colProps: { |
| 286 | 286 | span: 16, |
| 287 | 287 | }, |
| 288 | + componentProps: ({ formModel }) => { | |
| 289 | + return { | |
| 290 | + dataType: formModel[FormField.TYPE], | |
| 291 | + }; | |
| 292 | + }, | |
| 288 | 293 | }, |
| 289 | 294 | { |
| 290 | 295 | field: FormField.ACCESS_MODE, | ... | ... |