|
@@ -128,6 +128,7 @@ materialCalcObj = {
|
|
|
this.freightSheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onFreightValueChange);
|
|
this.freightSheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onFreightValueChange);
|
|
|
this.freightSheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onFreightSelectionChange);
|
|
this.freightSheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onFreightSelectionChange);
|
|
|
this.freightSheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onFreightEditStarting);
|
|
this.freightSheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onFreightEditStarting);
|
|
|
|
|
+ this.freightSheet.bind(GC.Spread.Sheets.Events.RangeChanged, this.onFreightPriceRangeChange);
|
|
|
this.freightSheet.name('freight_calc');
|
|
this.freightSheet.name('freight_calc');
|
|
|
if(projectReadOnly){
|
|
if(projectReadOnly){
|
|
|
disableSpread(this.freightSpread);
|
|
disableSpread(this.freightSpread);
|
|
@@ -172,6 +173,7 @@ materialCalcObj = {
|
|
|
sheetCommonObj.spreadDefaultStyle(this.priceSpread);
|
|
sheetCommonObj.spreadDefaultStyle(this.priceSpread);
|
|
|
this.priceSheet = this.priceSpread.getSheet(0);
|
|
this.priceSheet = this.priceSpread.getSheet(0);
|
|
|
sheetCommonObj.initSheet(this.priceSheet, this.priceSetting, 30);
|
|
sheetCommonObj.initSheet(this.priceSheet, this.priceSetting, 30);
|
|
|
|
|
+ this.priceSheet.bind(GC.Spread.Sheets.Events.RangeChanged, this.onFreightPriceRangeChange);
|
|
|
this.priceSheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onPriceValueChange);
|
|
this.priceSheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onPriceValueChange);
|
|
|
this.priceSheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onPriceSelectionChange);
|
|
this.priceSheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onPriceSelectionChange);
|
|
|
this.priceSheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onPriceEditStarting);
|
|
this.priceSheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onPriceEditStarting);
|
|
@@ -471,69 +473,100 @@ materialCalcObj = {
|
|
|
}
|
|
}
|
|
|
return t;
|
|
return t;
|
|
|
},
|
|
},
|
|
|
|
|
+ onFreightPriceRangeChange:function (sender,args) {
|
|
|
|
|
+ let me = materialCalcObj;
|
|
|
|
|
+ let dataMap={};
|
|
|
|
|
+ let sheetName = args.sheet.name();
|
|
|
|
|
+ for(let c of args.changedCells){
|
|
|
|
|
+ let info = {row:c.row,col:c.col,cancel:false};
|
|
|
|
|
+ sheetName == 'price_calc'?me.onPriceEditStarting(sender,info): me.onFreightEditStarting(sender,info);
|
|
|
|
|
+ if(info.cancel) return me.showDatas();
|
|
|
|
|
+ let value= args.sheet.getCell(c.row, c.col).text();
|
|
|
|
|
+ if(dataMap[c.row]){
|
|
|
|
|
+ dataMap[c.row][c.col]=value;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ dataMap[c.row] ={};
|
|
|
|
|
+ dataMap[c.row][c.col] = value;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ sheetName == 'price_calc'?me.addOrUpdatePriceCalc(dataMap):me.addOrUpdateFreightCalc(dataMap);
|
|
|
|
|
+ },
|
|
|
onFreightValueChange:function (sender,args) {
|
|
onFreightValueChange:function (sender,args) {
|
|
|
let me = materialCalcObj;
|
|
let me = materialCalcObj;
|
|
|
- let dataCode = me.freightSetting.header[args.col].dataCode;
|
|
|
|
|
- let value = args.newValue;
|
|
|
|
|
|
|
+ let dataMap = {};
|
|
|
|
|
+ dataMap[args.row]={};
|
|
|
|
|
+ dataMap[args.row][args.col] = args.newValue;
|
|
|
|
|
+ me.addOrUpdateFreightCalc(dataMap);
|
|
|
|
|
+ },
|
|
|
|
|
+ addOrUpdateFreightCalc:function (dataMap) {//{2:{col:value}}
|
|
|
|
|
+ let me = materialCalcObj;
|
|
|
let material = me.getMaterialSelected();
|
|
let material = me.getMaterialSelected();
|
|
|
- if (value&&!sheetCommonObj.checkData(args.col,me.freightSetting,value)) {
|
|
|
|
|
- alert('输入的数据类型不对,请重新输入!');
|
|
|
|
|
- me.showDatas();
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- if(dataCode != 'start'&&dataCode != 'conveyance'&&dataCode != 'calcType'&&dataCode != 'materialType'){
|
|
|
|
|
- value = value?scMathUtil.roundForObj(value,getDecimal("glj.unitPrice"))+'':'0'//4舍五入加默认为0
|
|
|
|
|
- }
|
|
|
|
|
- if(args.row >= me.freightDatas.length){//新增
|
|
|
|
|
|
|
+ let addDatas=[],updateDatas=[];
|
|
|
|
|
+ for(let row in dataMap) {
|
|
|
|
|
+ let t = dataMap[row];
|
|
|
let newData = {};
|
|
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];
|
|
|
|
|
- if(recode[dataCode] == value) return;
|
|
|
|
|
let doc = {};
|
|
let doc = {};
|
|
|
- doc[dataCode] = value;
|
|
|
|
|
- if(dataCode == "conveyance"){//如果运输方式从自办运输切换成其它的东西时,要把底下挂的定额和定额工料机都清空
|
|
|
|
|
- if(args.oldValue == "自办运输"){
|
|
|
|
|
- doc["rations"] = [];
|
|
|
|
|
- doc["ration_gljs"] = [];
|
|
|
|
|
|
|
+ let recode = me.freightDatas[row];
|
|
|
|
|
+ for (let col in t) {
|
|
|
|
|
+ let value = t[col];
|
|
|
|
|
+ let dataCode = me.freightSetting.header[col].dataCode;
|
|
|
|
|
+ if (value && !sheetCommonObj.checkData(col, me.freightSetting, value)) {
|
|
|
|
|
+ alert('输入的数据类型不对,请重新输入!');
|
|
|
|
|
+ return me.showDatas();
|
|
|
}
|
|
}
|
|
|
- if(value == "自办运输"){//当运输工具下拉选择“自办运输”时,“Km运距”、“装卸费单价”、“装卸次数”、“运价增加率(%)”列数据归0,且灰选不可编辑
|
|
|
|
|
- doc["kmDistance"] = '0';
|
|
|
|
|
- doc["unitLoadingFee"] ='0';
|
|
|
|
|
- doc["loadingTimes"] = '0';
|
|
|
|
|
- doc["freightIncreaseRate"] = '0';
|
|
|
|
|
|
|
+ if (dataCode != 'start' && dataCode != 'conveyance' && dataCode != 'calcType' && dataCode != 'materialType') {
|
|
|
|
|
+ value = value ? scMathUtil.roundForObj(value, getDecimal("glj.unitPrice")) + '' : '0'//4舍五入加默认为0
|
|
|
}
|
|
}
|
|
|
- if(args.oldValue =="汽车") doc["materialType"] = "";//当运输方式从汽车切换成其它方式时,清空材料类型
|
|
|
|
|
|
|
+ if (parseInt(row) >= me.freightDatas.length) {//新增
|
|
|
|
|
+ let tempFreight = null;
|
|
|
|
|
+ if (dataCode == "start") {
|
|
|
|
|
+ tempFreight = me.getSavedFreight(value, material);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (tempFreight) {
|
|
|
|
|
+ newData = tempFreight;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if(_.isEmpty(newData)) newData = me.getNewFreightData(material);
|
|
|
|
|
+ newData[dataCode] = value;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {//修改
|
|
|
|
|
+ if (recode[dataCode] == value) continue;
|
|
|
|
|
+ doc[dataCode] = value;
|
|
|
|
|
+ if (dataCode == "conveyance") {//如果运输方式从自办运输切换成其它的东西时,要把底下挂的定额和定额工料机都清空
|
|
|
|
|
+ if (recode[dataCode] == "自办运输") {//没改之前的值
|
|
|
|
|
+ doc["rations"] = [];
|
|
|
|
|
+ doc["ration_gljs"] = [];
|
|
|
|
|
+ }
|
|
|
|
|
+ if (value == "自办运输") {//当运输工具下拉选择“自办运输”时,“Km运距”、“装卸费单价”、“装卸次数”、“运价增加率(%)”列数据归0,且灰选不可编辑
|
|
|
|
|
+ doc["kmDistance"] = '0';
|
|
|
|
|
+ doc["unitLoadingFee"] = '0';
|
|
|
|
|
+ doc["loadingTimes"] = '0';
|
|
|
|
|
+ doc["freightIncreaseRate"] = '0';
|
|
|
|
|
+ }
|
|
|
|
|
+ if (recode[dataCode] == "汽车") doc["materialType"] = "";//当运输方式从汽车切换成其它方式时,清空材料类型
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
- /* if(dataCode == "calcType"){
|
|
|
|
|
- if(value == "全国") doc["materialType"] = "";
|
|
|
|
|
- if(value == "内蒙古"){
|
|
|
|
|
- doc["materialType"] = "地方材料";
|
|
|
|
|
- doc["unitFreight"] = me.calcNeiMengUnitFreight(recode.kmDistance,"地方材料");
|
|
|
|
|
- }
|
|
|
|
|
- }*/
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- 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 == "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;
|
|
|
|
|
|
|
+ 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);
|
|
|
|
|
|
|
+ if (!_.isEmpty(newData)) addDatas.push(newData);
|
|
|
|
|
+ if (!_.isEmpty(doc)) updateDatas.push({ID:recode.ID,doc:doc});
|
|
|
}
|
|
}
|
|
|
|
|
+ if(addDatas.length > 0 && updateDatas.length > 0) {
|
|
|
|
|
+ alert("不能同时增加和更新操作");
|
|
|
|
|
+ return me.showDatas();
|
|
|
|
|
+ }
|
|
|
|
|
+ if(addDatas.length > 0) projectObj.project.projectGLJ.addFreightCalc(addDatas,material.id);
|
|
|
|
|
+ if(updateDatas.length > 0) projectObj.project.projectGLJ.updateFreightCalc(updateDatas,material.id);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
},
|
|
},
|
|
|
calcNeiMengUnitFreight:function (tkmDistance,tmaterialType) {
|
|
calcNeiMengUnitFreight:function (tkmDistance,tmaterialType) {
|
|
|
if(!tkmDistance||tkmDistance == '0') return "0";
|
|
if(!tkmDistance||tkmDistance == '0') return "0";
|
|
@@ -633,39 +666,61 @@ materialCalcObj = {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
},
|
|
},
|
|
|
- onPriceValueChange:function(sender,args){
|
|
|
|
|
|
|
+ addOrUpdatePriceCalc:function (dataMap) {
|
|
|
let me = materialCalcObj;
|
|
let me = materialCalcObj;
|
|
|
- let dataCode = me.priceSetting.header[args.col].dataCode;
|
|
|
|
|
- let value = args.newValue;
|
|
|
|
|
let material = me.getMaterialSelected();
|
|
let material = me.getMaterialSelected();
|
|
|
- //输入有效性判断, to do
|
|
|
|
|
- if (value&&!sheetCommonObj.checkData(args.col,me.priceSetting,value)) {
|
|
|
|
|
- alert('输入的数据类型不对,请重新输入!');
|
|
|
|
|
- me.showDatas();
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- if(dataCode == 'coe'||dataCode == 'supplyPrice'){
|
|
|
|
|
- let decimal = dataCode == 'supplyPrice'?getDecimal("glj.unitPriceHasMix"):getDecimal("glj.unitPrice");
|
|
|
|
|
- value = value?scMathUtil.roundForObj(value,decimal)+'':'0'//4舍五入加默认为0
|
|
|
|
|
- }
|
|
|
|
|
- if(args.row >= me.priceDatas.length){//新增
|
|
|
|
|
- let newData = {
|
|
|
|
|
- ID:uuid.v1(),
|
|
|
|
|
- supplyLocation:"",
|
|
|
|
|
- supplyPrice:'0',
|
|
|
|
|
- coe:'1',
|
|
|
|
|
- connect_key:gljUtil.getIndex(material),
|
|
|
|
|
- unit_price_file_id:material.unit_price.unit_price_file_id
|
|
|
|
|
- };
|
|
|
|
|
- newData[dataCode] = value;
|
|
|
|
|
- projectObj.project.projectGLJ.addPriceCalc([newData],material.id);
|
|
|
|
|
- }else {//修改
|
|
|
|
|
- let recode = me.priceDatas[args.row];
|
|
|
|
|
- if(recode[dataCode] == value) return;
|
|
|
|
|
|
|
+ let addDatas=[],updateDatas=[];
|
|
|
|
|
+ for(let row in dataMap) {
|
|
|
|
|
+ let t = dataMap[row];
|
|
|
let doc = {};
|
|
let doc = {};
|
|
|
- doc[dataCode] = value;
|
|
|
|
|
- projectObj.project.projectGLJ.updatePriceCalc([{ID:recode.ID,doc:doc}],material.id);
|
|
|
|
|
|
|
+ let recode = me.priceDatas[row];
|
|
|
|
|
+ let newData = {};
|
|
|
|
|
+ for (let col in t) {
|
|
|
|
|
+ let value = t[col];
|
|
|
|
|
+ let dataCode = me.priceSetting.header[col].dataCode;;
|
|
|
|
|
+ if (value && !sheetCommonObj.checkData(col, me.priceSetting, value)) {
|
|
|
|
|
+ alert('输入的数据类型不对,请重新输入!');
|
|
|
|
|
+ return me.showDatas();
|
|
|
|
|
+ }
|
|
|
|
|
+ if(dataCode == 'coe'||dataCode == 'supplyPrice'){
|
|
|
|
|
+ let decimal = dataCode == 'supplyPrice'?getDecimal("glj.unitPriceHasMix"):getDecimal("glj.unitPrice");
|
|
|
|
|
+ value = value?scMathUtil.roundForObj(value,decimal)+'':'0'//4舍五入加默认为0
|
|
|
|
|
+ }
|
|
|
|
|
+ if(parseInt(row) >= me.priceDatas.length){//新增
|
|
|
|
|
+ if(_.isEmpty(newData)) newData = me.getNewPriceData(material);
|
|
|
|
|
+ newData[dataCode] = value;
|
|
|
|
|
+ }else {//修改
|
|
|
|
|
+ if(recode[dataCode] == value) continue;
|
|
|
|
|
+ doc[dataCode] = value;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!_.isEmpty(newData)) addDatas.push(newData);
|
|
|
|
|
+ if (!_.isEmpty(doc)) updateDatas.push({ID:recode.ID,doc:doc});
|
|
|
}
|
|
}
|
|
|
|
|
+ if(addDatas.length > 0 && updateDatas.length > 0) {
|
|
|
|
|
+ alert("不能同时增加和更新操作");
|
|
|
|
|
+ return me.showDatas();
|
|
|
|
|
+ }
|
|
|
|
|
+ if(addDatas.length > 0) projectObj.project.projectGLJ.addPriceCalc(addDatas,material.id);
|
|
|
|
|
+ if(updateDatas.length > 0) projectObj.project.projectGLJ.updatePriceCalc(updateDatas,material.id);
|
|
|
|
|
+ },
|
|
|
|
|
+ getNewPriceData:function (material) {
|
|
|
|
|
+ let newData = {
|
|
|
|
|
+ ID:uuid.v1(),
|
|
|
|
|
+ supplyLocation:"",
|
|
|
|
|
+ supplyPrice:'0',
|
|
|
|
|
+ coe:'1',
|
|
|
|
|
+ connect_key:gljUtil.getIndex(material),
|
|
|
|
|
+ unit_price_file_id:material.unit_price.unit_price_file_id
|
|
|
|
|
+ };
|
|
|
|
|
+ return newData;
|
|
|
|
|
+ },
|
|
|
|
|
+ onPriceValueChange:function(sender,args){
|
|
|
|
|
+ let me = materialCalcObj;
|
|
|
|
|
+ let dataMap = {};
|
|
|
|
|
+ dataMap[args.row]={};
|
|
|
|
|
+ dataMap[args.row][args.col] = args.newValue;
|
|
|
|
|
+ me.addOrUpdatePriceCalc(dataMap);
|
|
|
},
|
|
},
|
|
|
deleteMaterialCal:function (row) {
|
|
deleteMaterialCal:function (row) {
|
|
|
let record = this.materialDatas[row];//修改材料计算标记的同时还要删除原价计算,运费计算等
|
|
let record = this.materialDatas[row];//修改材料计算标记的同时还要删除原价计算,运费计算等
|