|
@@ -189,7 +189,483 @@ var installation_fee = {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
+ installation_fee.prototype.calcInstallationFee=function(callback){
|
|
|
|
+ let project = projectObj.project,me = this;
|
|
|
|
+ let engineering = projectInfoObj.projectInfo.property.engineering;
|
|
|
|
+ let installSetting = projectInfoObj.projectInfo.property.installSetting;
|
|
|
|
+ let rationInstallation = project.ration_installation;
|
|
|
|
+ let BXs = project.Bills.getAllBXs();//取所有补项
|
|
|
|
+ let allBillsDatas = _.sortBy(_.cloneDeep(project.Bills.datas),'code');//取所有清单信息,用来查找清单信息和存放中间过程产生的清单
|
|
|
|
+ let rationKeyMap={};//安装子目关联表
|
|
|
|
+ let newBills = [];
|
|
|
|
+ let billSerialMap = {};
|
|
|
|
+ let FBMap = {};//保存分部下对应的补项
|
|
|
|
+ let usedBXMap = {};//有使用到的补项
|
|
|
|
+ if(engineering!=engineeringType.BUILD_IN){//如果不是安装工程,则不用计算
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ for(let bx of BXs){//把补项放入映射表中
|
|
|
|
+ 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 ra_installs = rationInstallation.getCalcRIByItemID(d.libID,item.ID);//取所有有效的定额安装增加费
|
|
|
|
+ for(let ri of ra_installs){
|
|
|
|
+ let rationNode = project.mainTree.getNodeByID(ri.rationID);
|
|
|
|
+ if(rationNode){
|
|
|
|
+ if(rule_ration_map[ri.ruleId]){
|
|
|
|
+ rule_ration_map[ri.ruleId].push(rationNode.data);
|
|
|
|
+ }else {
|
|
|
|
+ rule_ration_map[ri.ruleId] = [rationNode.data];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ for(let ruleIDKey in rule_ration_map){
|
|
|
|
+ calcEachRule(item,d.libID,ruleIDKey,rule_ration_map[ruleIDKey],rationKeyMap,newBills);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ console.log("------------------生成的定额安装费");
|
|
|
|
+ console.log(rationKeyMap);
|
|
|
|
+ console.log("------------------新的清单");
|
|
|
|
+ console.log(newBills);
|
|
|
|
+ let updateData = {
|
|
|
|
+ bills:{
|
|
|
|
+ delete:[],
|
|
|
|
+ add:newBills
|
|
|
|
+ },
|
|
|
|
+ ration:{//定额更新只有更新对应的工料机数据
|
|
|
|
+ delete:[],
|
|
|
|
+ update:[],
|
|
|
|
+ add:[]
|
|
|
|
+ },
|
|
|
|
+ userID: userID
|
|
|
|
+ };
|
|
|
|
+ let oldITypeRations = _.cloneDeep(project.Ration.getAllInstallTypeRation())//取所有旧的安装增加费定额-没有用的要删除
|
|
|
|
+ let oldRationMap = {};
|
|
|
|
+ let deleteRationNodes = [];
|
|
|
|
+ let deleteBillsNodes = [];
|
|
|
|
+ let isChange = newBills.length>0;//记录数据是否发生了改变;
|
|
|
|
+ for(let o of oldITypeRations){//过滤出要删除的定额
|
|
|
|
+ if(rationKeyMap[o.installationKey]==undefined){
|
|
|
|
+ updateData.ration.delete.push(o);
|
|
|
|
+ let d_node = project.mainTree.getNodeByID(o.ID);
|
|
|
|
+ if(d_node){
|
|
|
|
+ deleteRationNodes.push(d_node);
|
|
|
|
+ isChange = true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ oldRationMap[o.installationKey] = o;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for(let inKey in rationKeyMap){
|
|
|
|
+ if(oldRationMap[inKey]){//存在,则更新就可以了
|
|
|
|
+ if(checkRation(oldRationMap[inKey],rationKeyMap[inKey])){//检查是否需要更新
|
|
|
|
+ updateData.ration.update.push(oldRationMap[inKey]);
|
|
|
|
+ isChange = true;
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ updateData.ration.add.push(rationKeyMap[inKey]);
|
|
|
|
+ isChange = true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for(let tem_bx of BXs){//过滤要删除的补项
|
|
|
|
+ if(usedBXMap[tem_bx.ParentID]==undefined){
|
|
|
|
+ updateData.bills.delete.push(tem_bx);
|
|
|
|
+ let b_node = project.mainTree.getNodeByID(tem_bx.ID);
|
|
|
|
+ if(b_node){
|
|
|
|
+ deleteBillsNodes.push(b_node);
|
|
|
|
+ isChange = true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ console.log(updateData);
|
|
|
|
+ console.log(isChange);
|
|
|
|
+ if(isChange == true){
|
|
|
|
+ $.bootstrapLoading.start()
|
|
|
|
+ CommonAjax.post("/project/calcInstallationFee",updateData,function (data) {
|
|
|
|
+ //提交后台成功后所做的操作,删除要先删除定额,再删除清单,添加要先添加清单再添加定额
|
|
|
|
+ console.log(data);
|
|
|
|
+ project.ration_glj.addDatasToList(data.add);//添加插入的定额
|
|
|
|
+ for(let ur of data.update){
|
|
|
|
+ let glj = project.ration_glj.getDataByID(ur.ID);
|
|
|
|
+ glj.quantity = ur.quantity;
|
|
|
|
+ glj.rationItemQuantity = ur.rationItemQuantity;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //对树节点的操作并删除、添加清单、删除添加定额、删除对应的定额工料机缓存
|
|
|
|
+ TREE_SHEET_HELPER.massOperationSheet(projectObj.mainController.sheet, function () {
|
|
|
|
+ deleteOldNodes(deleteRationNodes,deleteBillsNodes);
|
|
|
|
+ addNewNodes(updateData);
|
|
|
|
+ });
|
|
|
|
+ projectObj.project.projectGLJ.loadData(function () {
|
|
|
|
+ cbTools.refreshFormulaNodes();
|
|
|
|
+ if(callback){
|
|
|
|
+ callback();
|
|
|
|
+ }
|
|
|
|
+ $.bootstrapLoading.end();
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ function addNewNodes(updateData) {
|
|
|
|
+ let controller = projectObj.mainController;
|
|
|
|
+ let Bill = project.Bills;
|
|
|
|
+ let newAddNode = [];
|
|
|
|
+ for(let nb of updateData.bills.add){
|
|
|
|
+ let newSource = Bill.tree.insertByData(nb, nb.ParentID, -1, true);
|
|
|
|
+ let newNode = project.mainTree.insert(nb.ParentID, -1, newSource.data.ID);
|
|
|
|
+ newNode.source = newSource;
|
|
|
|
+ newNode.sourceType = Bill.getSourceType();
|
|
|
|
+ newNode.data = newSource.data;
|
|
|
|
+ controller.sheet.addRows(newNode.serialNo(), 1);
|
|
|
|
+ controller.sheet.showRow(newNode.serialNo(), GC.Spread.Sheets.VerticalPosition.center);
|
|
|
|
+ newAddNode.push(newNode);
|
|
|
|
+ Bill.datas.push(nb);
|
|
|
|
+ }
|
|
|
|
+ for(let nr of updateData.ration.add){
|
|
|
|
+ let newNode = project.mainTree.insert(nr.billsItemID, -1, nr.ID);
|
|
|
|
+ newNode.source = nr;
|
|
|
|
+ newNode.sourceType = project.Ration.getSourceType();
|
|
|
|
+ newNode.data = nr;
|
|
|
|
+ controller.sheet.addRows(newNode.serialNo(), 1);
|
|
|
|
+ controller.sheet.showRow(newNode.serialNo(), GC.Spread.Sheets.VerticalPosition.center);
|
|
|
|
+ newAddNode.push(newNode);
|
|
|
|
+ project.Ration.datas.push(nr);
|
|
|
|
+ }
|
|
|
|
+ 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();
|
|
|
|
+ for(let rd of deleteRationNodes){
|
|
|
|
+ controller.sheet.deleteRows(rd.serialNo(),1);
|
|
|
|
+ controller.tree.delete(rd);
|
|
|
|
+ Ration.removeByID(rd.getID());
|
|
|
|
+ ration_glj.deleteByRation(rd.data);
|
|
|
|
+ }
|
|
|
|
+ for(let bd of deleteBillsNodes){
|
|
|
|
+ controller.sheet.deleteRows(bd.serialNo(),1);
|
|
|
|
+ controller.tree.delete(bd);
|
|
|
|
+ Bill.tree.delete(bd.source);
|
|
|
|
+ Bill.removeByID(bd.getID());
|
|
|
|
+ }
|
|
|
|
+ controller.setTreeSelected(controller.tree.items[1]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ function checkRation(oldRation,newRation) {//检查定额是否需要更新
|
|
|
|
+ let gljs = project.ration_glj.getGljByRationID(oldRation.ID);
|
|
|
|
+ let modify = false;
|
|
|
|
+ let gljList =[];
|
|
|
|
+ for(let g of gljs){
|
|
|
|
+ if(g.quantity != newRation.glj[g.code].quantity){//消耗量不一样,需重新修改
|
|
|
|
+ let tem ={
|
|
|
|
+ ID:g.ID,
|
|
|
|
+ projectID:g.projectID,
|
|
|
|
+ quantity :newRation.glj[g.code].quantity,
|
|
|
|
+ rationItemQuantity:newRation.glj[g.code].rationItemQuantity
|
|
|
|
+ };
|
|
|
|
+ gljList.push(tem);
|
|
|
|
+ modify = true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ oldRation.glj = gljList;
|
|
|
|
+ return modify;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function calcEachRule(item,libID,ruleID,rations,rationKeyMap,newBills) {
|
|
|
|
+ let rule = me.getFeeRuleByID(libID,ruleID);
|
|
|
|
+ let pre_key = libID+item.ID+item.feeType+ruleID;
|
|
|
|
+ if(item.feeType == '子目费用'){
|
|
|
|
+ for(let r of rations){//在定额的同级新增一条
|
|
|
|
+ let billItemID = r.billsItemID;
|
|
|
|
+ let nextID = -1;
|
|
|
|
+ let newRationData = createNewRationData(billItemID,nextID,rule);
|
|
|
|
+ let [labourQuantity,materialQuantity,machineQuantity] = calcQuantity(rule,r);
|
|
|
|
+ newRationData = setGljQuantity(newRationData,labourQuantity,materialQuantity,machineQuantity);
|
|
|
|
+ let installationKey = pre_key+billItemID;
|
|
|
|
+ newRationData['installationKey'] = installationKey;
|
|
|
|
+ if(rationKeyMap[installationKey]){//如果已经存在,则工料机消耗量累加起来
|
|
|
|
+ sumGLJquantity(rationKeyMap[installationKey],labourQuantity,materialQuantity,machineQuantity);
|
|
|
|
+ }else {
|
|
|
|
+ rationKeyMap[installationKey] = newRationData;//在映射表中添加
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }else if(item.feeType == '措施费用'){//措施费用时,则在记取位置选择的清单下新增安装子目。
|
|
|
|
+ allInOne(item,rule,rations,newBills,pre_key,rationKeyMap);
|
|
|
|
+ }else if(item.feeType=='分项费用'){
|
|
|
|
+ if(installSetting==undefined||installSetting=="0"){//选择了“整个项目统一计取”,则在记取位置选择的分项下新增安装子目
|
|
|
|
+ allInOne(item,rule,rations,newBills,pre_key,rationKeyMap);
|
|
|
|
+ }else {//选择了每个分部单独记取
|
|
|
|
+ calcEveryFB(item,rule,rations,newBills,pre_key,rationKeyMap);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ function sumGLJquantity(ration,labourQuantity,materialQuantity,machineQuantity) {
|
|
|
|
+ let gljDecimal = getDecimal('glj.quantity');
|
|
|
|
+ let sumLabour = scMathUtil.roundForObj(ration.glj['RGFTZ'].quantity,gljDecimal)+labourQuantity;
|
|
|
|
+ let sumMaterial = scMathUtil.roundForObj(ration.glj['CLFTZ'].quantity,gljDecimal)+materialQuantity;
|
|
|
|
+ let sumMachine = scMathUtil.roundForObj(ration.glj['JXFTZ'].quantity,gljDecimal)+machineQuantity;
|
|
|
|
+ ration.glj['RGFTZ'].quantity =scMathUtil.roundToString(sumLabour,gljDecimal);
|
|
|
|
+ ration.glj['RGFTZ'].rationItemQuantity = scMathUtil.roundToString(sumLabour,gljDecimal);
|
|
|
|
+ ration.glj['CLFTZ'].quantity = scMathUtil.roundToString(sumMaterial,gljDecimal);
|
|
|
|
+ ration.glj['CLFTZ'].rationItemQuantity = scMathUtil.roundToString(sumMaterial,gljDecimal);
|
|
|
|
+ ration.glj['JXFTZ'].quantity = scMathUtil.roundToString(sumMachine,gljDecimal);
|
|
|
|
+ ration.glj['JXFTZ'].rationItemQuantity = scMathUtil.roundToString(sumMachine,gljDecimal);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function calcEveryFB(item,rule,rations,newBills,pre_key,rationKeyMap) {
|
|
|
|
+ let parentMap = {};
|
|
|
|
+ for(let r of rations){//先归类
|
|
|
|
+ let rationNode = project.mainTree.getNodeByID(r.ID);
|
|
|
|
+ if(rationNode){
|
|
|
|
+ if(parentMap[rationNode.parent.parent.getID()]){
|
|
|
|
+ parentMap[rationNode.parent.parent.getID()].push(r)
|
|
|
|
+ }else {
|
|
|
|
+ parentMap[rationNode.parent.parent.getID()] = [r];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ for(let billID_key in parentMap){
|
|
|
|
+ let gljDecimal = getDecimal('glj.quantity');
|
|
|
|
+ let tem_rations = parentMap[billID_key];
|
|
|
|
+ let BXNodeData;
|
|
|
|
+ if(FBMap[billID_key]){//查看有没有对应的补项,如果没有,新增一个
|
|
|
|
+ BXNodeData = FBMap[billID_key];
|
|
|
|
+ }else {//新增一个
|
|
|
|
+ BXNodeData = {
|
|
|
|
+ projectID: parseInt(project.ID()),
|
|
|
|
+ ParentID:billID_key,
|
|
|
|
+ NextSiblingID:-1,
|
|
|
|
+ code : 'BAZF',
|
|
|
|
+ name:'安装增加费',
|
|
|
|
+ unit:'元',
|
|
|
|
+ quantity:'1',
|
|
|
|
+ type:billType.BX
|
|
|
|
+ };
|
|
|
|
+ BXNodeData.ID = uuid.v1();
|
|
|
|
+ FBMap[billID_key] = BXNodeData;
|
|
|
|
+ newBills.push(BXNodeData);
|
|
|
|
+ }
|
|
|
|
+ usedBXMap[billID_key] = BXNodeData;//记录有用到的补项,最后没有用到的要删除
|
|
|
|
+ let newRationData = createNewRationData(BXNodeData.ID,-1,rule);
|
|
|
|
+ let labourSum = 0,materialSum =0,machineSum = 0;
|
|
|
|
+ for(let ra of tem_rations){//措施费用的情况下,多条定额生成一条安装子目
|
|
|
|
+ let [tem_labourQuantity,tem_materialQuantity,tem_machineQuantity] = calcQuantity(rule,ra);
|
|
|
|
+ labourSum =scMathUtil.roundForObj(labourSum+tem_labourQuantity,gljDecimal);
|
|
|
|
+ materialSum= scMathUtil.roundForObj(materialSum+tem_materialQuantity,gljDecimal);
|
|
|
|
+ machineSum = scMathUtil.roundForObj(machineSum+tem_machineQuantity,gljDecimal);
|
|
|
|
+ }
|
|
|
|
+ newRationData = setGljQuantity(newRationData,labourSum,materialSum,machineSum);
|
|
|
|
+ let installationKey = pre_key+BXNodeData.ID;
|
|
|
|
+ newRationData['installationKey'] = installationKey;
|
|
|
|
+ rationKeyMap[installationKey] = newRationData;//在映射表中添加
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ function allInOne(item,rule,rations,newBills,pre_key,rationKeyMap) {//统一设置
|
|
|
|
+ let billData = getBillNodeData(item,rule,newBills);//取对应的清单或生成一个新的清单数据
|
|
|
|
+ let newRationData = createNewRationData(billData.ID,-1,rule);
|
|
|
|
+ let gljDecimal = getDecimal('glj.quantity');
|
|
|
|
+ let labourSum = 0,materialSum =0,machineSum = 0;
|
|
|
|
+ for(let r of rations){//措施费用的情况下,多条定额生成一条安装子目
|
|
|
|
+ let [tem_labourQuantity,tem_materialQuantity,tem_machineQuantity] = calcQuantity(rule,r);
|
|
|
|
+ labourSum =scMathUtil.roundForObj(labourSum+tem_labourQuantity,gljDecimal);
|
|
|
|
+ materialSum= scMathUtil.roundForObj(materialSum+tem_materialQuantity,gljDecimal);
|
|
|
|
+ machineSum = scMathUtil.roundForObj(machineSum+tem_machineQuantity,gljDecimal);
|
|
|
|
+ }
|
|
|
|
+ newRationData = setGljQuantity(newRationData,labourSum,materialSum,machineSum);
|
|
|
|
+ let installationKey = pre_key+billData.ID;
|
|
|
|
+ newRationData['installationKey'] = installationKey;
|
|
|
|
+ rationKeyMap[installationKey] = newRationData;//在映射表中添加
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function setGljQuantity(rationData,labourQuantity,materialQuantity,machineQuantity) {
|
|
|
|
+ let gljDecimal = getDecimal('glj.quantity');
|
|
|
|
+ rationData.glj['RGFTZ'].quantity = scMathUtil.roundToString(labourQuantity,gljDecimal);
|
|
|
|
+ rationData.glj['RGFTZ'].rationItemQuantity = scMathUtil.roundToString(labourQuantity,gljDecimal);
|
|
|
|
+ rationData.glj['CLFTZ'].quantity = scMathUtil.roundToString(materialQuantity,gljDecimal);
|
|
|
|
+ rationData.glj['CLFTZ'].rationItemQuantity = scMathUtil.roundToString(materialQuantity,gljDecimal);
|
|
|
|
+ rationData.glj['JXFTZ'].quantity = scMathUtil.roundToString(machineQuantity,gljDecimal);
|
|
|
|
+ rationData.glj['JXFTZ'].rationItemQuantity = scMathUtil.roundToString(machineQuantity,gljDecimal);
|
|
|
|
+ return rationData;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function createNewRationData(billItemID,nextID,rule) {
|
|
|
|
+ let br = project.Ration.getBillsSortRation(billItemID);
|
|
|
|
+ let serialNo = 0;
|
|
|
|
+ if(billSerialMap[billItemID]){
|
|
|
|
+ serialNo = billSerialMap[billItemID]+1
|
|
|
|
+ }else {
|
|
|
|
+ serialNo = br.length > 0 ? br[br.length - 1].serialNo + 1 : 1;
|
|
|
|
+ billSerialMap[billItemID] = serialNo;
|
|
|
|
+ }
|
|
|
|
+ serialNo = br.length > 0 ? br[br.length - 1].serialNo + 1 : 1;
|
|
|
|
+ let newRationData = project.Ration.getTempRationData(project.Ration.getNewRationID(), billItemID, serialNo, rationType.install);
|
|
|
|
+ newRationData = setNewRationProperty(newRationData,nextID,rule);
|
|
|
|
+ return newRationData;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ function getBillNodeData(item,rule,newBills) {
|
|
|
|
+ let billData = null;
|
|
|
|
+ let billID = null;
|
|
|
|
+ if(rule.billID&&rule.billID!=""){
|
|
|
|
+ billData = getBillsByID(rule.billID);
|
|
|
|
+ billID = rule.billID;
|
|
|
|
+ }
|
|
|
|
+ if(!billData){
|
|
|
|
+ billData = getBillsByCode(rule.position);
|
|
|
|
+ if(!billData){//如果按ID和按code都找不到清单的话,自动生成一个
|
|
|
|
+ let newBillData = project.Bills.getNewInstallBillData(rule.position,billID,item.feeType);
|
|
|
|
+ if(item.feeType == '措施费用'){
|
|
|
|
+ newBillData.type = billType.BILL;
|
|
|
|
+ }else if(item.feeType == '分项费用'){
|
|
|
|
+ newBillData.type = billType.FX;
|
|
|
|
+ }
|
|
|
|
+ newBills.push(newBillData);
|
|
|
|
+ allBillsDatas.push(newBillData);
|
|
|
|
+ return newBillData;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return billData;
|
|
|
|
+ }
|
|
|
|
+ function getBillsByID(billID){
|
|
|
|
+ return _.find(allBillsDatas,{"ID":billID});
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function getBillsByCode(code){
|
|
|
|
+ return _.find(allBillsDatas, function(b) {
|
|
|
|
+ if(b.code&&b.code.indexOf(code)!=-1){
|
|
|
|
+ return true;
|
|
|
|
+ }else {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ function calcQuantity(rule,ration) {//计算单条定额的三个消耗量
|
|
|
|
+ let gljDecimal = getDecimal('glj.quantity');
|
|
|
|
+ let labourQuantity = 0, materialQuantity = 0, machineQuantity = 0;
|
|
|
|
+ let labour = rule.labour?rule.labour*0.01:0;
|
|
|
|
+ let material = rule.material?rule.material*0.01:0;
|
|
|
|
+ let machine = rule.machine?rule.machine*0.01:0;
|
|
|
|
+ let feeRate = rule.feeRate?rule.feeRate*0.01:0;
|
|
|
|
+ if(rule.base=='分别按人材机乘系数'){//'分别按人材机乘系数','人工','材料','机械'
|
|
|
|
+ labourQuantity = scMathUtil.roundForObj(parseFloat(project.Ration.getLabourTotalFee(ration))*parseFloat(labour),gljDecimal);
|
|
|
|
+ materialQuantity = scMathUtil.roundForObj(parseFloat(project.Ration.getMaterialTotalFee(ration))*parseFloat(material),gljDecimal);
|
|
|
|
+ machineQuantity = scMathUtil.roundForObj(parseFloat(project.Ration.getMachineTotalFee(ration))*parseFloat(machine),gljDecimal);
|
|
|
|
+ }else if(rule.base=='人工'){
|
|
|
|
+ labourQuantity = scMathUtil.roundForObj(parseFloat(project.Ration.getLabourTotalFee(ration))*parseFloat(feeRate)*parseFloat(labour),gljDecimal);
|
|
|
|
+ }else if(rule.base=='材料'){
|
|
|
|
+ materialQuantity = scMathUtil.roundForObj(parseFloat(project.Ration.getMaterialTotalFee(ration))*parseFloat(feeRate)*parseFloat(material),gljDecimal);
|
|
|
|
+ }else if(rule.base=='机械'){
|
|
|
|
+ machineQuantity = scMathUtil.roundForObj(parseFloat(project.Ration.getMachineTotalFee(ration))*parseFloat(feeRate)*parseFloat(machine),gljDecimal);
|
|
|
|
+ }
|
|
|
|
+ return [labourQuantity,materialQuantity,machineQuantity];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function setNewRationProperty(data,nextID,rule) {
|
|
|
|
+ data.code = rule.code;
|
|
|
|
+ data.name = rule.rule;
|
|
|
|
+ data.unit = '元';
|
|
|
|
+ data.quantity = '1';
|
|
|
|
+ data.nextID = nextID;
|
|
|
|
+ data.glj = {
|
|
|
|
+ 'RGFTZ':{
|
|
|
|
+ rationID:data.ID,
|
|
|
|
+ billsItemID:data.billsItemID,
|
|
|
|
+ shortName:project.projectGLJ.getShortNameByID(gljType.LABOUR),
|
|
|
|
+ GLJID:-1,
|
|
|
|
+ projectID:data.projectID,
|
|
|
|
+ code:'RGFTZ',
|
|
|
|
+ original_code:'RGFTZ',
|
|
|
|
+ name:'人工费调整',
|
|
|
|
+ specs:'',
|
|
|
|
+ unit:'元',
|
|
|
|
+ type:gljType.LABOUR,
|
|
|
|
+ basePrice:1,
|
|
|
|
+ adjCoe:null,
|
|
|
|
+ from:'std',
|
|
|
|
+ repositoryId:-1,
|
|
|
|
+ quantity:'0',
|
|
|
|
+ rationItemQuantity:'0'
|
|
|
|
+ },
|
|
|
|
+ 'CLFTZ':{
|
|
|
|
+ rationID:data.ID,
|
|
|
|
+ billsItemID:data.billsItemID,
|
|
|
|
+ shortName:project.projectGLJ.getShortNameByID(gljType.GENERAL_MATERIAL),
|
|
|
|
+ GLJID:-1,
|
|
|
|
+ projectID:data.projectID,
|
|
|
|
+ code:'CLFTZ',
|
|
|
|
+ original_code:'CLFTZ',
|
|
|
|
+ name:'材料费调整',
|
|
|
|
+ specs:'',
|
|
|
|
+ unit:'元',
|
|
|
|
+ type:gljType.GENERAL_MATERIAL,
|
|
|
|
+ basePrice:1,
|
|
|
|
+ adjCoe:null,
|
|
|
|
+ from:'std',
|
|
|
|
+ repositoryId:-1,
|
|
|
|
+ quantity:'0',
|
|
|
|
+ rationItemQuantity:'0'
|
|
|
|
+ },
|
|
|
|
+ 'JXFTZ':{
|
|
|
|
+ rationID:data.ID,
|
|
|
|
+ billsItemID:data.billsItemID,
|
|
|
|
+ shortName:project.projectGLJ.getShortNameByID(gljType.GENERAL_MACHINE),
|
|
|
|
+ GLJID:-1,
|
|
|
|
+ projectID:data.projectID,
|
|
|
|
+ code:'JXFTZ',
|
|
|
|
+ original_code:'JXFTZ',
|
|
|
|
+ name:'机械费调整',
|
|
|
|
+ specs:'',
|
|
|
|
+ unit:'元',
|
|
|
|
+ type:gljType.GENERAL_MACHINE,
|
|
|
|
+ basePrice:1,
|
|
|
|
+ adjCoe:null,
|
|
|
|
+ from:'std',
|
|
|
|
+ repositoryId:-1,
|
|
|
|
+ quantity:'0',
|
|
|
|
+ rationItemQuantity:'0'
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ return data;
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ installation_fee.prototype.updateInstallSetting = function (newValue,callback) {
|
|
|
|
+ let mixDatas = {
|
|
|
|
+ projectID: projectObj.project.ID(),
|
|
|
|
+ updateType: 'update',
|
|
|
|
+ properties: {
|
|
|
|
+ "property.installSetting":newValue
|
|
|
|
+ },
|
|
|
|
+ labourCoes: {},
|
|
|
|
+ rations: [],
|
|
|
|
+ bills: []
|
|
|
|
+ };
|
|
|
|
+ CommonAjax.post('/pm/api/updateMixDatas', {user_id: userID, mixDataArr: mixDatas}, function (rstData) {
|
|
|
|
+ projectInfoObj.projectInfo.property.installSetting = newValue;
|
|
|
|
+ if(callback){
|
|
|
|
+ callback();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
|
|
|
|
+ };
|
|
// 提交数据后返回数据处理
|
|
// 提交数据后返回数据处理
|
|
installation_fee.prototype.doAfterUpdate = function(err, data){
|
|
installation_fee.prototype.doAfterUpdate = function(err, data){
|
|
|
|
|