|
@@ -336,7 +336,7 @@ ProjectGLJ.prototype.updateCalcMaterial =async function (projectGLJ,updateField,
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-ProjectGLJ.prototype.calcAllMaterial = function (unitPriecs,isFromFeeRate) {//当材料发生改变时重算所有计算材料的价格
|
|
|
|
|
|
|
+ProjectGLJ.prototype.calcAllMaterial = function (unitPriecs,needReCalc) {//当材料发生改变时重算所有计算材料的价格
|
|
|
let priceMap = {};
|
|
let priceMap = {};
|
|
|
for(let unitPrice of unitPriecs){
|
|
for(let unitPrice of unitPriecs){
|
|
|
if(unitPrice && gljUtil.isDef(unitPrice.doc.market_price)) priceMap[unitPrice.projectGLJID] = unitPrice.doc.market_price;
|
|
if(unitPrice && gljUtil.isDef(unitPrice.doc.market_price)) priceMap[unitPrice.projectGLJID] = unitPrice.doc.market_price;
|
|
@@ -356,7 +356,7 @@ ProjectGLJ.prototype.calcAllMaterial = function (unitPriecs,isFromFeeRate) {//
|
|
|
let freightUpdateMap = {};
|
|
let freightUpdateMap = {};
|
|
|
for(let f of freightListMap[tIndex]){
|
|
for(let f of freightListMap[tIndex]){
|
|
|
if(f.conveyance != "自办运输") continue;//不是自办运输的不用管
|
|
if(f.conveyance != "自办运输") continue;//不是自办运输的不用管
|
|
|
- let calf = ifNeedReCalc(f,priceMap);
|
|
|
|
|
|
|
+ let calf = ifNeedReCalc(f,priceMap,needReCalc);
|
|
|
if(calf){
|
|
if(calf){
|
|
|
let f_task = this.calcEachFreightOrPrice(f,"freight",priceMap);
|
|
let f_task = this.calcEachFreightOrPrice(f,"freight",priceMap);
|
|
|
if(f_task){
|
|
if(f_task){
|
|
@@ -371,7 +371,7 @@ ProjectGLJ.prototype.calcAllMaterial = function (unitPriecs,isFromFeeRate) {//
|
|
|
if(originalListMap[tIndex]){ //运费重算
|
|
if(originalListMap[tIndex]){ //运费重算
|
|
|
let originalUpdateMap = {};
|
|
let originalUpdateMap = {};
|
|
|
for(let o of originalListMap[tIndex]){
|
|
for(let o of originalListMap[tIndex]){
|
|
|
- let calo = ifNeedReCalc(o,priceMap,isFromFeeRate);
|
|
|
|
|
|
|
+ let calo = ifNeedReCalc(o,priceMap,needReCalc);
|
|
|
if(calo){
|
|
if(calo){
|
|
|
let o_task = this.calcEachFreightOrPrice(o,"price",priceMap);
|
|
let o_task = this.calcEachFreightOrPrice(o,"price",priceMap);
|
|
|
if(o_task){
|
|
if(o_task){
|
|
@@ -385,7 +385,7 @@ ProjectGLJ.prototype.calcAllMaterial = function (unitPriecs,isFromFeeRate) {//
|
|
|
//判断映射表是否为空,如果为空则说明不用计算
|
|
//判断映射表是否为空,如果为空则说明不用计算
|
|
|
if(!_.isEmpty(fOrPDataMap)){
|
|
if(!_.isEmpty(fOrPDataMap)){
|
|
|
let t_unipPrice = this.materialCal(g.id,fOrPDataMap,g,freightListMap[tIndex],originalListMap[tIndex]);
|
|
let t_unipPrice = this.materialCal(g.id,fOrPDataMap,g,freightListMap[tIndex],originalListMap[tIndex]);
|
|
|
- if(t_unipPrice) unitPriecs.push(t_unipPrice);
|
|
|
|
|
|
|
+ if(t_unipPrice && !_.isEmpty(t_unipPrice.doc)) unitPriecs.push(t_unipPrice);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -402,9 +402,9 @@ ProjectGLJ.prototype.calcAllMaterial = function (unitPriecs,isFromFeeRate) {//
|
|
|
return [unitPriecs,sumUpdateMap];
|
|
return [unitPriecs,sumUpdateMap];
|
|
|
|
|
|
|
|
|
|
|
|
|
- function ifNeedReCalc(obj,IDMap,isFromFeeRate = false) {
|
|
|
|
|
|
|
+ function ifNeedReCalc(obj,IDMap,needReCalc = false) {
|
|
|
let calcf = false;
|
|
let calcf = false;
|
|
|
- if(isFromFeeRate == true) return true;//如果是从费率过来的,默认自动计算
|
|
|
|
|
|
|
+ if(needReCalc == true) return true;//如果是通过修改费率等地方触发的,默认自动计算
|
|
|
if(obj.ration_gljs){
|
|
if(obj.ration_gljs){
|
|
|
for(let rg of obj.ration_gljs){
|
|
for(let rg of obj.ration_gljs){
|
|
|
if(IDMap[rg.projectGLJID]){//判断是否关联了该项目工料机
|
|
if(IDMap[rg.projectGLJID]){//判断是否关联了该项目工料机
|
|
@@ -608,6 +608,7 @@ ProjectGLJ.prototype.m_updateUnitPrice = function (datas,isFromFeeRate) {//批
|
|
|
//socket推送更新信息
|
|
//socket推送更新信息
|
|
|
projectGljObject.onUnitFileChange(isFromFeeRate?false:true);//如果是从更新费率过来的,不用在项目属性上做标记,费率那里已经自动计算所有节点了
|
|
projectGljObject.onUnitFileChange(isFromFeeRate?false:true);//如果是从更新费率过来的,不用在项目属性上做标记,费率那里已经自动计算所有节点了
|
|
|
|
|
|
|
|
|
|
+ return gljList
|
|
|
|
|
|
|
|
function updateUnit(id,unitPrice) {
|
|
function updateUnit(id,unitPrice) {
|
|
|
let glj = _.find(me.datas.gljList,{'id':id});
|
|
let glj = _.find(me.datas.gljList,{'id':id});
|
|
@@ -740,15 +741,17 @@ ProjectGLJ.prototype.refreshEctrovalenceCache = function (updateMap) {
|
|
|
|
|
|
|
|
|
|
|
|
|
ProjectGLJ.prototype.refreshMaterialCalcCache = function (updateMap,isFromFeeRate = false){//从费率计算过来的时候,费率那里已经做了自动计算所有节点了
|
|
ProjectGLJ.prototype.refreshMaterialCalcCache = function (updateMap,isFromFeeRate = false){//从费率计算过来的时候,费率那里已经做了自动计算所有节点了
|
|
|
- if(updateMap["freight"]) updateList(this.datas.freightList,updateMap["freight"]);
|
|
|
|
|
|
|
+ let gljList = [];
|
|
|
|
|
+ if(updateMap["freight"]) updateList(this.datas.freightList,updateMap["freight"]);
|
|
|
if(updateMap["price"]) updateList(this.datas.originalList,updateMap["price"]);
|
|
if(updateMap["price"]) updateList(this.datas.originalList,updateMap["price"]);
|
|
|
if(updateMap["unitPrice"]) {
|
|
if(updateMap["unitPrice"]) {
|
|
|
if(Array.isArray(updateMap["unitPrice"])){
|
|
if(Array.isArray(updateMap["unitPrice"])){
|
|
|
- this.m_updateUnitPrice(updateMap["unitPrice"],isFromFeeRate);
|
|
|
|
|
|
|
+ gljList = this.m_updateUnitPrice(updateMap["unitPrice"],isFromFeeRate);
|
|
|
}else {
|
|
}else {
|
|
|
- this.m_updateUnitPrice([updateMap["unitPrice"]],isFromFeeRate);
|
|
|
|
|
|
|
+ gljList = this.m_updateUnitPrice([updateMap["unitPrice"]],isFromFeeRate);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ return gljList;
|
|
|
|
|
|
|
|
function updateList(list,updateMap) {
|
|
function updateList(list,updateMap) {
|
|
|
if(updateMap["update"]){
|
|
if(updateMap["update"]){
|
|
@@ -814,7 +817,7 @@ ProjectGLJ.prototype.changeAssistProductionFeeRate = async function (newFeeRate)
|
|
|
await ajaxPost("/glj/changeAssistProductionFeeRate",{unitFileID:projectObj.project.property.unitPriceFile.id,assistProductionFeeRate:newFeeRate});
|
|
await ajaxPost("/glj/changeAssistProductionFeeRate",{unitFileID:projectObj.project.property.unitPriceFile.id,assistProductionFeeRate:newFeeRate});
|
|
|
this.datas.constData.assistProductionFeeRate = newFeeRate;
|
|
this.datas.constData.assistProductionFeeRate = newFeeRate;
|
|
|
//todo 调用材料计算方法,所有材料重算一遍
|
|
//todo 调用材料计算方法,所有材料重算一遍
|
|
|
- let [unitPrices,sumMap] = this.calcAllMaterial([]);
|
|
|
|
|
|
|
+ let [unitPrices,sumMap] = this.calcAllMaterial([],true);
|
|
|
sumMap["unitPrice"] = unitPrices;
|
|
sumMap["unitPrice"] = unitPrices;
|
|
|
let result = await ajaxPost('/glj/updateMaterialCalcTasks',sumMap);
|
|
let result = await ajaxPost('/glj/updateMaterialCalcTasks',sumMap);
|
|
|
this.refreshMaterialCalcCache(sumMap);
|
|
this.refreshMaterialCalcCache(sumMap);
|
|
@@ -826,18 +829,20 @@ ProjectGLJ.prototype.changeAssistProductionFeeRate = async function (newFeeRate)
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-ProjectGLJ.prototype.calcAllWhenFeeRateChange = async function(){//当高原相关费率改变时,重新计算所有材料
|
|
|
|
|
|
|
+ProjectGLJ.prototype.calcAllMaterialWhenChange = async function(){//当费率单价等改变时,重新计算所有材料 返回价格有变化的项目工料机
|
|
|
|
|
+ let gljList = [];
|
|
|
try {
|
|
try {
|
|
|
let [unitPrices,sumMap] = this.calcAllMaterial([],true);
|
|
let [unitPrices,sumMap] = this.calcAllMaterial([],true);
|
|
|
if(unitPrices.length > 0){
|
|
if(unitPrices.length > 0){
|
|
|
sumMap["unitPrice"] = unitPrices;
|
|
sumMap["unitPrice"] = unitPrices;
|
|
|
let result = await ajaxPost('/glj/updateMaterialCalcTasks',sumMap);
|
|
let result = await ajaxPost('/glj/updateMaterialCalcTasks',sumMap);
|
|
|
- this.refreshMaterialCalcCache(sumMap,true);
|
|
|
|
|
- materialCalcObj.showDatas();
|
|
|
|
|
|
|
+ gljList = this.refreshMaterialCalcCache(sumMap,true);
|
|
|
|
|
+ materialCalcObj.showDatas();
|
|
|
}
|
|
}
|
|
|
-}catch (err){
|
|
|
|
|
- console.log(err);
|
|
|
|
|
-}
|
|
|
|
|
|
|
+ }catch (err){
|
|
|
|
|
+ console.log(err);
|
|
|
|
|
+ }
|
|
|
|
|
+ return gljList
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ProjectGLJ.prototype.loadFreightAndOriginalData = function(originalList,freightList){
|
|
ProjectGLJ.prototype.loadFreightAndOriginalData = function(originalList,freightList){
|
|
@@ -947,9 +952,12 @@ ProjectGLJ.prototype.calcEachFreightOrPrice = function (temp,type,priceMap) {//
|
|
|
}
|
|
}
|
|
|
sum = scMathUtil.roundForObj(sum,decimal)+"";
|
|
sum = scMathUtil.roundForObj(sum,decimal)+"";
|
|
|
if(type == "freight"){
|
|
if(type == "freight"){
|
|
|
- let exp = `((${expList.join("+")})+${temp.otherFee})x${temp.weightCoe}`
|
|
|
|
|
- return {ID:temp.ID,doc:{unitFreight:sum,heightFee:heightFee,exp:exp}};
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ let exp = `((${expList.join("+")})+${temp.otherFee})x${temp.weightCoe}`
|
|
|
|
|
+ let ndoc = {};
|
|
|
|
|
+ if(temp.unitFreight != sum) ndoc['unitFreight'] = sum;
|
|
|
|
|
+ if(temp.exp != exp) ndoc['exp'] = exp;
|
|
|
|
|
+ if(!_.isEmpty(ndoc)) return {ID:temp.ID,doc:ndoc};
|
|
|
|
|
+ }
|
|
|
if(type == "price" && temp.supplyPrice !=sum) return {ID:temp.ID,doc:{supplyPrice:sum,heightFee:heightFee}}
|
|
if(type == "price" && temp.supplyPrice !=sum) return {ID:temp.ID,doc:{supplyPrice:sum,heightFee:heightFee}}
|
|
|
}
|
|
}
|
|
|
return null;
|
|
return null;
|
|
@@ -1114,7 +1122,7 @@ ProjectGLJ.prototype.updatePrice = function (recode, updateField, newval,from,cb
|
|
|
let ext =electrovalenceObj.clacNewElecPrice(uobj);
|
|
let ext =electrovalenceObj.clacNewElecPrice(uobj);
|
|
|
if(ext) data.ext = ext;
|
|
if(ext) data.ext = ext;
|
|
|
}
|
|
}
|
|
|
- let callback = function (result) {
|
|
|
|
|
|
|
+ let callback =async function (result) {
|
|
|
if (updateField == 'base_price') {
|
|
if (updateField == 'base_price') {
|
|
|
glj.unit_price.base_price = newval;
|
|
glj.unit_price.base_price = newval;
|
|
|
me.setAdjustPrice(glj);
|
|
me.setAdjustPrice(glj);
|
|
@@ -1129,6 +1137,9 @@ ProjectGLJ.prototype.updatePrice = function (recode, updateField, newval,from,cb
|
|
|
//更新回传的父节点项目工料机价格
|
|
//更新回传的父节点项目工料机价格
|
|
|
let gljs = me.getProjectGLJs(result);
|
|
let gljs = me.getProjectGLJs(result);
|
|
|
// me.refreshRationGLJPrice(glj);//刷新定额工料机列表的记录
|
|
// me.refreshRationGLJPrice(glj);//刷新定额工料机列表的记录
|
|
|
|
|
+ let materialGljList =await me.calcAllMaterialWhenChange()
|
|
|
|
|
+ gljs= gljs.concat(materialGljList);
|
|
|
|
|
+
|
|
|
projectGljObject.refreshDataSheet();//更新工料机汇总缓存和显示
|
|
projectGljObject.refreshDataSheet();//更新工料机汇总缓存和显示
|
|
|
//projectObj.project.projectGLJ.loadCacheData();
|
|
//projectObj.project.projectGLJ.loadCacheData();
|
|
|
gljOprObj.showRationGLJSheetData();
|
|
gljOprObj.showRationGLJSheetData();
|
|
@@ -1137,7 +1148,7 @@ ProjectGLJ.prototype.updatePrice = function (recode, updateField, newval,from,cb
|
|
|
if(elec_glj) gljs.push(elec_glj);
|
|
if(elec_glj) gljs.push(elec_glj);
|
|
|
let nodes = me.getImpactRationNodes(gljs);//取到因为改变工料机价格而受影响的定额
|
|
let nodes = me.getImpactRationNodes(gljs);//取到因为改变工料机价格而受影响的定额
|
|
|
projectObj.project.calcProgram.calcNodesAndSave(nodes);//触发计算程序
|
|
projectObj.project.calcProgram.calcNodesAndSave(nodes);//触发计算程序
|
|
|
- projectGljObject.onUnitFileChange(result);
|
|
|
|
|
|
|
+ if(materialGljList.length==0)projectGljObject.onUnitFileChange(result);
|
|
|
if(cb){
|
|
if(cb){
|
|
|
cb(gljs);
|
|
cb(gljs);
|
|
|
}
|
|
}
|
|
@@ -1226,7 +1237,7 @@ ProjectGLJ.prototype.batchUpdatePrice = function (changeInfo,sheetName,callback)
|
|
|
}
|
|
}
|
|
|
if(updateData.length > 0){
|
|
if(updateData.length > 0){
|
|
|
$.bootstrapLoading.start();
|
|
$.bootstrapLoading.start();
|
|
|
- CommonAjax.post("/glj/batchUpdatePrices", updateData, function (result) {
|
|
|
|
|
|
|
+ CommonAjax.post("/glj/batchUpdatePrices", updateData,async function (result) {
|
|
|
let parentData = [];
|
|
let parentData = [];
|
|
|
//更新缓存
|
|
//更新缓存
|
|
|
for(let g of gljs){
|
|
for(let g of gljs){
|
|
@@ -1244,10 +1255,12 @@ ProjectGLJ.prototype.batchUpdatePrice = function (changeInfo,sheetName,callback)
|
|
|
}
|
|
}
|
|
|
let pgljs = me.getProjectGLJs(parentData);
|
|
let pgljs = me.getProjectGLJs(parentData);
|
|
|
gljs = gljs.concat(pgljs);
|
|
gljs = gljs.concat(pgljs);
|
|
|
|
|
+ let materialGljList = await me.calcAllMaterialWhenChange();
|
|
|
|
|
+ gljs = gljs.concat(materialGljList);
|
|
|
let nodes = me.getImpactRationNodes(gljs);//取到因为改变工料机价格而受影响的定额
|
|
let nodes = me.getImpactRationNodes(gljs);//取到因为改变工料机价格而受影响的定额
|
|
|
projectObj.project.calcProgram.calcNodesAndSave(nodes);//触发计算程序
|
|
projectObj.project.calcProgram.calcNodesAndSave(nodes);//触发计算程序
|
|
|
gljOprObj.showRationGLJSheetData();
|
|
gljOprObj.showRationGLJSheetData();
|
|
|
- projectGljObject.onUnitFileChange(gljs);
|
|
|
|
|
|
|
+ if(materialGljList.length == 0) projectGljObject.onUnitFileChange(gljs);
|
|
|
if(callback){
|
|
if(callback){
|
|
|
callback(gljs);
|
|
callback(gljs);
|
|
|
}
|
|
}
|
|
@@ -1379,65 +1392,6 @@ ProjectGLJ.prototype.changeVvTaxFile = async function (newVvTaxFileID,callback)
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-ProjectGLJ.prototype.addMixRatio = function(selections,callback){
|
|
|
|
|
- let gljList = [],allGLJ = gljOprObj.AllRecode;
|
|
|
|
|
- if(selections.length == 0) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- for(let glj of allGLJ){
|
|
|
|
|
- let i_key = gljOprObj.getIndex(glj, gljLibKeyArray);
|
|
|
|
|
- if(_.includes(selections,i_key)){
|
|
|
|
|
- let pglj = {
|
|
|
|
|
- project_id: projectObj.project.ID(),
|
|
|
|
|
- glj_id: glj.ID,
|
|
|
|
|
- name: glj.name,
|
|
|
|
|
- code: glj.code,
|
|
|
|
|
- original_code: glj.code,
|
|
|
|
|
- unit: glj.unit,
|
|
|
|
|
- specs: glj.specs,
|
|
|
|
|
- base_price: glj.basePrice,
|
|
|
|
|
- market_price: glj.basePrice,
|
|
|
|
|
- shortName: glj.shortName,
|
|
|
|
|
- type: glj.gljType,
|
|
|
|
|
- model:glj.model,
|
|
|
|
|
- adjCoe: glj.adjCoe,
|
|
|
|
|
- from:'std',
|
|
|
|
|
- repositoryId:glj.repositoryId,
|
|
|
|
|
- materialType:glj.materialType,
|
|
|
|
|
- materialCoe:glj.materialCoe,
|
|
|
|
|
- grossWeightCoe:glj.grossWeightCoe,
|
|
|
|
|
- purchaseStorageRate:glj.purchaseStorageRate,
|
|
|
|
|
- offSiteTransportLossRate:glj.offSiteTransportLossRate,
|
|
|
|
|
- handlingLossRate:glj.handlingLossRate
|
|
|
|
|
- };
|
|
|
|
|
- if (glj.hasOwnProperty("compilationId")) {
|
|
|
|
|
- pglj.from = "cpt";
|
|
|
|
|
- if (glj.code.indexOf('-') != -1) {//这条工料机是用户通过修改名称、规格、型号等保存到补充工料机库的
|
|
|
|
|
- pglj.original_code = glj.code.split('-')[0];//取-前的编号作为原始编号
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- gljList.push(pglj);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- gljList = _.sortByAll(gljList, ['type', 'code']);
|
|
|
|
|
- if(gljList.length == 0) return;
|
|
|
|
|
- let praentInfo = {
|
|
|
|
|
- unit_price_file_id:projectObj.project.property.unitPriceFile.id,
|
|
|
|
|
- connect_key:gljOprObj.getIndex(projectGljObject.selectedProjectGLJ,gljKeyArray)
|
|
|
|
|
- };
|
|
|
|
|
- $.bootstrapLoading.start();
|
|
|
|
|
- CommonAjax.post("/glj/add-ratio", {gljList:gljList,parentInfo:praentInfo}, function (data) {
|
|
|
|
|
- $.bootstrapLoading.end();
|
|
|
|
|
- if(callback){
|
|
|
|
|
- callback(data);
|
|
|
|
|
- }
|
|
|
|
|
- }, function () {
|
|
|
|
|
- $.bootstrapLoading.end();
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
ProjectGLJ.prototype.checkUnitFileName = function(newVal,callback){
|
|
ProjectGLJ.prototype.checkUnitFileName = function(newVal,callback){
|
|
|
let property = projectObj.project.projectInfo.property;
|
|
let property = projectObj.project.projectInfo.property;
|
|
|
let data = {
|
|
let data = {
|