|
@@ -325,18 +325,13 @@ const createNewPathTree = function (type, setting) {
|
|
|
/**
|
|
|
* 树结构根据显示排序
|
|
|
*/
|
|
|
- sortTreeNode(isResort, isReturn) {
|
|
|
- const resorts = [];
|
|
|
+ sortTreeNode(isResort) {
|
|
|
const self = this;
|
|
|
- if (isReturn) this.nodes.forEach((x, i) => { x.__org_tree_index = i });
|
|
|
const addSortNodes = function (nodes) {
|
|
|
if (!nodes) { return }
|
|
|
for (let i = 0; i < nodes.length; i++) {
|
|
|
self.nodes.push(nodes[i]);
|
|
|
nodes[i].index = self.nodes.length - 1;
|
|
|
- if (isReturn && nodes[i].__org_tree_index !== undefined && nodes[i].__org_tree_index !== nodes[i].index) {
|
|
|
- resorts.push(nodes[i]);
|
|
|
- }
|
|
|
if (!isResort) {
|
|
|
nodes[i].children = self.getChildren(nodes[i]);
|
|
|
} else {
|
|
@@ -352,7 +347,6 @@ const createNewPathTree = function (type, setting) {
|
|
|
this.sortByOrder(this.children);
|
|
|
}
|
|
|
addSortNodes(this.children);
|
|
|
- return resorts;
|
|
|
}
|
|
|
sortByOrder(datas) {
|
|
|
const setting = this.setting;
|
|
@@ -796,9 +790,9 @@ const createNewPathTree = function (type, setting) {
|
|
|
loadedData.push(this.getItems(node[this.setting.pid]));
|
|
|
loadedData.push(this.getItems(data[this.setting.pid]));
|
|
|
}
|
|
|
- // if (prop === this.setting.order) {
|
|
|
- // loadedData = loadedData.concat(this.getPosterity(node));
|
|
|
- // }
|
|
|
+ if (prop === this.setting.order) {
|
|
|
+ loadedData = loadedData.concat(this.getPosterity(node));
|
|
|
+ }
|
|
|
node[prop] = data[prop];
|
|
|
}
|
|
|
}
|
|
@@ -814,9 +808,7 @@ const createNewPathTree = function (type, setting) {
|
|
|
this.children = this.getChildren(null);
|
|
|
}
|
|
|
}
|
|
|
- const resortTreeNodes = this.sortTreeNode(true, true);
|
|
|
- loadedData.push(...resortTreeNodes);
|
|
|
- loadedData = _.uniq(loadedData);
|
|
|
+ this.sortTreeNode(true);
|
|
|
return loadedData;
|
|
|
};
|
|
|
/**
|
|
@@ -853,8 +845,8 @@ const createNewPathTree = function (type, setting) {
|
|
|
resortData.push(node);
|
|
|
}
|
|
|
const parent = this.getItems(node[this.setting.pid]);
|
|
|
- if (parent) {
|
|
|
- if (resortData.indexOf(parent) === -1) resortData.push(parent);
|
|
|
+ if (parent && resortData.indexOf(parent) === -1) {
|
|
|
+ resortData.push(parent);
|
|
|
} else {
|
|
|
resortData.push(this.setting.rootId);
|
|
|
}
|
|
@@ -907,7 +899,6 @@ const createNewPathTree = function (type, setting) {
|
|
|
for (const node of freeDatas) {
|
|
|
removeArrayData(this.nodes, node);
|
|
|
}
|
|
|
- this.sortTreeNode(true);
|
|
|
return freeDatas;
|
|
|
};
|
|
|
/**
|