|
@@ -1,5 +1,3 @@
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 工料机汇总相关数据
|
|
|
*
|
|
@@ -320,20 +318,23 @@ ProjectGLJ.prototype.updatePrice = function (recode, updateField, newval,from,td
|
|
|
let projectGljs = this.datas.gljList;
|
|
|
let pgljID = from=="rg"?recode.projectGLJID:recode.id;//和定额工料机统一接口,项目工料机ID取值不一样
|
|
|
let glj = _.find(projectGljs, {'id': pgljID});
|
|
|
- let udoc = tdoc?tdoc:{"priceFrom":""};//20200728 新增价格来源,默认为空
|
|
|
+ let udoc = tdoc?tdoc:{};//20200728 新增价格来源,默认为空
|
|
|
+ if(updateField == 'market_price') udoc = {"priceFrom":"",infoPrice:null};
|
|
|
if (glj) {
|
|
|
if(glj.unit_price[updateField] == newval){
|
|
|
return;
|
|
|
}
|
|
|
- newval = scMathUtil.roundForObj(newval,this.getPriceDecimal(glj));
|
|
|
+ if(updateField == 'market_price'||updateField == 'base_price' ){
|
|
|
+ newval = scMathUtil.roundForObj(newval,this.getPriceDecimal(glj));
|
|
|
+ }
|
|
|
let data = {id: glj.unit_price.id, field: updateField, newval: newval,project_id:glj.project_id,unit_price_file_id:glj.unit_price.unit_price_file_id};
|
|
|
- if(updateField == 'market_price') data.udoc=udoc;
|
|
|
+ if(!_.isEmpty(udoc)) data.udoc=udoc;
|
|
|
let callback = function (data) {
|
|
|
if (updateField == 'base_price') {
|
|
|
glj.unit_price.base_price = newval;
|
|
|
me.setAdjustPrice(glj);
|
|
|
} else {
|
|
|
- glj.unit_price.market_price = newval;
|
|
|
+ glj.unit_price[updateField] = newval;
|
|
|
gljUtil.setProperty(glj.unit_price,udoc);
|
|
|
}
|
|
|
//更新回传的父节点项目工料机价格
|
|
@@ -448,16 +449,43 @@ ProjectGLJ.prototype.batchUpdatePrice = function (changeInfo,sheetName,callback)
|
|
|
for(let ci of changeInfo){
|
|
|
let dataCode = setting.header[ci.col].dataCode;
|
|
|
let recode = sheetName =="materialTreeSheet"?projectGljObject.materialTree.items[ci.row].data:projectGljObject.projectGljSheetData[ci.row];
|
|
|
- if(dataCode=='basePrice'||dataCode=='marketPrice'){
|
|
|
- let editField = dataCode === 'basePrice'?"base_price":"market_price";
|
|
|
- let glj = _.find(projectGljs, {'id': recode.id});
|
|
|
- let newValue = ci.value;
|
|
|
- if(glj&&glj.unit_price[editField]!=newValue){
|
|
|
+ let glj = _.find(projectGljs, {'id': recode.id});
|
|
|
+ let editField = dataCode;
|
|
|
+ let newValue = ci.value;
|
|
|
+ if(dataCode=='basePrice'||dataCode=='marketPrice') editField = dataCode === 'basePrice'?"base_price":"market_price";
|
|
|
+ if(glj&&glj.unit_price[editField]!=newValue){
|
|
|
+ newValueMap[glj.id] = newValueMap[glj.id]||{};
|
|
|
+ if(dataCode=='basePrice'||dataCode=='marketPrice'){
|
|
|
newValue= scMathUtil.roundForObj(ci.value,this.getPriceDecimal(glj));
|
|
|
- updateData.push({unit_price: glj.unit_price, field: editField, newval: newValue,project_id:glj.project_id});
|
|
|
- newValueMap[glj.id]={field:editField,value:newValue};
|
|
|
- gljs.push(glj);
|
|
|
+ }else{//信息价,采保费率要重新计算市场价
|
|
|
+ editField = 'market_price';
|
|
|
+ let infoPrice = newValueMap[glj.id].infoPrice||glj.unit_price.infoPrice;
|
|
|
+ let purchaseFeeRate =newValueMap[glj.id].purchaseFeeRate|| glj.unit_price.purchaseFeeRate;
|
|
|
+ if(dataCode == 'infoPrice'){
|
|
|
+ newValueMap[glj.id].priceFrom = '自行询价';
|
|
|
+ newValueMap[glj.id].infoPrice = newValue;
|
|
|
+ infoPrice = newValue;
|
|
|
+ }
|
|
|
+ if(dataCode == 'purchaseFeeRate'){
|
|
|
+ newValueMap[glj.id].purchaseFeeRate = newValue;
|
|
|
+ purchaseFeeRate = newValue;
|
|
|
+ }
|
|
|
+ if(gljUtil.isDef(infoPrice)){
|
|
|
+ newValue = gljUtil.calcMarketPriceByInfoPrice(infoPrice,purchaseFeeRate,this.getPriceDecimal(glj))
|
|
|
+ }else{
|
|
|
+ editField = dataCode;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
+ if(dataCode=='marketPrice'){
|
|
|
+ newValueMap[glj.id].infoPrice = null;
|
|
|
+ newValueMap[glj.id].priceFrom = '';
|
|
|
+ }
|
|
|
+ newValueMap[glj.id][editField]=newValue;
|
|
|
+ if(!gljs.includes(glj)) {
|
|
|
+ updateData.push({unit_price: glj.unit_price, field: editField, newval: newValue,project_id:glj.project_id,ext:newValueMap[glj.id]});
|
|
|
+ gljs.push(glj);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if(updateData.length > 0){
|
|
@@ -466,7 +494,7 @@ ProjectGLJ.prototype.batchUpdatePrice = function (changeInfo,sheetName,callback)
|
|
|
let parentData = [];
|
|
|
//更新缓存
|
|
|
for(let g of gljs){
|
|
|
- g.unit_price[newValueMap[g.id].field] = newValueMap[g.id].value;
|
|
|
+ gljUtil.setProperty(g.unit_price,newValueMap[g.id]);
|
|
|
me.refreshTreeNodePriceIfNeed(g);//刷新造价书中主树上的定额工料机;
|
|
|
}
|
|
|
//更新父工料机价格
|