Jelajahi Sumber

Merge branch 'master' of http://smartcost.f3322.net:3000/SmartCost/ConstructionCost

chenshilong 7 tahun lalu
induk
melakukan
e5f770099e

+ 1 - 0
config/gulpConfig.js

@@ -80,6 +80,7 @@ module.exports = {
         'web/building_saas/main/js/models/ration_ass.js',
         // 'web/building_saas/main/js/models/volume_price.js',
         'web/building_saas/main/js/models/labour_coe.js',
+        'web/building_saas/main/js/models/installation_fee.js',
         'public/web/id_tree.js',
         'web/building_saas/main/js/models/cache_tree.js',
         'web/building_saas/main/js/calc/calc_fees.js',

+ 99 - 0
modules/main/facade/installation_facade.js

@@ -0,0 +1,99 @@
+/**
+ * Created by zhang on 2018/1/31.
+ */
+import {installSectionModel,installFeeItemModel} from "../../complementary_ration_lib/models/schemas";
+import installationFeeModel from "../models/installation_fee";
+import engineeringModel from "../../users/models/schema/engineering_lib";
+const uuidV1 = require('uuid/v1');
+let consts = require('../../main/models/project_consts')
+
+module.exports={
+    copyInstallationFeeFromLib:copyInstallationFeeFromLib,
+    getData:getData
+};
+
+async function copyInstallationFeeFromLib(projectID,engineering_id) {
+
+    //安装增加费用内嵌文档的方式
+    let engineering = await engineeringModel.findById(engineering_id);
+    let ration_lib = engineering.ration_lib;
+    let installationFeeList = [];
+    for(let rl of ration_lib){
+       let installFeeItems = await installFeeItemModel.find({'rationRepId':rl.id});
+       let installSections = await installSectionModel.find({'rationRepId':rl.id});
+       let newInstallationFee = {
+           libID:rl.id,
+           libName:rl.name,
+           projectID:projectID
+       };
+        newInstallationFee.ID = uuidV1();
+       let create = false;
+       if(installFeeItems && installFeeItems.length > 0) {//费用项
+           create = true;
+           let tem_installFeeItem = [];
+           for(let ifee of installFeeItems){
+                let tem_fee ={
+                    feeItem:ifee.feeItem,
+                    feeType:ifee.feeType,
+                    position:ifee.position,
+                    ID:ifee.ID
+                };
+               tem_installFeeItem.push(tem_fee);
+           }
+           newInstallationFee.installFeeItem = tem_installFeeItem;
+       }
+
+       if(installSections && installSections.length > 0){//章节项
+           create = true;
+           let tem_installSections = [];
+           let tem_feeRules = [];
+           for(let isect of installSections){
+                let tem_sec={
+                    ID:isect.ID,
+                    feeItemId:isect.feeItemId,
+                    name:isect.name
+                };
+                if(isect.feeRule && isect.feeRule.length > 0){//规则项
+                    tem_sec.feeRuleId = isect.feeRule[0].ID; //选中第一个
+                    for(let ifeeR of isect.feeRule){
+                        let tem_feeRule = {
+                            ID: ifeeR.ID,
+                            code: ifeeR.code,
+                            rule: ifeeR.rule,
+                            base: ifeeR.base,
+                            feeRate: ifeeR.feeRate,
+                            labour: ifeeR.labour,
+                            material: ifeeR.material,
+                            machine: ifeeR.machine
+                        };
+                        tem_feeRule.sectionId = isect.ID;
+                        tem_feeRule.feeItemId = isect.feeItemId;
+                        tem_feeRules.push(tem_feeRule);
+                    }
+                }
+               tem_installSections.push(tem_sec);
+           }
+           newInstallationFee.installSection = tem_installSections;
+           newInstallationFee.feeRule = tem_feeRules;
+       }
+       if(create==true){
+           installationFeeList.push(newInstallationFee);
+       }
+    }
+    console.log(installationFeeList);
+    if(installationFeeList.length > 0){
+        await installationFeeModel.insertMany(installationFeeList);
+    }
+}
+
+function getData(projectID, callback) {
+    installationFeeModel.find({'projectID': projectID}, (err, datas) => {
+        if (err) {
+            callback(1, '', null);
+        } else {
+            callback(0, consts.projectConst.INSTALLATION_FEE, datas);
+        }
+    })
+}
+
+

+ 51 - 0
modules/main/models/installation_fee.js

@@ -0,0 +1,51 @@
+/**
+ * Created by Zhong on 2017/9/13.
+ */
+import mongoose from "mongoose";
+let Schema = mongoose.Schema;
+
+//安装增加费-费用规则
+let feeRuleSchema = new Schema({
+    ID: String,
+    sectionId: String, //分册章节id
+    feeItemId:String,
+    code: String,
+    rule: String,
+    base: String,
+    feeRate: Number,
+    labour: Number,
+    material: Number,
+    machine: Number
+});
+
+//安装增加费-分册章节
+let installSectionSchema = new Schema({
+    ID: String,
+    feeItemId: String,
+    feeRuleId: String,
+    name: String,
+    position: String//记取位置
+});
+
+//安装增加费-费用项
+let installFeeItemSchema = new Schema({
+    ID: String,
+    feeItem: String, //费用项
+    feeType: String, //费用类型
+    position: String//记取位置
+});
+
+let installationFeeSchema = new Schema({
+    ID:String,
+    libID:Number,
+    libName:String,
+    projectID:String,
+    installFeeItem:[installFeeItemSchema],
+    installSection:[installSectionSchema],
+    feeRule:[feeRuleSchema]
+},{versionKey:false});
+
+let installationFeeModel = mongoose.model("installation_fee",installationFeeSchema,"installation_fee");
+
+
+export{ installationFeeModel as default}

+ 2 - 0
modules/main/models/project.js

@@ -15,6 +15,7 @@ let projSetting = require('./proj_setting_model');
 var labour_coe_facade = require('../facade/labour_coe_facade');
 var calc_program_facade = require('../facade/calc_program_facade');
 import GLJController from "../../glj/controllers/glj_controller";
+let installation_facade = require('../facade/installation_facade');
 
 
 const ProjectModel = require('../../pm/models/project_model').project;
@@ -40,6 +41,7 @@ moduleMap[projectConsts.FEERATE] = fee_rate_data;
 moduleMap[projectConsts.LABOUR_COE] = labour_coe_facade;
 moduleMap[projectConsts.CALC_PROGRAM] = calc_program_facade;
 moduleMap[projectConsts.PROJECTGLJ] = new GLJController();
+moduleMap[projectConsts.INSTALLATION_FEE] = installation_facade;
 
 var Project = function (){};
 

+ 2 - 1
modules/main/models/project_consts.js

@@ -16,7 +16,8 @@ let projectConst = {
     // VOLUMEPRICE: 'volume_price',
     FEERATE:'feeRate',
     LABOUR_COE:'labour_coe',
-    CALC_PROGRAM:'calc_program'
+    CALC_PROGRAM:'calc_program',
+    INSTALLATION_FEE:'installation_fee'
 };
 
 let projectConstList = [

+ 6 - 0
modules/pm/models/project_model.js

@@ -22,6 +22,7 @@ let copyProjController = require('../controllers/copy_proj_controller');
 let feeRateFacade = require('../../fee_rates/facade/fee_rates_facade');
 let labourCoeFacade = require('../../main/facade/labour_coe_facade');
 let calcProgramFacade = require('../../main/facade/calc_program_facade');
+let installationFacade = require('../../main/facade/installation_facade');
 let logger = require("../../../logs/log_helper").logger;
 let BillsModel = require("../../main/models/bills").model;
 
@@ -140,6 +141,11 @@ ProjectsDAO.prototype.updateUserProjects = async function (userId, compilationId
                     data.updateData.property.zanguCalcMode = 0;
                     //计算选项
                     data.updateData.property.calcOptions = calcOptions
+                    //安装增加费
+                    if(parseInt(data.updateData.property.engineering)==4){
+                        await installationFacade.copyInstallationFeeFromLib(data.updateData.ID,data.updateData.property.engineering_id);
+                    }
+
 
                 }
                 newProject = new Projects(data.updateData);

+ 10 - 1
modules/ration_glj/models/ration_glj_temp.js

@@ -122,6 +122,12 @@ var rationAssItemSchema = mongoose.Schema({
     maxValue: String
 }, { _id: false });
 
+//定额安装增加费用
+let rationInstSchema = mongoose.Schema({
+    feeItemId: String,
+    sectionId: String
+},{_id: false});
+
 var rationItemSchema = mongoose.Schema({
     ID:Number,
     code: String,
@@ -132,9 +138,12 @@ var rationItemSchema = mongoose.Schema({
     rationRepId: Number,
     caption: String,
     feeType: Number,
+    jobContent: String,
+    annotation: String,
     rationGljList: [rationGljItemSchema],
     rationCoeList: Array,
-    rationAssList: [rationAssItemSchema]
+    rationAssList: [rationAssItemSchema],
+    rationInstList: [rationInstSchema]
 });
 mongoose.model("std_ration_lib_ration_items",rationItemSchema, "std_ration_lib_ration_items");
 

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

@@ -96,6 +96,9 @@
                                   <li class="nav-item">
                                       <a class="nav-link" id="linkFZDE" data-toggle="tab" href="#subSpread" role="tab">辅助定额</a>
                                   </li>
+                                  <li class="nav-item" id="AZZJF_div" style="display: none">
+                                      <a class="nav-link" id="linkAZZJF" data-toggle="tab" href="#subSpread" role="tab">安装增加费</a>
+                                  </li>
                                   <li class="nav-item">
                                       <a class="nav-link" id="linkGCLMX" data-toggle="tab" href="#subSpread" role="tab">工程量明细</a>
                                   </li>
@@ -858,6 +861,64 @@
         </div>
     </div>
 
+    <!--弹出 计取安装费用-->
+    <div class="modal fade" id="calc_installation_fee" data-backdrop="static">
+        <div class="modal-dialog modal-lg" role="document">
+            <div class="modal-content">
+                <div class="modal-header">
+                    <h5 class="modal-title">统一设置计取安装费用</h5>
+                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                        <span aria-hidden="true">&times;</span>
+                    </button>
+                </div>
+                <div class="modal-body">
+                    <div style="height:200px"><!--sjs id设置在这个div-->
+                        <div class="row">
+                            <div class="modal-auto-height col-8" style="overflow: hidden" id="feeItemSheet">
+                                test ....
+                            </div>
+                            <div class="modal-auto-height col-4" style="overflow: hidden" id="install_setting">
+                                <div style="height: 100px;border:1px solid #f00" >
+                                    <fieldset class="form-group" >
+                                        <h5>分项费用</h5>
+                                        <div class="form-check">
+                                            <label class="form-check-label">
+                                                <input class="form-check-input" name="install_setting_radios" id="all_project_calc" value="0" type="radio">
+                                                整个项目统一计取
+                                            </label>
+                                        </div>
+                                        <div class="form-check">
+                                            <label class="form-check-label">
+                                                <input class="form-check-input" name="install_setting_radios" id="FB_calc" value="1" type="radio">
+                                                每个分部单独计取
+                                            </label>
+                                        </div>
+                                    </fieldset>
+                                </div>
+                            </div>
+                        </div>
+                        <!--<table class="table table-sm table-bordered m-0">
+                            <thead><tr><th></th><th>计取</th><th>费用项</th><th>费用类型</th><th>记取位置</th></tr></thead>
+                            <tr><td>1</td><td></td><td>重庆市安装工程计价定额(2008)</td><td></td><td></td></tr>
+                            <tr><td>2</td><td><input type="checkbox"></td><td>-高层增加费</td><td>子目费用</td><td><a href="javacript:void(0);" data-toggle="modal" data-target="#jqaz-wz">点击</a></td></tr>
+                        </table>-->
+                    </div>
+                    <div style="height:200px"><!--sjs id设置在这个div-->
+                        <table class="table table-sm table-bordered m-0">
+                            <thead><tr><th></th><th>分册章节</th><th>费用规则</th><th>编码</th><th>基数</th><th>费率(%)</th><th>其中人工(%)</th><th>其中材料(%)</th><th>其中机械(%)</th><th>记取位置</th></tr></thead>
+                            <tr><td>1</td><td>第一册 机械设备安装工程1~6、8~16章节</td><td>超高费(标高15m以内(第一册 机械设备安装工程1~6章节))</td><td>AZFY1</td><td>人材机乘系数</td><td></td><td>25</td><td></td><td>25</td><td><a href="javacript:void(0);" data-toggle="modal" data-target="#jqaz-wz">点击</a></td></tr>
+                        </table>
+                    </div>
+                </div>
+                <div class="modal-footer">
+                    <button type="button" class="btn btn-link" >恢复默认值</button>
+                    <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
+                    <a href="" class="btn btn-primary">确定</a>
+                </div>
+            </div>
+        </div>
+    </div>
+
         <!-- JS. -->
         <script type="text/javascript" src="/lib/spreadjs/sheets/gc.spread.sheets.all.10.0.1.min.js"></script>
 
@@ -930,9 +991,11 @@
         <script type="text/javascript" src="/web/building_saas/main/js/models/labour_coe.js"></script>
         <script type="text/javascript" src="/web/building_saas/main/js/models/calc_program.js"></script>
         <script type="text/javascript" src="/web/building_saas/main/js/models/calc_base.js"></script>
+        <script type="text/javascript" src="/web/building_saas/main/js/models/installation_fee.js"></script>
         <script type="text/javascript" src="/web/building_saas/main/js/views/calc_program_manage.js"></script>
 
 
+
         <script type="text/javascript" src="/public/web/id_tree.js"></script>
         <script type="text/javascript" src="/web/building_saas/main/js/models/cache_tree.js"></script>
         <script type="text/javascript" src="/web/building_saas/main/js/calc/calc_fees.js"></script>
@@ -965,6 +1028,7 @@
         <script type="text/javascript" src="/web/building_saas/main/js/views/calc_program_view.js"></script>
         <script type="text/javascript" src='/web/building_saas/main/js/views/confirm_modal.js'></script>
         <script type="text/javascript" src='/web/building_saas/main/js/views/zlfb_view.js'></script>
+        <script type="text/javascript" src='/web/building_saas/main/js/views/installation_fee_view.js'></script>
         <!--报表-->
         <script type="text/javascript" src="/public/web/rpt_tpl_def.js"></script>
         <script type="text/javascript" src="/public/web/treeDataHelper.js"></script>

+ 1 - 1
web/building_saas/main/js/models/bills.js

@@ -437,7 +437,7 @@ var Bills = {
 
 
         bills.prototype.getTechLeavesID=function () {//取所有分计算技术措施项目清单叶子节点ID
-            let items = projectObj.project.mainTree.roots;//所有节点;
+            let items = projectObj.project.mainTree.items;//所有节点;
             let techNode = null;
             for(let item of items){
                 if(isFlag(item.data)&&item.data.flagsIndex.fixed.flag==fixedFlag.CONSTRUCTION_TECH){

+ 33 - 0
web/building_saas/main/js/models/installation_fee.js

@@ -0,0 +1,33 @@
+/**
+ * Created by zhang on 2018/1/31.
+ */
+var installation_fee = {
+    createNew: function (project) {
+        // 用户定义private方法
+        var tools = {};
+
+        // 所有通过this访问的属性,都不应在此单元外部进行写入操作
+        var installation_fee = function (proj) {
+            // this.project = proj;
+            this.datas = [];
+
+            var sourceType = ModuleNames.installation_fee;
+            this.getSourceType = function () {
+                return sourceType;
+            }
+            proj.registerModule(ModuleNames.installation_fee, this);
+        };
+
+        // prototype用于定义public方法
+        installation_fee.prototype.loadData = function (datas) {
+            this.datas = datas;
+        };
+
+        // 提交数据后返回数据处理
+        installation_fee.prototype.doAfterUpdate = function(err, data){
+
+        };
+        return new installation_fee(project);
+    }
+
+};

+ 34 - 2
web/building_saas/main/js/models/main_consts.js

@@ -12,7 +12,8 @@ const ModuleNames = {
     ration_ass:'ration_ass',
     quantity_detail:'quantity_detail',
     labour_coe: 'labour_coe',
-    calc_program: 'calc_program'
+    calc_program: 'calc_program',
+    installation_fee:'installation_fee'
 };
 
 const gljType = {
@@ -233,4 +234,35 @@ const cpFeeTypes = [
     {type: 'adjustMachineLabour', name: '调整机上人工费'},
     {type: 'estimate', name: '暂估费'},
     {type: 'common', name: '工程造价'}
-];
+];
+
+const engineeringType = {
+    // 建筑工程
+    ARCHITECTURE: 1,
+    // 装饰工程
+    DECORATE: 2,
+    // 仿古建筑工程
+    ANTIQUE_ARCHITECTURE: 3,
+    // 安装工程
+    BUILD_IN: 4,
+    // 市政土建工程
+    MUNICIPAL_CONSTRUCTION: 5,
+    // 市政安装工程
+    MUNICIPAL_BUILD_IN: 6,
+    // 人工土石方工程
+    ARTIFICIAL_EARTHWORK: 7,
+    // 机械土石方工程
+    MECHANICAL_EARTHWORK: 8,
+    // 炉窖砌筑工程
+    KILN_MASONRY: 9,
+    // 园林工程
+    GARDEN: 10,
+    // 绿化工程
+    PLANTING: 11,
+    // 单拆除工程
+    DISMANTLE: 12,
+    // 建筑修缮工程
+    BUILDING_REPAIR: 13,
+    // 安装修缮工程
+    BUILD_IN_REPAIR: 14
+};

+ 1 - 0
web/building_saas/main/js/models/project.js

@@ -80,6 +80,7 @@ var PROJECT = {
             this.ration_coe = ration_coe.createNew(this);
             this.ration_ass = ration_ass.createNew(this);
             this.quantity_detail = quantity_detail.createNew(this);
+            this.installation_fee = installation_fee.createNew(this);
             this.FeeRate = FeeRate.createNew(this);
             // this.VolumePrice = VolumePrice.createNew(this);
             this.projectGLJ = new ProjectGLJ();

+ 1 - 0
web/building_saas/main/js/models/project_glj.js

@@ -482,6 +482,7 @@ ProjectGLJ.prototype.calcQuantity  = function (){
 ProjectGLJ.prototype.getQuantityPerGLJ =function (pglj,mixRatioSubdivisionMap,mixRatioTechMap) {
     let billIDs =   projectObj.project.Bills.getSubdivisionProjectLeavesID();//取分部分项上的所有叶子清单ID
     let tech_billIDS =  projectObj.project.Bills.getTechLeavesID();//取所有技术措施项目叶子清单ID
+    console.log(tech_billIDS);
     let ration_glj_list = projectObj.project.ration_glj.datas;
     let mixRatioMap = this.datas.mixRatioMap;
     let rations = projectObj.project.Ration.datas;

+ 0 - 2
web/building_saas/main/js/models/ration_ass.js

@@ -125,6 +125,4 @@ var ration_ass = {
         return new ration_ass(project);
     }
 
-
-
 };

+ 47 - 0
web/building_saas/main/js/views/installation_fee_view.js

@@ -0,0 +1,47 @@
+/**
+ * Created by zhang on 2018/1/30.
+ */
+let installationFeeObj={
+    rationInstallSheet:null,
+    installationFeeSpread:null,
+    rationInstallsetting: {
+        header: [
+            {headerName: "按统一设置", headerWidth: 100, dataCode: "name", dataType: "String"},
+            {headerName: "费用项", headerWidth: 120, dataCode: "stdValue", hAlign: "right", dataType: "String"},
+            {headerName: "费用规则", headerWidth: 120, dataCode: "actualValue", hAlign: "right", dataType: "String"},
+            {headerName: "编码", headerWidth: 120, dataCode: "actualValue", hAlign: "right", dataType: "String"},
+            {headerName: "基数", headerWidth: 120, dataCode: "actualValue", hAlign: "right", dataType: "String"},
+            {headerName: "费率(%)", headerWidth: 120, dataCode: "actualValue", hAlign: "right", dataType: "String"},
+            {headerName: "其中人工(%)", headerWidth: 120, dataCode: "actualValue", hAlign: "right", dataType: "String"},
+            {headerName: "其中材料(%)", headerWidth: 120, dataCode: "actualValue", hAlign: "right", dataType: "String"},
+            {headerName: "其中机械(%)", headerWidth: 120, dataCode: "actualValue", hAlign: "right", dataType: "String"},
+            {headerName: "费用类型", headerWidth: 120, dataCode: "actualValue", hAlign: "right", dataType: "String"},
+            {headerName: "记取位置", headerWidth: 120, dataCode: "actualValue", hAlign: "right", dataType: "String"}
+        ],
+        view: {
+            lockColumns: [0, 1]
+        }
+    },
+    showCalcInstallSettingDiv:function () {
+        $("#calc_installation_fee").modal({show:true});
+    },
+    engineeringTypeChecking:function () {
+        let property = projectInfoObj.projectInfo.property;
+        let engineering = property.engineering;
+        if(engineering==engineeringType.BUILD_IN){//如果是安装工程,则显示
+            $('#AZZJF_div').show();
+        }
+    }
+};
+
+$(function () {
+    $('#calc_installation_fee').on('shown.bs.modal',function () {
+        if(installationFeeObj.installationFeeSpread == null){//初始化显示
+
+        }
+
+    })
+
+
+
+});

+ 15 - 0
web/building_saas/main/js/views/project_view.js

@@ -497,6 +497,7 @@ var projectObj = {
                 console.log("加载完成-----"+endTime);
                 console.log(`时间——${endTime - startTime}`);
                 that.project.projectMarkChecking();//是否需要重新进行造价计算
+                installationFeeObj.engineeringTypeChecking();//检查是否安装工程
             }
             else {
 
@@ -705,6 +706,20 @@ var projectObj = {
                         return true;
                     }
                 },
+                "calc_installation_fee": {
+                    name: "计取安装费用",
+                    icon: 'fa-sign-in',
+                    disabled: function () {
+                        return false;
+                    },
+                    callback: function (key, opt) {
+                        installationFeeObj.showCalcInstallSettingDiv();
+                    },
+                    visible: function(key, opt){
+                        let engineering = projectInfoObj.projectInfo.property.engineering;
+                        return engineering==engineeringType.BUILD_IN;
+                    }
+                },
                 "spr1": '--------',
                 "delete": {
                     name: '删除',

+ 1 - 1
web/building_saas/main/js/views/sub_view.js

@@ -8,7 +8,7 @@ contentOprObj.buildSheet($("#jobSpread")[0]);
 characterOprObj.buildSheet($("#itemSpread")[0]);
 $("#tzjnrCon").hide();
 $("#subSpread").show();
-var subSpread = sheetCommonObj.createSpread($("#subSpread")[0], 5);
+var subSpread = sheetCommonObj.createSpread($("#subSpread")[0], 6);
 subSpread.getSheet(4).name('JSCX');
 
 pageCCOprObj.active = false;

+ 2 - 5
web/building_saas/main/js/views/zlfb_view.js

@@ -20,7 +20,7 @@ let zlfb_object={
                     FX_nodes.push(tem_node);
                     let l_code = zlfb_object.getLibCode(tem_node.data.code);
                     if(tem_node.data.billsLibId&&l_code!=false){
-                        reorganize= true;
+                        reorganize = true;
                         if(codeMap[l_code]){
                             codeMap[l_code].push(tem_node);
                         }else {
@@ -243,7 +243,6 @@ let zlfb_object={
         }
         updateData.projectID = FBFX.data.projectID;
         updateData.user_id = userID;
-        console.log(updateData);
         CommonAjax.post('/bills/reorganizeFBFX',updateData,function (data) {
             //更新前端缓存
             let billDatas = projectObj.project.Bills.datas;
@@ -285,8 +284,6 @@ let zlfb_object={
         },function () {
             //errorCallback
         });
-        console.log(newDataMap);
-        console.log(allNewNode);
     }
 }
 
@@ -300,4 +297,4 @@ $(function () {
         zlfb_object.sectionInfo=null;
     })
 
-})
+});