<script lang="ts" setup>
|
import { ref } from 'vue';
|
|
import { MonacoEditor } from '@jnpf/ui';
|
import { BasicModal, useModalInner } from '@jnpf/ui/modal';
|
|
const emit = defineEmits(['register', 'change']);
|
const [registerModal, { closeModal }] = useModalInner(init);
|
const editorRef = ref(null);
|
const value = ref();
|
|
function init(data) {
|
value.value = JSON.stringify(data.value ? JSON.parse(data.value) : '', null, 2);
|
}
|
function handleSubmit() {
|
emit('change', value.value);
|
setTimeout(() => {
|
closeModal();
|
}, 200);
|
}
|
</script>
|
<template>
|
<BasicModal v-bind="$attrs" @register="registerModal" title="数据设置" @ok="handleSubmit" destroy-on-close class="json-modal">
|
<MonacoEditor ref="editorRef" v-model="value" class="json-editor" />
|
</BasicModal>
|
</template>
|