瀏覽代碼

feat: 变更重庆地区套用信息价的计算

zhangweicheng 3 年之前
父節點
當前提交
f264612dca

+ 2 - 0
modules/all_models/unit_price.js

@@ -48,6 +48,8 @@ let modelSchema = {
     // 对应标准库工料机id
     glj_id: Number,
     priceFrom:String,//价格来源
+    infoPrice:Number,//信息价
+    purchaseFeeRate:Number,//采保费率
     //是否新增1为是,0为否
     is_add:{
         type: Number,

+ 2 - 1
modules/main/facade/info_price_facade.js

@@ -337,7 +337,8 @@ async function mutiApplyInfoPrice(data,compilation){
       for(let obj of data.pgljMap[index]){
         let infoPrice = gljUtil.getInfoMarketPrice(info,data.taxType);
         infoPrice = scMathUtil.roundToString(infoPrice,data.decimal);
-        let doc = {'market_price':infoPrice,'priceFrom':data.priceFrom};
+        const marketPrice = gljUtil.calcMarketPriceByInfoPrice(infoPrice,obj.purchaseFeeRate,data.decimal,scMathUtil);
+        let doc = {'market_price':marketPrice,'priceFrom':data.priceFrom,infoPrice};
         let task = {
           updateOne:{
               filter:{'id':obj.unitPriceID},

+ 5 - 0
public/web/gljUtil.js

@@ -655,6 +655,11 @@ let gljUtil = {
       if(!this.isDef(infoPrice)) infoPrice= info[fieldArray[1]];//信息价只有一个价格(含税价/不含税价),则不分计税方式,套用仅有的价格。
       return parseFloat(infoPrice);
     },
+    calcMarketPriceByInfoPrice:function(infoPrice,purchaseFeeRate,decimal,tscMathUtil){
+        if(!purchaseFeeRate) return infoPrice;
+        tscMathUtil = tscMathUtil||scMathUtil
+        return tscMathUtil.roundForObj(infoPrice*(1+purchaseFeeRate/100), decimal)
+    },
     getPirceInfoDatas: function (projectGLJList, contractor_list, labourCoeDatas, projectProperty, _, scMathUtil) {
         let datas = [];
         let pgljList = projectGLJList;

+ 43 - 15
web/building_saas/main/js/models/project_glj.js

@@ -1,5 +1,3 @@
-
-
 /**
  * 工料机汇总相关数据
  *
@@ -320,20 +318,23 @@ ProjectGLJ.prototype.updatePrice = function (recode, updateField, newval,from,td
     let projectGljs = this.datas.gljList;
     let pgljID = from=="rg"?recode.projectGLJID:recode.id;//和定额工料机统一接口,项目工料机ID取值不一样
     let glj = _.find(projectGljs, {'id': pgljID});
-    let udoc = tdoc?tdoc:{"priceFrom":""};//20200728 新增价格来源,默认为空
+    let udoc = tdoc?tdoc:{};//20200728 新增价格来源,默认为空
+    if(updateField == 'market_price') udoc = {"priceFrom":"",infoPrice:null};
     if (glj) {
         if(glj.unit_price[updateField] == newval){
             return;
         }
-        newval = scMathUtil.roundForObj(newval,this.getPriceDecimal(glj));
+        if(updateField == 'market_price'||updateField == 'base_price' ){
+            newval = scMathUtil.roundForObj(newval,this.getPriceDecimal(glj));
+        }
         let data = {id: glj.unit_price.id, field: updateField, newval: newval,project_id:glj.project_id,unit_price_file_id:glj.unit_price.unit_price_file_id};
-        if(updateField == 'market_price') data.udoc=udoc;
+        if(!_.isEmpty(udoc)) data.udoc=udoc;
         let callback = function (data) {
             if (updateField == 'base_price') {
                 glj.unit_price.base_price = newval;
                 me.setAdjustPrice(glj);
             } else {
-                glj.unit_price.market_price = newval;
+                glj.unit_price[updateField] = newval;
                 gljUtil.setProperty(glj.unit_price,udoc);
             }
             //更新回传的父节点项目工料机价格
@@ -448,16 +449,43 @@ ProjectGLJ.prototype.batchUpdatePrice = function (changeInfo,sheetName,callback)
     for(let ci of changeInfo){
         let dataCode = setting.header[ci.col].dataCode;
         let recode = sheetName =="materialTreeSheet"?projectGljObject.materialTree.items[ci.row].data:projectGljObject.projectGljSheetData[ci.row];
-        if(dataCode=='basePrice'||dataCode=='marketPrice'){
-            let editField = dataCode === 'basePrice'?"base_price":"market_price";
-            let glj = _.find(projectGljs, {'id': recode.id});
-            let newValue = ci.value;
-            if(glj&&glj.unit_price[editField]!=newValue){
+        let glj = _.find(projectGljs, {'id': recode.id});
+        let editField = dataCode;
+        let newValue = ci.value;
+        if(dataCode=='basePrice'||dataCode=='marketPrice') editField = dataCode === 'basePrice'?"base_price":"market_price";
+        if(glj&&glj.unit_price[editField]!=newValue){  
+            newValueMap[glj.id] = newValueMap[glj.id]||{};
+            if(dataCode=='basePrice'||dataCode=='marketPrice'){
                 newValue= scMathUtil.roundForObj(ci.value,this.getPriceDecimal(glj));
-                updateData.push({unit_price: glj.unit_price, field: editField, newval: newValue,project_id:glj.project_id});
-                newValueMap[glj.id]={field:editField,value:newValue};
-                gljs.push(glj);
+            }else{//信息价,采保费率要重新计算市场价
+                editField = 'market_price';
+                let infoPrice = newValueMap[glj.id].infoPrice||glj.unit_price.infoPrice;
+                let purchaseFeeRate =newValueMap[glj.id].purchaseFeeRate|| glj.unit_price.purchaseFeeRate;
+                if(dataCode == 'infoPrice'){
+                    newValueMap[glj.id].priceFrom = '自行询价';
+                    newValueMap[glj.id].infoPrice = newValue;
+                    infoPrice = newValue;
+                }
+                if(dataCode == 'purchaseFeeRate'){
+                    newValueMap[glj.id].purchaseFeeRate = newValue;
+                    purchaseFeeRate = newValue;
+                }
+                if(gljUtil.isDef(infoPrice)){
+                    newValue = gljUtil.calcMarketPriceByInfoPrice(infoPrice,purchaseFeeRate,this.getPriceDecimal(glj))
+                }else{
+                    editField = dataCode;
+                }
+                
             }
+            if(dataCode=='marketPrice'){
+                newValueMap[glj.id].infoPrice = null;
+                newValueMap[glj.id].priceFrom = '';
+            }
+            newValueMap[glj.id][editField]=newValue;
+           if(!gljs.includes(glj)) {
+            updateData.push({unit_price: glj.unit_price, field: editField, newval: newValue,project_id:glj.project_id,ext:newValueMap[glj.id]});
+            gljs.push(glj);
+           }  
         }
     }
     if(updateData.length > 0){
@@ -466,7 +494,7 @@ ProjectGLJ.prototype.batchUpdatePrice = function (changeInfo,sheetName,callback)
             let parentData = [];
             //更新缓存
             for(let g of gljs){
-                g.unit_price[newValueMap[g.id].field] = newValueMap[g.id].value;
+                gljUtil.setProperty(g.unit_price,newValueMap[g.id]);
                 me.refreshTreeNodePriceIfNeed(g);//刷新造价书中主树上的定额工料机;
             }
             //更新父工料机价格

+ 13 - 0
web/building_saas/main/js/views/glj_col.js

@@ -3,6 +3,7 @@
  */
 let gljCol = {
     showTaxRate: false,
+    showPurchaseFeeRate:false,
     hideInfoPrice:true,
     ration_glj_setting: {
         header: [
@@ -48,6 +49,8 @@ let gljCol = {
             {headerName: "税率", headerWidth: 70, dataCode: "taxRate", hAlign: "right", dataType: "Number",validator:"number",spanRows: [2]},//,decimalField:"glj.unitPrice"
             {headerName: "调整价", headerWidth: 70, dataCode: "adjustPrice", hAlign: "right", dataType: "Number",spanRows: [2]},//,decimalField:"glj.unitPrice"
             {headerName: "定额价", headerWidth: 70, dataCode: "basePrice", hAlign: "right", dataType: "Number",validator:"number",spanRows: [2]},//decimalField:'glj.unitPrice',
+            {headerName: "信息价", headerWidth: 70, dataCode: "infoPrice", hAlign: "right", dataType: "Number",validator:"number",spanRows: [2], visible: false},
+            {headerName: "采保费率%", headerWidth: 70, dataCode: "purchaseFeeRate", hAlign: "right", dataType: "Number",validator:"number",spanRows: [2], visible: false},
             {headerName: "总消耗量", headerWidth: 90, dataCode: "quantity", hAlign: "right", dataType: "Number",decimalField:'glj.quantity',spanRows: [2]},
             {headerName: "暂估", headerWidth: 45, dataCode: "is_evaluate", hAlign: "center", dataType: "String",cellType:'checkBox',spanRows: [2]},
             {headerName: "主要\n材料", headerWidth: 45, dataCode: "is_main_material", hAlign: "center", dataType: "String",cellType:'checkBox',spanRows: [2]},
@@ -261,6 +264,10 @@ let gljCol = {
             setting.view.lockColumns = newArray;
         }
     },
+    setVisible:function (dataCode,setting,visible) {
+        let head = setting.header.find((item)=>item.dataCode === dataCode);
+        if(head) head.visible = visible;
+      },
     initGljCol: function (showAdjustPrice, showTenderFields,init=false) {
       let me = gljCol;
       if (showAdjustPrice !== true) {
@@ -269,6 +276,12 @@ let gljCol = {
         me.removeCol('adjustPrice', me.mixRatio_Setting);
       };
       if (me.showTaxRate == false) me.removeCol('taxRate', me.project_glj_setting);
+      if(me.showPurchaseFeeRate){
+          me.setVisible('infoPrice', me.project_glj_setting,true);
+          me.setVisible('purchaseFeeRate', me.project_glj_setting,true);
+      }
+
+
       if (me.hideInfoPrice == true) { 
         $("#info-nav-li").hide();
         me.removeCol('priceFrom', me.project_glj_setting);

+ 35 - 7
web/building_saas/main/js/views/project_glj_view.js

@@ -1,3 +1,4 @@
+
 /**
  * Created by zhang on 2018/3/13.
  */
@@ -612,7 +613,7 @@ let projectGljObject = {
     if (isPaste == false && (dataCode == 'is_adjust_price' || dataCode == 'is_evaluate' || dataCode == 'is_main_material' || dataCode == 'is_eval_material' || dataCode == 'no_tax_eqp')) { //除了粘贴,拖动填充等操作,其它的都不能编辑
       return false;
     }
-    if (dataCode == 'basePrice' || dataCode == 'marketPrice' || dataCode == 'supply') { //有组成物时,市场单价、定额价、供货方式不能修改
+    if (dataCode == 'basePrice' || dataCode == 'marketPrice' || dataCode == 'supply'||dataCode == 'infoPrice'||dataCode == 'purchaseFeeRate') { //有组成物时,市场单价、定额价、供货方式,信息价,采保费率不能修改
       if (data.ratio_data && data.ratio_data.length > 0) return false;
       if (dataCode == 'basePrice' && data.is_add != 1) return false; //如果不是新增,定额价不可修改。
     }
@@ -785,7 +786,7 @@ let projectGljObject = {
     let setting = sheetName == "materialTreeSheet" ? me.materialSetting : me.projectGljSetting;
     for (let c of changeInfo) {
       c.dataCode = setting.header[c.col].dataCode;
-      if (c.dataCode == 'basePrice' || c.dataCode == 'marketPrice') {
+      if (c.dataCode == 'basePrice' || c.dataCode == 'marketPrice'||c.dataCode == 'infoPrice'||c.dataCode == 'purchaseFeeRate') {
         priceCells.push(c);
       } else {
         propertyCells.push(c);
@@ -1210,6 +1211,8 @@ let projectGljObject = {
       brand: glj.brand,
       unitPriceID: glj.unit_price.id,
       priceFrom: glj.unit_price.priceFrom,
+      infoPrice:glj.unit_price.infoPrice,
+      purchaseFeeRate:glj.unit_price.purchaseFeeRate,
       remark: glj.remark
     };
     gljOprObj.setGLJPrice(data, glj);
@@ -1455,7 +1458,29 @@ let projectGljObject = {
       };
       gljOprObj.refreshView();
     };
-    if (dataCode == 'basePrice' || dataCode == 'marketPrice') { //修改市场价和修改定额价时需要重新记算很多受影响的树节点,现在改成与定字额工料机那里调相同的方法。
+    if(dataCode == 'infoPrice'|| dataCode == 'purchaseFeeRate'){
+      let infoPrice = recode.infoPrice;
+      let purchaseFeeRate = recode.purchaseFeeRate;
+      let extendDoc = {};
+      if(dataCode == 'purchaseFeeRate') {
+        if(value !== null) value =  scMathUtil.roundForObj(value, getDecimal('feeRate'));
+        purchaseFeeRate = value;
+      }
+      if(dataCode == 'infoPrice') {
+        infoPrice = value;
+        if(value !== null){
+          value = scMathUtil.roundForObj(value, getDecimal("glj.unitPrice"));
+          extendDoc.priceFrom='自行询价';
+        } else{
+          extendDoc.priceFrom='';
+        }
+      }
+      if(gljUtil.isDef(infoPrice)){
+        extendDoc.market_price = gljUtil.calcMarketPriceByInfoPrice(infoPrice,purchaseFeeRate,getDecimal("glj.unitPrice"));
+      }
+
+      projectObj.project.projectGLJ.updatePrice(recode, dataCode, value, 'pg', extendDoc, callback);
+    }else if (dataCode == 'basePrice' || dataCode == 'marketPrice') { //修改市场价和修改定额价时需要重新记算很多受影响的树节点,现在改成与定字额工料机那里调相同的方法。
       let editField = dataCode === 'basePrice' ? "base_price" : "market_price";
       projectObj.project.projectGLJ.updatePrice(recode, editField, value, 'pg', null, callback);
     } else {
@@ -1802,8 +1827,10 @@ let projectGljObject = {
   },
   applyInfoPrice: function (projectGLJData, price, coe) {
     let priceFrom = this.getPriceFrom();
-    projectObj.project.projectGLJ.updatePrice(projectGLJData, "market_price", price * coe, 'pg', {
-      "priceFrom": priceFrom
+    let infoPrice = price * coe;
+    let marketPrice =  gljUtil.calcMarketPriceByInfoPrice(infoPrice,projectGLJData.purchaseFeeRate,getDecimal("glj.unitPrice"));
+    projectObj.project.projectGLJ.updatePrice(projectGLJData, "market_price", marketPrice, 'pg', {
+     priceFrom,infoPrice
     });
 
   },
@@ -2296,7 +2323,8 @@ $(function () {
         let obj = {
           pgljID: pglj.id,
           unitPriceID: pglj.unitPriceID,
-          fullIndex: gljUtil.getIndex(pglj)
+          fullIndex: gljUtil.getIndex(pglj),
+          purchaseFeeRate:pglj.purchaseFeeRate
         };
         pgljMap[index] ? pgljMap[index].push(obj) : pgljMap[index] = [obj]; //考虑到只用三个去匹配会有重复的工料机,所以这里用数组
       }
@@ -2306,7 +2334,7 @@ $(function () {
       period: year + "-" + month,
       areaID: areaID
     }
-    let priceFrom = '批量信息价';
+    let priceFrom = projectGljObject.getPriceFrom();
     projectObj.project.projectGLJ.mutiApplyInfoPrice(pgljMap, condition, priceFrom);
 
   });

+ 4 - 0
web/over_write/js/chongqing_2018.js

@@ -393,4 +393,8 @@ function getCustomerCoeData() {
         { amount:1, operator:'*', gljCode:null, coeType:'主材'},
         { amount:1, operator:'*', gljCode:null, coeType:'设备'}
     ]
+}
+
+if(typeof gljCol !== 'undefined'){
+    gljCol.showPurchaseFeeRate = true;
 }