vue+ant-design+formBuiler表单构建器——技能提升——form design——亲测有效

本文主要是介绍vue+ant-design+formBuiler表单构建器——技能提升——form design——亲测有效,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

最近看到后端同事在弄一个后台管理系统,额,前端真的是夹缝中生存啊,AI抢饭碗,后端也想干前端的活儿。。。

他用到了表单构建器,具体效果如下:
在这里插入图片描述
网上有很多适用于ElementUiant-designform design插件,下面介绍一套完整的适用于ant-design的使用方法

步骤1:form-builder组件封装

components中添加form-builder文件夹
文件夹内容如下:
在这里插入图片描述
稍后我会把整个文件夹压缩上传到资源中,有需要的可自行下载。

步骤2:在页面中使用

我这边是在个弹窗中使用的,所以需要在弹窗中引入

<template><a-modalwidth="100%":title="title":visible="visible":confirm-loading="confirmLoading":footer="null"@cancel="handleCancel"><div style="height: 600px;overflow-y:auto;"><FormBuilder v-model="data" :gateway="gateway" :userModel="{}" @getData="saveData" /></div></a-modal>
</template>

对应的script中的代码:

<script>
import FormBuilder from '@/components/form-builder/FormBuilder';
import { addProp, updateProp, getPropDetail } from '@/services/project/propTemplate';//这个是接口,具体得让后端同事处理了。
export default {components: {FormBuilder},data() {return {title: '新增属性',visible: false,confirmLoading: false,data: {propName: '',list: [],config: {}},gateway: this.$store.state.setting.gateway,//gateway: "http://192.168.16.100:9001",也是后端同事提供templateId: '',id: ''}},methods: {showModal(templateId, record) {this.templateId = templateId;if (record) {this.title = '编辑属性';this.id = record.id;this.getDetail();} else {this.title = '新增属性';this.id = '';this.data = {propName: '',list: [],config: {}}}this.visible = true;},getDetail() {getPropDetail({propertyTemplateId: this.templateId,templateId: this.id}).then(res => {this.data = {propName: res.data.name,list: res.data.templateFiled && JSON.parse(res.data.templateFiled),config: res.data.templateText && JSON.parse(res.data.templateText)}})},saveData(v) {this.visible = false;if (this.id) {updateProp({propertyTemplateId: this.templateId,templateId: this.id,//模板属性id}, {name: v.propName,templateText: JSON.stringify(v.config),templateFiled: JSON.stringify(v.data)}).then(res => {this.$message.success('保存成功');this.$emit('ok');})} else {addProp(this.templateId, {name: v.propName,templateText: JSON.stringify(v.config),templateFiled: JSON.stringify(v.data)}).then(res => {this.$message.success('保存成功');this.$emit('ok');})}},handleCancel() {this.visible = false;}}
}
</script>

步骤3:步骤2弹窗的使用

import PropEdit from './PropEdit';
export default {components: {PropEdit},
}

页面使用

<a-button type="primary" @click="$refs.propEdit.showModal(templateId)">新增</a-button>
<PropEdit ref="propEdit" @ok="getPropList"></PropEdit>

这篇关于vue+ant-design+formBuiler表单构建器——技能提升——form design——亲测有效的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/973191

相关文章

关于HTML的多媒体标签

代码示例如下: <!doctype html><html lang="en"><head><meta charset="UTF-8"><meta name="Generator" content="EditPlus?"><meta name="Author" content=""><meta name="Keywords" content=""><meta name="Descriptio

关于HTML的框架标签及内嵌框架

框架标签的代码示例如下: <!doctype html><html lang="en"><head><meta charset="UTF-8"><meta name="Generator" content="EditPlus?"><meta name="Author" content=""><meta name="Keywords" content=""><meta name="Desc

关于HTML的表格标签

代码示例如下: <!doctype html><html lang="en"><head><meta charset="UTF-8"><meta name="Generator" content="EditPlus?"><meta name="Author" content=""><meta name="Keywords" content=""><meta name="Descriptio

关于HTML的清单标签

代码示例如下: <!doctype html><html lang="en"><head><meta charset="UTF-8"><meta name="Generator" content="EditPlus?"><meta name="Author" content=""><meta name="Keywords" content=""><meta name="Descriptio

关于HTML的图片标签

代码示例如下: <!doctype html><html lang="en"><head><meta charset="UTF-8"><meta name="Generator" content="EditPlus?"><meta name="Author" content=""><meta name="Keywords" content=""><meta name="Descriptio

关于HTML的字体标签

代码示例如下: <!doctype html><html lang="en"><head><meta charset="UTF-8"><meta name="Generator" content="EditPlus?"><meta name="Author" content=""><meta name="Keywords" content=""><meta name="Descripti

关于HTML的排版标签

代码示例如下: <!doctype html><html lang="en"><head><meta charset="UTF-8"><meta name="Generator" content="EditPlus?"><meta name="Author" content=""><meta name="Keywords" content=""><meta name="Descriptio

Android测试系列之三 - 构建仪器单元测试

Android测试系列之一 - 测试分类(节选) Android测试系列之二 - 构建本地单元测试 Android测试系列之三 - 构建仪器单元测试 仪器单元测试,它是运行真机或者模拟器上进行测试,它有一个好处就是它们可以调用Android framework层的APIs以及 supporting APIs,比如:Android Testing Support Li

Jquery 实现表单提交按钮变灰,防止多次点击提交重复数据

表单提交时候我们应该控制提交按钮,不能点击多次进行数据的重复提交。要不然就会有冗余的重复的数据在系统中,造成系统出现数据垃圾。jQuery很简单的就可以实现对表单提交按钮控制,下面就是相关的例子和代码。 <form action="${pageContext.servletContext.contextPath}/XXX/###" method="post" id="messag