Parcourir la source

feat: 费率新需求

zhangweicheng il y a 5 ans
Parent
commit
c60076822d

+ 2 - 2
modules/all_models/compilation.js

@@ -62,11 +62,11 @@ let modelSchema = {
         type: Number,
         default: 0
     },
-
     // cld 办事处id
     categoryID: {
         type: Number,
         default: 12 // 总部id
-    }
+    },
+    defaultLocation:String//默认工程所在地
 };
 mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));

+ 2 - 0
modules/all_models/projects.js

@@ -3,6 +3,7 @@
  */
 /*项目*/
 const mongoose = require('mongoose');
+const { stringAt } = require('pdfkit/js/data');
 const Schema = mongoose.Schema;
 const deleteSchema = require('../all_schemas/delete_schema');
 
@@ -31,6 +32,7 @@ const ProjectSchema = new Schema({
         type: Schema.Types.Mixed,
         default: {}
     },
+    "location":String,//工程所在地
     "summaryFees":{
         totalFee: String,
         estimateFee: String,

+ 1 - 0
modules/main/routes/main_route.js

@@ -45,6 +45,7 @@ module.exports =function (app) {
                         userName: req.session.sessionUser.username,
                         projectData: projectData,
                         compilationName: req.session.sessionCompilation.name,
+                        defaultLocation:req.session.sessionCompilation.defaultLocation,
                         versionName: req.session.compilationVersion,
                         projectReadOnly: projectReadOnly,
                         projectCooperate: projectCooperate,

+ 13 - 3
web/building_saas/fee_rates/fee_rate.html

@@ -11,9 +11,19 @@
     <div class="toolsbar_feeRate px-1">
         <div class="row" style="margin-left: 0px">
             <div class="col-lg-8 p-0">
-                <div class="form-inline py-1">
-                    <label class="mx-2" >基于&nbsp;&nbsp;<span id="feeRateLibName">重庆渝建发[2016]35号</span></label>
-                    <a class="btn btn-sm ml-1" href="#" data-toggle="modal" data-target="#set-lv" id="setNewFeeRate"><i class="fa fa-cog"></i> 重选标准</a>
+                <div class="form-inline py-1 row">
+                    <div class="col-2 form-inline">   
+                        <label >工程所在地:</label> &nbsp;&nbsp;
+                        <select class="form-control form-control-sm" id="location"></select> 
+                    </div>
+                 
+                    <div class="col-4 form-inline">
+                        <label >费率标准:</label> &nbsp;&nbsp;
+                        <select class="form-control form-control-sm" id="feeRateStandard"><option value="广东">广东</option></select>   
+                    </div>  
+
+                       <!-- <label class="mx-2" >基于&nbsp;&nbsp;<span id="feeRateLibName">重庆渝建发[2016]35号</span></label>                 
+                 <a class="btn btn-sm ml-1" href="#" data-toggle="modal" data-target="#set-lv" id="setNewFeeRate"><i class="fa fa-cog"></i> 重选标准</a> -->
                 </div>
             </div>
             <!--<div class="col-lg-4 p-0">

+ 2 - 0
web/building_saas/main/html/main.html

@@ -39,6 +39,7 @@
         let lockBills = '<%- projectData.property.lockBills %>';
         let userAccount = '<%- userAccount %>';
         let userID = '<%- userID %>';
+        let defaultLocation = '<%- defaultLocation %>';
         const USER_NAME = '<%- userName %>';
         let projectReadOnly = JSON.parse('<%- projectReadOnly %>');
         let projectCooperate = JSON.parse('<%- projectCooperate %>');
@@ -48,6 +49,7 @@
         const markReadProjectIDs = JSON.parse('<%- markReadProjectIDs %>');
         const VERSION = '<%- version %>';
         const CUR_BOQ_TYPE = '<%- boqType %>';
+        console.log(defaultLocation);
     </script>
 </head>
 

+ 6 - 1
web/building_saas/main/js/models/main_consts.js

@@ -325,4 +325,9 @@ const materialComboMap = [
     {text:materialType[materialTypeMap.MC],value:materialTypeMap.MC},
     {text:materialType[materialTypeMap.SN],value:materialTypeMap.SN},
     {text:materialType[materialTypeMap.SZ],value:materialTypeMap.SZ}
-];
+];
+
+const locationList = ['北京','天津','河北','山西','内蒙古','辽宁',
+'吉林','黑龙江','上海','江苏','浙江','安徽','福建','江西','山东','河南',
+'湖北','湖南','四川','贵州','云南','西藏','陕西','甘肃','青海','宁夏','新疆',
+'广东','广西','海南','重庆']

+ 79 - 5
web/building_saas/main/js/views/fee_rate_view.js

@@ -8,6 +8,7 @@ var feeRateObject={
     mainFeeRateSpread:null,
     mainFeeRateSheet:null,
     mainFeeRateData:null,
+    feeRateSTDList:[],
     mainFeeRateSetting:{
         header: [
             {headerName: "专业名称", headerWidth: 250, dataCode: "name", dataType: "String"},
@@ -754,10 +755,58 @@ var feeRateObject={
     loadPageContent:function(){
         var feeRateFile = projectObj.project.FeeRate.getActivateFeeRate();
         var usageProjects = feeRateFile.usageProjects;
+        feeRateObject.setLocAndFeeRateSTD();
         $('#feeRateFileName').text(feeRateFile.name);
         $('#feeRateLibName').text(feeRateFile.libName);
         $('#projectCount').text(usageProjects.length);
     },
+    setLocAndFeeRateSTD:function(){
+        if(feeRateObject.feeRateSTDLoaded)  return;
+        let location = projectObj.project.projectInfo.location;
+        if(!location) location = defaultLocation;
+        $('#location').val(location);
+        //养护的工程所在地下拉框不可选
+        if(!commonUtil.isGLYun()) $('#location').attr("disabled","disabled");
+        feeRateObject.setFeeRateSTD(location);
+        feeRateObject.feeRateSTDLoaded = true;
+    },
+
+    setFeeRateSTD(location){
+        let feeRateFile = projectObj.project.FeeRate.getActivateFeeRate();
+        $('#feeRateStandard').empty();
+        setOption(feeRateFile.libID,feeRateFile.libName)
+        feeRateObject.getFeeRateStandards(function (data) {
+            _.forEach(data,function (s) {
+                if(s.ID != feeRateFile.libID){  
+                    if(s.libName.startsWith("部颁")){
+                        setOption(s.ID,s.libName) 
+                    }else {
+                        if(location){
+                            if(s.libName.startsWith(location)) setOption(s.ID,s.libName) 
+                        }else{
+                            setOption(s.ID,s.libName) 
+                        } 
+                    }
+                }
+            })
+            $('#feeRateStandard').val(feeRateFile.libID);
+        });
+
+        function setOption(ID,name){
+            var option =  $("<option>").val(ID).text(name);
+            $('#feeRateStandard').append(option);
+        }
+    },
+
+    loadLocationList:function(){
+        let htmlS = "<option></option>";
+        for(let l of locationList){
+            htmlS += `<option value='${l}'>${l} </option>`
+        }
+
+        $('#location').html(htmlS)
+    },
+
     loadFeeRateSelection:function() {
         if(!this.selectionLoad){
             var selectedID=0;
@@ -772,16 +821,22 @@ var feeRateObject={
         }
     },
     getFeeRateStandards:function (callback) {
-        CommonAjax.post('/feeRates/getFeeRateStandards', {"projectID": projectObj.project.ID()}, function (data) {
-            if (data) {
-                callback(data);
-            }
-        });
+        if(feeRateObject.feeRateSTDList.length == 0){//没有的话发送请求,存在的话直接返回
+            CommonAjax.post('/feeRates/getFeeRateStandards', {"projectID": projectObj.project.ID()}, function (data) {
+                if (data) {
+                    feeRateObject.feeRateSTDList = data;
+                    callback(data);
+                }
+            });
+        }else{
+            callback(feeRateObject.feeRateSTDList);
+        }
     },
     changeFeeRateStandard:function(newVal){
         $.bootstrapLoading.start();
         var callback=function () {
             feeRateObject.reFreshRateViews();
+            feeRateObject.setFeeRateSTD($("#location").val());
             $.bootstrapLoading.end();
         };
         projectObj.project.FeeRate.changeFeeRateStandard(newVal,callback);
@@ -1015,6 +1070,8 @@ function getPopoverContent() {
     return "费率的变化,将自动影响以下单位工程造价:<br>"+ popover_content;
 }
 
+
+
 $(function(){
     $('#pop-lv').tooltip({
             placement:"bottom",
@@ -1024,6 +1081,8 @@ $(function(){
         }
     );
 
+    feeRateObject.loadLocationList();
+
     $('#tab_fee_rate').on('shown.bs.tab', function (e) {
         sessionStorage.setItem('mainTab', '#tab_fee_rate');
         let me = feeRateObject;
@@ -1034,6 +1093,21 @@ $(function(){
         me.loadPageContent();
     });
 
+    //切换选择工程所在地
+    $('#location').change(async function () {
+        //console.log(this.value);
+        let updateData = {type:ModuleNames.project,data:{'ID' : projectObj.project.ID(),location:this.value}};//,'property.locateSetting':outstd
+        $.bootstrapLoading.start();
+        await projectObj.project.syncUpdateNodesAndRefresh([updateData]);
+        feeRateObject.setFeeRateSTD(this.value);
+        $.bootstrapLoading.end();
+    });
+
+    //切换费率标准
+    $('#feeRateStandard').change(async function () {
+        feeRateObject.changeFeeRateStandard(this.value);
+    });
+
     $('#setNewFeeRate').bind('click', function () {
         var feeRateFile = projectObj.project.FeeRate.getActivateFeeRate();
         var usageProjects = feeRateFile.usageProjects;