|
@@ -132,7 +132,7 @@ ProjectGLJ.prototype.updateData = function (id, data) {
|
|
*
|
|
*
|
|
* @return {void}
|
|
* @return {void}
|
|
*/
|
|
*/
|
|
-ProjectGLJ.prototype.loadCacheData = function () {
|
|
|
|
|
|
+ProjectGLJ.prototype.loadCacheData = function (resort) {
|
|
// 加载工料机数据
|
|
// 加载工料机数据
|
|
let data = this.datas === null ? null : this.datas;
|
|
let data = this.datas === null ? null : this.datas;
|
|
if (data === null) {
|
|
if (data === null) {
|
|
@@ -141,16 +141,18 @@ ProjectGLJ.prototype.loadCacheData = function () {
|
|
jsonData = data.gljList !== undefined && data.gljList.length > 0 ? data.gljList : [];
|
|
jsonData = data.gljList !== undefined && data.gljList.length > 0 ? data.gljList : [];
|
|
jsonData = filterProjectGLJ(jsonData);
|
|
jsonData = filterProjectGLJ(jsonData);
|
|
jsonData = sortProjectGLJ(jsonData);
|
|
jsonData = sortProjectGLJ(jsonData);
|
|
- projectGLJSheet.setData(jsonData);
|
|
|
|
- projectGLJSpread.specialColumn(jsonData);
|
|
|
|
|
|
+ if(projectGLJSheet&&projectGLJSpread){
|
|
|
|
+ projectGLJSheet.setData(jsonData);
|
|
|
|
+ projectGLJSpread.specialColumn(jsonData);
|
|
|
|
+ }
|
|
};
|
|
};
|
|
|
|
|
|
ProjectGLJ.prototype.updatePriceFromRG = function (recode, updateField, newval) {
|
|
ProjectGLJ.prototype.updatePriceFromRG = function (recode, updateField, newval) {
|
|
if (updateField == 'marketPrice') {
|
|
if (updateField == 'marketPrice') {
|
|
- this.updateBasePriceFromRG(recode, "market_price", newval);
|
|
|
|
|
|
+ this.updatePrice(recode, "market_price", newval,"rg");
|
|
}
|
|
}
|
|
if (updateField == 'basePrice') {
|
|
if (updateField == 'basePrice') {
|
|
- this.updateBasePriceFromRG(recode, "base_price", newval);
|
|
|
|
|
|
+ this.updatePrice(recode, "base_price", newval,"rg");
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
@@ -223,11 +225,11 @@ ProjectGLJ.prototype.updateGLJProperty = function (node, updateField, newval) {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-ProjectGLJ.prototype.updateBasePriceFromRG = function (recode, updateField, newval) {
|
|
|
|
|
|
+ProjectGLJ.prototype.updatePrice = function (recode, updateField, newval,from) {
|
|
let me = this;
|
|
let me = this;
|
|
let projectGljs = this.datas.gljList;
|
|
let projectGljs = this.datas.gljList;
|
|
- let glj = _.find(projectGljs, {'id': recode.projectGLJID});
|
|
|
|
- console.log(glj);
|
|
|
|
|
|
+ let pgljID = from=="rg"?recode.projectGLJID:recode.id;//和定额工料机统一接口,项目工料机ID取值不一样
|
|
|
|
+ let glj = _.find(projectGljs, {'id': pgljID});
|
|
if (glj) {
|
|
if (glj) {
|
|
let data = {id: glj.unit_price.id, field: updateField, newval: newval};
|
|
let data = {id: glj.unit_price.id, field: updateField, newval: newval};
|
|
let callback = function (data) {
|
|
let callback = function (data) {
|
|
@@ -237,12 +239,14 @@ ProjectGLJ.prototype.updateBasePriceFromRG = function (recode, updateField, newv
|
|
} else {
|
|
} else {
|
|
glj.unit_price.market_price = newval;
|
|
glj.unit_price.market_price = newval;
|
|
}
|
|
}
|
|
- //更新项目工料机价格
|
|
|
|
- me.refreshProjectGLJPrice(data);
|
|
|
|
|
|
+ //更新回传的父节点项目工料机价格
|
|
|
|
+ let gljs = me.getProjectGLJs(data);
|
|
me.refreshRationGLJPrice(glj);//刷新定额工料机列表的记录
|
|
me.refreshRationGLJPrice(glj);//刷新定额工料机列表的记录
|
|
|
|
+ projectObj.project.projectGLJ.loadCacheData();//更新工料机汇总缓存和显示
|
|
gljOprObj.showRationGLJSheetData();
|
|
gljOprObj.showRationGLJSheetData();
|
|
me.refreshTreeNodePriceIfNeed(glj);//刷新造价书中主树上的定额工料机;
|
|
me.refreshTreeNodePriceIfNeed(glj);//刷新造价书中主树上的定额工料机;
|
|
- let nodes = me.getImpactRationNodes(glj);//取到因为改变工料机价格而受影响的定额
|
|
|
|
|
|
+ gljs.push(glj);
|
|
|
|
+ let nodes = me.getImpactRationNodes(gljs);//取到因为改变工料机价格而受影响的定额
|
|
projectObj.project.calcProgram.calcRationsAndSave(nodes);//触发计算程序
|
|
projectObj.project.calcProgram.calcRationsAndSave(nodes);//触发计算程序
|
|
$.bootstrapLoading.end();
|
|
$.bootstrapLoading.end();
|
|
}
|
|
}
|
|
@@ -254,8 +258,10 @@ ProjectGLJ.prototype.updateBasePriceFromRG = function (recode, updateField, newv
|
|
gljOprObj.showRationGLJSheetData();
|
|
gljOprObj.showRationGLJSheetData();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
ProjectGLJ.prototype.refreshTreeNodePriceIfNeed = function (data) {
|
|
ProjectGLJ.prototype.refreshTreeNodePriceIfNeed = function (data) {
|
|
- if ((data.unit_price.type = gljType.MAIN_MATERIAL || data.unit_price.type == gljType.EQUIPMENT) && projectInfoObj.projectInfo.property.displaySetting.disPlayMainMaterial == true) {
|
|
|
|
|
|
+ if ((data.unit_price.type == gljType.MAIN_MATERIAL || data.unit_price.type == gljType.EQUIPMENT) && projectInfoObj.projectInfo.property.displaySetting.disPlayMainMaterial == true) {
|
|
var nodes = _.filter(projectObj.project.mainTree.items, function (tem) {
|
|
var nodes = _.filter(projectObj.project.mainTree.items, function (tem) {
|
|
if (tem.sourceType == ModuleNames.ration_glj && tem.data.projectGLJID == data.id) {
|
|
if (tem.sourceType == ModuleNames.ration_glj && tem.data.projectGLJID == data.id) {
|
|
tem.data.marketUnitFee = data.unit_price.market_price;
|
|
tem.data.marketUnitFee = data.unit_price.market_price;
|
|
@@ -268,21 +274,24 @@ ProjectGLJ.prototype.refreshTreeNodePriceIfNeed = function (data) {
|
|
}
|
|
}
|
|
|
|
|
|
//根据工料机,取得所有受影响的定额节点
|
|
//根据工料机,取得所有受影响的定额节点
|
|
-ProjectGLJ.prototype.getImpactRationNodes = function (glj) {
|
|
|
|
|
|
+ProjectGLJ.prototype.getImpactRationNodes = function (gljs) {
|
|
let nodes = [];
|
|
let nodes = [];
|
|
let rationMap = {};
|
|
let rationMap = {};
|
|
|
|
+ let idArray = _.map(gljs,'id');
|
|
|
|
+ let priceArray = _.map(gljs,'unit_price');
|
|
//先根据项目工料机ID,找到受影响定额的ID
|
|
//先根据项目工料机ID,找到受影响定额的ID
|
|
let ration_glj_list = projectObj.project.ration_glj.datas; //取定额工料机数据
|
|
let ration_glj_list = projectObj.project.ration_glj.datas; //取定额工料机数据
|
|
for (let rg of ration_glj_list) {
|
|
for (let rg of ration_glj_list) {
|
|
- if (rg.projectGLJID == glj.id) {
|
|
|
|
|
|
+ if (_.indexOf(idArray,rg.projectGLJID)!=-1) {
|
|
rationMap[rg.rationID] = true; //取所有定额ID,用MAP方式去重
|
|
rationMap[rg.rationID] = true; //取所有定额ID,用MAP方式去重
|
|
}
|
|
}
|
|
}
|
|
}
|
|
for (let item of projectObj.project.mainTree.items) {
|
|
for (let item of projectObj.project.mainTree.items) {
|
|
if (item.sourceType == ModuleNames.ration) {
|
|
if (item.sourceType == ModuleNames.ration) {
|
|
if (item.data.type == rationType.gljRation) {//取定额类型的工料机
|
|
if (item.data.type == rationType.gljRation) {//取定额类型的工料机
|
|
- if (item.data.projectGLJID == glj.id) {
|
|
|
|
- item.data.marketUnitFee = glj.unit_price.market_price; //更新市场单价
|
|
|
|
|
|
+ let idx = _.indexOf(idArray,item.data.projectGLJID);
|
|
|
|
+ if (idx != -1) {
|
|
|
|
+ item.data.marketUnitFee = priceArray[idx].market_price; //更新市场单价
|
|
nodes.push(item);
|
|
nodes.push(item);
|
|
}
|
|
}
|
|
} else if (rationMap[item.data.ID] == true) { //受影响的定额
|
|
} else if (rationMap[item.data.ID] == true) { //受影响的定额
|
|
@@ -306,11 +315,11 @@ ProjectGLJ.prototype.refreshRationTypeGLJ = function (glj) {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-ProjectGLJ.prototype.refreshProjectGLJPrice = function (data) {
|
|
|
|
|
|
+ProjectGLJ.prototype.getProjectGLJs = function (data,refreshPrice=true) {
|
|
let parentGlj = [];
|
|
let parentGlj = [];
|
|
//
|
|
//
|
|
let projectGljs = this.datas.gljList;
|
|
let projectGljs = this.datas.gljList;
|
|
- let indexList = ['code', 'name', 'specs', 'unit', 'type'];
|
|
|
|
|
|
+ let indexList = gljKeyArray;
|
|
for (let d of data) {
|
|
for (let d of data) {
|
|
if (d) {
|
|
if (d) {
|
|
let condition = {};
|
|
let condition = {};
|
|
@@ -321,11 +330,13 @@ ProjectGLJ.prototype.refreshProjectGLJPrice = function (data) {
|
|
}
|
|
}
|
|
let glj = _.find(projectGljs, condition);
|
|
let glj = _.find(projectGljs, condition);
|
|
if (glj) {
|
|
if (glj) {
|
|
- glj.unit_price.base_price = d.base_price;
|
|
|
|
- glj.unit_price.market_price = d.market_price;
|
|
|
|
- this.setAdjustPrice(glj);
|
|
|
|
- this.refreshRationGLJPrice(glj);
|
|
|
|
- this.refreshTreeNodePriceIfNeed(glj);
|
|
|
|
|
|
+ if(refreshPrice==true){
|
|
|
|
+ glj.unit_price.base_price = d.base_price;
|
|
|
|
+ glj.unit_price.market_price = d.market_price;
|
|
|
|
+ this.setAdjustPrice(glj);
|
|
|
|
+ this.refreshRationGLJPrice(glj);
|
|
|
|
+ this.refreshTreeNodePriceIfNeed(glj);
|
|
|
|
+ }
|
|
parentGlj.push(glj);
|
|
parentGlj.push(glj);
|
|
}
|
|
}
|
|
}
|
|
}
|