提交 bbabbf85 编写于 作者: laizhilong's avatar laizhilong

组织树,部门树增加搜索框

上级 554f721d
<template> <template>
<div class="design-tree-container"> <div class="design-tree-container">
<context-menu-container> <context-menu-container>
<el-input size="medium" placeholder="搜索..." v-model="filerText" @input="filterChange">
<i slot="prefix" class="el-input__icon el-icon-search"></i>
</el-input>
<el-tree <el-tree
:filter-node-method="filterNode"
class="tre" class="tre"
:data="this.TreeData" :data="this.TreeData"
ref="DeptTree" ref="DeptTree"
...@@ -28,6 +32,23 @@ ...@@ -28,6 +32,23 @@
}) })
export default class DeptTree extends Vue { export default class DeptTree extends Vue {
// 过滤文本
public filerText: any = '';
/**
* 过滤节点
*/
public filterNode(value:any,data:any){
if (!value) return true;
return data.label.indexOf(value) !==-1;
}
/**
* 树搜索触发
*/
public filterChange(){
const DeptTree:any = this.$refs.DeptTree;
DeptTree.filter(this.filerText);
}
/*树数据*/ /*树数据*/
public TreeData: any = []; public TreeData: any = [];
......
<template> <template>
<div class="design-tree-container"> <div class="design-tree-container">
<context-menu-container> <context-menu-container>
<el-input size="medium" placeholder="搜索..." v-model="filerText" @input="filterChange">
<i slot="prefix" class="el-input__icon el-icon-search"></i>
</el-input>
<el-tree <el-tree
:filter-node-method="filterNode"
class="tre" class="tre"
:data="this.TreeData" :data="this.TreeData"
ref="OrgTree" ref="OrgTree"
...@@ -27,6 +31,23 @@ ...@@ -27,6 +31,23 @@
}) })
export default class OrgTree extends Vue { export default class OrgTree extends Vue {
// 过滤文本
public filerText: any = '';
/**
* 过滤节点
*/
public filterNode(value:any,data:any){
if (!value) return true;
return data.label.indexOf(value) !==-1;
}
/**
* 树搜索触发
*/
public filterChange(){
const OrgTree:any = this.$refs.OrgTree;
OrgTree.filter(this.filerText);
}
/*树数据*/ /*树数据*/
public TreeData: any = []; public TreeData: any = [];
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册