|
@@ -255,74 +255,89 @@ let executeObj = {
|
|
|
},
|
|
|
base: function(calcBaseName) {
|
|
|
let me = executeObj, rst = 0,
|
|
|
- //base = getRationCalcBase(calcBaseName);
|
|
|
base = me.calcBase[calcBaseName];
|
|
|
|
|
|
if (base != null) {
|
|
|
- let price = 0, aprice = 0, mprice = 0, tmpSum = 0, mdSum = 0;
|
|
|
-
|
|
|
function isSubset(sub, arr){
|
|
|
- // if(!(sub instanceof Array) || !(arr instanceof Array)) return false;
|
|
|
- // if(sub.length > arr.length) return false;
|
|
|
for(var i = 0, len = sub.length; i < len; i++){
|
|
|
if(arr.indexOf(sub[i]) == -1) return false;
|
|
|
}
|
|
|
return true;
|
|
|
- }
|
|
|
-
|
|
|
+ };
|
|
|
// 机上人工费:多一层
|
|
|
- if (isSubset(base.gljTypes, [gljType.MACHINE_LABOUR])) {
|
|
|
- if (!me.treeNode.data.gljList) tmpSum = 0
|
|
|
- else{
|
|
|
- for (let glj of me.treeNode.data.gljList) {
|
|
|
- if (glj.type == gljType.GENERAL_MACHINE) {
|
|
|
- // 获取机械组成物
|
|
|
- let mds = projectObj.project.composition.getCompositionByCode(glj.code);
|
|
|
- if (!mds) mds = [];
|
|
|
- for (let md of mds){
|
|
|
- if (base.gljTypes.indexOf(md.glj_type) >= 0) {
|
|
|
- price = md["base_price"];
|
|
|
- if (!price) price = 0;
|
|
|
- mdSum = mdSum + (md["consumption"] * price).toDecimal(me.digit);
|
|
|
- mdSum = (mdSum).toDecimal(me.digitDefault);
|
|
|
- }
|
|
|
- };
|
|
|
- tmpSum = tmpSum + (glj["quantity"] * mdSum).toDecimal(me.digitDefault);
|
|
|
- tmpSum = (tmpSum).toDecimal(me.digitDefault);
|
|
|
- }
|
|
|
+ function machineLabourFee() {
|
|
|
+ if (!me.treeNode.data.gljList) return 0;
|
|
|
+ let result = 0, mdSum = 0;
|
|
|
+ for (let glj of me.treeNode.data.gljList) {
|
|
|
+ if (glj.type == gljType.GENERAL_MACHINE) {
|
|
|
+ // 获取机械组成物
|
|
|
+ let mds = projectObj.project.composition.getCompositionByCode(glj.code);
|
|
|
+ if (!mds) mds = [];
|
|
|
+ for (let md of mds){
|
|
|
+ if (base.gljTypes.indexOf(md.glj_type) >= 0) {
|
|
|
+ let q = md["consumption"] ? md["consumption"] : 0;
|
|
|
+ let p = md["base_price"] ? md["base_price"] : 0;
|
|
|
+ mdSum = mdSum + (q * p).toDecimal(me.digit);
|
|
|
+ mdSum = (mdSum).toDecimal(me.digitDefault);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ result = result + (glj["quantity"] * mdSum).toDecimal(me.digitDefault);
|
|
|
+ result = (result).toDecimal(me.digitDefault);
|
|
|
};
|
|
|
- }
|
|
|
- }else{
|
|
|
- if (!me.treeNode.data.gljList) tmpSum = 0
|
|
|
- else{
|
|
|
- for (let glj of me.treeNode.data.gljList) {
|
|
|
- if (base.gljTypes.indexOf(glj.type) >= 0) {
|
|
|
- if (base.calcType == baseCalc){ price = glj["basePrice"];}
|
|
|
- else if (base.calcType == adjustCalc){price = glj["adjustPrice"];}
|
|
|
- else if (base.calcType == budgetCalc){price = glj["marketPrice"];}
|
|
|
- else if (base.calcType == diffCalc){
|
|
|
- aprice = glj["adjustPrice"];
|
|
|
- if (!aprice) aprice = 0;
|
|
|
- mprice = glj["marketPrice"];
|
|
|
- if (!mprice) mprice = 0;
|
|
|
- price = mprice - aprice;
|
|
|
- };
|
|
|
- if (!price) price = 0;
|
|
|
- tmpSum = tmpSum + (glj["quantity"] * price).toDecimal(me.digitDefault);
|
|
|
- tmpSum = (tmpSum).toDecimal(me.digitDefault);
|
|
|
+ };
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+ function commonGLJFee(){
|
|
|
+ if (!me.treeNode.data.gljList) return 0;
|
|
|
+ let result = 0;
|
|
|
+ for (let glj of me.treeNode.data.gljList) {
|
|
|
+ let price = 0;
|
|
|
+ if (base.gljTypes.indexOf(glj.type) >= 0) {
|
|
|
+ if (base.calcType == baseCalc){ price = parseFloat(glj["basePrice"]);}
|
|
|
+ else if (base.calcType == adjustCalc){price = parseFloat(glj["adjustPrice"]);}
|
|
|
+ else if (base.calcType == budgetCalc){price = parseFloat(glj["marketPrice"]);}
|
|
|
+ else if (base.calcType == diffCalc){
|
|
|
+ let aprice = glj["adjustPrice"] ? glj["adjustPrice"] : 0;
|
|
|
+ let mprice = glj["marketPrice"] ? glj["marketPrice"] : 0;
|
|
|
+ price = (parseFloat(mprice) - parseFloat(aprice)).toDecimal(me.digitDefault);
|
|
|
};
|
|
|
+ result = result + (glj["quantity"] * price).toDecimal(me.digitDefault);
|
|
|
+ result = (result).toDecimal(me.digitDefault);
|
|
|
};
|
|
|
};
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+ // 量价没有具体的工料机类型,但仍然要用定额的计算程序,所以要给计算基数直接指定。
|
|
|
+ function volumePriceFee() {
|
|
|
+ let result = 0;
|
|
|
+ if (
|
|
|
+ ( me.treeNode.data.type === '人工' && base.dispName === '定额基价人工费') ||
|
|
|
+ ( me.treeNode.data.type === '材料' && base.dispName === '定额基价材料费') ||
|
|
|
+ ( me.treeNode.data.type === '机械' && base.dispName === '定额基价机械费') ||
|
|
|
+ ( me.treeNode.data.type === '主材' && base.dispName === '主材费') ||
|
|
|
+ ( me.treeNode.data.type === '设备' && base.dispName === '设备费')
|
|
|
+ ) result = me.treeNode.data.marketUnitFee;
|
|
|
+
|
|
|
+ return result;
|
|
|
};
|
|
|
|
|
|
- rst = (tmpSum).toDecimal(me.digitDefault);
|
|
|
+ if (me.treeNode.sourceType === projectObj.project.VolumePrice.getSourceType()){
|
|
|
+ rst = volumePriceFee();
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ if (isSubset(base.gljTypes, [gljType.MACHINE_LABOUR]))
|
|
|
+ rst = machineLabourFee()
|
|
|
+ else
|
|
|
+ rst = commonGLJFee();
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
return rst;
|
|
|
},
|
|
|
HJ: function () {
|
|
|
let me = this;
|
|
|
- return me.treeNode.calcBaseValue;
|
|
|
+ let rst = me.treeNode.data.marketUnitFee ? me.treeNode.data.marketUnitFee : 0;
|
|
|
+ return rst;
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -524,7 +539,7 @@ class CalcProgram {
|
|
|
};
|
|
|
};
|
|
|
|
|
|
- // 仅内部调用。注意:外部不能直接使用
|
|
|
+ // 仅内部调用。注意:外部不能直接使用,因为这里传入的树节点必须有一定的初始化。
|
|
|
InnerCalc(treeNode){
|
|
|
let me = this;
|
|
|
let project = me.project;
|
|
@@ -605,14 +620,18 @@ class CalcProgram {
|
|
|
treeNode.data.programID = defaultBillTemplate.ID;
|
|
|
};
|
|
|
}
|
|
|
- else {
|
|
|
- if (treeNode.sourceType === project.Ration.getSourceType()) {
|
|
|
- treeNode.data.gljList = project.ration_glj.getGljArrByRation(treeNode.data.ID);
|
|
|
- }
|
|
|
- else if (treeNode.sourceType === project.Bills.getSourceType()) {
|
|
|
- let rations = project.Ration.getBillsSortRation(treeNode.source.getID());
|
|
|
- treeNode.data.gljList = project.ration_glj.getGatherGljArrByRations(rations);
|
|
|
+ else if (treeNode.calcType == treeNodeCalcType.ctRationCalcProgram) {
|
|
|
+ let muf = treeNode.data.marketUnitFee ? treeNode.data.marketUnitFee : 0;
|
|
|
+ let q = treeNode.data.quantity ? treeNode.data.quantity : 0;
|
|
|
+ treeNode.data.marketTotalFee = (muf * q).toDecimal(me.digit);
|
|
|
+ treeNode.data.gljList = me.project.ration_glj.getGljArrByRation(treeNode.data.ID);
|
|
|
+ if (treeNode.data.programID == undefined){
|
|
|
+ treeNode.data.programID = 1;
|
|
|
};
|
|
|
+ }
|
|
|
+ else if (treeNode.calcType == treeNodeCalcType.ctBillCalcProgram) {
|
|
|
+ let rations = project.Ration.getBillsSortRation(treeNode.source.getID());
|
|
|
+ treeNode.data.gljList = project.ration_glj.getGatherGljArrByRations(rations);
|
|
|
|
|
|
if (treeNode.data.programID == undefined){
|
|
|
treeNode.data.programID = 1;
|
|
@@ -652,35 +671,25 @@ class CalcProgram {
|
|
|
let me = this;
|
|
|
|
|
|
let isRation = treeNode.sourceType === me.project.Ration.getSourceType();
|
|
|
+ let isVolumePrice = treeNode.sourceType === me.project.VolumePrice.getSourceType();
|
|
|
let isBill = treeNode.sourceType === me.project.Bills.getSourceType();
|
|
|
- let isLeafBill = isBill && treeNode.source.children && treeNode.source.children.length === 0;
|
|
|
+ let isLeafBill = isBill && treeNode.source.children && treeNode.source.children.length === 0; // 是清单且其下没有子清单
|
|
|
let isBillPriceCalc = me.project.projSetting.billsCalcMode === billsPrice;
|
|
|
|
|
|
- if (isRation)
|
|
|
- treeNode.calcType = treeNodeCalcType.ctRationCalcProgram
|
|
|
+ if (isRation || isVolumePrice){
|
|
|
+ treeNode.calcType = treeNodeCalcType.ctRationCalcProgram;
|
|
|
+ }
|
|
|
else if (isLeafBill) {
|
|
|
if (treeNode.children && treeNode.children.length > 0){
|
|
|
me.calcLeafBillChildren(treeNode);
|
|
|
- if (treeNode.children[0].sourceType == me.project.Ration.getSourceType()){
|
|
|
- if (isBillPriceCalc) // 清单单价计算模式下的叶子清单:取自己的计算程序ID,找到自己的计算程序计算
|
|
|
- treeNode.calcType = treeNodeCalcType.ctBillCalcProgram;
|
|
|
- else // 前三种计算模式下的叶子清单:汇总定额的计算程序的费用类别
|
|
|
- treeNode.calcType = treeNodeCalcType.ctGatherRations;
|
|
|
- }
|
|
|
- else if (treeNode.children[0].sourceType == me.project.VolumePrice.getSourceType()){
|
|
|
- let value = 20000;
|
|
|
- // if (treeNode.data.feesIndex && treeNode.data.feesIndex.common && treeNode.data.feesIndex.common.unitFee != 0)
|
|
|
- // value = treeNode.data.feesIndex.common.unitFee;
|
|
|
- treeNode.calcType = treeNodeCalcType.ctCalcBaseValue;
|
|
|
- treeNode.calcBaseValue = value;
|
|
|
- };
|
|
|
+
|
|
|
+ if (isBillPriceCalc) // 清单单价计算模式下的叶子清单:取自己的计算程序ID,找到自己的计算程序计算
|
|
|
+ treeNode.calcType = treeNodeCalcType.ctBillCalcProgram;
|
|
|
+ else // 前三种计算模式下的叶子清单:汇总定额的计算程序的费用类别
|
|
|
+ treeNode.calcType = treeNodeCalcType.ctGatherRations;
|
|
|
}
|
|
|
else{ // 公式计算
|
|
|
- let value = 20000;
|
|
|
- // if (treeNode.data.feesIndex && treeNode.data.feesIndex.common && treeNode.data.feesIndex.common.unitFee != 0)
|
|
|
- // value = treeNode.data.feesIndex.common.unitFee;
|
|
|
treeNode.calcType = treeNodeCalcType.ctCalcBaseValue;
|
|
|
- treeNode.calcBaseValue = value;
|
|
|
};
|
|
|
}
|
|
|
else if (isBill) // 父清单:汇总子清单的费用类别
|
|
@@ -720,8 +729,11 @@ class CalcProgram {
|
|
|
let data = {
|
|
|
ID: node.data.ID,
|
|
|
projectID: me.project.ID(),
|
|
|
+ type: node.data.type,
|
|
|
quantity: node.data.quantity,
|
|
|
programID: node.data.programID,
|
|
|
+ marketUnitFee: node.data.marketUnitFee,
|
|
|
+ marketTotalFee: node.data.marketTotalFee,
|
|
|
fees: node.data.fees
|
|
|
};
|
|
|
let newData = {'updateType': 'ut_update', 'updateData': data};
|