
<template>
<fc-designer ref="designer" :config="config" @save="handleSave" />
</template>
<script setup>
import { ref, nextTick, onMounted } from 'vue'
import { formCreate } from '@form-create/designer'
const designer = ref(null)
onMounted(() => {
const ruleJson = formCreate.toJson(
[
{
type: 'input',
field: 'Fv1fm9qur3drabc',
title: '输入框',
info: '',
$required: false,
_fc_id: 'id_Fx6mm9qur3dracc',
name: 'ref_Fpabm9qur3dradc',
display: true,
hidden: false,
_fc_drag_tag: 'input',
}
]
)
const optionsJson = formCreate.toJson({
form: {
inline: false,
hideRequiredAsterisk: false,
labelPosition: 'right',
size: 'default',
labelWidth: '125px'
},
resetBtn: {
show: false,
innerText: '重置'
},
submitBtn: {
show: true,
innerText: '提交'
}
}
)
nextTick(() => {
if (designer.value) {
designer.value.setRule(ruleJson)
designer.value.setOptions(optionsJson)
}
})
})
function handleSave({ rule, options }) {
console.log('表单保存成功', rule)
console.log('表单保存成功 options', options)
}
const config = {
showSaveBtn: true
}
</script>