el-table树结构的搜索---递归遍历

71 篇文章 3 订阅
订阅专栏

表格树结构搜索

点击可查看 ➡ element ui 树形表格过滤查询数据解决( 可直接套用 )

效果图

在这里插入图片描述
在这里插入图片描述

标题

在这里插入图片描述

 <el-table ref="tableData" :data="tableData" :height="tableheight" default-expand-all row-key="sysResourcesId" :tree-props="{children: 'children', hasChildren: 'hasChildren'}" style="width:100%;margin:0 auto 5px;font-size:0.8rem" v-loading="loading" highlight-current-row>
            <el-table-column show-overflow-tooltip min-width="100" prop="sortNum" label="排序号" align="left"></el-table-column>
            <el-table-column show-overflow-tooltip prop="resourcesCode" label="编码" align="left" min-width="100">
              <!--  -->
              <template #header v-if="headerItem.seach">
                <el-popover v-if="headerItem.seachSetting.type==='Input'" placement="bottom" trigger="click" width="200" v-model="headerItem.visible">
                  <el-input autofocus clearable @clear="clearSearch(headerItem)" style="width: 200px" size="small" v-model="headerItem.seachSetting.value" :placeholder="'请输入'+headerItem.label" @keyup.enter.native="todoSearchItself(headerItem)" />
                  <el-button size="small" style="margin-top: 10px;float: left;width: 47%" @click="clearSearchItself(headerItem)">重 置</el-button>
                  <el-button size="small" type="primary" style="margin-top: 10px;float: right;width: 47%" @click="todoSearchItself(headerItem)">搜 索</el-button>
                  <div style="display: flex;align-items: center" slot="reference">
                    <span class="search-title">{{ headerItem.label }}</span>
                    <img style="width: 13px;margin-left: 10px;cursor: pointer" :src="headerItem.seachSetting.value&&headerItem.seachSetting.value!==''?img2:img1" />
                  </div>
                </el-popover>
              </template>
              <!--  -->
              <template slot-scope="scope">
                <span>{{scope.row.resourcesCode}}</span>
              </template>
            </el-table-column>
            <!-- <el-table-column show-overflow-tooltip prop="resourcesCode" label="编码" align="left" min-width="100">
              <template slot-scope="scope">
                <span>{{scope.row.resourcesCode}}</span>
              </template>
            </el-table-column> -->
            .......
methods:{
	// 自身的按钮搜索点击、重置清除操作
    todoSearchItself (headerItem) {
      headerItem.visible = false
      if (headerItem.seachSetting.type === 'Input') {
        this.seachFormItself[headerItem.seachSetting.rename && headerItem.seachSetting.rename !== '' ? headerItem.seachSetting.rename : headerItem.prop] = headerItem.seachSetting.value
      }
      this.todoSearch(this.seachFormItself)
    },
    clearSearchItself (headerItem) {
      if (headerItem.seachSetting && headerItem.seachSetting.type) {
        headerItem.visible = false
        if (headerItem.seachSetting.type === 'Input') {
          headerItem.seachSetting.value = ''
          this.seachFormItself[headerItem.seachSetting.rename && headerItem.seachSetting.rename !== '' ? headerItem.seachSetting.rename : headerItem.prop] = ''
        }
        this.clearSearch(this.seachFormItself)
      }
    },
    // 触发的方法-操作
    clearSearch (val) {
      console.log('清空--clearSearch', val)
      this.pageNum = 1
      this.pageSize = 10
      this.seachForm = val
      this.computedTableData()
    },
    todoSearch (val) {
      console.log('val---todoSearch', val)
      this.pageNum = 1
      this.pageSize = 10
      this.seachForm = val
      this.computedTableData()
    },
    // 根据搜索条件模糊查询-计算tableData
    computedTableData () {
      console.log('查询', this.seachForm)
      /* resourcesCode  resourcesName */
      console.log('表格', this.tableData)
      const tableCopyData = JSON.parse(JSON.stringify(this.copyTableData))
      if (this.seachForm.resourcesCode && this.seachForm.resourcesName) {
        const array = this.handleTreeData(tableCopyData, this.seachForm.resourcesCode, 'resourcesCode')
        const arrayFinally = this.handleTreeData(array, this.seachForm.resourcesName, 'resourcesName')
        this.tableData = arrayFinally
      } else if (this.seachForm.resourcesCode && !this.seachForm.resourcesName) {
        const array = this.handleTreeData(tableCopyData, this.seachForm.resourcesCode, 'resourcesCode')
        this.tableData = array
      } else if (!this.seachForm.resourcesCode && this.seachForm.resourcesName) {
        const arrayFinally = this.handleTreeData(tableCopyData, this.seachForm.resourcesName, 'resourcesName')
        this.tableData = arrayFinally
      } else {
        this.tableData = tableCopyData
      }
      /* if (this.seachForm.resourcesCode && this.seachForm.resourcesName) {
        const array = this.recursiveFilter(tableCopyData, this.seachForm.resourcesCode, 'resourcesCode')
        const arrayFinally = this.recursiveFilter(array, this.seachForm.resourcesName, 'resourcesName')
        this.tableData = arrayFinally
      } else if (this.seachForm.resourcesCode && !this.seachForm.resourcesName) {
        const array = this.recursiveFilter(tableCopyData, this.seachForm.resourcesCode, 'resourcesCode')
        this.tableData = array
      } else if (!this.seachForm.resourcesCode && this.seachForm.resourcesName) {
        const arrayFinally = this.recursiveFilter(tableCopyData, this.seachForm.resourcesName, 'resourcesName')
        this.tableData = arrayFinally
      } else {
        this.tableData = tableCopyData
      } */
      // console.log('array', array)
    },
    //  树形表格过滤
    handleTreeData (treeData, searchValue, keyName) {
      if (!treeData || treeData.length === 0) {
        return []
      }
      const array = []
      for (let i = 0; i < treeData.length; i += 1) {
        let match = false
        for (const pro in treeData[i]) {
          if (pro === keyName) {
            match |= treeData[i][pro].includes(searchValue)
            if (match) break
          }
          /* if (typeof (treeData[i][pro]) === 'string') {
            match |= treeData[i][pro].includes(searchValue)
            if (match) break
          } */
        }
        if (this.handleTreeData(treeData[i].children, searchValue, keyName).length > 0 || match) {
          array.push({
            ...treeData[i],
            children: this.handleTreeData(treeData[i].children, searchValue, keyName)
          })
        }
      }
      return array
    },
    /* recursiveFilter (arr, type, keyName) {
      console.log('arr-type', arr, type)
      const that = this
      const data = arr.filter(item => {
        return item[keyName].indexOf(type) !== -1
      }).map((item) => {
        item = Object.assign({}, item)
        if (item.children) {
          // 递归循环
          item.children = that.recursiveFilter(item.children, type, keyName)
        }
        return item
      })
      return data
    }, */
}

【vue el-table 树状结构查询功能】
weixin_49207685的博客
03-10 600
table 列表
el-table 树形数据的过滤
qq_52209816的博客
01-22 505
/ 如果节点是数组,则对每个元素应用过滤逻辑。// 检查当前节点的值是否包含任何过滤值。filterValues是一个数组,包含过滤的要素。树形数据的过滤:返回包含所需的要素以及其父节点。这里可以根据你需要的条件进行修改。
一篇文章说明白el-table的树形数据和懒加载,编辑,删除的局部更新
最新发布
weixin_58572700的博客
05-04 601
此时的这个row就会有parentId,我们只要拿到parentId我们就可以从我们存储的Map中拿到load的参数,从而重新加载load函数。大体的逻辑就是我们在更新懒加载的table时,我们只需要更新load这个函数就可以了,这就是叫局部更新,而且也不会刷新页面,用户体验较好.row-key : 这个尤为关键,当我们懒加载时所绑定的row-keys绝对不能重复,如果后端出现重复的情况,那就需要我们前端进行生成。编辑的话,大家的业务不一样,涉及组件的传值,大家自行书写即可,我这边说一下删除的。
el-tabel 树状表格前端实现模糊搜索功能
weixin_45952434的博客
10-07 1355
<template> <div class="m-page"> <el-form class="m-card" :model="queryParams" ref="queryForm" :inline="true" label-width="68px" style="height:62px"> <el-form-i
elementUI 表格树使用 tableTree
weixin_43678533的博客
12-23 7344
elementUI 表格树使用 tableTree效果图一、load懒加载方式1.页面2.load方法二、使用el-table-tree-column标签1.页面2.接口返回数据结构三、注意 效果图 一、load懒加载方式 1.页面 代码如下(示例): <el-table :data="tableData" style="width: 100%;margin-bottom: 20px;" :header-cell-style="{background:'rgba(250,250
element ui 树形表格按多条件查询(前端处理)
weixin_44274094的博客
08-05 2447
边输入边查询,实现多条件查询树形表格。
Java递归遍历树形结构
09-02
主要介绍了Java递归遍历树形结构的相关资料,需要的朋友可以参考下
模糊匹配--递归遍历文件
08-22
boost库的regex正则表达式实现文件递归模糊匹配搜索
数据结构-非递归遍历二叉树
11-16
数据结构非递归先序、中序、后序遍历二叉树,数据结构非递归先序、中序、后序遍历二叉树
vue路由 遍历生成复数router-link的例子
10-16
今天小编就为大家分享一篇vue路由 遍历生成复数router-link的例子,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
Objective-C实现二叉树遍历算法(源代码)
04-30
遍历方法也使用递归的方式访问节点,并按照相应的顺序(中序、前序、后序)输出节点的值。最后,在main函数中创建了一个二叉树实例,并测试了插入节点和遍历方法的功能。通过这段代码,读者可以了解如何在Objective-...
el-table树形结构的数据结构处理
weixin_43550562的博客
05-14 5307
效果: 后台返回的数据结构 递归成树形数据结构处理 getList() { this.loading = true const query = Object.assign({}, this.listQuery) for (const key in query) { if (!query[key]) { delete query[key] } } this.comApiUrl.fetch
vue + elementui el-table表头 树形筛选 功能实现
Yang_Xingxing_的博客
09-07 1352
效果图 代码 <template> <el-popover placement="bottom" width="200" trigger="manual" v-model="visible" popper-class="organ-header-popover" > <el-tree :data="data" :props="defaultProps" node-key="value"
遍历树结构,当节点的children为空时,递归处理children设为undefined(递归)(整理)
在北风吹起的时候加入我们的队伍 在秋雨到来的时候成为彼此的温暖
05-10 2331
遍历树结构,当节点的children为空时,递归处理children设为undefined(递归)效果demo
纯前端实现搜索el-table表格数据
weixin_62462734的博客
04-18 1593
2.点击搜索按钮,在进行筛选之前,要先将筛选出的值组成的数组清空,以免出现重复点击搜索事件后,筛选的数据重复添加在表格中的问题。1.先对tabledata里面的数据进行深拷贝,防止搜索过滤之后更改了tabledata里面原本的数据。监听搜索框输入的内容,当内容为空时,把深拷贝的数据重新赋值给tabledata。根据输入框输入的值来对table表格进行筛选
el-table组件实现表头搜索
weixin_45723246的博客
12-11 1753
el-table实现在表头搜索数据,并解决点击搜索图标,搜索区域消失的问题
el-table 表头自定义动态树形筛选
chen_ai_tao的博客
12-12 2060
el-table 表头自定义动态树形筛选
ElementUI Tree懒加载的搜索功能, 主要看思路吧 【已解决】
风不知从何处起的小屋
07-09 4125
我这里的解决办法需要额外的后端接口,目前我总共额外需要了两个。 我这里就以组织人员管理为例进行列举,现在A组织下存在组织B和C,然后再B和C组织下存在若干的人员信息,每一层级之间通过懒加载进行渲染,可以通过搜索功能根据人员姓名进行搜索。 思路: 首先需要根据人的名称在后端查出人员的信息(最重要的是组织id)可以根据组织id去查找人员所在的组织node,然后判断当前展开的tree中是否存在这个结点 this.refs.tree.getNode(orgId),若存在直接this.refs.tree.getN
Vue3用el-table写树状表格遇到的问题(搜索时:行样式变更 以及 对应父节点展开)
weixin_50245419的博客
11-01 703
el-table写树状表格时要求实现:搜索时,行样式变更 以及 对应父节点展开
el-table 树形不展示
07-08
对于 el-table 的树形展示,您可能需要确保以下几点: 1. 确保您的数据源中具有树形结构的字段。通常,树形结构的字段应该包含父节点和子节点的关联信息。 2. 在 el-table 的列配置中,使用 scoped slot 来自定义树...

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
写文章

热门文章

  • vue -elementUI 输入框el-input 聚焦/失焦 7569
  • JS-button标签说明 6887
  • vue+elementUI el-table 点击表格的某一单元格变成输入框el-input 6267
  • element-ui upload组件(点击上传文件后 给弹框来确认是否继续) 6168
  • 摩天轮-position+animation 5578

分类专栏

  • vue+element+echarts+map 71篇
  • git 8篇
  • js 110篇
  • Vue 31篇
  • node.js 28篇
  • demo 15篇
  • 三-框架类 83篇
  • 快捷简便的插件 2篇
  • 移动端 7篇
  • 前端后端 45篇
  • 一些软件 1篇
  • reactjs 31篇
  • 前端后端demo 33篇
  • sass 4篇
  • gulp 8篇
  • jQuery 49篇
  • Ajax 12篇
  • html、css 35篇
  • cookie 3篇
  • php 5篇
  • 数据库 9篇

最新评论

  • element-ui el-upload框去除‘按 delete 键可删除’提示

    王志晗: 用这个就可以 ::v-deep .el-upload-list__item .el-icon--close-tip { display: none !important; }

  • JS-正则表达式进行文本的搜索替换重置demo

    m0_64642431: 坚持 到感动自己

  • JS-正则表达式进行文本的搜索替换重置demo

    jiubani: 拼搏 到无能为力

  • vue+elementUI el-table 点击表格的某一单元格变成输入框el-input

    咩有猫腻.: 哇 谢谢表情包

  • vue+elementUI el-table 点击表格的某一单元格变成输入框el-input

    来自上海的这位朋友: 自动获取焦点还可以这样的 [code=html] <el-input :id="'editInput'+scope.row.index"</el-input> cellClick(row, column, cell, event) { console.log('cellClick',row, column, cell, event) if (row.column.label === '还款金额') { this.tabClickIndex = row.index this.isInputBlur = true this.$nextTick(() => { let editInput = document.getElementById('editInput'+row.index); editInput.focus(); }) } else { this.tabClickIndex = null this.isInputBlur = false } }, [/code]

您愿意向朋友推荐“博客详情页”吗?

  • 强烈不推荐
  • 不推荐
  • 一般般
  • 推荐
  • 强烈推荐
提交

最新文章

  • dg-table+el-table【表格+分页】---css自适应高度+滚动条(拓展calc()函数)
  • px转vw----等比放大、缩小
  • 移动端适配问题:rem / px2rem+scss
2021年64篇
2020年398篇

目录

目录

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值

深圳SEO优化公司大庆网站推广方案公司邯郸建网站价格眉山至尊标王推荐潍坊网站优化按天收费公司光明营销网站哪家好九江seo排名报价阳泉百度竞价价格鹤岗百度关键词包年推广哪家好醴陵网站关键词优化哪家好银川网站优化按天扣费公司长春营销型网站建设报价淮南SEO按天收费价格孝感百度关键词包年推广公司厦门营销型网站建设推荐海南seo优化盘锦推广网站多少钱咸阳百度关键词包年推广价格宿州关键词按天扣费公司贵港seo网站推广哪家好楚雄百姓网标王推广亳州关键词按天扣费报价吴忠seo多少钱舟山关键词排名报价自贡百姓网标王推广推荐潮州SEO按天收费哪家好垦利推广网站聊城百度关键词包年推广报价郑州百度竞价包年推广大芬英文网站建设多少钱济源百度关键词包年推广公司歼20紧急升空逼退外机英媒称团队夜以继日筹划王妃复出草木蔓发 春山在望成都发生巨响 当地回应60岁老人炒菠菜未焯水致肾病恶化男子涉嫌走私被判11年却一天牢没坐劳斯莱斯右转逼停直行车网传落水者说“没让你救”系谣言广东通报13岁男孩性侵女童不予立案贵州小伙回应在美国卖三蹦子火了淀粉肠小王子日销售额涨超10倍有个姐真把千机伞做出来了近3万元金手镯仅含足金十克呼北高速交通事故已致14人死亡杨洋拄拐现身医院国产伟哥去年销售近13亿男子给前妻转账 现任妻子起诉要回新基金只募集到26元还是员工自购男孩疑遭霸凌 家长讨说法被踢出群充个话费竟沦为间接洗钱工具新的一天从800个哈欠开始单亲妈妈陷入热恋 14岁儿子报警#春分立蛋大挑战#中国投资客涌入日本东京买房两大学生合买彩票中奖一人不认账新加坡主帅:唯一目标击败中国队月嫂回应掌掴婴儿是在赶虫子19岁小伙救下5人后溺亡 多方发声清明节放假3天调休1天张家界的山上“长”满了韩国人?开封王婆为何火了主播靠辱骂母亲走红被批捕封号代拍被何赛飞拿着魔杖追着打阿根廷将发行1万与2万面值的纸币库克现身上海为江西彩礼“减负”的“试婚人”因自嘲式简历走红的教授更新简介殡仪馆花卉高于市场价3倍还重复用网友称在豆瓣酱里吃出老鼠头315晚会后胖东来又人满为患了网友建议重庆地铁不准乘客携带菜筐特朗普谈“凯特王妃P图照”罗斯否认插足凯特王妃婚姻青海通报栏杆断裂小学生跌落住进ICU恒大被罚41.75亿到底怎么缴湖南一县政协主席疑涉刑案被控制茶百道就改标签日期致歉王树国3次鞠躬告别西交大师生张立群任西安交通大学校长杨倩无缘巴黎奥运

深圳SEO优化公司 XML地图 TXT地图 虚拟主机 SEO 网站制作 网站优化