|
@@ -44,11 +44,7 @@ class PosData {
|
|
|
this.ledgerPos[masterKey].push(data);
|
|
|
}
|
|
|
for (const prop in this.ledgerPos) {
|
|
|
- if (this.ledgerPos[prop] instanceof Array) {
|
|
|
- this.ledgerPos[prop].sort(function (a, b) {
|
|
|
- return a.porder - b.porder;
|
|
|
- })
|
|
|
- }
|
|
|
+ this.resortLedgerPos(this.ledgerPos[prop]);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -58,7 +54,7 @@ class PosData {
|
|
|
*/
|
|
|
updateDatas(data) {
|
|
|
const datas = data instanceof Array ? data : [data];
|
|
|
- const result = { create: [], update: [] };
|
|
|
+ const result = { create: [], update: [] }, resort = [];
|
|
|
for (const d of datas) {
|
|
|
const key = itemsPre + d[this.setting.id];
|
|
|
if (!this.items[key]) {
|
|
@@ -78,8 +74,16 @@ class PosData {
|
|
|
}
|
|
|
result.update.push(pos);
|
|
|
}
|
|
|
+ const masterKey = itemsPre + d[this.setting.ledgerId];
|
|
|
+ if (resort.indexOf(masterKey) === -1) {
|
|
|
+ resort.push(masterKey);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (const s of resort) {
|
|
|
+ this.resortLedgerPos(this.ledgerPos[s]);
|
|
|
}
|
|
|
return result;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -129,6 +133,14 @@ class PosData {
|
|
|
return this.ledgerPos[itemsPre + mid];
|
|
|
}
|
|
|
|
|
|
+ resortLedgerPos(ledgerPos) {
|
|
|
+ if (ledgerPos instanceof Array) {
|
|
|
+ ledgerPos.sort(function (a, b) {
|
|
|
+ return a.porder - b.porder;
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 计算全部
|
|
|
*/
|