|
@@ -202,15 +202,16 @@ var installation_fee = {
|
|
|
let FBMap = {};//保存分部下对应的补项
|
|
|
let usedBXMap = {};//有使用到的补项
|
|
|
if(engineering!=engineeringType.BUILD_IN){//如果不是安装工程,则不用计算
|
|
|
+ if(callback) callback(false);
|
|
|
return;
|
|
|
}
|
|
|
for(let bx of BXs){//把补项放入映射表中
|
|
|
- FBMap[bx.ParentID] =bx;
|
|
|
+ FBMap[bx.ParentID] = bx;
|
|
|
}
|
|
|
for(let d of me.datas){
|
|
|
for(let item of d.installFeeItem){
|
|
|
if(item.isCal == 1){ //勾选了记取的费用项
|
|
|
- let rule_ration_map={};//费用规则定额映射表;
|
|
|
+ let rule_ration_map = {};//费用规则定额映射表;
|
|
|
let ra_installs = rationInstallation.getCalcRIByItemID(d.libID,item.ID);//取所有有效的定额安装增加费
|
|
|
for(let ri of ra_installs){
|
|
|
let rationNode = project.mainTree.getNodeByID(ri.rationID);
|
|
@@ -228,11 +229,6 @@ var installation_fee = {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- console.log("------------------生成的定额安装费");
|
|
|
- console.log(rationKeyMap);
|
|
|
- console.log("------------------新的清单");
|
|
|
- console.log(newBills);
|
|
|
let updateData = {
|
|
|
bills:{
|
|
|
delete:[],
|
|
@@ -246,9 +242,7 @@ var installation_fee = {
|
|
|
userID: userID
|
|
|
};
|
|
|
let oldITypeRations = _.cloneDeep(project.Ration.getAllInstallTypeRation())//取所有旧的安装增加费定额-没有用的要删除
|
|
|
- let oldRationMap = {};
|
|
|
- let deleteRationNodes = [];
|
|
|
- let deleteBillsNodes = [];
|
|
|
+ let oldRationMap = {}, deleteRationNodes = [], deleteBillsNodes = [];
|
|
|
let isChange = newBills.length>0;//记录数据是否发生了改变;
|
|
|
for(let o of oldITypeRations){//过滤出要删除的定额
|
|
|
if(rationKeyMap[o.installationKey]==undefined){
|
|
@@ -285,10 +279,8 @@ var installation_fee = {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- console.log(updateData);
|
|
|
- console.log(isChange);
|
|
|
if(isChange == true){
|
|
|
- $.bootstrapLoading.start()
|
|
|
+ $.bootstrapLoading.start();
|
|
|
CommonAjax.post("/project/calcInstallationFee",updateData,function (data) {
|
|
|
//提交后台成功后所做的操作,删除要先删除定额,再删除清单,添加要先添加清单再添加定额
|
|
|
console.log(data);
|
|
@@ -307,11 +299,13 @@ var installation_fee = {
|
|
|
projectObj.project.projectGLJ.loadData(function () {
|
|
|
cbTools.refreshFormulaNodes();
|
|
|
if(callback){
|
|
|
- callback();
|
|
|
+ callback(true);
|
|
|
}
|
|
|
$.bootstrapLoading.end();
|
|
|
});
|
|
|
});
|
|
|
+ }else {
|
|
|
+ if(callback) callback(false);
|
|
|
}
|
|
|
function addNewNodes(updateData) {
|
|
|
let controller = projectObj.mainController;
|
|
@@ -338,13 +332,13 @@ var installation_fee = {
|
|
|
newAddNode.push(newNode);
|
|
|
project.Ration.datas.push(nr);
|
|
|
}
|
|
|
+ console.log("add nodes");
|
|
|
TREE_SHEET_HELPER.refreshTreeNodeData(controller.setting, controller.sheet, newAddNode, false);
|
|
|
}
|
|
|
|
|
|
function deleteOldNodes(deleteRationNodes,deleteBillsNodes) {
|
|
|
let controller = projectObj.mainController, project = projectObj.project;
|
|
|
- let Bill = project.Bills, Ration = project.Bills.Ration,ration_glj = project.ration_glj;
|
|
|
- // let sels = controller.sheet.getSelections();
|
|
|
+ let Bill = project.Bills, Ration = project.Ration,ration_glj = project.ration_glj;
|
|
|
for(let rd of deleteRationNodes){
|
|
|
controller.sheet.deleteRows(rd.serialNo(),1);
|
|
|
controller.tree.delete(rd);
|
|
@@ -357,7 +351,8 @@ var installation_fee = {
|
|
|
Bill.tree.delete(bd.source);
|
|
|
Bill.removeByID(bd.getID());
|
|
|
}
|
|
|
- controller.setTreeSelected(controller.tree.items[1]);
|
|
|
+ let sels = controller.sheet.getSelections();
|
|
|
+ controller.setTreeSelected(controller.tree.items[sels[0].row]);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -379,7 +374,6 @@ var installation_fee = {
|
|
|
}
|
|
|
oldRation.glj = gljList;
|
|
|
return modify;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
function calcEachRule(item,libID,ruleID,rations,rationKeyMap,newBills) {
|
|
@@ -583,6 +577,7 @@ var installation_fee = {
|
|
|
data.name = rule.rule;
|
|
|
data.unit = '元';
|
|
|
data.quantity = '1';
|
|
|
+ data.contain ='1';
|
|
|
data.nextID = nextID;
|
|
|
data.glj = {
|
|
|
'RGFTZ':{
|
|
@@ -666,6 +661,27 @@ var installation_fee = {
|
|
|
});
|
|
|
|
|
|
};
|
|
|
+ installation_fee.prototype.resetToDefault = function (callback) {
|
|
|
+ let me = this;
|
|
|
+ let installFees = [];
|
|
|
+ for(let d of me.datas){
|
|
|
+ let ins ={
|
|
|
+ libID:d.libID,
|
|
|
+ ID:d.ID
|
|
|
+ };
|
|
|
+ installFees.push(ins);
|
|
|
+ }
|
|
|
+ //data.projectID,data.installFees
|
|
|
+ $.bootstrapLoading.start();
|
|
|
+ CommonAjax.post("/installation/resetToDefault",{projectID:project.ID(),installFees:installFees},function (result) {
|
|
|
+ console.log(result)
|
|
|
+ me.datas = result;
|
|
|
+ if(callback){
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ $.bootstrapLoading.end();
|
|
|
+ })
|
|
|
+ };
|
|
|
// 提交数据后返回数据处理
|
|
|
installation_fee.prototype.doAfterUpdate = function(err, data){
|
|
|
|