Files
maintenance_system/src/components/BuildCode/index.vue

62 lines
1.3 KiB
Vue
Raw Normal View History

<template>
<!-- 代码构建 -->
<div>
<v-form-designer
ref="buildRef"
class="build"
:designer-config="{ importJsonButton: true, exportJsonButton: true, exportCodeButton: true, generateSFCButton: true, formTemplates: true }"
>
<template v-if="showBtn" #customToolButtons>
<el-button link type="primary" icon="Select" @click="getJson">保存</el-button>
</template>
</v-form-designer>
</div>
</template>
2023-04-19 21:04:42 +08:00
<script setup lang="ts">
interface Props {
showBtn: boolean;
formJson: any;
}
const props = withDefaults(defineProps<Props>(), {
showBtn: true,
formJson: ''
});
2023-04-19 21:04:42 +08:00
const buildRef = ref();
const emits = defineEmits(['reJson', 'saveDesign']);
//获取表单json
const getJson = () => {
const formJson = JSON.stringify(buildRef.value.getFormJson());
const fieldJson = JSON.stringify(buildRef.value.getFieldWidgets());
2023-04-19 21:04:42 +08:00
let data = {
formJson,
fieldJson
};
emits('saveDesign', data);
};
2023-04-19 21:04:42 +08:00
onMounted(() => {
if (props.formJson) {
buildRef.value.setFormJson(props.formJson);
2023-04-19 21:04:42 +08:00
}
});
2023-04-19 21:04:42 +08:00
</script>
<style lang="scss">
.build {
margin: 0 !important;
overflow-y: auto !important;
& header.main-header {
display: none;
}
& .right-toolbar-con {
text-align: right !important;
}
}
</style>