|
@@ -268,6 +268,7 @@ $(document).ready(() => {
|
|
|
setAuditValue: function () {
|
|
|
for (const c of changeList) {
|
|
|
for (const audit of change.listAudits) {
|
|
|
+ c['audit_amount_' + audit.aid] = ZhCalc.round(c['audit_amount_' + audit.aid], findDecimal(c.unit));
|
|
|
c['sa_tp_' + audit.aid] = ZhCalc.round(ZhCalc.mul(ZhCalc.round(c['audit_amount_' + audit.aid], findDecimal(c.unit)), ZhCalc.round(c.unit_price, unitPriceUnit)), totalPriceUnit);
|
|
|
}
|
|
|
}
|
|
@@ -816,40 +817,58 @@ $(document).ready(() => {
|
|
|
});
|
|
|
// 数组去重
|
|
|
dealBillList = result.dealBills;
|
|
|
- // for (const db of gclGatherData) {
|
|
|
- // const exist_index = dealBillList.findIndex(function (item) {
|
|
|
- // return item.code === db.code && item.name === db.name && item.unit === db.unit && item.unit_price === db.unit_price;
|
|
|
- // });
|
|
|
- // if (exist_index !== -1) {
|
|
|
- // dealBillList.splice(exist_index, 1);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // changeListData = gclGatherData.concat(dealBillList);
|
|
|
changeListData = gclGatherData;
|
|
|
console.log(changeListData, dealBillList);
|
|
|
-
|
|
|
SpreadJsObj.initSpreadSettingEvents(changeSpreadSetting, changeCol);
|
|
|
SpreadJsObj.initSheet(changeSpreadSheet, changeSpreadSetting);
|
|
|
if (change.status === auditConst.status.checking || change.status === auditConst.status.checked) changeSpreadObj.setAuditValue();
|
|
|
SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
|
|
|
changeSpreadObj.makeSjsFooter();
|
|
|
- if (change.status === auditConst.status.checked) {
|
|
|
- changeSpreadObj.showHideAudit(false);
|
|
|
- } else {
|
|
|
- changeSpreadObj.showHideAudit(true);
|
|
|
- }
|
|
|
-
|
|
|
// 计算最新的变更总额和change的total_price是否一致,不一致则更新
|
|
|
if (change.status !== auditConst.status.checked) {
|
|
|
- let new_tp = 0;
|
|
|
+ // let new_tp = 0;
|
|
|
+ const updateArray = [];
|
|
|
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));
|
|
|
+ const oneUpdate = {};
|
|
|
+ if (ZhCalc.round(c.spamount, findDecimal(c.unit)) !== c.spamount) oneUpdate.spamount = ZhCalc.round(c.spamount, findDecimal(c.unit));
|
|
|
+ if (ZhCalc.round(c.oamount, findDecimal(c.unit)) !== c.oamount) oneUpdate.oamount = ZhCalc.round(c.oamount, findDecimal(c.unit));
|
|
|
+ if (ZhCalc.round(c.camount, findDecimal(c.unit)) !== c.camount) oneUpdate.camount = ZhCalc.round(c.camount, findDecimal(c.unit));
|
|
|
+ if (ZhCalc.round(c.unit_price, unitPriceUnit) !== c.unit_price) oneUpdate.unit_price = ZhCalc.round(c.unit_price, unitPriceUnit);
|
|
|
+ const audit_amount = c.audit_amount ? c.audit_amount.split(',') : null;
|
|
|
+ if (audit_amount) {
|
|
|
+ for (const i in audit_amount) {
|
|
|
+ if (ZhCalc.round(parseFloat(audit_amount[i]), findDecimal(c.unit)) !== parseFloat(audit_amount[i])) audit_amount[i] = ZhCalc.round(parseFloat(audit_amount[i]), findDecimal(c.unit));
|
|
|
+ }
|
|
|
+ if (c.audit_amount !== audit_amount.join(',')) oneUpdate.audit_amount = audit_amount.join(',');
|
|
|
+ }
|
|
|
+ if (!_.isEmpty(oneUpdate)) {
|
|
|
+ oneUpdate.id = c.id;
|
|
|
+ updateArray.push(oneUpdate);
|
|
|
+ }
|
|
|
+ // new_tp = ZhCalc.add(new_tp, ZhCalc.round(ZhCalc.mul(ZhCalc.round(c.spamount, findDecimal(c.unit)), ZhCalc.round(c.unit_price, unitPriceUnit)), totalPriceUnit));
|
|
|
}
|
|
|
- if (change.total_price && change.total_price !== new_tp) {
|
|
|
- postData(preUrl + '/list/save', {type: 'update_tp', updateData: new_tp}, function (result) {
|
|
|
+ console.log(updateArray);
|
|
|
+ if (updateArray.length > 0) {
|
|
|
+ // 更新至服务器
|
|
|
+ postData(preUrl + '/list/save', { type:'paste', updateData: updateArray }, function (result) {
|
|
|
+ changeList = result;
|
|
|
+ if (change.status === auditConst.status.checking) changeSpreadObj.setAuditValue();
|
|
|
+ SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
|
|
|
+ changeSpreadObj.makeSjsFooter();
|
|
|
});
|
|
|
}
|
|
|
+ // if (change.total_price && change.total_price !== new_tp) {
|
|
|
+ // postData(preUrl + '/list/save', {type: 'update_tp', updateData: new_tp}, function (result) {
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ if (change.status === auditConst.status.checked) {
|
|
|
+ changeSpreadObj.showHideAudit(false);
|
|
|
+ } else {
|
|
|
+ changeSpreadObj.showHideAudit(true);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
});
|
|
|
|
|
|
// 审批流程展示与隐藏
|