|
|
@@ -45,8 +45,8 @@ materialCalcObj = {
|
|
|
{headerName: "运价增\n加率(%)", headerWidth: 60, dataCode: "freightIncreaseRate", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:"glj.unitPrice"
|
|
|
{headerName: "加权\n系数", headerWidth: 60, dataCode: "weightCoe", hAlign: "right", dataType: "Number",validator:"number"},
|
|
|
{headerName: "计算式", headerWidth: 170, dataCode: "exp", hAlign: "left", dataType: "Number",getText:'forExp'},//,decimalField:"glj.unitPrice"
|
|
|
- {headerName: "计算方式", headerWidth: 80, dataCode: "calcType", dataType: "String",cellType:"comboBox",options:["全国","内蒙古"]},
|
|
|
- {headerName: "材料类型", headerWidth: 80, dataCode: "materialType", dataType: "String",cellType:"comboBox",options:["地方材料","外购材料","沥青、燃料等"]}
|
|
|
+ {headerName: "计算方式", headerWidth: 80, dataCode: "calcType",visible: false, dataType: "String",cellType:"comboBox",options:["全国","内蒙古"]},
|
|
|
+ {headerName: "材料类型", headerWidth: 80, dataCode: "materialType", visible: false,dataType: "String",cellType:"comboBox",options:["","地方材料","外购材料","沥青、燃料等"]}
|
|
|
],
|
|
|
view: {
|
|
|
lockColumns: ["exp"],
|
|
|
@@ -55,7 +55,7 @@ materialCalcObj = {
|
|
|
getText:{
|
|
|
forExp:function (item) {
|
|
|
let material = materialCalcObj.getMaterialSelected();
|
|
|
- if(item.calcType == "内蒙古"){
|
|
|
+ if(gljUtil.isDef(item.materialType)&&item.materialType != ""){
|
|
|
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}`;
|
|
|
}
|
|
|
@@ -191,8 +191,6 @@ materialCalcObj = {
|
|
|
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 ;
|
|
|
this.freightSheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
|
|
|
this.refreshRationView();
|
|
|
@@ -346,10 +344,10 @@ materialCalcObj = {
|
|
|
}else {
|
|
|
let freigth = me.freightDatas[args.row];
|
|
|
let dataCode = me.freightSetting.header[args.col].dataCode;
|
|
|
- if(dataCode == "calcType" || dataCode=="materialType"){
|
|
|
+ if(dataCode=="materialType"){
|
|
|
if(!freigth){
|
|
|
args.cancel = true;
|
|
|
- }else if(dataCode == "materialType" && freigth.calcType !="内蒙古"){//不是内蒙古的情况下,下拉框不可编辑
|
|
|
+ }else if(freigth.conveyance !="汽车"){//只有在汽车的情况下,材料类型列才能编辑
|
|
|
args.cancel = true;
|
|
|
}
|
|
|
}
|
|
|
@@ -359,7 +357,7 @@ materialCalcObj = {
|
|
|
}
|
|
|
if(dataCode == "unitFreight"){
|
|
|
if(freigth.rations && freigth.rations.length > 0) args.cancel = true;
|
|
|
- if(freigth.calcType == "内蒙古") args.cancel = true;
|
|
|
+ if(gljUtil.isDef(freigth.materialType) && freigth.materialType != "") args.cancel = true;//当材料类型有值时,说明是内蒙古计算,运费是能过运距算出来的,不能编辑
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -426,10 +424,41 @@ materialCalcObj = {
|
|
|
freightIncreaseRate:'0',//运价增加率
|
|
|
weightCoe:'1',//加权系数
|
|
|
connect_key:gljUtil.getIndex(material),
|
|
|
+ materialType:"",
|
|
|
unit_price_file_id:material.unit_price.unit_price_file_id
|
|
|
- }
|
|
|
+ };
|
|
|
return newData;
|
|
|
},
|
|
|
+ getSavedFreight:function (start,material) {
|
|
|
+ let t = null;
|
|
|
+ for(let f of this.userFreightList){
|
|
|
+ if(f.freight.start == start){
|
|
|
+ t = newDatas(f.freight,material);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return t;
|
|
|
+ function newDatas(freight,material) {
|
|
|
+ let doc = {};
|
|
|
+ for(let key in freight){
|
|
|
+ doc[key] = freight[key];
|
|
|
+ if(key == "ID") doc[key] = uuid.v1();
|
|
|
+ if(key == "connect_key") doc[key] = gljUtil.getIndex(material);
|
|
|
+ if(key == "unit_price_file_id") doc[key] = material.unit_price.unit_price_file_id;
|
|
|
+ }
|
|
|
+ return doc;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ checkSavedFreight:function (start) {
|
|
|
+ let t = null;
|
|
|
+ for(let f of this.userFreightList){
|
|
|
+ if(f.freight.start == start){
|
|
|
+ t = f;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return t;
|
|
|
+ },
|
|
|
onFreightValueChange:function (sender,args) {
|
|
|
let me = materialCalcObj;
|
|
|
let dataCode = me.freightSetting.header[args.col].dataCode;
|
|
|
@@ -444,10 +473,17 @@ materialCalcObj = {
|
|
|
value = value?scMathUtil.roundForObj(value,getDecimal("glj.unitPrice"))+'':'0'//4舍五入加默认为0
|
|
|
}
|
|
|
if(args.row >= me.freightDatas.length){//新增
|
|
|
- let newData = me.getNewFreightData(material);
|
|
|
- newData[dataCode] = value;
|
|
|
- newData.calcType = me.getDefualtCalcType();
|
|
|
- if(newData.calcType == "内蒙古") newData.materialType = "地方材料";
|
|
|
+ let newData = {};
|
|
|
+ let tempFreight = null;
|
|
|
+ if(dataCode == "start"){
|
|
|
+ tempFreight = me.getSavedFreight(value,material);
|
|
|
+ }
|
|
|
+ if(tempFreight){
|
|
|
+ newData = tempFreight;
|
|
|
+ }else {
|
|
|
+ newData = me.getNewFreightData(material);
|
|
|
+ newData[dataCode] = value;
|
|
|
+ }
|
|
|
projectObj.project.projectGLJ.addFreightCalc([newData],material.id);
|
|
|
}else {//修改
|
|
|
let recode = me.freightDatas[args.row];
|
|
|
@@ -465,17 +501,24 @@ materialCalcObj = {
|
|
|
doc["loadingTimes"] = '0';
|
|
|
doc["freightIncreaseRate"] = '0';
|
|
|
}
|
|
|
+ if(args.oldValue =="汽车") doc["materialType"] = "";//当运输方式从汽车切换成其它方式时,清空材料类型
|
|
|
+
|
|
|
}
|
|
|
- if(dataCode == "calcType"){
|
|
|
+ /* if(dataCode == "calcType"){
|
|
|
if(value == "全国") doc["materialType"] = "";
|
|
|
if(value == "内蒙古"){
|
|
|
doc["materialType"] = "地方材料";
|
|
|
doc["unitFreight"] = me.calcNeiMengUnitFreight(recode.kmDistance,"地方材料");
|
|
|
}
|
|
|
- }
|
|
|
- if(recode.calcType == "内蒙古"){
|
|
|
- if(dataCode == "materialType") doc["unitFreight"] = me.calcNeiMengUnitFreight(recode.kmDistance,value);
|
|
|
- if(dataCode == "kmDistance") doc["unitFreight"] = me.calcNeiMengUnitFreight(value,recode.materialType);
|
|
|
+ }*/
|
|
|
+
|
|
|
+ if(dataCode == "materialType" && value!="") doc["unitFreight"] = me.calcNeiMengUnitFreight(recode.kmDistance,value);
|
|
|
+ if(dataCode == "kmDistance" && gljUtil.isDef(recode.materialType)&&recode.materialType!="") doc["unitFreight"] = me.calcNeiMengUnitFreight(value,recode.materialType);
|
|
|
+
|
|
|
+ if(dataCode == "start"){
|
|
|
+ let t_f = me.getSavedFreight(value,material);
|
|
|
+ if(t_f) doc = t_f;
|
|
|
+
|
|
|
}
|
|
|
projectObj.project.projectGLJ.updateFreightCalc([{ID:recode.ID,doc:doc}],material.id);
|
|
|
}
|
|
|
@@ -640,10 +683,20 @@ materialCalcObj = {
|
|
|
|
|
|
},
|
|
|
saveFreight:function (row) {
|
|
|
+ let me = this;
|
|
|
let record = this.freightDatas[row];
|
|
|
if(record){
|
|
|
- console.log(record);
|
|
|
- //to do 检查是否已经存在,存在给出是否覆盖提示
|
|
|
+ let exist = this.checkSavedFreight(record.start);
|
|
|
+ if(exist){//已存在的情况,更新
|
|
|
+ let info =`起讫地点“${record.start}”已存在,是否覆盖?`;
|
|
|
+ //to do 检查是否已经存在,存在给出是否覆盖提示
|
|
|
+ hintBox.infoBox('操作确认', info, 2, function () {
|
|
|
+ me.updateUserFreight(record,exist)
|
|
|
+ }, function () {
|
|
|
+ //
|
|
|
+ },['确定','取消'],false);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
let user_freight = {rootProjectID:projectObj.project.projectInfo.property.rootProjectID};
|
|
|
let f = {};
|
|
|
for(let key in record){
|
|
|
@@ -653,9 +706,27 @@ materialCalcObj = {
|
|
|
user_freight.freight = f;
|
|
|
projectObj.project.projectGLJ.updateUserFreight({freights:[user_freight],action:"add"});
|
|
|
}
|
|
|
+ },
|
|
|
+
|
|
|
+ updateUserFreight:function (record,userFreight) {
|
|
|
+ let t = {};
|
|
|
+ for(let t_key in userFreight){
|
|
|
+ if(t_key == "ID") continue;
|
|
|
+ t[t_key] = userFreight[t_key];
|
|
|
+ }
|
|
|
+
|
|
|
+ t.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] = [];//下面的定额和工料机不用保存
|
|
|
+ }
|
|
|
+ t.freight = f;
|
|
|
+ projectObj.project.projectGLJ.updateUserFreight({ID:userFreight.ID,doc:t,action:"update"});
|
|
|
|
|
|
},
|
|
|
|
|
|
+
|
|
|
getSideResize: function () {
|
|
|
let rg_sideResizeEles = {};
|
|
|
rg_sideResizeEles.eleObj = {
|
|
|
@@ -685,7 +756,7 @@ materialCalcObj = {
|
|
|
name: "内蒙古计算",
|
|
|
icon: 'fa-sign-in',
|
|
|
visible:function () {
|
|
|
- return id == "freightSheet";
|
|
|
+ return false;//2019-11-17 改成不需要右键插入功能 id == "freightSheet";
|
|
|
},
|
|
|
disabled: function (){
|
|
|
let material = me.getMaterialSelected();
|