|
@@ -3,13 +3,13 @@ let divideObj = {
|
|
|
header: [
|
|
header: [
|
|
|
{headerName: "类别", headerWidth: 60, dataCode: "itemType", hAlign:'center', dataType: "String"},
|
|
{headerName: "类别", headerWidth: 60, dataCode: "itemType", hAlign:'center', dataType: "String"},
|
|
|
{headerName: "清单编号", headerWidth: 130, dataCode: "code", hAlign:'left', dataType: "String", formatter: "@"},
|
|
{headerName: "清单编号", headerWidth: 130, dataCode: "code", hAlign:'left', dataType: "String", formatter: "@"},
|
|
|
- {headerName: "名称", headerWidth: 160, dataCode: "name", dataType: "String",formatter: "@"},
|
|
|
|
|
- {headerName: "单位", headerWidth: 100, dataCode: "unit", dataType: "String",cellType:'comboBox',editable:true,options:['m', 'm2', 'm3', 'km', 't', 'kg', '台班', '工日', '昼夜', '元', '项', '处', '个', '件',
|
|
|
|
|
|
|
+ {headerName: "名称", headerWidth: 250, dataCode: "name", dataType: "String",formatter: "@"},
|
|
|
|
|
+ {headerName: "单位", headerWidth: 50, dataCode: "unit", dataType: "String",cellType:'comboBox',editable:true,options:['m', 'm2', 'm3', 'km', 't', 'kg', '台班', '工日', '昼夜', '元', '项', '处', '个', '件',
|
|
|
'根', '组', '系统', '台', '套', '株', '丛', '缸', '支', '只', '块', '座', '对', '份', '樘', '攒', '榀']},
|
|
'根', '组', '系统', '台', '套', '株', '丛', '缸', '支', '只', '块', '座', '对', '份', '樘', '攒', '榀']},
|
|
|
{headerName: "工程量", headerWidth: 80, dataCode: "quantity", dataType: "Number",validator:"number",getText:"notZero"},
|
|
{headerName: "工程量", headerWidth: 80, dataCode: "quantity", dataType: "Number",validator:"number",getText:"notZero"},
|
|
|
- {headerName: "单价", headerWidth: 100, dataCode: "marketPrice", dataType: "Number",validator:"number",getText:"notZero"},
|
|
|
|
|
- {headerName: "金额", headerWidth: 100, dataCode: "marketTotalFee", dataType: "Number",validator:"number",getText:"notZero"},
|
|
|
|
|
- {headerName: "预算价", headerWidth: 100, dataCode: "marketUnitFee", dataType: "Number",validator:"number",getText:"notZero"},
|
|
|
|
|
|
|
+ {headerName: "单价", headerWidth: 80, dataCode: "marketPrice", dataType: "Number",validator:"number",getText:"notZero"},
|
|
|
|
|
+ {headerName: "金额", headerWidth: 80, dataCode: "marketTotalFee", dataType: "Number",validator:"number",getText:"notZero"},
|
|
|
|
|
+ {headerName: "预算价", headerWidth: 80, dataCode: "marketUnitFee", dataType: "Number",validator:"number",getText:"notZero"},
|
|
|
{headerName: "取费类别", headerWidth: 60, dataCode: "programID", hAlign:'center', dataType: "String",cellType:'comboBox',editorValueType:true}
|
|
{headerName: "取费类别", headerWidth: 60, dataCode: "programID", hAlign:'center', dataType: "String",cellType:'comboBox',editorValueType:true}
|
|
|
],
|
|
],
|
|
|
view:{
|
|
view:{
|
|
@@ -35,7 +35,7 @@ let divideObj = {
|
|
|
{headerName: "不可分摊", headerWidth: 80, dataCode: "unDivide", dataType: "Number",cellType:'checkBox'}
|
|
{headerName: "不可分摊", headerWidth: 80, dataCode: "unDivide", dataType: "Number",cellType:'checkBox'}
|
|
|
],
|
|
],
|
|
|
view:{
|
|
view:{
|
|
|
- lockColumns: [0,1,2,3,4,5,6],
|
|
|
|
|
|
|
+ lockColumns: [0,1,2,3,4,5,6,7],
|
|
|
colHeaderHeight:30
|
|
colHeaderHeight:30
|
|
|
},
|
|
},
|
|
|
treeCol:1
|
|
treeCol:1
|
|
@@ -47,19 +47,19 @@ let divideObj = {
|
|
|
{headerName: "分摊比例", headerWidth: 100, dataCode: "divideRate", dataType: "Number",validator:"number"}
|
|
{headerName: "分摊比例", headerWidth: 100, dataCode: "divideRate", dataType: "Number",validator:"number"}
|
|
|
],
|
|
],
|
|
|
view:{
|
|
view:{
|
|
|
- lockColumns: [0,1,2],
|
|
|
|
|
|
|
+ lockColumns: [0,1],
|
|
|
colHeaderHeight:30
|
|
colHeaderHeight:30
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
billsSetting:{
|
|
billsSetting:{
|
|
|
header: [
|
|
header: [
|
|
|
- {headerName: "编号", headerWidth: 130, dataCode: "code", hAlign:'left', dataType: "String"},
|
|
|
|
|
- {headerName: "名称", headerWidth: 160, dataCode: "name", dataType: "String"},
|
|
|
|
|
- {headerName: "分摊比例", headerWidth: 80, dataCode: "divideRate", dataType: "Number",validator:"number"},
|
|
|
|
|
- {headerName: "分摊金额", headerWidth: 100, dataCode: "dividePrice", dataType: "Number",validator:"number"},
|
|
|
|
|
- {headerName: "原始金额", headerWidth: 100, dataCode: "originalPrice", dataType: "Number",validator:"number"},
|
|
|
|
|
- {headerName: "合计", headerWidth: 100, dataCode: "totalPrice", dataType: "Number",validator:"number"},
|
|
|
|
|
- {headerName: "金额", headerWidth: 60, dataCode: "price", dataType: "Number",validator:"number"}
|
|
|
|
|
|
|
+ {headerName: "编号", headerWidth: 100, dataCode: "code", hAlign:'left', dataType: "String"},
|
|
|
|
|
+ {headerName: "名称", headerWidth: 250, dataCode: "name", dataType: "String"},
|
|
|
|
|
+ {headerName: "分摊比例", headerWidth: 70, dataCode: "divideRate", dataType: "Number",validator:"number"},
|
|
|
|
|
+ {headerName: "分摊金额", headerWidth: 80, dataCode: "dividePrice", dataType: "Number",validator:"number"},
|
|
|
|
|
+ {headerName: "原始金额", headerWidth: 80, dataCode: "originalPrice", dataType: "Number",validator:"number"},
|
|
|
|
|
+ {headerName: "合计", headerWidth: 80, dataCode: "totalPrice", dataType: "Number",validator:"number"},
|
|
|
|
|
+ {headerName: "金额", headerWidth: 80, dataCode: "price", dataType: "Number",validator:"number"}
|
|
|
],
|
|
],
|
|
|
view:{
|
|
view:{
|
|
|
lockColumns: [0,1,2,3,4,5,6],
|
|
lockColumns: [0,1,2,3,4,5,6],
|
|
@@ -82,30 +82,39 @@ let divideObj = {
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
initExecSpread:function(){
|
|
initExecSpread:function(){
|
|
|
- if(this.billsSelectedSpread) return;
|
|
|
|
|
|
|
+ if(this.billsSelectedSpread){
|
|
|
|
|
+ this.billsSelectedSpread.refresh();
|
|
|
|
|
+ this.execBillsSpread.refresh();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
this.billsSelectedSpread = SheetDataHelper.createNewSpread($("#billSelectedSheet")[0]);
|
|
this.billsSelectedSpread = SheetDataHelper.createNewSpread($("#billSelectedSheet")[0]);
|
|
|
sheetCommonObj.spreadDefaultStyle(this.billsSelectedSpread);
|
|
sheetCommonObj.spreadDefaultStyle(this.billsSelectedSpread);
|
|
|
this.billsSelectedSheet = this.billsSelectedSpread.getSheet(0);
|
|
this.billsSelectedSheet = this.billsSelectedSpread.getSheet(0);
|
|
|
sheetCommonObj.initSheet(this.billsSelectedSheet, this.billsSelectedSetting);
|
|
sheetCommonObj.initSheet(this.billsSelectedSheet, this.billsSelectedSetting);
|
|
|
- // this.billsSelectedSheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onDivideEditStarting);
|
|
|
|
|
- // this.billsSelectedSheet.bind(GC.Spread.Sheets.Events.ValueChanged,this.onDivideValueChange)
|
|
|
|
|
- // this.billsSelectedSheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onDivideSelectionChange);
|
|
|
|
|
|
|
+ this.billsSelectedSpread.bind(GC.Spread.Sheets.Events.ButtonClicked, this.onbillsSelected);
|
|
|
|
|
+
|
|
|
this.execBillsSpread = SheetDataHelper.createNewSpread($("#execBillSheet")[0]);
|
|
this.execBillsSpread = SheetDataHelper.createNewSpread($("#execBillSheet")[0]);
|
|
|
sheetCommonObj.spreadDefaultStyle(this.execBillsSpread);
|
|
sheetCommonObj.spreadDefaultStyle(this.execBillsSpread);
|
|
|
this.execBillsSheet = this.execBillsSpread.getSheet(0);
|
|
this.execBillsSheet = this.execBillsSpread.getSheet(0);
|
|
|
sheetCommonObj.initSheet(this.execBillsSheet, this.execBillsSetting);
|
|
sheetCommonObj.initSheet(this.execBillsSheet, this.execBillsSetting);
|
|
|
|
|
+ this.execBillsSheet.bind(GC.Spread.Sheets.Events.ValueChanged,this.onExecBillsValueChange);
|
|
|
|
|
+ this.execBillsSheet.bind(GC.Spread.Sheets.Events.RangeChanged, this.onExecBillsRangeChanged);
|
|
|
|
|
|
|
|
SheetDataHelper.protectdSheet(this.billsSelectedSheet);
|
|
SheetDataHelper.protectdSheet(this.billsSelectedSheet);
|
|
|
SheetDataHelper.protectdSheet(this.execBillsSheet);
|
|
SheetDataHelper.protectdSheet(this.execBillsSheet);
|
|
|
},
|
|
},
|
|
|
showDatas:function(){
|
|
showDatas:function(){
|
|
|
this.showDivideDatas();
|
|
this.showDivideDatas();
|
|
|
|
|
+ this.showSubDatas();
|
|
|
|
|
+ },
|
|
|
|
|
+ showSubDatas:function(){
|
|
|
this.showBillsDatas();
|
|
this.showBillsDatas();
|
|
|
this.showRationGLJDatas();
|
|
this.showRationGLJDatas();
|
|
|
this.showCalcProgramDatas();
|
|
this.showCalcProgramDatas();
|
|
|
},
|
|
},
|
|
|
- showExecDatas:function(){
|
|
|
|
|
|
|
+ showExecDatas:function(init){
|
|
|
this.showSelectedBillsDatas();
|
|
this.showSelectedBillsDatas();
|
|
|
|
|
+ this.showExecBillsDatas(init);
|
|
|
},
|
|
},
|
|
|
refreshViews:function(){
|
|
refreshViews:function(){
|
|
|
if(!$('#divide_main').is(':visible')) return;
|
|
if(!$('#divide_main').is(':visible')) return;
|
|
@@ -175,14 +184,76 @@ let divideObj = {
|
|
|
sheetCommonObj.showData(this.calcProgramSheet, calcProgramObj.setting, datas);
|
|
sheetCommonObj.showData(this.calcProgramSheet, calcProgramObj.setting, datas);
|
|
|
customRowHeader(this.calcProgramSheet, datas.length);
|
|
customRowHeader(this.calcProgramSheet, datas.length);
|
|
|
},
|
|
},
|
|
|
- showSelectedBillsDatas:function(){
|
|
|
|
|
|
|
+ showExecBillsDatas:function(init=false){
|
|
|
|
|
+ this.execBillsDatas = [];
|
|
|
|
|
+ let parentMap = _.indexBy(this.selectedBillsDatas,"ParentID");
|
|
|
|
|
+ let divideType = parseInt($("input[name='divide_type']:checked").val());
|
|
|
|
|
+ let total = 0;
|
|
|
|
|
+ let ctotal = 0;
|
|
|
|
|
+ let concreteMap = {};
|
|
|
|
|
+ let billsRationGLJMap = {};
|
|
|
|
|
+ if(divideType == 1){//按混凝土计算
|
|
|
|
|
+ billsRationGLJMap = _.groupBy(projectObj.project.ration_glj.datas,"billsItemID");
|
|
|
|
|
+ }
|
|
|
|
|
+ for(let b of this.selectedBillsDatas){
|
|
|
|
|
+ if(b.selected == 1 && !parentMap[b.ID]){
|
|
|
|
|
+ let e = {ID:b.ID,code:b.code,name:b.name,divideRate:0,totalFee:b.totalFee};
|
|
|
|
|
+ if(b.totalFee != "") total = scMathUtil.roundForObj(total + parseFloat(b.totalFee),getDecimal("process"))
|
|
|
|
|
+ if(divideType == 1 && billsRationGLJMap[b.ID]){
|
|
|
|
|
+ let btotal = 0;
|
|
|
|
|
+ for(let glj of billsRationGLJMap[b.ID]){
|
|
|
|
|
+ //“混凝土”、“砂浆”、“配合比”。
|
|
|
|
|
+ if(glj.type == gljType.CONCRETE || glj.type == gljType.MORTAR||glj.type == gljType.MIX_RATIO){
|
|
|
|
|
+ let rNode = projectObj.project.mainTree.findNode(glj.rationID);
|
|
|
|
|
+ let gquantity = gljUtil.getTotalQuantity(glj,rNode.data,getDecimal("ration.quantity"),getDecimal("glj.quantity"));
|
|
|
|
|
+ btotal = scMathUtil.roundForObj(btotal + parseFloat(gquantity),getDecimal("process"));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ btotal = scMathUtil.roundForObj(btotal,getDecimal("glj.quantity"));
|
|
|
|
|
+ ctotal = scMathUtil.roundForObj(ctotal + btotal,getDecimal("process"));
|
|
|
|
|
+ concreteMap[b.ID] = btotal;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.execBillsDatas.push(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ total = scMathUtil.roundForObj(total,getDecimal("bills.totalPrice"));
|
|
|
|
|
+ for(let e of this.execBillsDatas){
|
|
|
|
|
+ if(init == true){//如果是初始化打开页面,要读取已经保存的分摊比例
|
|
|
|
|
+ //使用已保存的分摊信息
|
|
|
|
|
+ let item = divideObj.getSelectedItem();
|
|
|
|
|
+ let IDMap = {};
|
|
|
|
|
+ if(item.bills) IDMap = _.indexBy(item.bills,"ID");
|
|
|
|
|
+ if(IDMap[e.ID]){
|
|
|
|
|
+ e.divideRate = IDMap[e.ID].divideRate;
|
|
|
|
|
+ }
|
|
|
|
|
+ }else if(divideType == 0){//按清单金额比例
|
|
|
|
|
+ if(e.totalFee != "" && total!=0) {
|
|
|
|
|
+ totalFee = scMathUtil.roundForObj(e.totalFee,getDecimal("bills.totalPrice"));
|
|
|
|
|
+ e.divideRate = scMathUtil.roundForObj((totalFee/total) * 100,3);
|
|
|
|
|
+ }
|
|
|
|
|
+ }else if(divideType == 1){//按混凝土用量
|
|
|
|
|
+ let cquantity = concreteMap[e.ID];
|
|
|
|
|
+ if(cquantity && ctotal != 0) e.divideRate = scMathUtil.roundForObj((cquantity/ctotal) * 100,3);
|
|
|
|
|
+ }
|
|
|
|
|
+ //自定义的不用管
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- this.selectedBillsDatas = getSelectedBillsDatas();
|
|
|
|
|
|
|
+ sheetCommonObj.showData(this.execBillsSheet, this.execBillsSetting,this.execBillsDatas);
|
|
|
|
|
+ this.execBillsSheet.setRowCount(this.execBillsDatas.length);
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ showSelectedBillsDatas:function(datas){
|
|
|
|
|
+ if(!datas)this.selectedBillsDatas = getSelectedBillsDatas();
|
|
|
this.billsSelectedSheet.setRowCount(this.selectedBillsDatas.length);
|
|
this.billsSelectedSheet.setRowCount(this.selectedBillsDatas.length);
|
|
|
sheetCommonObj.showTreeData(this.billsSelectedSheet, this.billsSelectedSetting,this.selectedBillsDatas);
|
|
sheetCommonObj.showTreeData(this.billsSelectedSheet, this.billsSelectedSetting,this.selectedBillsDatas);
|
|
|
|
|
|
|
|
function getSelectedBillsDatas(){
|
|
function getSelectedBillsDatas(){
|
|
|
let datas = [];
|
|
let datas = [];
|
|
|
|
|
+ let item = divideObj.getSelectedItem();
|
|
|
|
|
+ let IDMap = {};
|
|
|
|
|
+ if(item.bills) IDMap = _.indexBy(item.bills,"ID");
|
|
|
for(let n of projectObj.project.mainTree.roots){
|
|
for(let n of projectObj.project.mainTree.roots){
|
|
|
getDatas(n)
|
|
getDatas(n)
|
|
|
}
|
|
}
|
|
@@ -203,6 +274,12 @@ let divideObj = {
|
|
|
unDivide:0,
|
|
unDivide:0,
|
|
|
collapsed:false
|
|
collapsed:false
|
|
|
};
|
|
};
|
|
|
|
|
+ if(IDMap[d.ID]) t.selected = 1;
|
|
|
|
|
+ //有基数计算的,不可选择
|
|
|
|
|
+ if(d.calcBase&&d.calcBase!="") t.unDivide = 1;
|
|
|
|
|
+ //数量*单价的(判断金额列是否有值),不可选择
|
|
|
|
|
+ if(d.calcFlag == treeNodeCalcFlag.customUnitPrice && t.totalFee !="") t.unDivide = 1;
|
|
|
|
|
+
|
|
|
datas.push(t);
|
|
datas.push(t);
|
|
|
if(!node.children) return;
|
|
if(!node.children) return;
|
|
|
for(let c of node.children){
|
|
for(let c of node.children){
|
|
@@ -288,6 +365,14 @@ let divideObj = {
|
|
|
return datas;
|
|
return datas;
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+ getGLJListByRationID:function(rationID){
|
|
|
|
|
+ let divideSetting = projectObj.project.divide_setting.datas;
|
|
|
|
|
+ let datas = [];
|
|
|
|
|
+ for(r of divideSetting.ration_gljs){
|
|
|
|
|
+ if(r.rationID==rationID ) datas.push(r);
|
|
|
|
|
+ }
|
|
|
|
|
+ return datas;
|
|
|
|
|
+ },
|
|
|
getRationGLJDatas : function (ration){//这里是给计算程序统一调用的方法,树结构不用这个方法了
|
|
getRationGLJDatas : function (ration){//这里是给计算程序统一调用的方法,树结构不用这个方法了
|
|
|
let datas = [];
|
|
let datas = [];
|
|
|
let selected = ration;
|
|
let selected = ration;
|
|
@@ -334,9 +419,53 @@ let divideObj = {
|
|
|
}
|
|
}
|
|
|
return cusList;
|
|
return cusList;
|
|
|
},
|
|
},
|
|
|
|
|
+ updateActualValue:async function(assList,index,newVal,isAdjust = 1){
|
|
|
|
|
+ let item = this.getSelectedItem();
|
|
|
|
|
+ let newList = _.cloneDeep(assList);
|
|
|
|
|
+ if(gljUtil.isDef(newVal))newList[index].actualValue=newVal;
|
|
|
|
|
+ newList[index].isAdjust = isAdjust;
|
|
|
|
|
+ let u = {ID:item.ID,type:'update',updateAss:true,doc:{rationAssList:newList}}
|
|
|
|
|
+ await this.updateItem([u]);
|
|
|
|
|
+ await this.calcDivideItem(item);
|
|
|
|
|
+ zmhs_obj.showDatas();
|
|
|
|
|
+ },
|
|
|
getStableList:function(){
|
|
getStableList:function(){
|
|
|
return this.rationGLJDatas.filter(glj => !glj.isMixRatio && glj.rationProportion);
|
|
return this.rationGLJDatas.filter(glj => !glj.isMixRatio && glj.rationProportion);
|
|
|
},
|
|
},
|
|
|
|
|
+ updateProportion:async function(datas){
|
|
|
|
|
+ let updateDatas = [];
|
|
|
|
|
+ let item = this.getSelectedItem();
|
|
|
|
|
+ for(let d of datas){
|
|
|
|
|
+ updateDatas.push({ID:d.ID,type:'update',rationID:item.ID,model:'ration_gljs',updateProportion:true,doc:{"adjustProportion":d.adjustProportion}});
|
|
|
|
|
+ }
|
|
|
|
|
+ await this.updateItem(updateDatas);
|
|
|
|
|
+ await this.calcDivideItem(item);
|
|
|
|
|
+ zmhs_obj.showDatas();
|
|
|
|
|
+ },
|
|
|
|
|
+ updateCoeAdjust:async function(data){
|
|
|
|
|
+ console.log(data);
|
|
|
|
|
+ let divideSetting = projectObj.project.divide_setting.datas;
|
|
|
|
|
+ data.divideID = divideSetting.ID;
|
|
|
|
|
+ try {
|
|
|
|
|
+ $.bootstrapLoading.start();
|
|
|
|
|
+ let result = await ajaxPost("/divide/updateCoeAdjust",data)
|
|
|
|
|
+ this.refreshDivideCaches(result.updateDatas);
|
|
|
|
|
+ if(result.projectGLJList && result.projectGLJList.length > 0) projectObj.project.projectGLJ.loadNewProjectGLJToCaches(result.projectGLJList);
|
|
|
|
|
+ if(result.ration_gljs && result.ration_gljs.length > 0) divideSetting.ration_gljs = divideSetting.ration_gljs.concat(result.ration_gljs);
|
|
|
|
|
+ if(result.delete && result.delete.length > 0){
|
|
|
|
|
+ _.remove(result.ration_gljs,function(o){
|
|
|
|
|
+ return _.includes(result.delete,o.ID)
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.log(error)
|
|
|
|
|
+ }
|
|
|
|
|
+ $.bootstrapLoading.end();
|
|
|
|
|
+ await this.calcDivideItem(this.getSelectedItem());
|
|
|
|
|
+ this.showDatas();
|
|
|
|
|
+ zmhs_obj.showDatas();
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
getProgramOptions:function(){
|
|
getProgramOptions:function(){
|
|
|
let names = projectObj.project.calcProgram.compiledTemplateNames;
|
|
let names = projectObj.project.calcProgram.compiledTemplateNames;
|
|
|
let map = projectObj.project.calcProgram.compiledTemplateMaps;
|
|
let map = projectObj.project.calcProgram.compiledTemplateMaps;
|
|
@@ -366,6 +495,15 @@ let divideObj = {
|
|
|
}
|
|
}
|
|
|
return false;
|
|
return false;
|
|
|
},
|
|
},
|
|
|
|
|
+
|
|
|
|
|
+ rationGLJEditChecking:function(row,col){//return false表示不能编辑
|
|
|
|
|
+ let me = this;
|
|
|
|
|
+ let data = me.rationGLJDatas[row],setting = gljCol.ration_glj_setting;
|
|
|
|
|
+ let dataCode = setting.header[col].dataCode;
|
|
|
|
|
+ if(data.isMixRatio == true && (dataCode=="customQuantity"||dataCode=="basePrice")) return false;
|
|
|
|
|
+ return true;
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
showBillsDatas:function(){
|
|
showBillsDatas:function(){
|
|
|
if(!$('#divide_bills_sheet').is(':visible')) return;
|
|
if(!$('#divide_bills_sheet').is(':visible')) return;
|
|
|
this.billsDatas = getBillsDatas();
|
|
this.billsDatas = getBillsDatas();
|
|
@@ -373,7 +511,36 @@ let divideObj = {
|
|
|
this.billsSheet.setRowCount(this.billsDatas.length);
|
|
this.billsSheet.setRowCount(this.billsDatas.length);
|
|
|
|
|
|
|
|
function getBillsDatas(){
|
|
function getBillsDatas(){
|
|
|
- return [];
|
|
|
|
|
|
|
+ let datas = [];
|
|
|
|
|
+ let item = divideObj.getSelectedItem();
|
|
|
|
|
+ if(item.bills){
|
|
|
|
|
+ for(let b of item.bills){
|
|
|
|
|
+ let bNode = projectObj.project.mainTree.findNode(b.ID);
|
|
|
|
|
+ if (!bNode) continue;
|
|
|
|
|
+ let t = {
|
|
|
|
|
+ ID:b.ID,
|
|
|
|
|
+ divideRate:b.divideRate,
|
|
|
|
|
+ name:bNode.data.name,
|
|
|
|
|
+ code:bNode.data.code,
|
|
|
|
|
+ dividePrice:0,
|
|
|
|
|
+ originalPrice:0,
|
|
|
|
|
+ totalPrice:0,
|
|
|
|
|
+ price:0
|
|
|
|
|
+ }
|
|
|
|
|
+ if(bNode.data.feesIndex.common.totalFee){
|
|
|
|
|
+ let totalFee = scMathUtil.roundForObj(bNode.data.feesIndex.common.totalFee,getDecimal("bills.totalPrice"));
|
|
|
|
|
+ t.price = totalFee;
|
|
|
|
|
+ t.divideRate = scMathUtil.roundForObj(t.divideRate * 0.01,3);
|
|
|
|
|
+ t.dividePrice = scMathUtil.roundForObj(item.marketTotalFee * t.divideRate,getDecimal("bills.totalPrice"));
|
|
|
|
|
+ }
|
|
|
|
|
+ if(bNode.data.feesIndex.rationCommon && bNode.data.feesIndex.rationCommon.totalFee){
|
|
|
|
|
+ t.originalPrice = scMathUtil.roundForObj(bNode.data.feesIndex.rationCommon.totalFee,getDecimal("bills.totalPrice"));
|
|
|
|
|
+ }
|
|
|
|
|
+ t.totalPrice = scMathUtil.roundForObj(t.dividePrice + t.originalPrice,getDecimal("bills.totalPrice"));
|
|
|
|
|
+ datas.push(t);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return datas;
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
getSelectedItem:function(){
|
|
getSelectedItem:function(){
|
|
@@ -394,6 +561,7 @@ let divideObj = {
|
|
|
if(type) newItem.subType = type;
|
|
if(type) newItem.subType = type;
|
|
|
let selected = this.getSelectedItem();
|
|
let selected = this.getSelectedItem();
|
|
|
if(itemType!="分摊项"){//当插入定额或者量价时:
|
|
if(itemType!="分摊项"){//当插入定额或者量价时:
|
|
|
|
|
+ newItem.divideType = 0;
|
|
|
newItem.ParentID = selected.itemType == "分摊项"?selected.ID:selected.ParentID;
|
|
newItem.ParentID = selected.itemType == "分摊项"?selected.ID:selected.ParentID;
|
|
|
newItem.fees = [{fieldName:"common",tenderTotalFee:0,unitFee:0,totalFee:0,tenderUnitFee:0}];
|
|
newItem.fees = [{fieldName:"common",tenderTotalFee:0,unitFee:0,totalFee:0,tenderUnitFee:0}];
|
|
|
}
|
|
}
|
|
@@ -421,6 +589,8 @@ let divideObj = {
|
|
|
}
|
|
}
|
|
|
if(c.ID == bills.ID) item = c;
|
|
if(c.ID == bills.ID) item = c;
|
|
|
}
|
|
}
|
|
|
|
|
+ item.fees=[];
|
|
|
|
|
+ item.feesIndex={};
|
|
|
if(subNodes.length > 0) projectObj.project.calcProgram.innerCalcBill({data:item, sourceType:"bills", updateData:[],children:subNodes},3);
|
|
if(subNodes.length > 0) projectObj.project.calcProgram.innerCalcBill({data:item, sourceType:"bills", updateData:[],children:subNodes},3);
|
|
|
if(subNodes.length == 0){
|
|
if(subNodes.length == 0){
|
|
|
item.calcFlag = 2;
|
|
item.calcFlag = 2;
|
|
@@ -454,7 +624,7 @@ let divideObj = {
|
|
|
}
|
|
}
|
|
|
subItems.push({type:"delete",ID:selected.ID,itemType:selected.itemType});
|
|
subItems.push({type:"delete",ID:selected.ID,itemType:selected.itemType});
|
|
|
await this.updateItem(subItems);
|
|
await this.updateItem(subItems);
|
|
|
-
|
|
|
|
|
|
|
+ zmhs_obj.showDatas();
|
|
|
},
|
|
},
|
|
|
getNewSeqs:function(selected,newItem){
|
|
getNewSeqs:function(selected,newItem){
|
|
|
let seq = 1,datas=[],refreshSeq = false;
|
|
let seq = 1,datas=[],refreshSeq = false;
|
|
@@ -476,8 +646,8 @@ let divideObj = {
|
|
|
let divideSetting = projectObj.project.divide_setting.datas
|
|
let divideSetting = projectObj.project.divide_setting.datas
|
|
|
try {
|
|
try {
|
|
|
$.bootstrapLoading.start();
|
|
$.bootstrapLoading.start();
|
|
|
- let result = ajaxPost("/divide/updateItem",{ID:divideSetting.ID,updateDatas:datas})
|
|
|
|
|
- this.refreshDivideCaches(datas);
|
|
|
|
|
|
|
+ let result = await ajaxPost("/divide/updateItem",{ID:divideSetting.ID,updateDatas:datas})
|
|
|
|
|
+ this.refreshDivideCaches(result.updateDatas);
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
console.log(error)
|
|
console.log(error)
|
|
|
}
|
|
}
|
|
@@ -498,7 +668,9 @@ let divideObj = {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if(d.type == "update"){
|
|
if(d.type == "update"){
|
|
|
- let item = _.find(divideSetting.divideList,{'ID':d.ID});
|
|
|
|
|
|
|
+ let model = "divideList";
|
|
|
|
|
+ if(d.model) model = d.model;
|
|
|
|
|
+ let item = _.find(divideSetting[model],{'ID':d.ID});
|
|
|
if(item) gljUtil.updateProperty(item,d.doc);
|
|
if(item) gljUtil.updateProperty(item,d.doc);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -521,9 +693,8 @@ let divideObj = {
|
|
|
let sel = this.divideSheet.getSelections()[0];
|
|
let sel = this.divideSheet.getSelections()[0];
|
|
|
await this.updateDivideRation(data);
|
|
await this.updateDivideRation(data);
|
|
|
this.divideSheet.setSelection(sel.row+1,sel.col,sel.rowCount,sel.colCount);
|
|
this.divideSheet.setSelection(sel.row+1,sel.col,sel.rowCount,sel.colCount);
|
|
|
- this.showRationGLJDatas();
|
|
|
|
|
- this.showCalcProgramDatas();
|
|
|
|
|
-
|
|
|
|
|
|
|
+ this.showSubDatas();
|
|
|
|
|
+ zmhs_obj.showDatas();
|
|
|
},
|
|
},
|
|
|
updateDivideRation:async function(data){
|
|
updateDivideRation:async function(data){
|
|
|
let divideSetting = projectObj.project.divide_setting.datas;
|
|
let divideSetting = projectObj.project.divide_setting.datas;
|
|
@@ -555,36 +726,73 @@ let divideObj = {
|
|
|
}
|
|
}
|
|
|
$.bootstrapLoading.end();
|
|
$.bootstrapLoading.end();
|
|
|
},
|
|
},
|
|
|
|
|
+ calcDivideAfterGLJUpdate:async function(gljs){
|
|
|
|
|
+ let divideSetting = projectObj.project.divide_setting.datas
|
|
|
|
|
+ let indexMap = {};
|
|
|
|
|
+ let rationIDMap = {};
|
|
|
|
|
+ let rations = [];
|
|
|
|
|
+ for(let glj of gljs){
|
|
|
|
|
+ let index = gljUtil.getIndex(glj);
|
|
|
|
|
+ indexMap[index] = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ for(let rg of divideSetting.ration_gljs){
|
|
|
|
|
+ if(indexMap[gljUtil.getIndex(rg)]){
|
|
|
|
|
+ rationIDMap[rg.rationID] = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if(_.isEmpty(rationIDMap)) return;
|
|
|
|
|
+ for(let d of divideSetting.divideList){
|
|
|
|
|
+ if(rationIDMap[d.ID]){
|
|
|
|
|
+ rations.push(d)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if(rations.length > 0){
|
|
|
|
|
+ let updateDatas= this.getCalcDivideDatas(rations);
|
|
|
|
|
+ updateDatas.length > 0?await this.updateItem(updateDatas):this.showDatas();
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
calcDivideItem:async function(divide){
|
|
calcDivideItem:async function(divide){
|
|
|
|
|
+ let updateDatas= this.getCalcDivideDatas([divide]);
|
|
|
|
|
+ updateDatas.length > 0?await this.updateItem(updateDatas):this.showDatas();
|
|
|
|
|
+ },
|
|
|
|
|
+ getCalcDivideDatas:function(divides){
|
|
|
let updateDatas = [];
|
|
let updateDatas = [];
|
|
|
- let children =[];
|
|
|
|
|
let divideSetting = projectObj.project.divide_setting.datas
|
|
let divideSetting = projectObj.project.divide_setting.datas
|
|
|
- if(divide.itemType != "分摊项"){//不是分摊项,调用计算程序
|
|
|
|
|
- let parentSum = 0;
|
|
|
|
|
- let parent = null;
|
|
|
|
|
- projectObj.project.calcProgram.innerCalcRation({data:divide, sourceType:"ration", calcType: 1, updateData:[]});
|
|
|
|
|
- if(divide.itemType == "定额"){
|
|
|
|
|
- updateDatas.push({ID:divide.ID,type:'update',doc:{fees:divide.fees}});
|
|
|
|
|
|
|
+ let parentMap={};
|
|
|
|
|
+ let parents=[];
|
|
|
|
|
+ for(let divide of divides){//先计算所有子项和传入的分摊项(与传入子项不关联,因为计算子项时会计算对应的分摊项)
|
|
|
|
|
+ if(divide.itemType != "分摊项"){//不是分摊项,调用计算程序
|
|
|
|
|
+ divide.fees=[];
|
|
|
|
|
+ divide.feesIndex={};
|
|
|
|
|
+ projectObj.project.calcProgram.innerCalcRation({data:divide, sourceType:"ration", calcType: 1, updateData:[]});
|
|
|
|
|
+ if(divide.itemType == "定额"){
|
|
|
|
|
+ updateDatas.push({ID:divide.ID,type:'update',doc:{fees:divide.fees}});
|
|
|
|
|
+ }else{
|
|
|
|
|
+ updateDatas.push({ID:divide.ID,type:'update',doc:{fees:divide.fees,marketUnitFee:divide.marketUnitFee}});
|
|
|
|
|
+ }
|
|
|
|
|
+ parentMap[divide.ParentID] = [];
|
|
|
}else{
|
|
}else{
|
|
|
- updateDatas.push({ID:divide.ID,type:'update',doc:{fees:divide.fees,marketUnitFee:divide.marketUnitFee}});
|
|
|
|
|
- }
|
|
|
|
|
- for(let c of divideSetting.divideList){
|
|
|
|
|
- if(c.ID == divide.ParentID) parent = c;
|
|
|
|
|
- if(c.ParentID == divide.ParentID){
|
|
|
|
|
- let t = c.ID != divide.ID?c:divide;
|
|
|
|
|
- this.initFeeIndexs(t);
|
|
|
|
|
- children.push({data:t, sourceType:"ration", calcType: 1, updateData:[]});
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ divide = this.calcBills(divide);
|
|
|
|
|
+ updateDatas.push({ID:divide.ID,type:'update',doc:{fees:divide.fees}});
|
|
|
}
|
|
}
|
|
|
- if(children.length > 0){
|
|
|
|
|
- projectObj.project.calcProgram.innerCalcBill({data:parent, sourceType:"bills", updateData:[],children:children},3);
|
|
|
|
|
- updateDatas.push({ID:parent.ID,type:'update',doc:{fees:parent.fees}});
|
|
|
|
|
- }
|
|
|
|
|
- }else{
|
|
|
|
|
- divide = this.calcBills(divide);
|
|
|
|
|
- updateDatas.push({ID:divide.ID,type:'update',doc:{fees:divide.fees}});
|
|
|
|
|
}
|
|
}
|
|
|
- updateDatas.length > 0?await this.updateItem(updateDatas):this.showDatas();
|
|
|
|
|
|
|
+ for(let c of divideSetting.divideList){
|
|
|
|
|
+ if(parentMap[c.ID]) parents.push(c);//把所有父节点挑出来
|
|
|
|
|
+ if(parentMap[c.ParentID]){
|
|
|
|
|
+ let t = c.ID != divide.ID?c:divide;
|
|
|
|
|
+ this.initFeeIndexs(t);
|
|
|
|
|
+ //生成并归类父节点对应的子节点(用于父节点的计算)
|
|
|
|
|
+ parentMap[c.ParentID].push({data:t, sourceType:"ration", calcType: 1, updateData:[]});
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ for(let p of parents){
|
|
|
|
|
+ p.fees=[];
|
|
|
|
|
+ p.feesIndex={};
|
|
|
|
|
+ projectObj.project.calcProgram.innerCalcBill({data:p, sourceType:"bills", updateData:[],children:parentMap[p.ID]},3);
|
|
|
|
|
+ updateDatas.push({ID:p.ID,type:'update',doc:{fees:p.fees}});
|
|
|
|
|
+ }
|
|
|
|
|
+ return updateDatas;
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
getTotolFee:function name(divide) {
|
|
getTotolFee:function name(divide) {
|
|
@@ -606,10 +814,9 @@ let divideObj = {
|
|
|
this.divideSheet = this.divideSpread.getSheet(0);
|
|
this.divideSheet = this.divideSpread.getSheet(0);
|
|
|
sheetCommonObj.initSheet(this.divideSheet, this.divideSetting, 2);
|
|
sheetCommonObj.initSheet(this.divideSheet, this.divideSetting, 2);
|
|
|
this.divideSheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onDivideEditStarting);
|
|
this.divideSheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onDivideEditStarting);
|
|
|
- this.divideSheet.bind(GC.Spread.Sheets.Events.ValueChanged,this.onDivideValueChange)
|
|
|
|
|
|
|
+ this.divideSheet.bind(GC.Spread.Sheets.Events.ValueChanged,this.onDivideValueChange);
|
|
|
this.divideSheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onDivideSelectionChange);
|
|
this.divideSheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onDivideSelectionChange);
|
|
|
- /* ;
|
|
|
|
|
- this.divideSheet.bind(GC.Spread.Sheets.Events.RangeChanged, this.onCoeRangeChanged); */
|
|
|
|
|
|
|
+ this.divideSheet.bind(GC.Spread.Sheets.Events.RangeChanged, this.onDivideRangeChanged);
|
|
|
|
|
|
|
|
SheetDataHelper.protectdSheet(this.divideSheet);
|
|
SheetDataHelper.protectdSheet(this.divideSheet);
|
|
|
},
|
|
},
|
|
@@ -621,6 +828,54 @@ let divideObj = {
|
|
|
args.cancel = true;
|
|
args.cancel = true;
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+ onRationGljEditStarting:function(sender,args){
|
|
|
|
|
+ let me = divideObj;
|
|
|
|
|
+ let row = args.row;
|
|
|
|
|
+ let col = args.col;
|
|
|
|
|
+ if(divideObj.rationGLJEditChecking(row,col)==false){
|
|
|
|
|
+ args.cancel = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ onRationGLJRangeChanged:async function(e,args){
|
|
|
|
|
+ for(let c of args.changedCells){
|
|
|
|
|
+ let value= args.sheet.getCell(c.row, c.col).text();
|
|
|
|
|
+ if(divideObj.rationGLJEditChecking(c.row,c.col)==false){
|
|
|
|
|
+ return divideObj.showRationGLJDatas();
|
|
|
|
|
+ }
|
|
|
|
|
+ divideObj.onRationGLJValueChange(e,{row:c.row,col:c.col,newValue:value,sheet:args.sheet});
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ onExecBillsRangeChanged:async function(e,args){
|
|
|
|
|
+ for(let c of args.changedCells){
|
|
|
|
|
+ let value= args.sheet.getCell(c.row, c.col).text();
|
|
|
|
|
+ divideObj.onExecBillsValueChange(e,{row:c.row,col:c.col,newValue:value,sheet:args.sheet});
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ onExecBillsValueChange:function(sender,info){
|
|
|
|
|
+ let me = divideObj,row = info.row, col = info.col;
|
|
|
|
|
+ let setting = me.execBillsSetting;
|
|
|
|
|
+ let dataCode = setting.header[col].dataCode;
|
|
|
|
|
+ let record = me.execBillsDatas[row];
|
|
|
|
|
+ let value = info.newValue;
|
|
|
|
|
+ if(value && !sheetCommonObj.checkData(col,setting,value)) {
|
|
|
|
|
+ alert('输入的数据类型不对,请重新输入!');
|
|
|
|
|
+ return info.sheet.setValue(row, col, record[dataCode], GC.Spread.Sheets.SheetArea.viewport);
|
|
|
|
|
+ }
|
|
|
|
|
+ record[dataCode] = scMathUtil.roundForObj(value,3);
|
|
|
|
|
+
|
|
|
|
|
+ },
|
|
|
|
|
+ onDivideRangeChanged:async function(e,args){
|
|
|
|
|
+ for(let c of args.changedCells){
|
|
|
|
|
+ if(divideObj.divideEditChecking(c.row,c.col)==false){
|
|
|
|
|
+ return divideObj.showDivideDatas();
|
|
|
|
|
+ }
|
|
|
|
|
+ let value= args.sheet.getCell(c.row, c.col).text();
|
|
|
|
|
+ divideObj.onDivideValueChange(e,{row:c.row,col:c.col,newValue:value});
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
onDivideValueChange:async function(sender,info){
|
|
onDivideValueChange:async function(sender,info){
|
|
|
let me = divideObj,row = info.row, col = info.col;
|
|
let me = divideObj,row = info.row, col = info.col;
|
|
|
let setting = me.divideSetting;
|
|
let setting = me.divideSetting;
|
|
@@ -641,6 +896,48 @@ let divideObj = {
|
|
|
await me.updateItem([me.getDivideUpdateData(record,dataCode,value)]);
|
|
await me.updateItem([me.getDivideUpdateData(record,dataCode,value)]);
|
|
|
await me.calcDivideItem(record);
|
|
await me.calcDivideItem(record);
|
|
|
},
|
|
},
|
|
|
|
|
+
|
|
|
|
|
+ onRationGLJValueChange:async function(sender,info){
|
|
|
|
|
+ let me = divideObj,row = info.row, col = info.col;
|
|
|
|
|
+ let setting = gljCol.ration_glj_setting;
|
|
|
|
|
+ let dataCode = setting.header[col].dataCode;
|
|
|
|
|
+ let record = me.rationGLJDatas[row];
|
|
|
|
|
+ let value = info.newValue;
|
|
|
|
|
+ if(value && !sheetCommonObj.checkData(col,setting,value)) {
|
|
|
|
|
+ alert('输入的数据类型不对,请重新输入!');
|
|
|
|
|
+ return me.showRationGLJDatas();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (dataCode == 'marketPrice' || dataCode == 'basePrice') {
|
|
|
|
|
+ if(!value) value = 0;
|
|
|
|
|
+ projectObj.project.projectGLJ.updatePriceFromRG(record, dataCode, value);
|
|
|
|
|
+ }else if(dataCode=='customQuantity'){
|
|
|
|
|
+ if(value) value = scMathUtil.roundForObj(value, getDecimal("glj.quantity"))
|
|
|
|
|
+ let u= {ID:record.ID,type:'update',rationID:record.rationID,model:'ration_gljs',doc:{"customQuantity":value}}
|
|
|
|
|
+ await me.updateItem([u]);
|
|
|
|
|
+ await me.calcDivideItem(me.getSelectedItem());
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ onbillsSelected:function(sender, args){
|
|
|
|
|
+ let dataCode = divideObj.billsSelectedSetting.header[args.col].dataCode;
|
|
|
|
|
+ if(dataCode != "selected") return;
|
|
|
|
|
+ let checkboxValue = args.sheet.getCell(args.row, args.col).value();
|
|
|
|
|
+ let newval = checkboxValue? 0:1;
|
|
|
|
|
+ let data = divideObj.selectedBillsDatas[args.row];
|
|
|
|
|
+ let parentMap = {};
|
|
|
|
|
+ parentMap[data.ID]=true;
|
|
|
|
|
+ data.selected=newval;
|
|
|
|
|
+ for(let d of divideObj.selectedBillsDatas){
|
|
|
|
|
+ if(parentMap[d.ParentID]){
|
|
|
|
|
+ if(d.unDivide == 0) d.selected=newval;
|
|
|
|
|
+ parentMap[d.ID] = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ divideObj.showSelectedBillsDatas(divideObj.selectedBillsDatas);
|
|
|
|
|
+ divideObj.showExecBillsDatas();
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
replaceDivideRation:async function(code,record){
|
|
replaceDivideRation:async function(code,record){
|
|
|
let divideSetting = projectObj.project.divide_setting.datas;
|
|
let divideSetting = projectObj.project.divide_setting.datas;
|
|
|
let data = {ID:divideSetting.ID,type:"update",rationID:record.ID,code:code};
|
|
let data = {ID:divideSetting.ID,type:"update",rationID:record.ID,code:code};
|
|
@@ -655,7 +952,7 @@ let divideObj = {
|
|
|
data.projectID = projectObj.project.ID();
|
|
data.projectID = projectObj.project.ID();
|
|
|
data.oldData = record;
|
|
data.oldData = record;
|
|
|
await this.updateDivideRation(data);
|
|
await this.updateDivideRation(data);
|
|
|
-
|
|
|
|
|
|
|
+ zmhs_obj.showDatas();
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
@@ -665,8 +962,8 @@ let divideObj = {
|
|
|
let oldSel = args.oldSelections?args.oldSelections[0]:{};
|
|
let oldSel = args.oldSelections?args.oldSelections[0]:{};
|
|
|
if(newSel.row != oldSel.row){
|
|
if(newSel.row != oldSel.row){
|
|
|
me.initNavItem();
|
|
me.initNavItem();
|
|
|
- me.showRationGLJDatas();
|
|
|
|
|
- me.showCalcProgramDatas();
|
|
|
|
|
|
|
+ me.showSubDatas();
|
|
|
|
|
+ zmhs_obj.showDatas();
|
|
|
}
|
|
}
|
|
|
args.sheet.repaint();
|
|
args.sheet.repaint();
|
|
|
},
|
|
},
|
|
@@ -685,11 +982,14 @@ let divideObj = {
|
|
|
if(dataCode == "marketPrice"){
|
|
if(dataCode == "marketPrice"){
|
|
|
value = scMathUtil.roundForObj(value,getDecimal("bills.unitPrice"));
|
|
value = scMathUtil.roundForObj(value,getDecimal("bills.unitPrice"));
|
|
|
let commonFee = _.find(recode.fees,{"fieldName":"common"})
|
|
let commonFee = _.find(recode.fees,{"fieldName":"common"})
|
|
|
- if (commonFee){
|
|
|
|
|
- //let tu = scMathUtil.roundForObj(commonFee.unitFee&&commonFee.unitFee!=""?commonFee.unitFee:0,getDecimal("bills.unitPrice"))
|
|
|
|
|
- commonFee.unitFee = scMathUtil.roundForObj(value,getDecimal("bills.unitPrice"));
|
|
|
|
|
- doc["fees"] = recode.fees;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if(!commonFee){
|
|
|
|
|
+ commonFee = {fieldName: "common",tenderTotalFee: 0,tenderUnitFee: 0,totalFee: 0,unitFee: 0};
|
|
|
|
|
+ recode.fees?recode.fees.push(commonFee):recode.fees=[commonFee];
|
|
|
|
|
+ }
|
|
|
|
|
+ //let tu = scMathUtil.roundForObj(commonFee.unitFee&&commonFee.unitFee!=""?commonFee.unitFee:0,getDecimal("bills.unitPrice"))
|
|
|
|
|
+ commonFee.unitFee = scMathUtil.roundForObj(value,getDecimal("bills.unitPrice"));
|
|
|
|
|
+ doc["fees"] = recode.fees;
|
|
|
|
|
+
|
|
|
return {ID:recode.ID,type:'update',doc:doc};
|
|
return {ID:recode.ID,type:'update',doc:doc};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -720,6 +1020,10 @@ let divideObj = {
|
|
|
sheetCommonObj.spreadDefaultStyle(this.divideSubSpread);
|
|
sheetCommonObj.spreadDefaultStyle(this.divideSubSpread);
|
|
|
this.divideSubSheet = this.divideSubSpread.getSheet(0);
|
|
this.divideSubSheet = this.divideSubSpread.getSheet(0);
|
|
|
sheetCommonObj.initSheet(this.divideSubSheet, gljCol.ration_glj_setting, 0);
|
|
sheetCommonObj.initSheet(this.divideSubSheet, gljCol.ration_glj_setting, 0);
|
|
|
|
|
+ this.divideSubSheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onRationGljEditStarting);
|
|
|
|
|
+ this.divideSubSheet.bind(GC.Spread.Sheets.Events.ValueChanged,this.onRationGLJValueChange);
|
|
|
|
|
+ this.divideSubSheet.bind(GC.Spread.Sheets.Events.RangeChanged, this.onRationGLJRangeChanged);
|
|
|
|
|
+
|
|
|
SheetDataHelper.protectdSheet(this.divideSubSheet);
|
|
SheetDataHelper.protectdSheet(this.divideSubSheet);
|
|
|
this.calcProgramSheet = this.divideSubSpread.getSheet(1);
|
|
this.calcProgramSheet = this.divideSubSpread.getSheet(1);
|
|
|
calcProgramObj.initSheet(this.calcProgramSheet);
|
|
calcProgramObj.initSheet(this.calcProgramSheet);
|
|
@@ -857,29 +1161,6 @@ let divideObj = {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- "calcRation": {
|
|
|
|
|
- name: "计算定额/量价",
|
|
|
|
|
- icon: 'fa-sign-in',
|
|
|
|
|
- disabled: function () {
|
|
|
|
|
- return me.rightClickTarget.row === undefined
|
|
|
|
|
- },
|
|
|
|
|
- callback: function (key, opt) {
|
|
|
|
|
- let selected = me.getSelectedItem();
|
|
|
|
|
- projectObj.project.calcProgram.innerCalcRation({data:selected, sourceType:"ration", calcType: 1, updateData:[]});
|
|
|
|
|
- console.log(selected)
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- "calcBills": {
|
|
|
|
|
- name: "计算分摊项",
|
|
|
|
|
- icon: 'fa-sign-in',
|
|
|
|
|
- disabled: function () {
|
|
|
|
|
- return me.rightClickTarget.row === undefined
|
|
|
|
|
- },
|
|
|
|
|
- callback: function (key, opt) {
|
|
|
|
|
- let selected = me.getSelectedItem();
|
|
|
|
|
- console.log(me.calcBills(selected));
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
"removeItem": {
|
|
"removeItem": {
|
|
|
name: "删除",
|
|
name: "删除",
|
|
|
icon: 'fa-trash-o',
|
|
icon: 'fa-trash-o',
|
|
@@ -914,6 +1195,98 @@ let divideObj = {
|
|
|
totalHeight: `$(window).height()-$('.header').height()-$('#divideToolsBar').height()-5`
|
|
totalHeight: `$(window).height()-$('.header').height()-$('#divideToolsBar').height()-5`
|
|
|
};
|
|
};
|
|
|
return divideResizeEles;
|
|
return divideResizeEles;
|
|
|
|
|
+ },
|
|
|
|
|
+ calcDivideNodes : async function(item){
|
|
|
|
|
+ if(!item.marketTotalFee) return;
|
|
|
|
|
+ let changeNode=[];
|
|
|
|
|
+ let datas = [];
|
|
|
|
|
+ let usedIDMap={};
|
|
|
|
|
+ for(let b of item.bills){
|
|
|
|
|
+ let bNode = projectObj.project.mainTree.findNode(b.ID);
|
|
|
|
|
+ if(!bNode) continue;
|
|
|
|
|
+ let divideRate = scMathUtil.roundForObj(b.divideRate * 0.01,3);
|
|
|
|
|
+ let marketUnitFee = item.marketPrice?scMathUtil.roundForObj(item.marketPrice,getDecimal("bills.unitPrice")):0;
|
|
|
|
|
+ let quantity = item.quantity?scMathUtil.roundForObj(item.quantity,3):0;
|
|
|
|
|
+ quantity = scMathUtil.roundForObj(quantity*divideRate,getDecimal("ration.quantity"))//量价数量为分摊项的数量*分摊比例
|
|
|
|
|
+ if(quantity > 0 && marketUnitFee > 0){
|
|
|
|
|
+ let serialNo = 0;
|
|
|
|
|
+ let preID = "";
|
|
|
|
|
+ let divdeNode = null;
|
|
|
|
|
+ for(let cNode of bNode.children ){
|
|
|
|
|
+ if(cNode.data.divideID == item.ID){//说明已经存在了自动生成的量价,更新一下数据就行
|
|
|
|
|
+ let doc = {};
|
|
|
|
|
+ usedIDMap[cNode.data.ID] = true;
|
|
|
|
|
+ divdeNode = cNode;
|
|
|
|
|
+ if(cNode.data.name != item.name) doc.name = item.name;
|
|
|
|
|
+ if(cNode.data.unit != item.unit) doc.unit = item.unit;
|
|
|
|
|
+ if(cNode.data.quantity != quantity) doc.quantity = quantity;
|
|
|
|
|
+ if(cNode.data.marketUnitFee != marketUnitFee) doc.marketUnitFee = marketUnitFee;
|
|
|
|
|
+ if(!_.isEmpty(doc)){
|
|
|
|
|
+ doc.ID = cNode.data.ID;
|
|
|
|
|
+ datas.push({type:ModuleNames.ration,data:doc})
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ preID = cNode.data.ID;
|
|
|
|
|
+ serialNo = cNode.data.serialNo;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(divdeNode == null){//说明需要新增
|
|
|
|
|
+ let newID = uuid.v1()
|
|
|
|
|
+ let newData = projectObj.project.Ration.getTempRationData(newID, b.ID, serialNo+1, rationType.volumePrice);
|
|
|
|
|
+ newData.name = item.name;
|
|
|
|
|
+ newData.unit = item.unit;
|
|
|
|
|
+ newData.quantity = quantity;
|
|
|
|
|
+ newData.marketUnitFee = marketUnitFee;
|
|
|
|
|
+ newData.divideID = item.ID;
|
|
|
|
|
+ datas.push({type:ModuleNames.ration,data:newData,preSiblingID:preID,action:"add",parentID:b.ID});
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //删除之前生成的,但是这次执行时没有用的节点
|
|
|
|
|
+ for(let r of projectObj.project.Ration.datas){
|
|
|
|
|
+ if(r.divideID == item.ID){
|
|
|
|
|
+ if(!usedIDMap[r.ID]){//没有用的删除
|
|
|
|
|
+ datas.push({type:ModuleNames.ration,data:{ID:r.ID},action:"delete"});
|
|
|
|
|
+ let pNode = projectObj.project.mainTree.findNode(r.billsItemID);
|
|
|
|
|
+ if(pNode)changeNode.push(pNode);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if(datas.length == 0) return;
|
|
|
|
|
+ //刷新缓存和树节点的插入删除
|
|
|
|
|
+ let nodes = await projectObj.project.syncUpdateNodesAndRefresh(datas);
|
|
|
|
|
+ //重新计算
|
|
|
|
|
+ cbTools.refreshFormulaNodes();
|
|
|
|
|
+ projectObj.project.calcProgram.calcNodesAndSave(changeNode.concat(nodes));
|
|
|
|
|
+ },
|
|
|
|
|
+ cancelDivide:async function(divideID){//如果不传ID,相当于取消所有
|
|
|
|
|
+ let changeNode=[],datas=[],itemDatas=[];
|
|
|
|
|
+ let divideSetting = projectObj.project.divide_setting.datas
|
|
|
|
|
+ for(let d of divideSetting.divideList){
|
|
|
|
|
+ if(d.itemType == "分摊项"){
|
|
|
|
|
+ if(divideID && d.ID != divideID) continue;
|
|
|
|
|
+ if(d.bills && d.bills.length > 0){
|
|
|
|
|
+ itemDatas.push({ID:d.ID,type:'update',doc:{bills:[],divideType:0}});
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if(itemDatas.length > 0) await this.updateItem(itemDatas);
|
|
|
|
|
+
|
|
|
|
|
+ for(let r of projectObj.project.Ration.datas){
|
|
|
|
|
+ if(!r.divideID || r.divideID=="") continue;
|
|
|
|
|
+ if(divideID && r.divideID != divideID) continue;
|
|
|
|
|
+ datas.push({type:ModuleNames.ration,data:{ID:r.ID},action:"delete"});
|
|
|
|
|
+ let pNode = projectObj.project.mainTree.findNode(r.billsItemID);
|
|
|
|
|
+ if(pNode)changeNode.push(pNode);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(datas.length == 0) return;
|
|
|
|
|
+ //刷新缓存和树节点的插入删除
|
|
|
|
|
+ let nodes = await projectObj.project.syncUpdateNodesAndRefresh(datas);
|
|
|
|
|
+ //重新计算
|
|
|
|
|
+ cbTools.refreshFormulaNodes();
|
|
|
|
|
+ projectObj.project.calcProgram.calcNodesAndSave(changeNode.concat(nodes));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -974,7 +1347,7 @@ dividRationLibResizeEles.limit = {
|
|
|
totalHeight: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#divide_deToolsBar').height()-5`
|
|
totalHeight: `$(window).height()-$('.header').height()-$('.toolsbar').height()-$('#divide_deToolsBar').height()-5`
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-function showDivideSide(tabPanel, show, id){
|
|
|
|
|
|
|
+function getDivideSideResizeEles(){
|
|
|
let divideSideResizeEles = {};
|
|
let divideSideResizeEles = {};
|
|
|
divideSideResizeEles.eleObj = {
|
|
divideSideResizeEles.eleObj = {
|
|
|
module: 'divideRationLibTab',
|
|
module: 'divideRationLibTab',
|
|
@@ -987,7 +1360,21 @@ function showDivideSide(tabPanel, show, id){
|
|
|
min: 150,
|
|
min: 150,
|
|
|
max: `$('#divideRow').width()-150`
|
|
max: `$('#divideRow').width()-150`
|
|
|
};
|
|
};
|
|
|
|
|
+ return divideSideResizeEles;
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
+let dSideResizeEles = getDivideSideResizeEles();
|
|
|
|
|
+//水平拖动
|
|
|
|
|
+SlideResize.horizontalSlide(dSideResizeEles.eleObj, dSideResizeEles.limit, function(){
|
|
|
|
|
+ SlideResize.loadVerticalHeight(dividRationLibResizeEles.eleObj.module, dividRationLibResizeEles.eleObj, dividRationLibResizeEles.limit, function () {
|
|
|
|
|
+ if(rationLibObj.divide_rationChapterSpread) rationLibObj.divide_rationChapterSpread.refresh();
|
|
|
|
|
+ if(rationLibObj.divide_sectionRationsSpread) rationLibObj.divide_sectionRationsSpread.refresh();
|
|
|
|
|
+ });
|
|
|
|
|
+ divideObj.refreshViews();
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+function showDivideSide(tabPanel, show, id){
|
|
|
|
|
+ let divideSideResizeEles = getDivideSideResizeEles();
|
|
|
divideSideResizeEles.eleObj.module = id;
|
|
divideSideResizeEles.eleObj.module = id;
|
|
|
if (show) {
|
|
if (show) {
|
|
|
//刚打开各库时的默认比例
|
|
//刚打开各库时的默认比例
|
|
@@ -1069,9 +1456,22 @@ $('#divide_zmhs_toogle').bind('click',function (){
|
|
|
|
|
|
|
|
$('#exec_divide_btn').bind('click',function (){
|
|
$('#exec_divide_btn').bind('click',function (){
|
|
|
if(projectReadOnly) return;
|
|
if(projectReadOnly) return;
|
|
|
|
|
+ let selected = divideObj.getSelectedItem();
|
|
|
|
|
+ if(selected.itemType !="分摊项") return;
|
|
|
$("#exec_divide_div").modal('show');
|
|
$("#exec_divide_div").modal('show');
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+$('#cancel_divide_btn').bind('click',function (){
|
|
|
|
|
+ if(projectReadOnly) return;
|
|
|
|
|
+ let selected = divideObj.getSelectedItem();
|
|
|
|
|
+ if(selected.itemType !="分摊项") return;
|
|
|
|
|
+ divideObj.cancelDivide(selected.ID);
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+$('#cancel_all_divide_btn').bind('click',function (){
|
|
|
|
|
+ if(projectReadOnly) return;
|
|
|
|
|
+ divideObj.cancelDivide();
|
|
|
|
|
+});
|
|
|
|
|
|
|
|
$('#divideBottom ul li a').on('shown.bs.tab',function () {
|
|
$('#divideBottom ul li a').on('shown.bs.tab',function () {
|
|
|
divideObj.showRationGLJDatas();
|
|
divideObj.showRationGLJDatas();
|
|
@@ -1080,5 +1480,29 @@ $('#divideBottom ul li a').on('shown.bs.tab',function () {
|
|
|
|
|
|
|
|
$('#exec_divide_div').on('shown.bs.modal',function () {
|
|
$('#exec_divide_div').on('shown.bs.modal',function () {
|
|
|
divideObj.initExecSpread();
|
|
divideObj.initExecSpread();
|
|
|
- divideObj.showExecDatas();
|
|
|
|
|
|
|
+ divideObj.showExecDatas(true);
|
|
|
|
|
+ let selected = divideObj.getSelectedItem();
|
|
|
|
|
+ let divideType = selected.divideType?selected.divideType:0;
|
|
|
|
|
+ for(let radio of $(".divide_type")){
|
|
|
|
|
+ $(radio).prop('checked', divideType == $(radio).val());
|
|
|
|
|
+ }
|
|
|
|
|
+ divideObj.selectedRadio=divideType;
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+$("#divide_confirm").bind('click',async function (){
|
|
|
|
|
+ let divideType = parseInt($("input[name='divide_type']:checked").val());
|
|
|
|
|
+ let item = divideObj.getSelectedItem();
|
|
|
|
|
+ let updateData = {ID:item.ID,type:'update',doc:{bills:divideObj.execBillsDatas,divideType:divideType}}
|
|
|
|
|
+ await divideObj.updateItem([updateData]);
|
|
|
|
|
+ await divideObj.calcDivideNodes(item);
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+$("input[name='divide_type']").each(function(){
|
|
|
|
|
+ $(this).click(function(){
|
|
|
|
|
+ if(divideObj.selectedRadio == $(this).val()) return;
|
|
|
|
|
+ if($(this).val() == 2) return;
|
|
|
|
|
+ divideObj.selectedRadio = $(this).val();
|
|
|
|
|
+ divideObj.showExecBillsDatas();
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|