index.vue
1.42 KB
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
<script lang="ts" setup>
import { Button } from 'ant-design-vue';
import { nextTick, ref, watch } from 'vue';
import { BasicForm, useForm } from '/@/components/Form';
import { BasicModal } from '/@/components/Modal';
const show = ref(false);
const props = withDefaults(
defineProps<{
value?: object;
disabled?: boolean;
}>(),
{
value: () => ({}),
}
);
const emit = defineEmits(['update:value']);
const [registerForm, { setFieldsValue, getFieldsValue, setProps }] = useForm({
schemas: [
{
field: 'registerAddress',
component: 'Input',
label: '寄存器地址',
componentProps: {
placeholder: '请输入寄存器地址',
},
},
],
showActionButtonGroup: false,
});
const handleClick = async () => {
show.value = true;
await nextTick();
setProps({ disabled: props.disabled });
setFieldsValue(props.value);
};
const handleSubmit = () => {
const value = getFieldsValue();
emit('update:value', value);
show.value = false;
};
watch(
() => props.value,
(value) => {
setFieldsValue(value);
}
);
</script>
<template>
<section>
<Button type="link" @click="handleClick">新增扩展描述</Button>
<BasicModal title="扩展描述" v-model:visible="show" @ok="handleSubmit">
<BasicForm @register="registerForm" />
</BasicModal>
</section>
</template>