|
@@ -111,6 +111,7 @@ projectGljObject={
|
|
|
this.mixRatioSheet = this.mixRatioSpread .getSheet(0);
|
|
|
this.initSheet(this.mixRatioSheet,this.mixRatioSetting);
|
|
|
this.mixRatioSheet.name('mixRatioSheet');
|
|
|
+ this.mixRatioSheet.bind(GC.Spread.Sheets.Events.RangeChanged, this.onMixRatioRangeChange);
|
|
|
},
|
|
|
initMaterialTreeSheet:function () {
|
|
|
this.materialTreeSheet = this.projectGljSpread.getSheet(1);
|
|
@@ -225,7 +226,8 @@ projectGljObject={
|
|
|
type:glj.type,
|
|
|
short_name:projectObj.project.projectGLJ.getShortNameByID(glj.type),
|
|
|
consumption:glj.ratio_data.consumption,
|
|
|
- unit_price:glj.unit_price
|
|
|
+ unit_price:glj.unit_price,
|
|
|
+ connect_key:glj.ratio_data.connect_key
|
|
|
};
|
|
|
gljOprObj.setGLJPrice(data,glj);
|
|
|
return data;
|
|
@@ -238,7 +240,7 @@ projectGljObject={
|
|
|
args.cancel = true;
|
|
|
}
|
|
|
},
|
|
|
- projectGljEditChecking:function (row,col) {//return false表示不能编辑
|
|
|
+ projectGljEditChecking:function (row,col,isPaste=false) {//return false表示不能编辑
|
|
|
let me = projectGljObject;
|
|
|
let data = null, setting=null;
|
|
|
let sheet = me.projectGljSpread.getActiveSheet();
|
|
@@ -256,7 +258,7 @@ projectGljObject={
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- if(dataCode=='is_adjust_price'||dataCode=='is_evaluate'||dataCode=='is_main_material'){
|
|
|
+ if(isPaste == false &&(dataCode=='is_adjust_price'||dataCode=='is_evaluate'||dataCode=='is_main_material')){//除了粘贴,拖动填充等操作,其它的都不能编辑
|
|
|
return false;
|
|
|
}
|
|
|
if(dataCode=='basePrice'||dataCode=='marketPrice'||dataCode=='supply'){//有组成物时,市场单价、定额价、供货方式不能修改
|
|
@@ -282,7 +284,7 @@ projectGljObject={
|
|
|
},
|
|
|
onSelectionChange:function (){
|
|
|
let me = projectGljObject;
|
|
|
- me.projectGljRowChang();
|
|
|
+ me.showMixRatioData();
|
|
|
me.materialTreeSheet.repaint();
|
|
|
},
|
|
|
onProjectGljSelectionChange:function (sender, args) {
|
|
@@ -296,7 +298,11 @@ projectGljObject={
|
|
|
},
|
|
|
projectGljRowChang:function(row){
|
|
|
let me = projectGljObject;
|
|
|
- me.mixRatioSheet.getSelections()[0].row = -1;
|
|
|
+ let sel = me.mixRatioSheet.getSelections()[0];
|
|
|
+ sel.row = -1;
|
|
|
+ sel.col = 0;
|
|
|
+ sel.rowCount = 1;
|
|
|
+ sel.colCount = 1;
|
|
|
me.showMixRatioData();
|
|
|
},
|
|
|
rightClickCallback:function (row) {
|
|
@@ -312,18 +318,20 @@ projectGljObject={
|
|
|
let me = projectGljObject;
|
|
|
let changeInfo=[];
|
|
|
let canChange = true;
|
|
|
- if(me.projectGljEditChecking(info.row,info.col) == false){
|
|
|
- canChange = false;
|
|
|
- }else if (info.action == GC.Spread.Sheets.RangeChangedAction.clear) {
|
|
|
- info.newValue = null;
|
|
|
- me.onProjectGLJValueChange(sender,info);
|
|
|
- return ;
|
|
|
+ if(info.action == GC.Spread.Sheets.RangeChangedAction.clear){
|
|
|
+ if(me.projectGljEditChecking(info.row,info.col) == false){
|
|
|
+ canChange = false;
|
|
|
+ }else {
|
|
|
+ info.newValue = null;
|
|
|
+ me.onProjectGLJValueChange(sender,info);
|
|
|
+ return ;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
for(let c of info.changedCells){
|
|
|
let value= info.sheet.getCell(c.row, c.col).text();
|
|
|
changeInfo.push({row:c.row,col:c.col,value:value});
|
|
|
- if(me.projectGljEditChecking(c.row,c.col)==false){//如果不能编辑
|
|
|
+ if(me.projectGljEditChecking(c.row,c.col,true)==false){//如果不能编辑
|
|
|
canChange = false;
|
|
|
}
|
|
|
if (canChange==true&&!me.checkData(c.col,me.projectGljSetting,value)) {
|
|
@@ -334,18 +342,87 @@ projectGljObject={
|
|
|
if(canChange == false){//恢复原来的值
|
|
|
info.sheetName =="materialTreeSheet"?me.showMaterialTreeData():me.showProjectGljData();
|
|
|
}else if(info.sheetName =="projectGljSheet"){
|
|
|
- me.batchUpdatePrice(changeInfo);
|
|
|
+ me.batchUpdateProjectGLJ(changeInfo);
|
|
|
}
|
|
|
},
|
|
|
- batchUpdatePrice(changeInfo){
|
|
|
+ onMixRatioRangeChange:function (sender,info){
|
|
|
+ let me = projectGljObject;
|
|
|
+ let canChange = true;
|
|
|
+ let changeInfo=[];
|
|
|
+ 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 (!me.checkData(c.col,me.mixRatioSetting,value)) {
|
|
|
+ alert('输入的数据类型不对,请重新输入!');
|
|
|
+ canChange = false;
|
|
|
+ break;
|
|
|
+ }else {
|
|
|
+ changeInfo.push({row:c.row,col:c.col,value:value});
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(canChange == false){//数据类型不对
|
|
|
+ me.showMixRatioData();
|
|
|
+ }
|
|
|
+ if(changeInfo.length > 0){
|
|
|
+ me.batchUpdateConsumption(changeInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+ batchUpdateProjectGLJ:function(changeInfo){
|
|
|
let projectGLJ = projectObj.project.projectGLJ;
|
|
|
let me = projectGljObject;
|
|
|
+ me.batchUpdateGLJProperty(changeInfo);
|
|
|
projectGLJ.batchUpdatePrice(changeInfo,function (impactList) {
|
|
|
let selected = me.projectGljSheet.getSelections()[0];
|
|
|
me.showProjectGljData();
|
|
|
me.projectGljSheet.setSelection(selected.row,selected.col,selected.rowCount,selected.colCount);
|
|
|
});
|
|
|
},
|
|
|
+ batchUpdateGLJProperty:function (changeInfo) {
|
|
|
+ console.log(changeInfo)
|
|
|
+ },
|
|
|
+ batchUpdateConsumption:function(changeInfo){
|
|
|
+ let projectGLJ = projectObj.project.projectGLJ;
|
|
|
+ let me = projectGljObject;
|
|
|
+ let updateMap = {},updateData = [],parentBasePrice = 0,parentMarketPrice = 0;
|
|
|
+ let parentKey = '',unit_price_file_id=null;
|
|
|
+ for(let c of changeInfo){
|
|
|
+ let record = me.mixRatioData[c.row];
|
|
|
+ let value = scMathUtil.roundForObj(c.value,getDecimal("glj.quantity"));
|
|
|
+ updateMap[record.mix_ratio_id] = {consumption: value,record:record };
|
|
|
+ updateData.push({type:'mix_ratio',query:{id:record.mix_ratio_id},doc:{consumption:value}});
|
|
|
+ parentKey = record.connect_key;
|
|
|
+ unit_price_file_id = record.unit_price.unit_price_file_id;
|
|
|
+ }
|
|
|
+ for(let sub of me.mixRatioData){
|
|
|
+ let marketPrice = scMathUtil.roundForObj(sub.unit_price.market_price,getDecimal("process"));
|
|
|
+ let basePrice = scMathUtil.roundForObj(sub.unit_price.base_price,getDecimal("process"));
|
|
|
+ let consumption = updateMap[sub.mix_ratio_id]?updateMap[sub.mix_ratio_id].consumption:scMathUtil.roundForObj(sub.consumption,getDecimal("glj.quantity"));
|
|
|
+ parentMarketPrice = scMathUtil.roundForObj(marketPrice*consumption + parentMarketPrice,getDecimal("process"));
|
|
|
+ parentBasePrice = scMathUtil.roundForObj(basePrice*consumption + parentBasePrice,getDecimal("process"));
|
|
|
+ }
|
|
|
+ parentBasePrice = scMathUtil.roundForObj(parentBasePrice,getDecimal("glj.unitPrice"));
|
|
|
+ parentMarketPrice = scMathUtil.roundForObj(parentMarketPrice,getDecimal("glj.unitPrice"));
|
|
|
+ updateData.push({type:'parent',connect_key:parentKey,base_price:parentBasePrice,market_price:parentMarketPrice,unit_price_file_id:unit_price_file_id});
|
|
|
+ projectGLJ.batchUpdateConsumption(updateData,updateMap,function () {
|
|
|
+ //更新人材机汇总表
|
|
|
+ let parentSheet = me.projectGljSpread.getActiveSheet();//三材汇总表和工料机汇总表
|
|
|
+ let prow = parentSheet.getActiveRowIndex();//取父机械或组成物的下标
|
|
|
+ let prowData = parentSheet.name() == 'projectGljSheet'?me.projectGljSheetData[prow]:me.materialTree.items[prow].data;
|
|
|
+ me.refreshParentData(prow,prowData.id);
|
|
|
+ me.onUnitFileChange(updateData);
|
|
|
+ });
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
showProjectGljData:function () {
|
|
|
this.projectGljSpread.setActiveSheetIndex(0);
|
|
|
let sel = this.projectGljSheet.getSelections()[0];
|