| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <template>
- <div class="main">
- <div class="input-warp">
- <el-input size="small" suffix-icon="el-icon-search" placeholder="请输入功能名称" v-model="filterText"> </el-input>
- </div>
- <el-tree
- class="filter-tree"
- :data="data"
- :props="defaultProps"
- default-expand-all
- :highlight-current="true"
- :filter-node-method="filterNode"
- @node-click="handleNodeClick"
- ref="tree"
- >
- </el-tree>
- </div>
- </template>
- <script>
- export default {
- props: {
- data: {
- type: Array,
- default() {
- return [];
- },
- },
- },
- data() {
- return {
- filterText: "",
- defaultProps: {
- children: "children",
- label: "label",
- },
- };
- },
- watch: {
- filterText(val) {
- this.$refs.tree.filter(val);
- },
- },
- methods: {
- filterNode(value, data) {
- if (!value) return true;
- return data.label.indexOf(value) !== -1;
- },
- handleNodeClick(data, Node){
- this.$emit("change", data);
- }
- },
- };
- </script>
- <style lang="scss" scoped>
- .input-warp{
- padding: 10px;
- }
- .main{
- background: #ffffff;
- }
- </style>
|