| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- 'use strict';
- /**
- *
- *
- * @author Zhong
- * @date 2019/4/17
- * @version
- */
- //允许使用的工料机类型:人工、普通材料、混凝土、砂浆、配合比、商品混凝土、商品砂浆、机械台班、机械组成物、机上人工、主材、设备、企业管理费、利润
- if(typeof allowGljType !== 'undefined'){
- allowGljType = [1, 201, 202, 203, 204, 205, 206, 301, 302, 303, 4, 5, 6, 7];
- }
- if(typeof allowComponent !== 'undefined'){
- //允许含有组成物的工料机类型:混凝土、砂浆、配合比、机械台班、主材
- allowComponent = [202, 203, 204, 301, 4];
- }
- if(typeof componentType !== 'undefined'){
- //可以作为组成物的工料机类型:普通材料、机械组成物、机上人工、主材
- componentType = [201, 302, 303, 4];
- }
- if(typeof machineAllowComponent !== 'undefined'){
- //允许含有组成物的机械工料机类型:机械台班
- machineAllowComponent = [301];
- }
- if(typeof machineComponent !== 'undefined'){
- //可以作为机械工料机组成物的工料机类型:机械组成物、机上人工
- machineComponent = [302, 303];
- }
- if(typeof materialAllowComponent !== 'undefined'){
- //允许含有组成物的材料工料机类型:混凝土、砂浆、配合比
- materialAllowComponent = [202, 203, 204];
- }
- if(typeof materialComponent !== 'undefined'){
- //可以作为材料工料机组成物的工料机类型:普通材料
- materialComponent = [201];
- }
- //覆盖前端定额基价计算
- //基价=人工费+材料费+机械费+管理费利润
- //管理费利润=Round(人工费*(管理费消耗量+利润消耗量)%,2) 注:书中管理费、利润的单位都是“%”
- if (typeof rationGLJOprObj !== 'undefined' && typeof rationGLJOprObj.rationCal !== 'undefined') {
- rationGLJOprObj.rationCal = function () {
- let me = rationGLJOprObj;
- let price = {gljType1: [], gljType2: [], gljType3: []},
- rst = {labourPrice: 0, materialPrice: 0, machinePrice: 0},
- rationBasePrc = 0;
- let manageProfitConsume = 0; //管理费、利润消耗量
- if(me.currentRationItem && me.cache['_GLJ_' + me.currentRationItem.ID]){
- let cacheArr = me.cache['_GLJ_' + me.currentRationItem.ID];
- cacheArr.forEach(function (gljData) {
- if(gljData.gljType && gljData.basePrice && gljData.consumeAmt){
- let parentGLJType = parseInt(String(gljData.gljType)[0]);
- if (parentGLJType <= 3) { // 人工、材料、机械
- // 单位为%,单条基价计算为定额价*消耗量*0.01
- if (gljData.unit === '%') {
- price['gljType' + parentGLJType].push(scMathUtil.roundTo(gljData.basePrice * gljData.consumeAmt * 0.01, -3));//取三位
- } else {
- price['gljType' + parentGLJType].push(scMathUtil.roundTo(gljData.basePrice * gljData.consumeAmt, -3));//取三位
- }
- }
- if([6, 7].includes(gljData.gljType)){
- manageProfitConsume = scMathUtil.roundTo(manageProfitConsume + gljData.consumeAmt, -6);
- }
- }
- });
- if(price.gljType1.length > 0){
- let labourPrice = 0;
- price.gljType1.forEach(function (singlePrc) {
- labourPrice = scMathUtil.roundTo(labourPrice + singlePrc, me.processDecimal);
- });
- let roundPrice = scMathUtil.roundTo(labourPrice, -2);
- rst.labourPrice = roundPrice;
- rationBasePrc = scMathUtil.roundTo(rationBasePrc + roundPrice, -2);
- //管理费利润
- let manageProfitPrc = scMathUtil.roundTo(roundPrice * manageProfitConsume * 0.01, -2);
- rationBasePrc = scMathUtil.roundTo(rationBasePrc + manageProfitPrc, -2);
- }
- if(price.gljType2.length > 0){
- let materialPrice = 0;
- price.gljType2.forEach(function (singlePrc) {
- materialPrice = scMathUtil.roundTo(materialPrice + singlePrc, me.processDecimal);
- });
- let roundPrice = scMathUtil.roundTo(materialPrice, -2);
- rst.materialPrice = roundPrice;
- rationBasePrc = scMathUtil.roundTo(rationBasePrc + roundPrice, -2);
- }
- if(price.gljType3.length > 0){
- let machinePrice = 0;
- price.gljType3.forEach(function (singlePrc) {
- machinePrice = scMathUtil.roundTo(machinePrice + singlePrc, me.processDecimal);
- });
- let roundPrice = scMathUtil.roundTo(machinePrice, -2);
- rst.machinePrice = roundPrice;
- rationBasePrc = scMathUtil.roundTo(rationBasePrc + roundPrice, -2);
- }
- rst.rationBasePrc = rationBasePrc;
- }
- return rst;
- }
- }
- if (typeof module !== 'undefined') {
- module.exports = {
- // 计算定额基价
- calcRation: function (gljArr, scMathUtil) {
- let labourPrc = [],
- materialPrc = [],
- machinePrc = [],
- manageProfitConsume = 0,
- singlePrc,
- updatePrc = {labourPrice: 0, materialPrice: 0, machinePrice: 0, manageProfitPrice: 0, basePrice: 0};
- gljArr.forEach(function (gljItem) {
- if(gljItem.gljParentType !== -1){
- if (gljItem.gljParentType <= 3 && gljItem.unit === '%') {
- singlePrc = scMathUtil.roundTo(gljItem.basePrice * gljItem.consumeAmt * 0.01, -3);
- } else {
- singlePrc = scMathUtil.roundTo(gljItem.basePrice * gljItem.consumeAmt, -3);
- }
- if(gljItem.gljParentType === 1){
- labourPrc.push(singlePrc);
- } else if(gljItem.gljParentType ===2){
- materialPrc.push(singlePrc);
- } else if(gljItem.gljParentType === 3){
- machinePrc.push(singlePrc);
- } else if(gljItem.gljParentType === 6){
- manageProfitConsume = scMathUtil.roundTo(manageProfitConsume + gljItem.consumeAmt, -6);
- } else if(gljItem.gljParentType === 7){
- manageProfitConsume = scMathUtil.roundTo(manageProfitConsume + gljItem.consumeAmt, -6);
- }
- }
- });
- if(labourPrc.length > 0){
- let sumLaP = 0;
- for(let i=0; i<labourPrc.length; i++){
- sumLaP = scMathUtil.roundTo(sumLaP + labourPrc[i], -6);
- }
- updatePrc.labourPrice = scMathUtil.roundTo(sumLaP, -2);
- updatePrc.manageProfitPrice = scMathUtil.roundTo(updatePrc.labourPrice * manageProfitConsume * 0.01, -2);
- updatePrc.basePrice = scMathUtil.roundTo(updatePrc.labourPrice + updatePrc.manageProfitPrice, -2);
- }
- if(materialPrc.length > 0){
- let sumMtP = 0;
- for(let i= 0; i<materialPrc.length; i++){
- sumMtP = scMathUtil.roundTo(sumMtP + materialPrc[i], -6);
- }
- updatePrc.materialPrice = scMathUtil.roundTo(sumMtP, -2);
- updatePrc.basePrice = scMathUtil.roundTo(updatePrc.basePrice + updatePrc.materialPrice, -2);
- }
- if(machinePrc.length > 0){
- let sumMaP = 0;
- for(let i =0; i< machinePrc.length; i++){
- sumMaP = scMathUtil.roundTo(sumMaP + machinePrc[i], -6);
- }
- updatePrc.machinePrice = scMathUtil.roundTo(sumMaP, -2);
- updatePrc.basePrice = scMathUtil.roundTo(updatePrc.basePrice + updatePrc.machinePrice, -2);
- }
- return updatePrc;
- }
- };
- }
|