|
@@ -87,15 +87,16 @@ $(document).ready(() => {
|
|
|
|
|
|
// 计算最新的变更总额和change的total_price是否一致,不一致则更新
|
|
|
if (changeStatus !== auditConst.status.checked) {
|
|
|
- let new_tp = 0;
|
|
|
- for (const c of changeList) {
|
|
|
- new_tp = ZhCalc.add(new_tp, ZhCalc.round(ZhCalc.mul(ZhCalc.round(c.spamount, findDecimal(c.unit)), ZhCalc.round(c.unit_price, unitPriceUnit)), totalPriceUnit));
|
|
|
- }
|
|
|
- console.log(changeTp, new_tp);
|
|
|
- if (changeTp !== new_tp) {
|
|
|
- postData(window.location.pathname + '/save', { type:'update_tp', updateData: new_tp }, function (result) {
|
|
|
- });
|
|
|
- }
|
|
|
+ calcChangePrice();
|
|
|
+ // let new_tp = 0;
|
|
|
+ // for (const c of changeList) {
|
|
|
+ // new_tp = ZhCalc.add(new_tp, ZhCalc.round(ZhCalc.mul(ZhCalc.round(c.spamount, findDecimal(c.unit)), ZhCalc.round(c.unit_price, unitPriceUnit)), totalPriceUnit));
|
|
|
+ // }
|
|
|
+ // console.log(changeTp, new_tp);
|
|
|
+ // if (changeTp !== new_tp) {
|
|
|
+ // postData(window.location.pathname + '/save', { type:'update_tp', updateData: new_tp }, function (result) {
|
|
|
+ // });
|
|
|
+ // }
|
|
|
}
|
|
|
|
|
|
//tab change
|
|
@@ -496,6 +497,46 @@ $(document).ready(() => {
|
|
|
xmjSpread.refresh();
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+function calcChangePrice() {
|
|
|
+ let positive_tp = 0;
|
|
|
+ let negative_tp = 0;
|
|
|
+ let new_tp = 0;
|
|
|
+ for (const c of changeList) {
|
|
|
+ if (c.spamount) {
|
|
|
+ const price = ZhCalc.round(ZhCalc.mul(ZhCalc.round(c.spamount, findDecimal(c.unit)), ZhCalc.round(c.unit_price, unitPriceUnit)), totalPriceUnit);
|
|
|
+ new_tp = ZhCalc.add(new_tp, price);
|
|
|
+ if (price >= 0) {
|
|
|
+ positive_tp = ZhCalc.add(positive_tp, price);
|
|
|
+ } else {
|
|
|
+ negative_tp = ZhCalc.add(negative_tp, price);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const updateTpList = {};
|
|
|
+ let updateFlag = false;
|
|
|
+ if (changeTp !== new_tp) {
|
|
|
+ updateTpList.total_price = new_tp;
|
|
|
+ updateFlag = true;
|
|
|
+ }
|
|
|
+ if (positive_tp !== changePp) {
|
|
|
+ updateTpList.positive_tp = positive_tp;
|
|
|
+ updateFlag = true;
|
|
|
+ }
|
|
|
+ if (negative_tp !== changeNp) {
|
|
|
+ updateTpList.negative_tp = negative_tp;
|
|
|
+ updateFlag = true;
|
|
|
+ }
|
|
|
+ if (updateFlag) {
|
|
|
+ console.log(updateTpList);
|
|
|
+ postData(window.location.pathname + '/save', { type:'update_tp', updateData: updateTpList }, function () {
|
|
|
+ changePp = positive_tp;
|
|
|
+ changeNp = negative_tp;
|
|
|
+ changeTp = new_tp;
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
function findDecimal(unit) {
|
|
|
let value = precision.other.value;
|
|
|
const changeUnits = precision;
|