<el-tree class="task-note-tree" ref="elTree" :data="tagTreeList" default-expand-all node-key="labelId"
:props="defaultProps" highlight-current :expand-on-click-node="false"
@node-click="handleNodeClick">
<div slot-scope="{node, data}" class="tree-node">
<span class="node-name text-hide-one" :title="data.name">{{ data.name }}</span>
</div>
</el-tree>
async getinitData () {
const res = await markTaskDetailPoints({
photoId: this.currentData.Id,
subTaskId: this.currentData.Id,
taskCollectionId: this.currentData.taskCollectionId
});
this.table.loading = false;
if (res.code === 200) {
this.currentCanvasAll = res.data;
await this.selectTree(this.tagTreeList, this.currentCanvasAll);
}
},
handleNodeClick (data) {
this.currentLabelId = data.labelId;
this.currentCanvasData = this.currentCanvasAll.filter(item => item.labelId === this.currentLabelId);
this.$nextTick(() => {
this.clickFN();
});
},
selectTree (treeData, currentCanvasAll) {
this.currentCanvasData = [];
treeData.forEach(node => {
currentCanvasAll.forEach(item => {
if (item.labelId === node.labelId) {
this.$refs.elTree.setCurrentKey(item.labelId);
this.$nextTick(() => {
this.handleNodeClick(item);
});
}
});
判断是否有子数据,有就执行回调
if (node.child && node.child.length > 0) {
this.selectTree(node.child, currentCanvasAll);
}
});
},