|
|
@@ -108,14 +108,14 @@
|
|
|
return this.$refs.tree;
|
|
|
},
|
|
|
// 获取树结构数据
|
|
|
- async getTreeData(id) {
|
|
|
+ async getTreeData(id, defChecked) {
|
|
|
try {
|
|
|
this.treeLoading = true;
|
|
|
|
|
|
const res = this.isProjects
|
|
|
? await getProjectAndCategoryLevelTree()
|
|
|
: await getTreeByPid(id);
|
|
|
-
|
|
|
+
|
|
|
this.treeLoading = false;
|
|
|
if (res?.code === '0') {
|
|
|
this.treeList = res.data;
|
|
|
@@ -124,6 +124,9 @@
|
|
|
this.treeList = this.treeFormate(this.treeList);
|
|
|
}
|
|
|
this.$nextTick(() => {
|
|
|
+ if(this.isProjects){
|
|
|
+ this.setCurrentKey(defChecked);
|
|
|
+ }
|
|
|
// 默认高亮第一级树节点
|
|
|
if (this.treeList[0] && this.isFirstRefreshTable) {
|
|
|
this.setCurrentKey(this.treeList[0].id);
|
|
|
@@ -135,30 +138,9 @@
|
|
|
});
|
|
|
return this.treeList;
|
|
|
}
|
|
|
- } catch (error) {
|
|
|
- console.error(error);
|
|
|
- }
|
|
|
+ } catch (error) {}
|
|
|
this.treeLoading = false;
|
|
|
},
|
|
|
- // 递归 - 往树children里面添加parentName
|
|
|
- // _setParentName (tree) {
|
|
|
- // let data = tree;
|
|
|
- // for (let i = 0; i < data.length; i++) {
|
|
|
- // if (data[i].parentId === '0') {
|
|
|
- // this.parentName = data[i].name;
|
|
|
- // originId = data[i].id;
|
|
|
- // originType = data[i].type;
|
|
|
- // }
|
|
|
-
|
|
|
- // data[i]['originId'] = originId;
|
|
|
- // data[i]['originType'] = originType;
|
|
|
- // data[i]['parentId'] = data[i]['parentId'];
|
|
|
- // if (data[i].children && data[i].children.length > 0) {
|
|
|
- // this._setParentName(data[i].children);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // return data;
|
|
|
- // },
|
|
|
|
|
|
handleNodeClick(data, node) {
|
|
|
this.$emit('handleNodeClick', data, node);
|