VisualOptionsModal.vue
1.21 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
<script lang="ts" setup>
import { onMounted, ref, unref } from 'vue';
import { modeOne, modeTwo, modeThree, modeFour } from '../config/visualOptions';
import { useForm, BasicForm } from '/@/components/Form';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { ComponentInfo } from '/@/api/dataBoard/model';
const emit = defineEmits(['close']);
const recordId = ref('');
const [registerForm, method] = useForm({
schemas: modeTwo,
showActionButtonGroup: false,
labelWidth: 120,
baseColProps: {
span: 12,
},
});
const [register, { closeModal }] = useModalInner(
(data: { recordId: string; componentInfo: ComponentInfo }) => {
recordId.value = data.recordId;
method.setFieldsValue(data.componentInfo || {});
}
);
const handleGetValue = () => {
const value = method.getFieldsValue();
emit('close', unref(recordId), value);
};
const handleClose = () => {
handleGetValue();
closeModal();
};
</script>
<template>
<BasicModal
v-bind="$attrs"
destroy-on-close
@register="register"
@ok="handleClose"
title="选项"
width="60%"
>
<BasicForm @register="registerForm" />
</BasicModal>
</template>