|
@@ -35,6 +35,9 @@ var VolumePrice = {
|
|
|
|
|
|
loadData (datas) {
|
|
|
this.datas = datas;
|
|
|
+ for (let data of datas) {
|
|
|
+ this.maxID(data.ID);
|
|
|
+ }
|
|
|
};
|
|
|
setMaxID (ID) {
|
|
|
this.maxID(ID);
|
|
@@ -55,6 +58,15 @@ var VolumePrice = {
|
|
|
return arr;
|
|
|
};
|
|
|
|
|
|
+ getCounterData (count) {
|
|
|
+ var updateData = {'projectID': this.getProject().ID()};
|
|
|
+ if (count) {
|
|
|
+ updateData[this.getSourceType()] = this.maxID() + count;
|
|
|
+ } else {
|
|
|
+ updateData[this.getSourceType()] = this.maxID() + 1;
|
|
|
+ }
|
|
|
+ return updateData;
|
|
|
+ };
|
|
|
getInsertVolumePriceData (billsID, pre) {
|
|
|
let bv = this.getBillsSortVolumePrice(billsID);
|
|
|
let updateData = [];
|
|
@@ -70,7 +82,7 @@ var VolumePrice = {
|
|
|
return updateData;
|
|
|
};
|
|
|
insertVolumePrice (billsID, pre) {
|
|
|
- tools.owner.pushNow('insertVolumePrice', [this.getSourceType()], [this.getInsertVolumePriceData(billsID, pre)]);
|
|
|
+ tools.owner.pushNow('insertVolumePrice', [this.getSourceType(), this.getProject().projCounter()], [this.getInsertVolumePriceData(billsID, pre), this.getCounterData()]);
|
|
|
|
|
|
let bv = this.getBillsSortVolumePrice(billsID), newVP = null;
|
|
|
if (pre) {
|
|
@@ -85,7 +97,44 @@ var VolumePrice = {
|
|
|
this.datas.push(newVP);
|
|
|
}
|
|
|
return newVP;
|
|
|
- }
|
|
|
+ };
|
|
|
+
|
|
|
+ getDeleteData (volumePrice) {
|
|
|
+ var updateData = [];
|
|
|
+ updateData.push({'updateType': 'ut_delete', 'updateData': {'ID': volumePrice.ID, 'projectID': this.getProject().ID()}});
|
|
|
+ return updateData;
|
|
|
+ };
|
|
|
+ delete (volumePrice) {
|
|
|
+ this.getProject().pushNow('deleteVolumePrice', [this.getSourceType()], [this.getDeleteData(volumePrice)]);
|
|
|
+ this.datas.splice(this.datas.indexOf(volumePrice), 1);
|
|
|
+ };
|
|
|
+
|
|
|
+ getDeleteDataByBills (nodes) {
|
|
|
+ let updateData = [];
|
|
|
+ for (let node of nodes) {
|
|
|
+ if (node.children.length > 0) {
|
|
|
+ updateData = updateData.concat(this.getDeleteDataByBills[node.children]);
|
|
|
+ } else {
|
|
|
+ let vps = this.getBillsSortVolumePrice(node.getID());
|
|
|
+ for (let vp of vps) {
|
|
|
+ updateData.push({'updateType': 'ut_delete', 'updateData': {'ID': vp.ID, 'projectID': this.getProject().ID()}});
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return updateData;
|
|
|
+ };
|
|
|
+ deleteByBills (nodes) {
|
|
|
+ for (let node of nodes) {
|
|
|
+ if (node.children.length > 0) {
|
|
|
+ this.deleteByBills([node.children]);
|
|
|
+ } else {
|
|
|
+ let vps = this.getBillsSortVolumePrice(node.getID());
|
|
|
+ for (let vp of vps) {
|
|
|
+ this.datas.splice(this.datas.indexOf(vp), 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
}
|
|
|
|
|
|
return new volumePrice();
|