|
@@ -344,6 +344,11 @@ module.exports = app => {
|
|
|
datas.sort(function (x, y) {
|
|
|
return x.level - y.level;
|
|
|
});
|
|
|
+ for (const data of datas) {
|
|
|
+ data.children = datas.filter(function (x) {
|
|
|
+ return x.ledger_pid === data.ledger_id;
|
|
|
+ })
|
|
|
+ }
|
|
|
for (let index = 0; index < datas.length; index++) {
|
|
|
const data = datas[index];
|
|
|
const newId = maxId + index + 1;
|
|
@@ -353,11 +358,9 @@ module.exports = app => {
|
|
|
data.id = this.uuid.v4();
|
|
|
idChange.new = data.id;
|
|
|
data.tender_id = this.ctx.tender.id;
|
|
|
- if (!data.is_leaf) {
|
|
|
- for (const children of datas) {
|
|
|
- if (children.ledger_pid === data.ledger_id) {
|
|
|
- children.ledger_pid = newId;
|
|
|
- }
|
|
|
+ if (data.children && data.children.length > 0) {
|
|
|
+ for (const child of data.children) {
|
|
|
+ child.ledger_pid = newId;
|
|
|
}
|
|
|
}
|
|
|
data.ledger_id = newId;
|
|
@@ -372,6 +375,7 @@ module.exports = app => {
|
|
|
newIds.push(data.id);
|
|
|
}
|
|
|
for (const data of datas) {
|
|
|
+ delete data.children;
|
|
|
const p = datas.find(function (x) {
|
|
|
return x.ledger_id === data.ledger_pid;
|
|
|
});
|
|
@@ -393,7 +397,6 @@ module.exports = app => {
|
|
|
throw err;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// 查询应返回的结果
|
|
|
const order = [];
|
|
|
for (let i = 1; i <= copyNodes.length; i++) {
|