当前位置: 首页 > news >正文

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>
http://www.lryc.cn/news/349029.html

相关文章:

  • Git 如何管理标签命令(tag)
  • 零样本身份保持:ID-Animator引领个性化视频生成技术新前沿
  • 在Go语言中,可以这样使用Json
  • React useEffect Hook: 理解和解决组件双重渲染问题
  • 【C语言】—— 动态内存管理
  • Oracle到PostgreSQL的不停机数据库迁移
  • OpenAI 发布新款大型语言模型 GPT-4o,带大家了解最新ChatGPT动态。
  • 网络编程套接字(一) 【简单的Udp网络程序】
  • 【CANoe】CAPL中生成报告常用的测试函数
  • WEB后端复习——MVC、SSM【含登录页面代码】
  • 灵卡科技HDMI音视频采集及H.264编码一体化采集卡—LCC260
  • 智能自助终端主板RK3288/RK3568在酒店前台自助机方案的应用,支持鸿蒙,支持免费定制
  • Visual Studio环境搭载
  • 添砖Java之路(其八)——继承,final关键字
  • 一篇详解Git版本控制工具
  • 谷歌邮箱2024最新注册教程
  • Spring事务深度解析
  • 机器学习周报第41周
  • gin框架学习笔记(三) ——路由请求与相关参数
  • HTML常用标签-多媒体标签(图片、音频、视频)
  • Flutter 中的 AnimatedIcon 小部件:全面指南
  • 0510Goods的Maven项目
  • 使用Pyramid、Mako和PyJade生成 HTML
  • 什么是Facebook付费广告营销?
  • 面对.halo勒索病毒,如何有效防范与应对?
  • JSON 转为json串后出现 “$ref“
  • Nachi那智不二越机器人维修技术合集
  • C++类与对象基础探秘系列(二)
  • MyBatis-Plus核心功能详解:条件构造器、自定义SQL与Service接口
  • 莆田市C++专项选拔第二轮题4