|
@@ -341,6 +341,9 @@ module.exports = app => {
|
|
|
|
|
|
const leafBillsId = [];
|
|
|
// 计算粘贴数据中需更新部分
|
|
|
+ datas.sort(function (x, y) {
|
|
|
+ return x.level - y.level;
|
|
|
+ });
|
|
|
for (let index = 0; index < datas.length; index++) {
|
|
|
const data = datas[index];
|
|
|
const newId = maxId + index + 1;
|
|
@@ -352,16 +355,12 @@ module.exports = app => {
|
|
|
data.tender_id = this.ctx.tender.id;
|
|
|
if (!data.is_leaf) {
|
|
|
for (const children of datas) {
|
|
|
- children.full_path = children.full_path.replace('-' + data.ledger_id, '-' + newId);
|
|
|
if (children.ledger_pid === data.ledger_id) {
|
|
|
children.ledger_pid = newId;
|
|
|
}
|
|
|
}
|
|
|
- } else {
|
|
|
- data.full_path = data.full_path.replace('-' + data.ledger_id, '-' + newId);
|
|
|
}
|
|
|
data.ledger_id = newId;
|
|
|
- data.full_path = data.full_path.replace(orgParentPath, newParentPath);
|
|
|
if (data.ledger_pid === node.ledger_pid) {
|
|
|
data.ledger_pid = selectData.ledger_pid;
|
|
|
data.order = selectData.order + iNode + 1;
|
|
@@ -372,6 +371,16 @@ module.exports = app => {
|
|
|
}
|
|
|
newIds.push(data.id);
|
|
|
}
|
|
|
+ for (const data of datas) {
|
|
|
+ const p = datas.find(function (x) {
|
|
|
+ return x.ledger_id === data.ledger_pid;
|
|
|
+ });
|
|
|
+ if (p) {
|
|
|
+ data.full_path = p.full_path + '-' + data.ledger_id;
|
|
|
+ } else {
|
|
|
+ data.full_path = newParentPath + '' + data.ledger_id;
|
|
|
+ }
|
|
|
+ }
|
|
|
const newData = await this.transaction.insert(this.tableName, datas);
|
|
|
for (const id of leafBillsId) {
|
|
|
await this.ctx.service.pos.copyBillsPosData(id.org, id.new, this.transaction);
|