|
@@ -135,6 +135,7 @@ let projectGljObject={
|
|
|
$("#current-name").text(me.usedUnitPriceInfo.name);
|
|
|
let usedCount = me.usedTenderList.length <= 0 ? 1 : me.usedTenderList.length;
|
|
|
$("#used-project-count").text(usedCount);
|
|
|
+ $("#editUnitFile").attr("href",`/unitPrice/index/${me.usedUnitPriceInfo.id}`)
|
|
|
},
|
|
|
getUsedTenderInfo:function() {
|
|
|
return "人材机单价的变化,将自动影响以下单位工程造价:<br>"+projectGljObject.usedTenderList.join("<br>");
|
|
@@ -177,7 +178,7 @@ let projectGljObject={
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
- addMixRatio:function () {
|
|
|
+ addMixRatio:async function () {
|
|
|
let me = this, projectGLJ = projectObj.project.projectGLJ;
|
|
|
let tdatas = me.mixRatioData;
|
|
|
if(me.subList.length > 0) tdatas = me.subList;
|
|
@@ -186,15 +187,85 @@ let projectGljObject={
|
|
|
let t_index = gljOprObj.GLJSelection.indexOf(m_key);
|
|
|
t_index != -1?gljOprObj.GLJSelection.splice(t_index,1):'';
|
|
|
}
|
|
|
- projectGLJ.addMixRatio(gljOprObj.GLJSelection,function (mixRatios) {
|
|
|
- me.showMixRatioData();//这里添加的组成物的消耗量默认都是0,所以对父工料机的价格不会有影响,不用触发计算
|
|
|
- projectGLJ.loadData(function () {
|
|
|
- me.showProjectGljData();
|
|
|
- gljOprObj.showRationGLJSheetData();
|
|
|
- me.onUnitFileChange(me.selectedProjectGLJ);
|
|
|
- });
|
|
|
+ await me.addMixRatioFromLib(gljOprObj.GLJSelection,()=>{
|
|
|
+ me.showMixRatioData();//这里添加的组成物的消耗量默认都是0,所以对父工料机的价格不会有影响,不用触发计算
|
|
|
+ projectGLJ.loadData(function () {
|
|
|
+ me.showProjectGljData();
|
|
|
+ gljOprObj.showRationGLJSheetData();
|
|
|
+ me.onUnitFileChange(me.selectedProjectGLJ);
|
|
|
+ });
|
|
|
});
|
|
|
},
|
|
|
+ addMixRatioFromLib:async function(selections,callback){
|
|
|
+ let gljList = [],allGLJ = gljOprObj.AllRecode;
|
|
|
+ let url = "/glj/add-ratio";
|
|
|
+ let result = null;
|
|
|
+ if(selections.length == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ for(let glj of allGLJ){
|
|
|
+ let i_key = gljUtil.getIndex(glj,gljLibKeyArray);
|
|
|
+ if(_.includes(selections,i_key)){
|
|
|
+ let pglj = {
|
|
|
+ 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(typeof projectObj !== 'undefined') pglj.project_id = projectObj.project.ID();
|
|
|
+ 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 parentInfo ={};
|
|
|
+ if(typeof unitPriceObj !== 'undefined'){
|
|
|
+ url = "/unitPrice/addMixRatio";
|
|
|
+ pdata = unitPriceObj.getSelectedUnitPrice();
|
|
|
+ parentInfo = {
|
|
|
+ unit_price_file_id:pdata.unit_price_file_id,
|
|
|
+ connect_key:gljUtil.getIndex(pdata)
|
|
|
+ };
|
|
|
+ }else{
|
|
|
+ parentInfo = {
|
|
|
+ unit_price_file_id:projectObj.project.property.unitPriceFile.id,
|
|
|
+ connect_key:gljOprObj.getIndex(projectGljObject.selectedProjectGLJ,gljKeyArray)
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ $.bootstrapLoading.start();
|
|
|
+ result= await ajaxPost(url,{gljList:gljList,parentInfo:parentInfo})
|
|
|
+ if(callback) callback(result);
|
|
|
+ } catch (error) {
|
|
|
+ alert(error);
|
|
|
+ console.log(error);
|
|
|
+ }
|
|
|
+ $.bootstrapLoading.end();
|
|
|
+ return result;
|
|
|
+ },
|
|
|
showMixRatioData:function () {
|
|
|
let me = this,gljId = null,gljType = null;
|
|
|
if(!me.projectGljSpread) return;
|
|
@@ -313,9 +384,11 @@ let projectGljObject={
|
|
|
let style = gljOprObj.getSelStyle(true,{});
|
|
|
me.projectGljSheet.setStyle(newSel.row, -1, style);
|
|
|
let orow = oldSel.row==''||oldSel.row==-1?0:oldSel.row;
|
|
|
- let tstyle = gljOprObj.getSelStyle(false,{},me.projectGljSheetData[orow].bgColour);
|
|
|
- me.projectGljSheet.setStyle(orow, -1, tstyle);
|
|
|
- me.projectGljRowChang();
|
|
|
+ if(me.projectGljSheetData[orow]){
|
|
|
+ let tstyle = gljOprObj.getSelStyle(false,{},me.projectGljSheetData[orow].bgColour);
|
|
|
+ me.projectGljSheet.setStyle(orow, -1, tstyle);
|
|
|
+ me.projectGljRowChang();
|
|
|
+ }
|
|
|
}else{
|
|
|
me.projectGljSheet.repaint();
|
|
|
}
|
|
@@ -376,14 +449,15 @@ let projectGljObject={
|
|
|
let me = projectGljObject;
|
|
|
let canChange = true;
|
|
|
let changeInfo=[];
|
|
|
- if (info.action == GC.Spread.Sheets.RangeChangedAction.clear) {
|
|
|
+ /* if (info.action == GC.Spread.Sheets.RangeChangedAction.clear) {
|
|
|
info.newValue = 0;
|
|
|
me.onMixRatioValueChange(sender,info);
|
|
|
info.sheet.getCell(info.row, info.col).text(0);
|
|
|
return ;
|
|
|
- }
|
|
|
+ } */
|
|
|
for(let c of info.changedCells){
|
|
|
let value = info.sheet.getCell(c.row, c.col).text();
|
|
|
+ if(_.isEmpty(value)) value = 0;
|
|
|
if (!me.checkData(c.col,me.mixRatioSetting,value)) {
|
|
|
alert('输入的数据类型不对,请重新输入!');
|
|
|
canChange = false;
|
|
@@ -392,12 +466,8 @@ let projectGljObject={
|
|
|
changeInfo.push({row:c.row,col:c.col,value:value});
|
|
|
}
|
|
|
}
|
|
|
- if(canChange == false){//数据类型不对
|
|
|
- me.showMixRatioData();
|
|
|
- }
|
|
|
- if(changeInfo.length > 0){
|
|
|
- me.batchUpdateConsumption(changeInfo);
|
|
|
- }
|
|
|
+ if(canChange == false) me.showMixRatioData(); //数据类型不对
|
|
|
+ if(changeInfo.length > 0) me.batchUpdateConsumption(changeInfo);
|
|
|
},
|
|
|
batchUpdateProjectGLJ:function(changeInfo,sheetName){
|
|
|
let projectGLJ = projectObj.project.projectGLJ;
|
|
@@ -822,18 +892,7 @@ let projectGljObject={
|
|
|
return false;
|
|
|
}
|
|
|
value = scMathUtil.roundToString(value,getDecimal("glj.quantity"));
|
|
|
- let [parentMarketPrice, parentBasePrice] = me.getCompositionSumPrice('modify', row, value);
|
|
|
- let updateData ={id: recode.mix_ratio_id, field: 'mix_ratio.' + dataCode, value: value, market_price: parentMarketPrice, base_price: parentBasePrice};
|
|
|
- let prow = parentSheet.getActiveRowIndex();//取父机械或组成物的下标
|
|
|
- let prowData = parentSheet.name() == 'projectGljSheet'?me.projectGljSheetData[prow]:me.materialTree.items[prow].data;
|
|
|
- composition.updateConsumption(updateData,recode,prowData.id,function (sid) {
|
|
|
- /* if(parentSheet.name() == 'projectGljSheet'){ 之前是单行刷新,父工料机与组成物对应的工料机分开刷,发现这样比整个刷新慢所以先整个刷新,当以后数据量大的时候再测试
|
|
|
- me.refreshProjectGljRowByID(sid);
|
|
|
- }*/
|
|
|
- projectObj.project.projectGLJ.calcQuantity();
|
|
|
- me.refreshParentData(prow,prowData.id,sid);
|
|
|
- me.onUnitFileChange(recode);
|
|
|
- });
|
|
|
+ me.batchUpdateConsumption([{row:row,col:col,value}]);
|
|
|
},
|
|
|
refreshParentData:function (row,pid,sid) {
|
|
|
let me = this;
|
|
@@ -1035,22 +1094,6 @@ let projectGljObject={
|
|
|
},
|
|
|
checkData : function(col,setting, value) {
|
|
|
return sheetCommonObj.checkData(col,setting, value);
|
|
|
- /* let result = true;
|
|
|
- let validator = setting.header[col].validator !== undefined ? setting.header[col].validator : null;
|
|
|
- if (validator === null) {
|
|
|
- return result;
|
|
|
- }
|
|
|
- switch (validator) {
|
|
|
- case 'number':
|
|
|
- let regular = /^\d+(\.\d+)?$/;
|
|
|
- result = regular.test(value);
|
|
|
- break;
|
|
|
- case 'boolean':
|
|
|
- let booleanValue = [true, false];
|
|
|
- result = booleanValue.indexOf(value) >= 0;
|
|
|
- break;
|
|
|
- }
|
|
|
- return result;*/
|
|
|
},
|
|
|
getProjectGLJSelected:function () {
|
|
|
let me = projectGljObject;
|