|
@@ -191,8 +191,6 @@ materialCalcObj = {
|
|
|
let startCol = _.findIndex(this.freightSetting.header,{'dataCode':'start'});
|
|
let startCol = _.findIndex(this.freightSetting.header,{'dataCode':'start'});
|
|
|
let startOptions = this.getUserFreightOptions();
|
|
let startOptions = this.getUserFreightOptions();
|
|
|
sheetCommonObj.setComboBox(-1,startCol,this.freightSheet,startOptions,false,true);
|
|
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();
|
|
@@ -427,9 +425,39 @@ materialCalcObj = {
|
|
|
weightCoe:'1',//加权系数
|
|
weightCoe:'1',//加权系数
|
|
|
connect_key:gljUtil.getIndex(material),
|
|
connect_key:gljUtil.getIndex(material),
|
|
|
unit_price_file_id:material.unit_price.unit_price_file_id
|
|
unit_price_file_id:material.unit_price.unit_price_file_id
|
|
|
- }
|
|
|
|
|
|
|
+ };
|
|
|
return newData;
|
|
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) {
|
|
onFreightValueChange:function (sender,args) {
|
|
|
let me = materialCalcObj;
|
|
let me = materialCalcObj;
|
|
|
let dataCode = me.freightSetting.header[args.col].dataCode;
|
|
let dataCode = me.freightSetting.header[args.col].dataCode;
|
|
@@ -444,10 +472,19 @@ materialCalcObj = {
|
|
|
value = value?scMathUtil.roundForObj(value,getDecimal("glj.unitPrice"))+'':'0'//4舍五入加默认为0
|
|
value = value?scMathUtil.roundForObj(value,getDecimal("glj.unitPrice"))+'':'0'//4舍五入加默认为0
|
|
|
}
|
|
}
|
|
|
if(args.row >= me.freightDatas.length){//新增
|
|
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;
|
|
|
|
|
+ newData.calcType = me.getDefualtCalcType();
|
|
|
|
|
+ if(newData.calcType == "内蒙古") newData.materialType = "地方材料";
|
|
|
|
|
+ }
|
|
|
projectObj.project.projectGLJ.addFreightCalc([newData],material.id);
|
|
projectObj.project.projectGLJ.addFreightCalc([newData],material.id);
|
|
|
}else {//修改
|
|
}else {//修改
|
|
|
let recode = me.freightDatas[args.row];
|
|
let recode = me.freightDatas[args.row];
|
|
@@ -477,6 +514,11 @@ materialCalcObj = {
|
|
|
if(dataCode == "materialType") doc["unitFreight"] = me.calcNeiMengUnitFreight(recode.kmDistance,value);
|
|
if(dataCode == "materialType") doc["unitFreight"] = me.calcNeiMengUnitFreight(recode.kmDistance,value);
|
|
|
if(dataCode == "kmDistance") doc["unitFreight"] = me.calcNeiMengUnitFreight(value,recode.materialType);
|
|
if(dataCode == "kmDistance") 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);
|
|
projectObj.project.projectGLJ.updateFreightCalc([{ID:recode.ID,doc:doc}],material.id);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
@@ -640,10 +682,20 @@ materialCalcObj = {
|
|
|
|
|
|
|
|
},
|
|
},
|
|
|
saveFreight:function (row) {
|
|
saveFreight:function (row) {
|
|
|
|
|
+ let me = this;
|
|
|
let record = this.freightDatas[row];
|
|
let record = this.freightDatas[row];
|
|
|
if(record){
|
|
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 user_freight = {rootProjectID:projectObj.project.projectInfo.property.rootProjectID};
|
|
|
let f = {};
|
|
let f = {};
|
|
|
for(let key in record){
|
|
for(let key in record){
|
|
@@ -653,9 +705,27 @@ materialCalcObj = {
|
|
|
user_freight.freight = f;
|
|
user_freight.freight = f;
|
|
|
projectObj.project.projectGLJ.updateUserFreight({freights:[user_freight],action:"add"});
|
|
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 () {
|
|
getSideResize: function () {
|
|
|
let rg_sideResizeEles = {};
|
|
let rg_sideResizeEles = {};
|
|
|
rg_sideResizeEles.eleObj = {
|
|
rg_sideResizeEles.eleObj = {
|