|
@@ -32,6 +32,7 @@ materialCalcObj = {
|
|
|
freightSheet:null,
|
|
freightSheet:null,
|
|
|
freightDatas:[],
|
|
freightDatas:[],
|
|
|
conveyanceOptions:["自办运输","汽车","火车","船舶","马车","手推车","拖拉机"],
|
|
conveyanceOptions:["自办运输","汽车","火车","船舶","马车","手推车","拖拉机"],
|
|
|
|
|
+ userFreightList:[],
|
|
|
freightSetting:{
|
|
freightSetting:{
|
|
|
header:[
|
|
header:[
|
|
|
{headerName: "起讫地点", headerWidth: 80, dataCode: "start", dataType: "String"},
|
|
{headerName: "起讫地点", headerWidth: 80, dataCode: "start", dataType: "String"},
|
|
@@ -54,8 +55,12 @@ materialCalcObj = {
|
|
|
getText:{
|
|
getText:{
|
|
|
forExp:function (item) {
|
|
forExp:function (item) {
|
|
|
let material = materialCalcObj.getMaterialSelected();
|
|
let material = materialCalcObj.getMaterialSelected();
|
|
|
|
|
+ if(item.calcType == "内蒙古"){
|
|
|
|
|
+ let uString = materialCalcObj.getNeiMengUnitFreightString(item.kmDistance,item.materialType);
|
|
|
|
|
+ return `((${uString}x(1+${item.freightIncreaseRate}%)+${item.unitLoadingFee}x${item.loadingTimes})/1.09+${item.otherFee})x${material.grossWeightCoe_n}x${item.weightCoe}`;
|
|
|
|
|
+ }
|
|
|
//(单位运价×(1+运距增加率%)+装卸费单价×装卸次数+其它费用)×单位毛重×加权系数
|
|
//(单位运价×(1+运距增加率%)+装卸费单价×装卸次数+其它费用)×单位毛重×加权系数
|
|
|
- if(item.conveyance == "自办运输" || item.calcType == "内蒙古") return `(${item.unitFreight}x(1+${item.freightIncreaseRate}%)+${item.unitLoadingFee}x${item.loadingTimes}+${item.otherFee})x${material.grossWeightCoe_n}x${item.weightCoe}`;
|
|
|
|
|
|
|
+ if(item.conveyance == "自办运输") return `(${item.unitFreight}x(1+${item.freightIncreaseRate}%)+${item.unitLoadingFee}x${item.loadingTimes}+${item.otherFee})x${material.grossWeightCoe_n}x${item.weightCoe}`;
|
|
|
|
|
|
|
|
//(单位运价×km运距×(1+运距增加率%)+装卸费单价×装卸次数+其它费用)×单位毛重×加权系数
|
|
//(单位运价×km运距×(1+运距增加率%)+装卸费单价×装卸次数+其它费用)×单位毛重×加权系数
|
|
|
return `(${item.unitFreight}x${item.kmDistance}x(1+${item.freightIncreaseRate}%)+${item.unitLoadingFee}x${item.loadingTimes}+${item.otherFee})x${material.grossWeightCoe_n}x${item.weightCoe}`;
|
|
return `(${item.unitFreight}x${item.kmDistance}x(1+${item.freightIncreaseRate}%)+${item.unitLoadingFee}x${item.loadingTimes}+${item.otherFee})x${material.grossWeightCoe_n}x${item.weightCoe}`;
|
|
@@ -111,7 +116,7 @@ materialCalcObj = {
|
|
|
this.initRightClick("materialCalcSheet",this.materialSpread)
|
|
this.initRightClick("materialCalcSheet",this.materialSpread)
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- initFreightSpread:function(){
|
|
|
|
|
|
|
+ initFreightSpread:async function(){
|
|
|
this.freightSpread = SheetDataHelper.createNewSpread($("#freightSheet")[0]);
|
|
this.freightSpread = SheetDataHelper.createNewSpread($("#freightSheet")[0]);
|
|
|
sheetCommonObj.spreadDefaultStyle(this.freightSpread);
|
|
sheetCommonObj.spreadDefaultStyle(this.freightSpread);
|
|
|
this.freightSheet = this.freightSpread.getSheet(0);
|
|
this.freightSheet = this.freightSpread.getSheet(0);
|
|
@@ -125,6 +130,7 @@ materialCalcObj = {
|
|
|
}else {
|
|
}else {
|
|
|
this.initRightClick("freightSheet",this.freightSpread)
|
|
this.initRightClick("freightSheet",this.freightSpread)
|
|
|
}
|
|
}
|
|
|
|
|
+ this.userFreightList = await projectObj.project.projectGLJ.getUserFreights();
|
|
|
},
|
|
},
|
|
|
initFreightRationSpread:function () {
|
|
initFreightRationSpread:function () {
|
|
|
this.freightRationSpread = SheetDataHelper.createNewSpread($("#freight_ration_sheet")[0]);
|
|
this.freightRationSpread = SheetDataHelper.createNewSpread($("#freight_ration_sheet")[0]);
|
|
@@ -157,7 +163,7 @@ materialCalcObj = {
|
|
|
this.initRightClick("price_ration_sheet",this.priceRationSpread);
|
|
this.initRightClick("price_ration_sheet",this.priceRationSpread);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- initPriceSpread:function(){
|
|
|
|
|
|
|
+ initPriceSpread:async function(){
|
|
|
this.priceSpread = SheetDataHelper.createNewSpread($("#priceSheet")[0]);
|
|
this.priceSpread = SheetDataHelper.createNewSpread($("#priceSheet")[0]);
|
|
|
sheetCommonObj.spreadDefaultStyle(this.priceSpread);
|
|
sheetCommonObj.spreadDefaultStyle(this.priceSpread);
|
|
|
this.priceSheet = this.priceSpread.getSheet(0);
|
|
this.priceSheet = this.priceSpread.getSheet(0);
|
|
@@ -182,10 +188,22 @@ materialCalcObj = {
|
|
|
this.freightSheet.setRowCount(this.freightDatas+20);
|
|
this.freightSheet.setRowCount(this.freightDatas+20);
|
|
|
let convCol = _.findIndex(this.freightSetting.header,{'dataCode':'conveyance'});
|
|
let convCol = _.findIndex(this.freightSetting.header,{'dataCode':'conveyance'});
|
|
|
sheetCommonObj.setComboBox(-1,convCol,this.freightSheet,this.conveyanceOptions,false);
|
|
sheetCommonObj.setComboBox(-1,convCol,this.freightSheet,this.conveyanceOptions,false);
|
|
|
|
|
+ let startCol = _.findIndex(this.freightSetting.header,{'dataCode':'start'});
|
|
|
|
|
+ let startOptions = this.getUserFreightOptions();
|
|
|
|
|
+ sheetCommonObj.setComboBox(-1,startCol,this.freightSheet,startOptions,false,true);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
sel.row = oldData?_.findIndex(this.freightDatas,{'ID':oldData.ID}):sel.row ;
|
|
sel.row = oldData?_.findIndex(this.freightDatas,{'ID':oldData.ID}):sel.row ;
|
|
|
this.freightSheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
|
|
this.freightSheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
|
|
|
this.refreshRationView();
|
|
this.refreshRationView();
|
|
|
},
|
|
},
|
|
|
|
|
+ getUserFreightOptions :function () {
|
|
|
|
|
+ let options = [];
|
|
|
|
|
+ for(let uf of this.userFreightList){
|
|
|
|
|
+ options.push(uf.freight.start);
|
|
|
|
|
+ }
|
|
|
|
|
+ return options;
|
|
|
|
|
+ },
|
|
|
showFreightRationDatas:function (freight) {
|
|
showFreightRationDatas:function (freight) {
|
|
|
let sel = this.freightRationSheet.getSelections()[0];
|
|
let sel = this.freightRationSheet.getSelections()[0];
|
|
|
let oldData = sel.row<this.freightRations.length?this.freightRations[sel.row]:"";
|
|
let oldData = sel.row<this.freightRations.length?this.freightRations[sel.row]:"";
|
|
@@ -231,10 +249,10 @@ materialCalcObj = {
|
|
|
this.priceSheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
|
|
this.priceSheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
|
|
|
this.showPriceRationDatas();
|
|
this.showPriceRationDatas();
|
|
|
},
|
|
},
|
|
|
- showDatas:function(){
|
|
|
|
|
|
|
+ showDatas:async function(){
|
|
|
if(!$('#materialCalcSheet').is(':visible')) return;
|
|
if(!$('#materialCalcSheet').is(':visible')) return;
|
|
|
if(!this.materialSpread) this.initMaterialSpread();
|
|
if(!this.materialSpread) this.initMaterialSpread();
|
|
|
- if(!this.freightSpread) this.initFreightSpread();
|
|
|
|
|
|
|
+ if(!this.freightSpread)await this.initFreightSpread();
|
|
|
if(!this.priceSpread) this.initPriceSpread();
|
|
if(!this.priceSpread) this.initPriceSpread();
|
|
|
if(!this.freightRationSpread) this.initFreightRationSpread();
|
|
if(!this.freightRationSpread) this.initFreightRationSpread();
|
|
|
if(!this.priceRationSpread) this.initPriceRationSpread();
|
|
if(!this.priceRationSpread) this.initPriceRationSpread();
|
|
@@ -462,27 +480,56 @@ materialCalcObj = {
|
|
|
projectObj.project.projectGLJ.updateFreightCalc([{ID:recode.ID,doc:doc}],material.id);
|
|
projectObj.project.projectGLJ.updateFreightCalc([{ID:recode.ID,doc:doc}],material.id);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- calcNeiMengUnitFreight:function (kmDistance,materialType) {
|
|
|
|
|
- if(!kmDistance||kmDistance == '0') return "0";
|
|
|
|
|
|
|
+ calcNeiMengUnitFreight:function (tkmDistance,tmaterialType) {
|
|
|
|
|
+ if(!tkmDistance||tkmDistance == '0') return "0";
|
|
|
|
|
+ let decimal = getDecimal("glj.unitPrice");
|
|
|
|
|
+ tkmDistance = scMathUtil.roundForObj(tkmDistance,decimal);
|
|
|
|
|
+ return scMathUtil.roundForObj(this.calNeiMengTotalFreight(tkmDistance,tmaterialType)/tkmDistance,decimal);
|
|
|
|
|
+ },
|
|
|
|
|
+ calNeiMengTotalFreight:function (kmDistance,materialType) {
|
|
|
|
|
+ if(!kmDistance||kmDistance == '0') return 0;
|
|
|
let decimal = getDecimal("glj.unitPrice");
|
|
let decimal = getDecimal("glj.unitPrice");
|
|
|
let baseMap = {"地方材料":6,"外购材料":13,"沥青、燃料等":19};//"地方材料","外购材料","沥青、燃料等"
|
|
let baseMap = {"地方材料":6,"外购材料":13,"沥青、燃料等":19};//"地方材料","外购材料","沥青、燃料等"
|
|
|
let baseFreight = baseMap[materialType];
|
|
let baseFreight = baseMap[materialType];
|
|
|
kmDistance = scMathUtil.roundForObj(kmDistance,decimal);
|
|
kmDistance = scMathUtil.roundForObj(kmDistance,decimal);
|
|
|
//用截取的方式,一段段取值
|
|
//用截取的方式,一段段取值
|
|
|
let less = kmDistance - 5;//kmDistance <= 5 这段
|
|
let less = kmDistance - 5;//kmDistance <= 5 这段
|
|
|
- if(less <= 0) return baseFreight+"" ; //kmDistance <= 5 的时候直接取baseFreight
|
|
|
|
|
|
|
+ if(less <= 0) return baseFreight ; //kmDistance <= 5 的时候直接取baseFreight
|
|
|
|
|
|
|
|
- //5< kmDistance <= 15 每增运1km 则增加0.6
|
|
|
|
|
|
|
+ //5< kmDistance <= 15 每增运1km 则增加0.6
|
|
|
less = less - 10;
|
|
less = less - 10;
|
|
|
- if(less <=0) return scMathUtil.roundForObj(baseFreight + scMathUtil.roundForObj((less + 10) * 0.6,6),decimal)+"";//baseFreight + (less + 10) * 0.6;
|
|
|
|
|
|
|
+ if(less <=0) return scMathUtil.roundForObj(baseFreight + scMathUtil.roundForObj((less + 10) * 0.6,6),decimal);//baseFreight + (less + 10) * 0.6;
|
|
|
baseFreight = baseFreight + 10 * 0.6; //累加5到15这一段的运费;
|
|
baseFreight = baseFreight + 10 * 0.6; //累加5到15这一段的运费;
|
|
|
|
|
|
|
|
- //15< kmDistance <= 100 每增运1km 则增加0.45
|
|
|
|
|
|
|
+ //15< kmDistance <= 100 每增运1km 则增加0.45
|
|
|
less = less - 85;
|
|
less = less - 85;
|
|
|
- if(less <=0) return scMathUtil.roundForObj(baseFreight + scMathUtil.roundForObj((less + 85)*0.45,6),decimal)+"";//baseFreight + (less + 85)*0.45;
|
|
|
|
|
|
|
+ if(less <=0) return scMathUtil.roundForObj(baseFreight + scMathUtil.roundForObj((less + 85)*0.45,6),decimal);//baseFreight + (less + 85)*0.45;
|
|
|
baseFreight = scMathUtil.roundForObj(baseFreight + scMathUtil.roundForObj(85*0.45,6),6) ; //累加15到100这一段的运费;
|
|
baseFreight = scMathUtil.roundForObj(baseFreight + scMathUtil.roundForObj(85*0.45,6),6) ; //累加15到100这一段的运费;
|
|
|
- return scMathUtil.roundForObj(baseFreight + scMathUtil.roundForObj(less * 0.35,6),decimal)+""; // >100 的所有部分每增运1km 则增加0.35 baseFreight + less * 0.35
|
|
|
|
|
|
|
+ return scMathUtil.roundForObj(baseFreight + scMathUtil.roundForObj(less * 0.35,6),decimal); // >100 的所有部分每增运1km 则增加0.35 baseFreight + less * 0.35
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ getNeiMengUnitFreightString:function (kmDistance,materialType) {
|
|
|
|
|
+ if(!kmDistance||kmDistance == '0') return "0";
|
|
|
|
|
+ let decimal = getDecimal("glj.unitPrice");
|
|
|
|
|
+ let baseMap = {"地方材料":6,"外购材料":13,"沥青、燃料等":19};//"地方材料","外购材料","沥青、燃料等"
|
|
|
|
|
+ let baseFreight = baseMap[materialType];
|
|
|
|
|
+ kmDistance = scMathUtil.roundForObj(kmDistance,decimal);
|
|
|
|
|
+ let resultString = baseFreight+"";
|
|
|
|
|
+ //用截取的方式,一段段取值
|
|
|
|
|
+ let less = kmDistance - 5;//kmDistance <= 5 这段
|
|
|
|
|
+ if(less <= 0) return resultString ; //kmDistance <= 5 的时候直接取baseFreight
|
|
|
|
|
+
|
|
|
|
|
+ //5< kmDistance <= 15 每增运1km 则增加0.6
|
|
|
|
|
+ less = less - 10;
|
|
|
|
|
+ if(less <=0) return `(${resultString}+0.6x${less + 10})`;//baseFreight + (less + 10) * 0.6;
|
|
|
|
|
+ resultString = `${resultString}+0.6x10`;
|
|
|
|
|
+ //15< kmDistance <= 100 每增运1km 则增加0.45
|
|
|
|
|
+ less = less - 85;
|
|
|
|
|
+ if(less <=0) return `(${resultString}+0.45x${less + 85})`; //baseFreight + (less + 85)*0.45;
|
|
|
|
|
+ resultString = `${resultString}+0.45x85`;
|
|
|
|
|
+ return `(${resultString}+0.35x${less})`;// >100 的所有部分每增运1km 则增加0.35 baseFreight + less * 0.35
|
|
|
},
|
|
},
|
|
|
|
|
+
|
|
|
onFreightRationValueChange:function (sender,args) {
|
|
onFreightRationValueChange:function (sender,args) {
|
|
|
materialCalcObj.onRationValueChange(sender,args,"freight");
|
|
materialCalcObj.onRationValueChange(sender,args,"freight");
|
|
|
},
|
|
},
|
|
@@ -592,6 +639,23 @@ materialCalcObj = {
|
|
|
projectObj.project.projectGLJ.updateMaterialRation(datas);
|
|
projectObj.project.projectGLJ.updateMaterialRation(datas);
|
|
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
+ saveFreight:function (row) {
|
|
|
|
|
+ let record = this.freightDatas[row];
|
|
|
|
|
+ if(record){
|
|
|
|
|
+ console.log(record);
|
|
|
|
|
+ //to do 检查是否已经存在,存在给出是否覆盖提示
|
|
|
|
|
+ let user_freight = {rootProjectID:projectObj.project.projectInfo.property.rootProjectID};
|
|
|
|
|
+ let f = {};
|
|
|
|
|
+ for(let key in record){
|
|
|
|
|
+ f[key] = record[key];
|
|
|
|
|
+ if(key =="ration" || key == "ration_gljs")f[key] = [];//下面的定额和工料机不用保存
|
|
|
|
|
+ }
|
|
|
|
|
+ user_freight.freight = f;
|
|
|
|
|
+ projectObj.project.projectGLJ.updateUserFreight({freights:[user_freight],action:"add"});
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
getSideResize: function () {
|
|
getSideResize: function () {
|
|
|
let rg_sideResizeEles = {};
|
|
let rg_sideResizeEles = {};
|
|
|
rg_sideResizeEles.eleObj = {
|
|
rg_sideResizeEles.eleObj = {
|
|
@@ -632,7 +696,22 @@ materialCalcObj = {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
+ "saveFreight":{
|
|
|
|
|
+ name: "保存运输起讫地点",
|
|
|
|
|
+ icon: 'fa-sign-in',
|
|
|
|
|
+ visible:function () {
|
|
|
|
|
+ return id == "freightSheet";
|
|
|
|
|
+ },
|
|
|
|
|
+ disabled: function (){
|
|
|
|
|
+ if(id == "freightSheet") return me.rightClickTarget.row >= me.freightDatas.length;
|
|
|
|
|
+ return me.rightClickTarget.row === undefined;
|
|
|
|
|
+ },
|
|
|
|
|
+ callback:function () {
|
|
|
|
|
+ let row = me.rightClickTarget.row;
|
|
|
|
|
+ me.saveFreight(row);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ },
|
|
|
"delete": {
|
|
"delete": {
|
|
|
name: "删除",
|
|
name: "删除",
|
|
|
icon: 'fa-trash-o',
|
|
icon: 'fa-trash-o',
|