|
@@ -307,9 +307,7 @@ const createNewPathTree = function (type, setting) {
|
|
|
if (!isResort) {
|
|
|
nodes[i].children = self.getChildren(nodes[i]);
|
|
|
} else {
|
|
|
- nodes[i].children.sort(function (a, b) {
|
|
|
- return a.order - b.order;
|
|
|
- })
|
|
|
+ nodes[i].children.sort((a, b) => { return a[self.setting.order] - b[self.setting.order]; })
|
|
|
}
|
|
|
addSortNodes(nodes[i].children);
|
|
|
}
|
|
@@ -318,9 +316,7 @@ const createNewPathTree = function (type, setting) {
|
|
|
if (!isResort) {
|
|
|
this.children = this.getChildren();
|
|
|
} else {
|
|
|
- this.children.sort(function (a, b) {
|
|
|
- return a.order - b.order;
|
|
|
- })
|
|
|
+ this.children.sort((a, b) => { return a[self.setting.order] - b[self.setting.order]; });
|
|
|
}
|
|
|
addSortNodes(this.children);
|
|
|
}
|
|
@@ -329,7 +325,7 @@ const createNewPathTree = function (type, setting) {
|
|
|
* @param datas
|
|
|
*/
|
|
|
loadDatas(datas) {
|
|
|
- self = this;
|
|
|
+ const self = this;
|
|
|
// 清空旧数据
|
|
|
this.items = {};
|
|
|
this.nodes = [];
|
|
@@ -358,9 +354,7 @@ const createNewPathTree = function (type, setting) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- this.children.sort(function (a, b) {
|
|
|
- return a.order - b.order;
|
|
|
- });
|
|
|
+ this.children.sort((a, b) => { return a[self.setting.order] - b[self.setting.order]; });
|
|
|
this.sortTreeNode(true);
|
|
|
if (this.hasMark) {
|
|
|
if (this.setting.markExpandKey) {
|
|
@@ -477,9 +471,7 @@ const createNewPathTree = function (type, setting) {
|
|
|
const children = this.datas.filter(function (x) {
|
|
|
return x[setting.pid] === pid;
|
|
|
});
|
|
|
- children.sort(function (a, b) {
|
|
|
- return a.order - b.order;
|
|
|
- });
|
|
|
+ children.sort((a, b) => { return a[setting.order] - b[setting.order]; });
|
|
|
return children;
|
|
|
};
|
|
|
|
|
@@ -524,7 +516,7 @@ const createNewPathTree = function (type, setting) {
|
|
|
*/
|
|
|
isLastSibling(node) {
|
|
|
const siblings = this.getChildren(this.getParent(node));
|
|
|
- return (siblings && siblings.length > 0) ? node.order === siblings[siblings.length - 1].order : false;
|
|
|
+ return (siblings && siblings.length > 0) ? node[this.setting.order] === siblings[siblings.length - 1][this.setting.order] : false;
|
|
|
};
|
|
|
|
|
|
/**
|
|
@@ -1546,7 +1538,7 @@ const createNewPathTree = function (type, setting) {
|
|
|
return fun(a[field], b[field]);
|
|
|
});
|
|
|
for (const [i, node] of nodes.entries()) {
|
|
|
- node.order = i + 1;
|
|
|
+ node[self.setting.order] = i + 1;
|
|
|
}
|
|
|
};
|
|
|
const addSortNodes = function (nodes) {
|