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

element树形控件编辑节点组装节点

需求功能:
编辑树节点,组装节点

在这里插入图片描述

<el-scrollbar class="scrollbar-wrapper"><el-tree :data="nodeList" ref="tree" :props="defaultProps" :expand-on-click-node="false"><template slot-scope="{ node, data }"><div class="custom-tree-node"><template v-if="node.label"><span>{{node.label}} <span v-if="node.level==4 && false" style="padding-left:30px"><el-checkbox v-model="data.isCommon" true-label="Y" false-label="N">是否常用分类</el-checkbox></span></span><span style="margin-left:20px"><el-button size="small" type="text" @click.stop="appendNode(node,data)":disabled='node.level==4'>新增</el-button><el-button size="small" type="text" @click.stop="editNode(node,data)">编辑</el-button><el-button size="small" type="text" @click.stop="removeNode(node,data)">删除</el-button></span></template><template v-else="!node.investFormCodeText"><el-row :gutter="20" style="width:80%"><el-col :span="3"><div class="">编号:</div></el-col><el-col :span="6"><el-input v-model="data.investFormCode" size="small" placeholder="请输入编号"></el-input></el-col><el-col :span="3"><div class="">描述:</div></el-col><el-col :span="12"><el-input v-model="data.investFormCodeDesc" size="small" placeholder="请输入描述"></el-input></el-col></el-row><span style="margin-left:20px"><el-button size="small" @click="handleCancel(node,data)">取消</el-button><el-button size="small" type="primary" @click.stop="addChild(node,data)":disabled='node.level==4'>保存</el-button></span></template></div></template></el-tree></el-scrollbar>
data () {return {nodeList: [],defaultProps: {children: 'childList',label: 'investFormCodeText'},deleteList: [],}}
appendNode (node, data) {//为 Tree 中的一个节点追加一个子节点this.$refs.tree.append({dictKey: "marketQuotationInvestForm",investFormCodeText: '',childList: []}, node)},editNode (node, data) {this.$set(data, "tempInvestFormCodeText", data.investFormCodeText);this.$set(data, "investFormCodeText", "");},removeNode (node, data) {const parent = node.parent;const childList = parent.data.childList || parent.data;const index = childList.findIndex(d => d === data);if (data.id) {this.$confirm('删除配置项将影响历史数据,请确认是否删除?', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {childList.splice(index, 1);this.deleteList.push({id: data.id});this.$message({type: 'success',message: '删除成功!'});}).catch(() => {this.$message({type: 'info',message: '已取消删除'});});}else {childList.splice(index, 1);}},
// 数据结构
"nodeList": [{"investFormCodeText": "TF01 -- 搜索广告","investFormCode": "TF01","childList": null,"id": 14,"investFormCodeDesc": "搜索广告","parentId": 0},{"investFormCodeText": "TF02 -- 开屏","investFormCode": "TF02","childList": [{"investFormCodeText": "A001 -- 抖音-开屏","investFormCode": "A001","childList": [{"investFormCodeText": "B001 -- 优选互动","investFormCode": "B001","childList": null,"id": 17,"investFormCodeDesc": "优选互动","parentId": 16},{"investFormCodeText": "B002 -- 优选点击","investFormCode": "B002","childList": null,"id": 18,"investFormCodeDesc": "优选点击","parentId": 16},{"investFormCodeText": "B003 -- 超级优选","investFormCode": "B003","childList": null,"id": 19,"investFormCodeDesc": "超级优选","parentId": 16}],"id": 16,"investFormCodeDesc": "抖音-开屏","parentId": 15},{"investFormCodeText": "A002 -- 头条-开屏","investFormCode": "A002","childList": [{"investFormCodeText": "B001 -- 优选互动","investFormCode": "B001","childList": null,"id": 21,"investFormCodeDesc": "优选互动","parentId": 20},{"investFormCodeText": "B002 -- 优选点击","childList": null,"id": 22,"investFormCodeDesc": "优选点击","parentId": 20}],"id": 20,"investFormCodeDesc": "头条-开屏","parentId": 15}],
http://www.lryc.cn/news/188882.html

相关文章:

  • 【算法-动态规划】斐波那契第 n 项
  • Linux系统运行级别详解,切换、配置和常见服务
  • 企业需要ERP系统的八大理由,最后一个尤其重要
  • Java-Atomic原子操作类详解及源码分析,Java原子操作类进阶,LongAdder源码分析
  • 算法通过村第十二关-字符串|黄金笔记|冲刺难题
  • 3ds Max渲染太慢?创意云“一键云渲染”提升3ds Max渲染体验
  • 记录一次公益SRC的常见的cookie注入漏洞(适合初学者)
  • [ACTF2020 新生赛]Exec1
  • DeepFace【部署 03】轻量级人脸识别和面部属性分析框架deepface在Linux环境下服务部署(conda虚拟环境+docker)
  • vuex的求和案例和mapstate,mapmutations,mapgetters
  • Docker 网络访问原理解密
  • 统信UOS离线安装nginx
  • 机器学习基础-手写数字识别
  • idea 插件推荐(持续更新)
  • 实现Promise所有核心功能和方法
  • 学习总结1
  • 使用 Apache Camel 和 Quarkus 的微服务(二)
  • pid-limit参数实验
  • jvm--执行引擎
  • day13|二叉树理论
  • php+html+js+ajax实现文件上传
  • 日期时间参数,格式配置(SpringBoot)
  • JAVA 泛型的定义以及使用
  • Day-08 基于 Docker安装 Nginx 镜像-负载均衡
  • 3、在 CentOS 8 系统上安装 PostgreSQL 15.4
  • sap 一次性供应商 供应商账户组 临时供应商 <转载>
  • 总结html5中常见的选择器
  • Java基础面试-JDK JRE JVM
  • OpenCV实现图像傅里叶变换
  • 快手新版本sig3参数算法还原