拆分文档详情

This commit is contained in:
caoyang
2022-02-25 18:01:36 +08:00
parent 5367bd3bbe
commit ce208e3a52
3 changed files with 431 additions and 57 deletions
@@ -3,7 +3,6 @@
<a-card :bordered="false">
<div class="subscribtion-search-wrapper">
<div class="subscribtion-search-header">
<!-- <search ></search>-->
<a-form layout="inline" @keyup.enter.native="searchQuery(queryParams)">
<a-form-model
class="subscribtion-content"
@@ -11,10 +11,12 @@
>
<a-input-search v-model="searchValue" style="margin-bottom: 8px" placeholder="节点快速查找" @change="onChange" />
<a-tree
v-if="treeData && treeData.length"
v-model="checkedKeys"
checkable
:expanded-keys="expandedKeys"
:auto-expand-parent="autoExpandParent"
:defaultExpandAll="true"
:tree-data="treeData"
:selected-keys="selectedKeys"
@select="onSelect"
@@ -92,6 +94,7 @@
},
mounted() {
this.visible=this.subVisible
this.generateList(this.treeData)
},
methods:{
//获取数据
@@ -114,58 +117,6 @@
this.visible = false;
this.$emit('visible',false)
},
onExpand(expandedKeys) {
console.log('onExpand', expandedKeys);
// if not set autoExpandParent to false, if children expanded, parent can not collapse.
// or, you can remove all expanded children keys.
this.expandedKeys = expandedKeys;
this.autoExpandParent = false;
},
onCheck(checkedKeys) {
console.log('onCheck', checkedKeys);
this.checkedKeys = checkedKeys;
},
onSelect(selectedKeys, info) {
console.log('onSelect', info);
this.selectedKeys = selectedKeys;
},
generateData(_level, _preKey, _tns){
const preKey = _preKey || '0';
const tns = _tns || this.treeData;
const children = [];
for (let i = 0; i < x; i++) {
const key = `${preKey}-${i}`;
tns.push({ title: key, key, scopedSlots: { title: 'title' } });
if (i < y) {
children.push(key);
}
}
if (_level < 0) {
return tns;
}
const level = _level - 1;
children.forEach((key, index) => {
tns[index].children = [];
return this.generateData(level, key, tns[index].children);
});
},
onChange(e) {
const value = e.target.value;
const expandedKeys = this.dataList
.map(item => {
if (item.title.indexOf(value) > -1) {
return this.getParentKey(item.key, this.treeData);
}
return null;
})
.filter((item, i, self) => item && self.indexOf(item) === i);
Object.assign(this, {
expandedKeys,
searchValue: value,
autoExpandParent: true,
});
},
generateList(data){
for (let i = 0; i < data.length; i++) {
const node = data[i];
@@ -176,6 +127,7 @@
}
}
},
getParentKey(key, tree){
let parentKey;
for (let i = 0; i < tree.length; i++) {
@@ -190,6 +142,35 @@
}
return parentKey;
},
onExpand(expandedKeys){
this.expandedKeys = expandedKeys;
this.autoExpandParent = false;
},
onChange(e) {
const value = e.target.value;
const expandedKeys = this.dataList
.map(item => {
if (item.title.indexOf(value) > -1) {
return this.getParentKey(item.key, this.gData);
}
return null;
})
.filter((item, i, self) => item && self.indexOf(item) === i);
Object.assign(this, {
expandedKeys,
searchValue: value,
autoExpandParent: true,
})
},
onCheck(checkedKeys) {
console.log('onCheck', checkedKeys);
this.checkedKeys = checkedKeys;
},
onSelect(selectedKeys, info) {
console.log('onSelect', info);
this.selectedKeys = selectedKeys;
},
}
}