VisualOptionsModal.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
<script lang="ts" setup>
import { ref, unref } from 'vue';
import { WidgetComponentType, schemasMap } from '../config/visualOptions';
import { useForm, BasicForm } from '/@/components/Form';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { ComponentInfo } from '/@/api/dataBoard/model';
import { computed } from '@vue/reactivity';
const emit = defineEmits(['close']);
const props = defineProps<{
value?: string;
}>();
const recordId = ref('');
const getSchemas = computed(() => {
return schemasMap.get((props.value as WidgetComponentType) || 'text-component-1');
});
const [registerForm, method] = useForm({
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" :schemas="getSchemas" />
</BasicModal>
</template>