|
@@ -1,6 +1,7 @@
|
|
|
|
|
|
|
|
let unitPriceObj = {
|
|
let unitPriceObj = {
|
|
|
unitPriceMap:{},
|
|
unitPriceMap:{},
|
|
|
|
|
+ selectedData : null,
|
|
|
setUntiPriceMap:function(){
|
|
setUntiPriceMap:function(){
|
|
|
for(let u of unitPriceList){
|
|
for(let u of unitPriceList){
|
|
|
this.unitPriceMap[gljUtil.getIndex(u)] = u;
|
|
this.unitPriceMap[gljUtil.getIndex(u)] = u;
|
|
@@ -16,10 +17,10 @@ let unitPriceObj = {
|
|
|
{headerName: "类型", headerWidth: 45, dataCode: "short_name", hAlign: "center", dataType: "String"},
|
|
{headerName: "类型", headerWidth: 45, dataCode: "short_name", hAlign: "center", dataType: "String"},
|
|
|
{headerName: "定额价", headerWidth: 70, dataCode: "basePrice", hAlign: "right", dataType: "Number",validator:"number"},//decimalField:'glj.unitPrice',
|
|
{headerName: "定额价", headerWidth: 70, dataCode: "basePrice", hAlign: "right", dataType: "Number",validator:"number"},//decimalField:'glj.unitPrice',
|
|
|
{headerName: "预算价", headerWidth: 70, dataCode: "marketPrice", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:"glj.unitPrice"
|
|
{headerName: "预算价", headerWidth: 70, dataCode: "marketPrice", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:"glj.unitPrice"
|
|
|
- {headerName: "是否新增", headerWidth: 50, dataCode: "is_add", hAlign: "center", dataType: "String",cellType:'checkBox'}
|
|
|
|
|
|
|
+ {headerName: "是否\n新增", headerWidth: 50, dataCode: "is_add", hAlign: "center", dataType: "String",cellType:'checkBox'}
|
|
|
],
|
|
],
|
|
|
view: {
|
|
view: {
|
|
|
- lockColumns: ["code","name","specs","unit","short_name","basePrice","is_add"],
|
|
|
|
|
|
|
+ lockColumns: ["code","name","specs","unit","short_name","basePrice"],
|
|
|
colHeaderHeight:36
|
|
colHeaderHeight:36
|
|
|
},
|
|
},
|
|
|
getStyle:function (data,row,activeRow) {
|
|
getStyle:function (data,row,activeRow) {
|
|
@@ -42,7 +43,7 @@ let unitPriceObj = {
|
|
|
{headerName: "消耗量", headerWidth: 80, dataCode: "consumption", hAlign: "right", dataType: "Number",validator:"number",tofix:3}
|
|
{headerName: "消耗量", headerWidth: 80, dataCode: "consumption", hAlign: "right", dataType: "Number",validator:"number",tofix:3}
|
|
|
],
|
|
],
|
|
|
view: {
|
|
view: {
|
|
|
- lockColumns: [0,1,2,3,4,5,6,7],
|
|
|
|
|
|
|
+ lockColumns: [0,1,2,3,4,5,6],
|
|
|
rowHeaderWidth: 25
|
|
rowHeaderWidth: 25
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
@@ -55,17 +56,13 @@ let unitPriceObj = {
|
|
|
this.mainSheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onMainSelectionChange);
|
|
this.mainSheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onMainSelectionChange);
|
|
|
this.mainSpread.bind(GC.Spread.Sheets.Events.RangeChanged, this.onMainRangeChange);
|
|
this.mainSpread.bind(GC.Spread.Sheets.Events.RangeChanged, this.onMainRangeChange);
|
|
|
this.mainSheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onMainValueChange);
|
|
this.mainSheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onMainValueChange);
|
|
|
- // this.sheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onElectrovalenceEditStarting);
|
|
|
|
|
-
|
|
|
|
|
- /* if(projectReadOnly){
|
|
|
|
|
- disableSpread(this.spread);
|
|
|
|
|
- } */
|
|
|
|
|
|
|
+ this.mainSheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onMainEditStarting);
|
|
|
},
|
|
},
|
|
|
showMainDatas:function(){
|
|
showMainDatas:function(){
|
|
|
unitPriceList = gljUtil.sortProjectGLJ(unitPriceList);
|
|
unitPriceList = gljUtil.sortProjectGLJ(unitPriceList);
|
|
|
this.setData(unitPriceList);
|
|
this.setData(unitPriceList);
|
|
|
let sel = this.mainSheet.getSelections()[0];
|
|
let sel = this.mainSheet.getSelections()[0];
|
|
|
- let oldData = sel.row<unitPriceList.length?unitPriceList[sel.row]:"";
|
|
|
|
|
|
|
+ let oldData = this.selectedData;
|
|
|
sheetCommonObj.showData(this.mainSheet, this.mainSetting,unitPriceList);
|
|
sheetCommonObj.showData(this.mainSheet, this.mainSetting,unitPriceList);
|
|
|
this.mainSheet.setRowCount(unitPriceList.length);
|
|
this.mainSheet.setRowCount(unitPriceList.length);
|
|
|
sel.row = oldData?_.findIndex(unitPriceList,{'id':oldData.id}):sel.row ;
|
|
sel.row = oldData?_.findIndex(unitPriceList,{'id':oldData.id}):sel.row ;
|
|
@@ -116,6 +113,7 @@ let unitPriceObj = {
|
|
|
let tstyle = me.getSelStyle(false,{},unitPriceList[orow].bgColour);
|
|
let tstyle = me.getSelStyle(false,{},unitPriceList[orow].bgColour);
|
|
|
args.sheet.setStyle(orow, -1, tstyle);
|
|
args.sheet.setStyle(orow, -1, tstyle);
|
|
|
me.showSubDatas();
|
|
me.showSubDatas();
|
|
|
|
|
+ me.selectedData = unitPriceList[newSel.row];
|
|
|
}
|
|
}
|
|
|
}else{
|
|
}else{
|
|
|
args.sheet.repaint();
|
|
args.sheet.repaint();
|
|
@@ -124,6 +122,31 @@ let unitPriceObj = {
|
|
|
args.sheet.resumePaint();
|
|
args.sheet.resumePaint();
|
|
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
+ onMainEditStarting:function(sender, args){
|
|
|
|
|
+ let me = unitPriceObj;
|
|
|
|
|
+ let row = args.row;
|
|
|
|
|
+ let col = args.col;
|
|
|
|
|
+ if(me.mainEditChecking(row,col)==false){
|
|
|
|
|
+ args.cancel = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ mainEditChecking:function(row,col,isPaste=false){
|
|
|
|
|
+ let me = unitPriceObj;
|
|
|
|
|
+ if(row>=unitPriceList.length) return false;
|
|
|
|
|
+ let data = unitPriceList[row];
|
|
|
|
|
+ let setting = me.mainSetting;
|
|
|
|
|
+ let dataCode = setting.header[col].dataCode;
|
|
|
|
|
+ if(isPaste == false &&dataCode=='is_add'){//除了粘贴,拖动填充等操作,其它的都不能编辑
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(dataCode=='marketPrice'){
|
|
|
|
|
+ if(gljUtil.isConcreteType(data.type)) return false;//混凝土,浆砂,配合比,不能修改市场单价,定额价
|
|
|
|
|
+ let uindex = gljUtil.getIndex(data);
|
|
|
|
|
+ if(mixRatioMap[uindex] && mixRatioMap[uindex].length > 0) return false;//有组成物的不能编辑
|
|
|
|
|
+ if(data.calcMaterial == 1) return false //有材料计算时不能修改
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+ },
|
|
|
onMainValueChange:function(e,info){
|
|
onMainValueChange:function(e,info){
|
|
|
let me = unitPriceObj;
|
|
let me = unitPriceObj;
|
|
|
let value = info.newValue;
|
|
let value = info.newValue;
|
|
@@ -135,14 +158,18 @@ let unitPriceObj = {
|
|
|
return me.showMainDatas();
|
|
return me.showMainDatas();
|
|
|
}
|
|
}
|
|
|
me.batchUpdateUnitPrice([{row:info.row,col:info.col,value:value}]);
|
|
me.batchUpdateUnitPrice([{row:info.row,col:info.col,value:value}]);
|
|
|
-
|
|
|
|
|
},
|
|
},
|
|
|
onMainRangeChange:function(sender,info){
|
|
onMainRangeChange:function(sender,info){
|
|
|
let me = unitPriceObj;
|
|
let me = unitPriceObj;
|
|
|
let canChange = true;
|
|
let canChange = true;
|
|
|
|
|
+ let changeInfo = [];
|
|
|
for(let c of info.changedCells){
|
|
for(let c of info.changedCells){
|
|
|
let value= info.sheet.getCell(c.row, c.col).text();
|
|
let value= info.sheet.getCell(c.row, c.col).text();
|
|
|
changeInfo.push({row:c.row,col:c.col,value:value});
|
|
changeInfo.push({row:c.row,col:c.col,value:value});
|
|
|
|
|
+ if(me.mainEditChecking(c.row,c.col,true)==false){//如果不能编辑
|
|
|
|
|
+ canChange = false;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
if (!sheetCommonObj.checkData(c.col,me.mainSetting,value)) {
|
|
if (!sheetCommonObj.checkData(c.col,me.mainSetting,value)) {
|
|
|
alert('输入的数据类型不对,请重新输入!');
|
|
alert('输入的数据类型不对,请重新输入!');
|
|
|
canChange = false;
|
|
canChange = false;
|
|
@@ -161,22 +188,42 @@ let unitPriceObj = {
|
|
|
for(let ci of changeInfo){
|
|
for(let ci of changeInfo){
|
|
|
let dataCode = me.mainSetting.header[ci.col].dataCode;
|
|
let dataCode = me.mainSetting.header[ci.col].dataCode;
|
|
|
let recode = unitPriceList[ci.row];
|
|
let recode = unitPriceList[ci.row];
|
|
|
|
|
+ let ndata = newValueMap[recode.id]?newValueMap[recode.id]:{unit_price:recode};
|
|
|
if(dataCode=='basePrice'||dataCode=='marketPrice'){
|
|
if(dataCode=='basePrice'||dataCode=='marketPrice'){
|
|
|
let editField = dataCode === 'basePrice'?"base_price":"market_price";
|
|
let editField = dataCode === 'basePrice'?"base_price":"market_price";
|
|
|
let newValue = ci.value;
|
|
let newValue = ci.value;
|
|
|
if(recode && recode[editField]!=newValue){
|
|
if(recode && recode[editField]!=newValue){
|
|
|
- newValue= scMathUtil.roundForObj(ci.value,3);
|
|
|
|
|
- updateData.push({unit_price: recode, field: editField, newval: newValue});
|
|
|
|
|
- newValueMap[recode.id]={field:editField,value:newValue};
|
|
|
|
|
- refreshList.push(recode);
|
|
|
|
|
|
|
+ newValue= scMathUtil.roundForObj(ci.value,3);
|
|
|
|
|
+ ndata['field'] = editField;
|
|
|
|
|
+ ndata['newval'] = newValue;
|
|
|
|
|
+ newValueMap[recode.id]=ndata;
|
|
|
}
|
|
}
|
|
|
|
|
+ }else{
|
|
|
|
|
+ let ext = {};
|
|
|
|
|
+ if(dataCode === 'is_add'){
|
|
|
|
|
+ value = ci.value == true?1:0;
|
|
|
|
|
+ }
|
|
|
|
|
+ ext[dataCode] = value;
|
|
|
|
|
+ ndata['ext'] = ext;
|
|
|
|
|
+ newValueMap[recode.id]=ndata;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ for(let key in newValueMap){
|
|
|
|
|
+ updateData.push(newValueMap[key]);
|
|
|
|
|
+ refreshList.push(newValueMap[key].unit_price)
|
|
|
|
|
+ }
|
|
|
if(updateData.length > 0){
|
|
if(updateData.length > 0){
|
|
|
$.bootstrapLoading.start();
|
|
$.bootstrapLoading.start();
|
|
|
let result = await ajaxPost("/glj/batchUpdatePrices",updateData);
|
|
let result = await ajaxPost("/glj/batchUpdatePrices",updateData);
|
|
|
for(let r of refreshList){
|
|
for(let r of refreshList){
|
|
|
- r[newValueMap[r.id].field] = newValueMap[r.id].value;
|
|
|
|
|
|
|
+ let rdata = newValueMap[r.id];
|
|
|
|
|
+ if(rdata.field) r[rdata.field] = rdata.newval;
|
|
|
|
|
+ if(rdata.ext){
|
|
|
|
|
+ for(let ekey in rdata.ext){
|
|
|
|
|
+ r[ekey] = rdata.ext[ekey];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
for(let r of result){
|
|
for(let r of result){
|
|
|
let pdata = r.updateOne.filter;
|
|
let pdata = r.updateOne.filter;
|
|
@@ -188,10 +235,11 @@ let unitPriceObj = {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
|
|
+ console.log(error);
|
|
|
alert(error);
|
|
alert(error);
|
|
|
}
|
|
}
|
|
|
$.bootstrapLoading.end();
|
|
$.bootstrapLoading.end();
|
|
|
- me.showMainDatas();
|
|
|
|
|
|
|
+ me.onUnitPriceChange();
|
|
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
|
@@ -201,13 +249,9 @@ let unitPriceObj = {
|
|
|
sheetCommonObj.spreadDefaultStyle(this.subSpread);
|
|
sheetCommonObj.spreadDefaultStyle(this.subSpread);
|
|
|
this.subSheet = this.subSpread.getSheet(0);
|
|
this.subSheet = this.subSpread.getSheet(0);
|
|
|
sheetCommonObj.initSheet(this.subSheet, this.subSetting, 30);
|
|
sheetCommonObj.initSheet(this.subSheet, this.subSetting, 30);
|
|
|
- // this.sheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onElectrovalenceSelectionChange);
|
|
|
|
|
- // this.sheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onElectrovalenceValueChange);
|
|
|
|
|
- // this.sheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onElectrovalenceEditStarting);
|
|
|
|
|
-
|
|
|
|
|
- /* if(projectReadOnly){
|
|
|
|
|
- disableSpread(this.spread);
|
|
|
|
|
- } */
|
|
|
|
|
|
|
+ this.subSheet.bind(GC.Spread.Sheets.Events.RangeChanged, this.onSubRangeChange);
|
|
|
|
|
+ this.subSheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onSubValueChange);
|
|
|
|
|
+ this.initSubRightClick();
|
|
|
},
|
|
},
|
|
|
showSubDatas:function(){
|
|
showSubDatas:function(){
|
|
|
let parentData = this.getSelectedUnitPrice();
|
|
let parentData = this.getSelectedUnitPrice();
|
|
@@ -220,6 +264,182 @@ let unitPriceObj = {
|
|
|
this.subSheet.setRowCount(this.mixRatioList.length);
|
|
this.subSheet.setRowCount(this.mixRatioList.length);
|
|
|
this.subSheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
|
|
this.subSheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
|
|
|
},
|
|
},
|
|
|
|
|
+ onSubValueChange:function(sender,info){
|
|
|
|
|
+ let me = unitPriceObj;
|
|
|
|
|
+ let value = info.newValue;
|
|
|
|
|
+ if(info.newValue === undefined){
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(value && !sheetCommonObj.checkData(info.col,me.mainSetting,value)) {
|
|
|
|
|
+ alert('输入的数据类型不对,请重新输入!');
|
|
|
|
|
+ return me.showMainDatas();
|
|
|
|
|
+ }
|
|
|
|
|
+ me.batchUpdateConsumption([{row:info.row,col:info.col,value:value}]);
|
|
|
|
|
+
|
|
|
|
|
+ },
|
|
|
|
|
+ onSubRangeChange:function(sender,info){
|
|
|
|
|
+ let me = unitPriceObj;
|
|
|
|
|
+ let changeInfo=[];
|
|
|
|
|
+ let canChange = true;
|
|
|
|
|
+ for(let c of info.changedCells){
|
|
|
|
|
+ let value = info.sheet.getCell(c.row, c.col).text();
|
|
|
|
|
+ if(_.isEmpty(value)) value = 0;
|
|
|
|
|
+ if (!sheetCommonObj.checkData(c.col,me.subSetting,value)) {
|
|
|
|
|
+ alert('输入的数据类型不对,请重新输入!');
|
|
|
|
|
+ canChange = false;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }else {
|
|
|
|
|
+ changeInfo.push({row:c.row,col:c.col,value:value});
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if(canChange == false) me.showSubDatas();
|
|
|
|
|
+ me.batchUpdateConsumption(changeInfo);
|
|
|
|
|
+ },
|
|
|
|
|
+ calcParentPrice:function(list,updateMap,deleteID){
|
|
|
|
|
+ let parentMarketPrice = 0;
|
|
|
|
|
+ for(let sub of list){
|
|
|
|
|
+ if(deleteID && sub.id == deleteID) continue
|
|
|
|
|
+ let marketPrice = scMathUtil.roundForObj(sub.marketPrice,6);
|
|
|
|
|
+ let basePrice = scMathUtil.roundForObj(sub.basePrice,6);
|
|
|
|
|
+ let consumption = updateMap[sub.id]?updateMap[sub.id].consumption:scMathUtil.roundForObj(sub.consumption,3);
|
|
|
|
|
+ parentMarketPrice = scMathUtil.roundForObj(marketPrice*consumption + parentMarketPrice,6);
|
|
|
|
|
+ // parentBasePrice = scMathUtil.roundForObj(basePrice*consumption + parentBasePrice,getDecimal("process"));
|
|
|
|
|
+ }
|
|
|
|
|
+ parentMarketPrice = scMathUtil.roundForObj(parentMarketPrice,2);
|
|
|
|
|
+ return parentMarketPrice;
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ deleteMixRatio:async function(row){
|
|
|
|
|
+ let me = this, deleteRecode = me.mixRatioList[row];
|
|
|
|
|
+ let parentMarketPrice = me.calcParentPrice(me.mixRatioList,{},deleteRecode.id);
|
|
|
|
|
+ let parentData = me.getSelectedUnitPrice();
|
|
|
|
|
+ let updateData = {id: deleteRecode.id,connect_key:gljUtil.getIndex(parentData)};
|
|
|
|
|
+ let ext = {};
|
|
|
|
|
+ ext[parentData.id] = {marketPrice:parentMarketPrice};
|
|
|
|
|
+ updateData.parent = {connect_key:gljUtil.getIndex(parentData),query:{id:parentData.id},doc:{market_price: parentMarketPrice}};
|
|
|
|
|
+ if(com_electrovalence){ //计算综合电价
|
|
|
|
|
+ let elecP = me.clacNewElecPrice(ext);
|
|
|
|
|
+ if(elecP) updateData.unitPrice = {connect_key:elecP.connect_key,query:{id:elecP.id},doc:elecP.doc};
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ $.bootstrapLoading.start();
|
|
|
|
|
+ await ajaxPost("/glj/delete-ratio",{id: updateData.id,parent:updateData.parent,unitPrice:updateData.unitPrice});
|
|
|
|
|
+ let mlist = mixRatioMap[updateData.connect_key];
|
|
|
|
|
+ _.remove(mlist,{id:updateData.id});
|
|
|
|
|
+ if(updateData.parent){
|
|
|
|
|
+ let pglj = me.unitPriceMap[updateData.parent.connect_key];
|
|
|
|
|
+ if(pglj) gljUtil.setProperty(pglj,updateData.parent.doc);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(updateData.unitPrice){
|
|
|
|
|
+ let eglj = me.unitPriceMap[updateData.unitPrice.connect_key];
|
|
|
|
|
+ if(eglj) gljUtil.setProperty(eglj,updateData.unitPrice.doc);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ alert(error);
|
|
|
|
|
+ console.log(error);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $.bootstrapLoading.end();
|
|
|
|
|
+ me.onUnitPriceChange();
|
|
|
|
|
+ },
|
|
|
|
|
+ batchUpdateConsumption:async function(changeInfo){
|
|
|
|
|
+ let me = unitPriceObj;
|
|
|
|
|
+ let updateMap = {},updateData = [],parentBasePrice = 0,parentMarketPrice = 0;
|
|
|
|
|
+ let parentKey = '',unit_price_file_id=null;
|
|
|
|
|
+ for(let c of changeInfo){
|
|
|
|
|
+ let record = me.mixRatioList[c.row];
|
|
|
|
|
+ let value = scMathUtil.roundForObj(c.value,3);
|
|
|
|
|
+ updateMap[record.id] = {consumption: value,record:record};
|
|
|
|
|
+ updateData.push({type:'mix_ratio',connect_key:record.connect_key,query:{id:record.id},doc:{consumption:scMathUtil.roundToString(value,3)}});
|
|
|
|
|
+ parentKey = record.connect_key;
|
|
|
|
|
+ unit_price_file_id = record.unit_price_file_id;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(!gljUtil.isConcreteType(parseInt(parentKey.split("|-|")[4]))){//父类型不属于混凝土浆砂配合比,才要计算
|
|
|
|
|
+ parentMarketPrice = me.calcParentPrice(me.mixRatioList,updateMap);
|
|
|
|
|
+ }
|
|
|
|
|
+ let parentData = me.getSelectedUnitPrice();
|
|
|
|
|
+ if(parentData){
|
|
|
|
|
+ let ext = {};
|
|
|
|
|
+ ext[parentData.id] = {marketPrice:parentMarketPrice};
|
|
|
|
|
+ if(com_electrovalence){ //计算综合电价
|
|
|
|
|
+ let elecP = me.clacNewElecPrice(ext);
|
|
|
|
|
+ if(elecP){
|
|
|
|
|
+ updateData.push({type:'unitPrice',connect_key:elecP.connect_key,query:{id:elecP.id},doc:elecP.doc});
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ updateData.push({type:'unitPrice',connect_key:gljUtil.getIndex(parentData),query:{id:parentData.id},doc:{market_price:parentMarketPrice}});
|
|
|
|
|
+ }
|
|
|
|
|
+ if(updateData.length > 0){
|
|
|
|
|
+ try {
|
|
|
|
|
+ $.bootstrapLoading.start();
|
|
|
|
|
+ let result = await ajaxPost("/glj/batchUpdateConsumption",updateData);
|
|
|
|
|
+ for(let up of updateData){
|
|
|
|
|
+ if(up.type == 'unitPrice'){
|
|
|
|
|
+ let nu = me.unitPriceMap[up.connect_key];
|
|
|
|
|
+ if(nu) gljUtil.setProperty(nu,up.doc);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ let nlist = mixRatioMap[up.connect_key];
|
|
|
|
|
+ for(let nc of nlist){
|
|
|
|
|
+ if(nc.id == up.query.id){
|
|
|
|
|
+ gljUtil.setProperty(nc,up.doc);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ alert(error);
|
|
|
|
|
+ console.log(error);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $.bootstrapLoading.end();
|
|
|
|
|
+ me.onUnitPriceChange();
|
|
|
|
|
+ },
|
|
|
|
|
+ clacNewElecPrice:function(ext){
|
|
|
|
|
+ for(let u of unitPriceList){
|
|
|
|
|
+ if(u.code == gljUtil.getElecCode() && u.name == "电" && u.unit == "kW·h"){//更新电价
|
|
|
|
|
+ let datas = this.getElectrovalenceDatas(ext);
|
|
|
|
|
+ if(datas.length > 0){
|
|
|
|
|
+ let marketPrice = this.calcPertElectrovalenceMarketPrice(datas,ext);
|
|
|
|
|
+ if(marketPrice && u.market_price != marketPrice+'') return {id:u.id,'unit_price_file_id':u.unit_price_file_id,'connect_key':gljUtil.getIndex(u),doc:{'market_price':marketPrice+''}}
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ calcPertElectrovalenceMarketPrice:function (datas,ext) {
|
|
|
|
|
+ let total = 0;
|
|
|
|
|
+ for(let d of datas){
|
|
|
|
|
+ if(ext && ext[d.uid] && gljUtil.isDef(ext[d.uid].marketPrice)) d.marketPrice = ext[d.uid].marketPrice;
|
|
|
|
|
+ if(d.name == "电网电"){
|
|
|
|
|
+ d.electPrice = d.marketPrice;
|
|
|
|
|
+ }else {
|
|
|
|
|
+ let w = parseInt(d.name);
|
|
|
|
|
+ if(!w) continue;
|
|
|
|
|
+ let t = scMathUtil.roundForObj(d.marketPrice/w,6);
|
|
|
|
|
+ d.electPrice = scMathUtil.roundForObj(t * gljUtil.getElecCoe(),2);
|
|
|
|
|
+ }
|
|
|
|
|
+ let et = scMathUtil.roundForObj(d.electPrice * d.coe,6);
|
|
|
|
|
+ total = scMathUtil.roundForObj(et + total,6);
|
|
|
|
|
+ }
|
|
|
|
|
+ this.total = scMathUtil.roundForObj(total,2);
|
|
|
|
|
+ return this.total;
|
|
|
|
|
+},
|
|
|
|
|
+ getElectrovalenceDatas:function(ext){
|
|
|
|
|
+ let datas = [];
|
|
|
|
|
+ if(com_electrovalence && com_electrovalence.gljList){
|
|
|
|
|
+ for(let g of com_electrovalence.gljList){
|
|
|
|
|
+ let u = unitPriceMap[gljUtil.getIndex(g)]
|
|
|
|
|
+ if(u){
|
|
|
|
|
+ g.uid = u.id;
|
|
|
|
|
+ g.basePrice = this.getPrice("base_price",u);
|
|
|
|
|
+ g.marketPrice = this.getPrice("market_price",u);
|
|
|
|
|
+ datas.push(g);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
setMixRatioData:function(mixRatioList){
|
|
setMixRatioData:function(mixRatioList){
|
|
|
for(let m of mixRatioList){
|
|
for(let m of mixRatioList){
|
|
|
m.short_name = this.getShortNameByType(m.type);
|
|
m.short_name = this.getShortNameByType(m.type);
|
|
@@ -270,6 +490,94 @@ let unitPriceObj = {
|
|
|
style.backColor = selected ? selectedColor : recColor;
|
|
style.backColor = selected ? selectedColor : recColor;
|
|
|
return style;
|
|
return style;
|
|
|
},
|
|
},
|
|
|
|
|
+ initSubRightClick:function(){
|
|
|
|
|
+ let me = this;
|
|
|
|
|
+ $.contextMenu({
|
|
|
|
|
+ selector: '#subSpread',
|
|
|
|
|
+ build: function ($trigger, e) {
|
|
|
|
|
+ me.rightClickTarget = SheetDataHelper.safeRightClickSelection($trigger, e, me.subSpread);
|
|
|
|
|
+ return me.rightClickTarget.hitTestType === GC.Spread.Sheets.SheetArea.viewport ||
|
|
|
|
|
+ me.rightClickTarget.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
|
|
|
|
|
+ },
|
|
|
|
|
+ items: {
|
|
|
|
|
+ "deleteMixRatio": {
|
|
|
|
|
+ name: "删除",
|
|
|
|
|
+ icon: 'fa-trash-o',
|
|
|
|
|
+ disabled: function () {
|
|
|
|
|
+ return me.rightClickTarget.row === undefined;
|
|
|
|
|
+ },
|
|
|
|
|
+ callback: function (key, opt) {
|
|
|
|
|
+ let row = me.rightClickTarget.row;
|
|
|
|
|
+ me.deleteMixRatio(row);
|
|
|
|
|
+ },
|
|
|
|
|
+ visible: function(key, opt){
|
|
|
|
|
+ let projectGLJ = me.getSelectedUnitPrice();
|
|
|
|
|
+ return projectGLJ && !gljUtil.isConcreteType(projectGLJ.type);
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ "addMixRatio":{
|
|
|
|
|
+ name: '添加',
|
|
|
|
|
+ icon: 'fa-sign-in',
|
|
|
|
|
+ disabled: function () {
|
|
|
|
|
+ let projectGLJ = me.getSelectedUnitPrice();
|
|
|
|
|
+ return !_.includes(compositionTypes,projectGLJ.type);
|
|
|
|
|
+ },
|
|
|
|
|
+ callback: function (key, opt) {
|
|
|
|
|
+ projectGljObject.selectedProjectGLJ = me.getSelectedUnitPrice();
|
|
|
|
|
+ getGLJData('unitPriceAddMix',true,me.getGLJLibData);
|
|
|
|
|
+ },
|
|
|
|
|
+ visible: function(key, opt){
|
|
|
|
|
+ let projectGLJ = me.getSelectedUnitPrice();
|
|
|
|
|
+ return projectGLJ && !gljUtil.isConcreteType(projectGLJ.type);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ addMixRatio:async function(){
|
|
|
|
|
+ let me = this;
|
|
|
|
|
+ for(let mix of me.mixRatioList){
|
|
|
|
|
+ let m_key = gljUtil.getIndex(mix);
|
|
|
|
|
+ _.remove(gljOprObj.GLJSelection,n =>{
|
|
|
|
|
+ return m_key == n;
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ let result = await projectGljObject.addMixRatioFromLib(gljOprObj.GLJSelection)
|
|
|
|
|
+ if(result.mixRatios && result.mixRatios.length > 0){
|
|
|
|
|
+ let mList = mixRatioMap[result.mixRatios[0].connect_key];
|
|
|
|
|
+ if(mList){
|
|
|
|
|
+ mixRatioMap[result.mixRatios[0].connect_key] = mixRatioMap[result.mixRatios[0].connect_key].concat(result.mixRatios);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ for(let u of result.newUnitPriceList){
|
|
|
|
|
+ me.unitPriceMap[gljUtil.getIndex(u)] = u;
|
|
|
|
|
+ unitPriceList.push(u);
|
|
|
|
|
+ }
|
|
|
|
|
+ me.onUnitPriceChange();
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ onUnitPriceChange:function(){
|
|
|
|
|
+ unitPriceObj.showMainDatas();
|
|
|
|
|
+ unitPriceObj.showSubDatas();
|
|
|
|
|
+ },
|
|
|
|
|
+ getGLJLibData : function (url, cb) {
|
|
|
|
|
+ //let property = projectObj.project.projectInfo.property;
|
|
|
|
|
+ //let engineerID = property.engineering_id;
|
|
|
|
|
+ CommonAjax.get(url, function (data) {
|
|
|
|
|
+ //编办中有多单价设置
|
|
|
|
|
+ if(data.datas.priceProperties && data.datas.priceProperties.length > 0){
|
|
|
|
|
+ let tem = _.find(data.datas.priceProperties,{region:property.region,taxModel:parseInt(property.taxType)});
|
|
|
|
|
+ if(tem){
|
|
|
|
|
+ let dataCode = tem.price.dataCode;
|
|
|
|
|
+ for(let glj of data.datas.stdGLJ){
|
|
|
|
|
+ if(glj.priceProperty && gljUtil.isDef(glj.priceProperty[dataCode])) glj.basePrice = glj.priceProperty[dataCode];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ cb(data);
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -285,6 +593,7 @@ function initPage(){
|
|
|
unitPriceObj.initMainSpread();
|
|
unitPriceObj.initMainSpread();
|
|
|
unitPriceObj.initSubSpread();
|
|
unitPriceObj.initSubSpread();
|
|
|
unitPriceObj.showMainDatas();
|
|
unitPriceObj.showMainDatas();
|
|
|
|
|
+ unitPriceObj.showSubDatas();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
unitPriceObj.setUntiPriceMap();
|
|
unitPriceObj.setUntiPriceMap();
|