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

网站开发客户对话北京百度竞价托管公司

网站开发客户对话,北京百度竞价托管公司,英文版网站建站要求,做一个公司网站多少钱目录 1. 代码实现2. 效果图3. 解决新增、删除、修改之后树节点不刷新问题。&#xff08;[参考文章](https://blog.csdn.net/weixin_41549971/article/details/135504471)&#xff09; 1. 代码实现 <template><div><!-- lazy 是否懒加载子节点数据 --><!-…

目录

  • 1. 代码实现
  • 2. 效果图
  • 3. 解决新增、删除、修改之后树节点不刷新问题。([参考文章](https://blog.csdn.net/weixin_41549971/article/details/135504471))

1. 代码实现

<template><div><!-- lazy 是否懒加载子节点数据 --><!-- load 加载子节点数据的函数,lazy 为 true 时生效,函数第二个参数包含了节点的层级信息 --><!-- :default-expand-all="defaultExpandAll" 是否默认展开所有行,当 Table 包含展开行存在或者为树形表格时有效  --><!-- expand-row-keys 可以通过该属性设置 Table 目前的展开行,需要设置 row-key 属性才能使用,该属性为展开行的 keys 数组。 --><!-- row-click 当某一行被点击时会触发该事件 --><!-- expand-change 当用户对某一行展开或者关闭的时候会触发该事件(展开行时,回调的第二个参数为 expandedRows;树形表格时第二参数为 expanded)	 --><el-table ref="tableRef" :data="deptList" row-key="deptId" :lazy="true" :load="load":tree-props="{ children: 'children', hasChildren: 'existSub' }" :expand-row-keys="expandRowKeys"@row-click="(row, column, e) => clickRowLoad(row, column, e)" @expand-change="handleExpandChange"><el-table-column prop="deptName" label="名称" min-width="260" /><el-table-column prop="orderNum" label="排序" /><el-table-column label="创建时间" align="center" prop="createTime" min-width="200"><template slot-scope="scope"><span>{{ (scope.row.createTime) }}</span></template></el-table-column><el-table-column label="操作" align="center" fixed="right" min-width="220"><template slot-scope="scope"><el-button size="mini" type="primary" @click.stop="clickHandle(scope.row)">查看</el-button></template></el-table-column></el-table></div>
</template><script>export default {name: "TablePage3",data() {return {// 模拟数据1deptList_01: [{"createTime": "2023-10-23 11:39:03","deptId": 2104,"deptName": "部门1","parentName": null,"parentId": 0,"orderNum": 0,"children": [],"existSub": true,},{"createTime": "2023-10-23 11:39:03","deptId": 2105,"deptName": "部门2","parentName": null,"parentId": 0,"orderNum": 1,"children": [],"existSub": true,},{"createTime": "2023-10-23 11:39:03","deptId": 2106,"deptName": "部门3","parentName": null,"parentId": 0,"orderNum": 2,"children": [],"existSub": false,}],// 模拟数据2deptList_02: [{"createTime": "2023-10-23 11:39:03","deptId": 21041,"deptName": "部门1-1","parentName": null,"parentId": 2104,"orderNum": 1,"children": [],"existSub": false,},{"createTime": "2023-10-23 11:39:03","deptId": 21042,"deptName": "部门1-2","parentName": null,"parentId": 2104,"orderNum": 1,"children": [],"existSub": false,},],// 模拟数据3deptList_03: [{"createTime": "2023-10-23 11:39:03","deptId": 21051,"deptName": "部门2-1","parentName": null,"parentId": 2105,"orderNum": 1,"children": [],"existSub": true,},],// 模拟数据4deptList_04: [{"createTime": "2023-10-23 11:39:03","deptId": 210511,"deptName": "部门2-1-1","parentName": null,"parentId": 21051,"orderNum": 1,"children": [],"existSub": false,},],// 部门表格树数据deptList: [],// 重新渲染表格状态refreshTable: true,//父级的IdparentId: '',expandRowKeys: [],};},mounted() {// 列表this.getList()},methods: {/** 查询列表 懒加载 */getList() {//根据实际项目调用接口// lazyList(this.queryParams).then(response => {//     console.log(response, 'response查询列表')//     this.deptList = response.data// }) // 模拟数据1this.deptList = this.deptList_01;this.deptList.forEach(item => {item.hasChildren = item.existSub})// 如果只是单纯的更新绑定的数据:是在重新加载时,清空对应ref下的这两个数据// this.$set(this.$refs["tableRef"].store.states, "lazyTreeNodeMap", {});// this.$set(this.$refs["tableRef"].store.states, "treeData", {});console.log(this.deptList, ' this.deptList')// ------------触发点击事件load------------------//一、-------默认展开了deptList的第一层所有数据的下级数据--------// 一、-------默认展开了deptList的第一层所有数据的下级数据(相当于自动点击了一次)--------this.openTreeHandle(this.deptList)//二、 展开所有行,(建议直接使用非懒加载,配置default-expand-all为true)},// 点击列表懒加载load(tree, treeNode, resolve) {console.log(tree, 'tree')// console.log(treeNode, 'treeNode')//根据实际项目调用接口,获取对应的下级数据// this.parentId = tree.deptId// lazyList(this.queryParams).then(res => {// console.log(res.data, 'res.data')// resolve(res.data)// })// 模拟数据2,模拟数据3, 模拟数据4let tempList = []if (tree.deptName == '部门1') {tempList = this.deptList_02} else if (tree.deptName == '部门2') {tempList = this.deptList_03} else if (tree.deptName == '部门2-1') {tempList = this.deptList_04}resolve(tempList)},// 一、-------根据接口得到deptList,根据实际需要获取需要展开的节点的id,也就是table绑定的row-key属性值(如deptId)--------openTreeHandle(deptList) {const deptId = deptList ? deptList.map(item => (item.deptId).toString()) : []// expandRowKeys 可以通过该属性设置 Table 目前的展开行,需要设置 row-key 属性才能使用,该属性为展开行的 keys 数组// 这个必须配置,只有配置了这个,getElementsByClassName才能获取到对应的数据els,下面click事件才会触发this.expandRowKeys = this.expandRowKeys.concat(deptId)console.log(this.expandRowKeys, ' this.expandRowKeys')const els = document.getElementsByClassName('el-table__expand-icon el-table__expand-icon--expanded')this.$nextTick(() => {console.log(els, 'els')console.log(els.length, 'els.length')if (els.length > 0) {for (let i = 0; i < els.length; i++) {els[i].click()}}})},// 展开改变触发函数,只展开一行handleExpandChange(row, expandedRows) {// console.log(row, 'row')// console.log(expandedRows, 'expandedRows')if (expandedRows.length > 1) {this.$refs.tableRef.toggleRowExpansion(expandedRows[0])}},//点击整行load (能够点击一行的任意位置都可以进行伸缩)clickRowLoad(r, c, e) {if (e.currentTarget && e.currentTarget.firstElementChild.firstElementChild.firstElementChild) {console.log(e.currentTarget, 'e.currentTarget')if (e.currentTarget.firstElementChild.firstElementChild.firstElementChild.tagName == 'DIV') {e.currentTarget.firstElementChild.firstElementChild.firstElementChild.click()} else {e.currentTarget.firstElementChild.firstElementChild.firstElementChild.nextElementSibling.click()}}},clickHandle(row) {console.log(row, '点击')},},
};
</script>

2. 效果图

在这里插入图片描述

3. 解决新增、删除、修改之后树节点不刷新问题。(参考文章)

http://www.hengruixuexiao.com/news/11142.html

相关文章:

  • 深圳龙华 网站建设百度seo关键词排名 s
  • 上海网站托管拉新工作室在哪里接项目
  • flash网站源文件seo引擎优化培训
  • 做PPT的网站canva百度认证服务平台
  • 网站对联广告百度权重
  • 兰州网站建设关键词排名的工具
  • 二七郑州网站建设网站的优化公司
  • 运城有做网站设计那个推广平台好用
  • wordpress怎么设置导航最新seo黑帽技术工具软件
  • 吉林做网站找谁网站seo优化方案
  • 怎么做 在线电影网站二级不死域名购买
  • 网站建设企业建站网络营销心得体会1000字
  • 免费咨询法律律师电话号码找索引擎seo
  • 企业网站排名好搜网
  • 如何建设一个国外网站求购买链接
  • 佛山网站优化流程营销和运营的区别是什么
  • 天津网站建设网络公司软件开发培训多少钱
  • 网站功能测试方法手机搜索引擎排行榜
  • 河南网站建设报价seo基础理论
  • 乐温州网站建设兰州网络推广
  • 建设网站项目的目的是什么惠州网站seo排名优化
  • 专业高端网站建设济南seo网站关键词排名
  • 北京架设网站seo范畴有哪些
  • 罗湖商城网站建设哪家服务周到中国网络营销公司
  • 网站设计大作业百度seo培训
  • 网络营销文案实例宁波seo推广费用
  • 外贸做平台好还是自己建网站好学历提升哪个教育机构好一些
  • dw做asp购物网站百度做网站需要多少钱
  • 无锡网站建设 app互联网营销案例分析
  • 无锡网站设计哪家公司好相关搜索优化软件