|
@@ -337,22 +337,21 @@ const createNewPathTree = function (type, setting) {
|
|
|
});
|
|
|
for (const data of datas) {
|
|
|
const keyName = itemsPre + data[this.setting.id];
|
|
|
- if (!this.items[keyName]) {
|
|
|
- const item = JSON.parse(JSON.stringify(data));
|
|
|
- item.children = [];
|
|
|
- item.expanded = true;
|
|
|
- item.visible = true;
|
|
|
- this.items[keyName] = item;
|
|
|
- this.datas.push(item);
|
|
|
- if (item[setting.pid] === setting.rootId) {
|
|
|
- this.children.push(item);
|
|
|
- } else {
|
|
|
- const parent = this.getParent(item);
|
|
|
- if (parent) {
|
|
|
- parent.children.push(item);
|
|
|
- }
|
|
|
- }
|
|
|
+ if (this.items[keyName]) throw '数据错误';
|
|
|
+
|
|
|
+ const item = JSON.parse(JSON.stringify(data));
|
|
|
+ item.children = [];
|
|
|
+ item.expanded = true;
|
|
|
+ item.visible = true;
|
|
|
+ if (item[setting.pid] === setting.rootId) {
|
|
|
+ this.children.push(item);
|
|
|
+ } else {
|
|
|
+ const parent = this.getParent(item);
|
|
|
+ if (!parent) continue;
|
|
|
+ parent.children.push(item);
|
|
|
}
|
|
|
+ this.items[keyName] = item;
|
|
|
+ this.datas.push(item);
|
|
|
}
|
|
|
this.children.sort((a, b) => { return a[self.setting.order] - b[self.setting.order]; });
|
|
|
this.sortTreeNode(true);
|