自定义操作按钮和预览表单
<template>
<div class="list-wraper previewForm">
<fm-making-form
ref="makingform"
style="height: 670px;"
>
<template slot="action">
<!-- 自定义操作区域插槽 -->
<el-button type="text" icon="el-icon-upload" @click="saveData">保存</el-button>
<!-- 预览 -->
<el-dialog v-drag @click="previewHide" title="预览" :visible.sync="previewVisible" :close-on-click-modal="false" width="50%" style="width:100%;">
<div class="demo-image__preview">
<fm-generate-form
:data="jsonData"
ref="generateForm"
@on-change="handleDataChange"
>
</fm-generate-form>
<templete slot="footer" class="dialog-footer" align="center">
<div>
<el-button @click="previewVisible = false">取 消</el-button>
<el-button type="primary" @click="previewVisible = false">确 定</el-button>
</div>
</templete>
</div>
</el-dialog>
</template>
</fm-making-form>
</div>
</template>
<script>
export default {
data () {
return {
previewVisible: false,
jsonData: {},// 渲染表单的JSON数据
editData: {},// 表单内部的值
remoteFuncs: {
// 远程方法
},
}
},
methods: {
saveData() {
this.$confirm('是否确定保存表单?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
// this.$refs.makingform.widgetForm 当前设计的form表单的json数据
// this.$refs.makingform.jsonCopyValue 当前设计的form表单的点击生成json后得到的数据
this.jsonData = this.$refs.makingform.widgetForm
this.previewVisible = true;// 保存后预览表单
console.log(this.$refs.generateForm)
}).catch(() => {
console.log('取消')
});
},
previewHide() {
this.previewVisible = false;
},
handleDataChange (field, value, data) {
console.log(field, value, data)
}
},
}
</script>
自定义操作按钮
自定义预览表单
后续可能会继续更新。。。