|
@@ -102,6 +102,8 @@
|
|
|
|
|
|
|
|
import { getInfoById } from '@/api/classifyManage';
|
|
import { getInfoById } from '@/api/classifyManage';
|
|
|
|
|
|
|
|
|
|
+ import { reloadPageTab } from '@/utils/page-tab-util';
|
|
|
|
|
+
|
|
|
export default {
|
|
export default {
|
|
|
components: {
|
|
components: {
|
|
|
IndexData,
|
|
IndexData,
|
|
@@ -165,13 +167,28 @@
|
|
|
if (res?.code === '0') {
|
|
if (res?.code === '0') {
|
|
|
this.treeList = res.data;
|
|
this.treeList = res.data;
|
|
|
|
|
|
|
|
- this.$nextTick(() => {
|
|
|
|
|
- // 默认高亮第一级树节点
|
|
|
|
|
- if (this.treeList[0]) {
|
|
|
|
|
- this.rootTreeId = this.treeList[0].id;
|
|
|
|
|
- this.getDetail(this.treeList[0].id);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ if (!this.$route.query.categoryLevelId) {
|
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
|
+ //默认高亮第一级树节点;
|
|
|
|
|
+ if (this.treeList[0]) {
|
|
|
|
|
+ this.rootTreeId = this.treeList[0].id;
|
|
|
|
|
+ this.getDetail(this.treeList[0].id);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.getDetail(this.$route.query.categoryLevelId);
|
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
|
+ this.$refs.treeRef.setCurrentKey(
|
|
|
|
|
+ this.$route.query.categoryLevelId
|
|
|
|
|
+ );
|
|
|
|
|
+ });
|
|
|
|
|
+ const objByid = this.findNodeById(
|
|
|
|
|
+ this.treeList,
|
|
|
|
|
+ this.$route.query.categoryLevelId
|
|
|
|
|
+ );
|
|
|
|
|
+ console.log(objByid, '当前选择的物品');
|
|
|
|
|
+ this.publicfun(objByid);
|
|
|
|
|
+ }
|
|
|
return this.treeList;
|
|
return this.treeList;
|
|
|
}
|
|
}
|
|
|
} catch (error) {}
|
|
} catch (error) {}
|
|
@@ -189,9 +206,32 @@
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+ findNodeById(tree, targetId) {
|
|
|
|
|
+ function traverse(nodes) {
|
|
|
|
|
+ for (let node of nodes) {
|
|
|
|
|
+ if (node.id === targetId) {
|
|
|
|
|
+ return node;
|
|
|
|
|
+ } else if (node.children && node.children.length > 0) {
|
|
|
|
|
+ const foundNode = traverse(node.children);
|
|
|
|
|
+ if (foundNode) {
|
|
|
|
|
+ return foundNode;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return traverse(tree);
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ async handleNodeClick(data, node) {
|
|
|
|
|
+ this.$route.query.categoryLevelId = '';
|
|
|
|
|
|
|
|
- handleNodeClick(data, node) {
|
|
|
|
|
this.curNode = node;
|
|
this.curNode = node;
|
|
|
|
|
+ await this.publicfun(data);
|
|
|
|
|
+ await this.getDetail(data.id);
|
|
|
|
|
+ },
|
|
|
|
|
+ publicfun(data) {
|
|
|
this.pathList = this.findParent([], data, this.treeList);
|
|
this.pathList = this.findParent([], data, this.treeList);
|
|
|
this.rootTreeId = null;
|
|
this.rootTreeId = null;
|
|
|
if (this.pathList.length == 0) {
|
|
if (this.pathList.length == 0) {
|
|
@@ -232,12 +272,9 @@
|
|
|
PathInfo.categoryLevelName = data.name;
|
|
PathInfo.categoryLevelName = data.name;
|
|
|
PathInfo.ruleCode = ruleCode;
|
|
PathInfo.ruleCode = ruleCode;
|
|
|
|
|
|
|
|
- console.log(PathInfo, '点击产品分类');
|
|
|
|
|
|
|
+ console.log(PathInfo, '点击物品分类');
|
|
|
this.currentData = PathInfo;
|
|
this.currentData = PathInfo;
|
|
|
-
|
|
|
|
|
- this.getDetail(data.id);
|
|
|
|
|
},
|
|
},
|
|
|
-
|
|
|
|
|
/* 刷新表格 */
|
|
/* 刷新表格 */
|
|
|
reload(where) {
|
|
reload(where) {
|
|
|
this.$refs.listData.reload(where);
|
|
this.$refs.listData.reload(where);
|