|
@@ -27,13 +27,13 @@ ProjectGLJ.prototype.loadData = function (callback = null) {
|
|
|
type: 'post',
|
|
|
dataType: 'json',
|
|
|
data: {project_id: scUrlUtil.GetQueryString('project')},
|
|
|
- error: function() {
|
|
|
+ error: function () {
|
|
|
// alert('数据传输错误');
|
|
|
},
|
|
|
- beforeSend: function() {
|
|
|
+ beforeSend: function () {
|
|
|
self.isLoading = true;
|
|
|
},
|
|
|
- success: function(response) {
|
|
|
+ success: function (response) {
|
|
|
self.isLoading = false;
|
|
|
if (response.err === 1) {
|
|
|
let msg = response.msg !== undefined && response.msg !== '' ? response.msg : '读取工料机数据失败!';
|
|
@@ -53,7 +53,7 @@ ProjectGLJ.prototype.loadData = function (callback = null) {
|
|
|
|
|
|
ProjectGLJ.prototype.loadToCache = function (data) {
|
|
|
this.datas = data;
|
|
|
- projectObj.project.projectGLJ=this;
|
|
|
+ projectObj.project.projectGLJ = this;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -74,7 +74,7 @@ ProjectGLJ.prototype.getDataByCode = function (code) {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- for(let tmp of gljList) {
|
|
|
+ for (let tmp of gljList) {
|
|
|
if (tmp.code === code) {
|
|
|
result = tmp;
|
|
|
break;
|
|
@@ -91,7 +91,7 @@ ProjectGLJ.prototype.getDataByCode = function (code) {
|
|
|
* @param {Object} data
|
|
|
* @return {boolean}
|
|
|
*/
|
|
|
-ProjectGLJ.prototype.updateData = function(id, data) {
|
|
|
+ProjectGLJ.prototype.updateData = function (id, data) {
|
|
|
let result = false;
|
|
|
if (this.datas === null) {
|
|
|
return result;
|
|
@@ -104,7 +104,7 @@ ProjectGLJ.prototype.updateData = function(id, data) {
|
|
|
|
|
|
// 查找对应的index
|
|
|
let index = -1;
|
|
|
- for(let tmp in gljList) {
|
|
|
+ for (let tmp in gljList) {
|
|
|
if (gljList[tmp].id === id) {
|
|
|
index = tmp;
|
|
|
break;
|
|
@@ -116,8 +116,8 @@ ProjectGLJ.prototype.updateData = function(id, data) {
|
|
|
}
|
|
|
|
|
|
// 修改数据
|
|
|
- for(let tmpIndex in data) {
|
|
|
- if(tmpIndex.indexOf('_price') >= 0) {
|
|
|
+ for (let tmpIndex in data) {
|
|
|
+ if (tmpIndex.indexOf('_price') >= 0) {
|
|
|
// 修改unit_price中的对象
|
|
|
this.datas.gljList[index]['unit_price'][tmpIndex] = data[tmpIndex];
|
|
|
} else {
|
|
@@ -132,110 +132,110 @@ ProjectGLJ.prototype.updateData = function(id, data) {
|
|
|
*
|
|
|
* @return {void}
|
|
|
*/
|
|
|
-ProjectGLJ.prototype.loadCacheData = function() {
|
|
|
+ProjectGLJ.prototype.loadCacheData = function () {
|
|
|
// 加载工料机数据
|
|
|
let data = this.datas === null ? null : this.datas;
|
|
|
if (data === null) {
|
|
|
return;
|
|
|
}
|
|
|
jsonData = data.gljList !== undefined && data.gljList.length > 0 ? data.gljList : [];
|
|
|
- jsonData=filterProjectGLJ(jsonData);
|
|
|
+ jsonData = filterProjectGLJ(jsonData);
|
|
|
jsonData = sortProjectGLJ(jsonData);
|
|
|
projectGLJSheet.setData(jsonData);
|
|
|
projectGLJSpread.specialColumn(jsonData);
|
|
|
};
|
|
|
|
|
|
-ProjectGLJ.prototype.updatePriceFromRG=function(recode,updateField,newval){
|
|
|
- if(updateField=='marketPrice'){
|
|
|
- this.updateBasePriceFromRG(recode,"market_price",newval);
|
|
|
+ProjectGLJ.prototype.updatePriceFromRG = function (recode, updateField, newval) {
|
|
|
+ if (updateField == 'marketPrice') {
|
|
|
+ this.updateBasePriceFromRG(recode, "market_price", newval);
|
|
|
}
|
|
|
- if(updateField=='basePrice'){
|
|
|
- this.updateBasePriceFromRG(recode,"base_price",newval);
|
|
|
+ if (updateField == 'basePrice') {
|
|
|
+ this.updateBasePriceFromRG(recode, "base_price", newval);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-ProjectGLJ.prototype.updatePropertyFromMainSpread = function (node,updateField,newval) {
|
|
|
- if(updateField=="contain"){
|
|
|
+ProjectGLJ.prototype.updatePropertyFromMainSpread = function (node, updateField, newval) {
|
|
|
+ if (updateField == "contain") {
|
|
|
|
|
|
- }else {
|
|
|
- this.updateGLJProperty(node,updateField,newval);
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ this.updateGLJProperty(node, updateField, newval);
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
|
|
|
-ProjectGLJ.prototype.updateGLJProperty=function (node,updateField,newval) {
|
|
|
+ProjectGLJ.prototype.updateGLJProperty = function (node, updateField, newval) {
|
|
|
let rationTypeGLJ = node.data;
|
|
|
let postData = {};
|
|
|
- if(rationTypeGLJ[updateField]==newval){
|
|
|
+ if (rationTypeGLJ[updateField] == newval) {
|
|
|
return;
|
|
|
}
|
|
|
- let data ={
|
|
|
+ let data = {
|
|
|
glj_id: rationTypeGLJ.GLJID,
|
|
|
project_id: rationTypeGLJ.projectID,
|
|
|
code: rationTypeGLJ.code,
|
|
|
- original_code:rationTypeGLJ.original_code,
|
|
|
+ original_code: rationTypeGLJ.original_code,
|
|
|
name: rationTypeGLJ.name,
|
|
|
- shortName:rationTypeGLJ.shortName,
|
|
|
+ shortName: rationTypeGLJ.shortName,
|
|
|
specs: rationTypeGLJ.specs,
|
|
|
unit: rationTypeGLJ.unit,
|
|
|
- type:rationTypeGLJ.subType,
|
|
|
- type_of_work:rationTypeGLJ.subType,
|
|
|
+ type: rationTypeGLJ.subType,
|
|
|
+ type_of_work: rationTypeGLJ.subType,
|
|
|
base_price: rationTypeGLJ.basePrice,
|
|
|
market_price: rationTypeGLJ.basePrice,
|
|
|
- repositoryId:rationTypeGLJ.repositoryId,
|
|
|
- adjCoe:rationTypeGLJ.adjCoe,
|
|
|
- from:rationTypeGLJ.from?rationTypeGLJ.from:'std'//std:标准工料机库, cpt:补充工料机库
|
|
|
+ repositoryId: rationTypeGLJ.repositoryId,
|
|
|
+ adjCoe: rationTypeGLJ.adjCoe,
|
|
|
+ from: rationTypeGLJ.from ? rationTypeGLJ.from : 'std'//std:标准工料机库, cpt:补充工料机库
|
|
|
};
|
|
|
- if(updateField=='subType'){
|
|
|
+ if (updateField == 'subType') {
|
|
|
data.type = newval;
|
|
|
data.type_of_work = newval;
|
|
|
data.shortName = this.getShortNameByID(newval);
|
|
|
- }else {
|
|
|
- data[updateField]=newval;
|
|
|
+ } else {
|
|
|
+ data[updateField] = newval;
|
|
|
}
|
|
|
postData.ration = {
|
|
|
- ID:rationTypeGLJ.ID,
|
|
|
- projectID:rationTypeGLJ.projectID
|
|
|
+ ID: rationTypeGLJ.ID,
|
|
|
+ projectID: rationTypeGLJ.projectID
|
|
|
};
|
|
|
postData.updateData = data;
|
|
|
$.bootstrapLoading.start();
|
|
|
- CommonAjax.post("/glj/modifyKeyValue",postData,function (result) {
|
|
|
+ CommonAjax.post("/glj/modifyKeyValue", postData, function (result) {
|
|
|
console.log(result); //更新节点信息
|
|
|
- rationTypeGLJ[updateField]=newval;
|
|
|
+ rationTypeGLJ[updateField] = newval;
|
|
|
rationTypeGLJ.projectGLJID = result.id;
|
|
|
rationTypeGLJ.code = result.code;
|
|
|
rationTypeGLJ.basePrice = result.unit_price.base_price;
|
|
|
rationTypeGLJ.marketUnitFee = result.unit_price.market_price;
|
|
|
rationTypeGLJ.isAdd = result.unit_price.is_add;
|
|
|
- rationTypeGLJ.isEstimate=result.is_evaluate;
|
|
|
+ rationTypeGLJ.isEstimate = result.is_evaluate;
|
|
|
rationTypeGLJ.shortName = result.unit_price.short_name;
|
|
|
//触发计算并更新节点信息
|
|
|
- node.changed=true;
|
|
|
+ node.changed = true;
|
|
|
projectObj.project.projectGLJ.loadData(function () {
|
|
|
projectObj.project.calcProgram.calculate(node);
|
|
|
projectObj.project.calcProgram.saveNode(node);
|
|
|
$.bootstrapLoading.end();
|
|
|
});//重新加载项目工料机数据
|
|
|
//上面两步都是异步操作,这句应该是要等上面两步做完了再执行的
|
|
|
- },function (err) {
|
|
|
+ }, function (err) {
|
|
|
$.bootstrapLoading.end();
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-ProjectGLJ.prototype.updateBasePriceFromRG=function(recode,updateField,newval){
|
|
|
+ProjectGLJ.prototype.updateBasePriceFromRG = function (recode, updateField, newval) {
|
|
|
let me = this;
|
|
|
let projectGljs = this.datas.gljList;
|
|
|
- let glj = _.find(projectGljs,{'id':recode.projectGLJID});
|
|
|
+ let glj = _.find(projectGljs, {'id': recode.projectGLJID});
|
|
|
console.log(glj);
|
|
|
- if(glj){
|
|
|
- let data = {id:glj.unit_price.id,field:updateField,newval:newval};
|
|
|
- let callback =function (data) {
|
|
|
- if(updateField=='base_price'){
|
|
|
- glj.unit_price.base_price=newval;
|
|
|
+ if (glj) {
|
|
|
+ let data = {id: glj.unit_price.id, field: updateField, newval: newval};
|
|
|
+ let callback = function (data) {
|
|
|
+ if (updateField == 'base_price') {
|
|
|
+ glj.unit_price.base_price = newval;
|
|
|
me.setAdjustPrice(glj);
|
|
|
- }else {
|
|
|
- glj.unit_price.market_price=newval;
|
|
|
+ } else {
|
|
|
+ glj.unit_price.market_price = newval;
|
|
|
}
|
|
|
//更新项目工料机价格
|
|
|
me.refreshProjectGLJPrice(data);
|
|
@@ -247,17 +247,17 @@ ProjectGLJ.prototype.updateBasePriceFromRG=function(recode,updateField,newval){
|
|
|
$.bootstrapLoading.end();
|
|
|
}
|
|
|
$.bootstrapLoading.start();
|
|
|
- CommonAjax.post("/glj/updatePrice",data,callback,function (err) {
|
|
|
+ CommonAjax.post("/glj/updatePrice", data, callback, function (err) {
|
|
|
$.bootstrapLoading.end();
|
|
|
});
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
gljOprObj.showRationGLJSheetData();
|
|
|
}
|
|
|
}
|
|
|
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){
|
|
|
- var nodes = _.filter(projectObj.project.mainTree.items,function (tem) {
|
|
|
- if(tem.sourceType==ModuleNames.ration_glj&&tem.data.projectGLJID ==data.id){
|
|
|
+ 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) {
|
|
|
+ if (tem.sourceType == ModuleNames.ration_glj && tem.data.projectGLJID == data.id) {
|
|
|
tem.data.marketUnitFee = data.unit_price.market_price;
|
|
|
return true;
|
|
|
}
|
|
@@ -269,35 +269,35 @@ ProjectGLJ.prototype.refreshTreeNodePriceIfNeed = function (data) {
|
|
|
|
|
|
//根据工料机,取得所有受影响的定额节点
|
|
|
ProjectGLJ.prototype.getImpactRationNodes = function (glj) {
|
|
|
- let nodes=[];
|
|
|
+ let nodes = [];
|
|
|
let rationMap = {};
|
|
|
//先根据项目工料机ID,找到受影响定额的ID
|
|
|
- let ration_glj_list =projectObj.project.ration_glj.datas; //取定额工料机数据
|
|
|
- for(let rg of ration_glj_list){
|
|
|
- if(rg.projectGLJID==glj.id){
|
|
|
+ let ration_glj_list = projectObj.project.ration_glj.datas; //取定额工料机数据
|
|
|
+ for (let rg of ration_glj_list) {
|
|
|
+ if (rg.projectGLJID == glj.id) {
|
|
|
rationMap[rg.rationID] = true; //取所有定额ID,用MAP方式去重
|
|
|
}
|
|
|
}
|
|
|
- for(let item of projectObj.project.mainTree.items){
|
|
|
- if(item.sourceType==ModuleNames.ration){
|
|
|
- if(item.data.type==rationType.gljRation){//取定额类型的工料机
|
|
|
- if(item.data.projectGLJID == glj.id){
|
|
|
+ for (let item of projectObj.project.mainTree.items) {
|
|
|
+ if (item.sourceType == ModuleNames.ration) {
|
|
|
+ if (item.data.type == rationType.gljRation) {//取定额类型的工料机
|
|
|
+ if (item.data.projectGLJID == glj.id) {
|
|
|
item.data.marketUnitFee = glj.unit_price.market_price; //更新市场单价
|
|
|
nodes.push(item);
|
|
|
}
|
|
|
- }else if( rationMap[item.data.ID]==true){ //受影响的定额
|
|
|
- nodes.push(item)
|
|
|
+ } else if (rationMap[item.data.ID] == true) { //受影响的定额
|
|
|
+ nodes.push(item)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return nodes;
|
|
|
};
|
|
|
-ProjectGLJ.prototype.refreshRationGLJPrice=function (glj) {
|
|
|
- for(let ration_glj of gljOprObj.sheetData){
|
|
|
- if(ration_glj.projectGLJID ==glj.id){
|
|
|
- ration_glj.basePrice=glj.unit_price.base_price;
|
|
|
- ration_glj.marketPrice=glj.unit_price.market_price;
|
|
|
- ration_glj.adjustPrice=this.getAdjustPrice(glj);
|
|
|
+ProjectGLJ.prototype.refreshRationGLJPrice = function (glj) {
|
|
|
+ for (let ration_glj of gljOprObj.sheetData) {
|
|
|
+ if (ration_glj.projectGLJID == glj.id) {
|
|
|
+ ration_glj.basePrice = glj.unit_price.base_price;
|
|
|
+ ration_glj.marketPrice = glj.unit_price.market_price;
|
|
|
+ ration_glj.adjustPrice = this.getAdjustPrice(glj);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -306,19 +306,19 @@ ProjectGLJ.prototype.refreshRationTypeGLJ = function (glj) {
|
|
|
|
|
|
}
|
|
|
|
|
|
-ProjectGLJ.prototype.refreshProjectGLJPrice=function(data){
|
|
|
+ProjectGLJ.prototype.refreshProjectGLJPrice = function (data) {
|
|
|
let projectGljs = this.datas.gljList;
|
|
|
- let indexList = ['code','name','specs','unit','type'];
|
|
|
- for(let d of data){
|
|
|
- if(d){
|
|
|
+ let indexList = ['code', 'name', 'specs', 'unit', 'type'];
|
|
|
+ for (let d of data) {
|
|
|
+ if (d) {
|
|
|
let condition = {};
|
|
|
- for(let index of indexList){
|
|
|
- if(d[index]!=null&&d[index]!=undefined&&d[index]!=''){
|
|
|
- condition[index]=d[index]
|
|
|
+ for (let index of indexList) {
|
|
|
+ if (d[index] != null && d[index] != undefined && d[index] != '') {
|
|
|
+ condition[index] = d[index]
|
|
|
}
|
|
|
}
|
|
|
- let glj = _.find(projectGljs,condition);
|
|
|
- if(glj){
|
|
|
+ let glj = _.find(projectGljs, condition);
|
|
|
+ if (glj) {
|
|
|
glj.unit_price.base_price = d.base_price;
|
|
|
glj.unit_price.market_price = d.market_price;
|
|
|
this.setAdjustPrice(glj);
|
|
@@ -329,7 +329,7 @@ ProjectGLJ.prototype.refreshProjectGLJPrice=function(data){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-ProjectGLJ.prototype.setAdjustPrice=function(glj){
|
|
|
+ProjectGLJ.prototype.setAdjustPrice = function (glj) {
|
|
|
switch (glj.unit_price.type + '') {
|
|
|
// 人工: 调整基价=基价单价*调整系数
|
|
|
case GLJTypeConst.LABOUR:
|
|
@@ -348,18 +348,34 @@ ProjectGLJ.prototype.setAdjustPrice=function(glj){
|
|
|
|
|
|
ProjectGLJ.prototype.getAdjustPrice = function (glj) {
|
|
|
GLJTypeConst = this.datas.constData.GLJTypeConst !== undefined ? JSON.parse(this.datas.constData.GLJTypeConst) : GLJTypeConst;
|
|
|
- if(glj.unit_price.type==GLJTypeConst.LABOUR||glj.unit_price.type==GLJTypeConst.MACHINE_LABOUR){
|
|
|
+ let decimal = getDecimal("glj.unitPrice");
|
|
|
+ let quantity_decimal = getDecimal("glj.quantity")
|
|
|
+ if (glj.unit_price.type == GLJTypeConst.LABOUR || glj.unit_price.type == GLJTypeConst.MACHINE_LABOUR) {//人工、机上人工,调整价根据定额价*调整系数计算得出。
|
|
|
let labour = projectObj.project.calcProgram.compiledLabourCoes[glj.adjCoe];
|
|
|
//let labour=1;
|
|
|
- let coe = labour&&labour.coe?labour.coe:1;
|
|
|
- let decimal = getDecimal("glj.unitPrice");
|
|
|
- return scMathUtil.roundTo(parseFloat(coe*glj.unit_price.base_price),-decimal);
|
|
|
- }else {
|
|
|
+ let coe = labour && labour.coe ? labour.coe : 1;
|
|
|
+ return scMathUtil.roundTo(parseFloat(coe * scMathUtil.roundForObj(glj.unit_price.base_price,decimal)), -decimal);
|
|
|
+ } else if (notEditType.indexOf(glj.unit_price.type)>0) {//对于混凝土、配合比、砂浆、机械台班,调整价根据组成物计算得出。
|
|
|
+ let p =0;
|
|
|
+ for(let ratio of glj.ratio_data){
|
|
|
+ let tem = _.find( projectObj.project.projectGLJ.datas.gljList,{
|
|
|
+ 'code': ratio.code,
|
|
|
+ 'name': ratio.name,
|
|
|
+ 'specs':ratio.specs,
|
|
|
+ 'type': ratio.type,
|
|
|
+ 'unit': ratio.unit
|
|
|
+ })
|
|
|
+ if(tem){
|
|
|
+ p+=scMathUtil.roundForObj(this.getAdjustPrice(tem)*scMathUtil.roundForObj(ratio.consumption,quantity_decimal),decimal);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return scMathUtil.roundForObj(p,decimal);
|
|
|
+ } else {//对于其他普通材料等,无调整系数,调整价=定额价。
|
|
|
return glj.unit_price.base_price
|
|
|
}
|
|
|
}
|
|
|
|
|
|
ProjectGLJ.prototype.getShortNameByID = function (ID) {
|
|
|
let gljTypeMap = this.datas.constData.gljTypeMap;
|
|
|
- return gljTypeMap["typeId"+ID].shortName;
|
|
|
+ return gljTypeMap["typeId" + ID].shortName;
|
|
|
}
|