Browse Source

单价文件编辑

zhangweicheng 5 năm trước cách đây
mục cha
commit
7fc5b7aa97

+ 97 - 0
modules/unit_price_file/controllers/unit_price_controller.js

@@ -0,0 +1,97 @@
+
+let mongoose = require("mongoose")
+let logger = require("../../../logs/log_helper").logger;
+let config = require("../../../config/config.js");
+let unitPriceFileModel = mongoose.model('unit_price_file');
+let projectModel = mongoose.model('projects');
+const ProjectDao = require('../../pm/models/project_model').project;
+let unitPriceModel = mongoose.model('unit_price');
+let mixRatioModel = mongoose.model('mix_ratio');
+let glj_type_util = require('../../../public/cache/std_glj_type_util');
+let ration_facade = require('../../main/facade/ration_facade');
+let unit_price_facade = require('../facade/unit_price_facade');
+let _ = require("lodash");
+
+module.exports={
+    index:async function(req,res){
+      let unitPriceFileID = req.params.unitPriceFileID;
+      let unitPriceFile = await unitPriceFileModel.findOne({id:unitPriceFileID}).lean();
+      let project = await projectModel.findOne({ID:unitPriceFile.root_project_id}).lean();
+      let tenderData = await ProjectDao.getTenderByUnitPriceFileId(unitPriceFileID);
+      let unitpriceList = await unitPriceModel.find({unit_price_file_id:unitPriceFileID},{supplyLocation:0}).lean();
+      let mixRatioList = await mixRatioModel.find({unit_price_file_id:unitPriceFileID}).lean();
+      let mixRatioMap = _.groupBy(mixRatioList,"connect_key");
+      let projectID = null;
+
+      let gljTypeMap = glj_type_util.getStdGljTypeCacheObj().innerGljTypeObj;
+      let usedTenderList = [];
+      if (tenderData !== null && tenderData.length > 0) {
+          for (let tmp of tenderData) {
+              usedTenderList.push(tmp.name);
+          }
+          projectID = tenderData[0].ID;
+      }
+      let usedTenderString = "人材机单价的变化,将自动影响以下单位工程造价:<br>"+usedTenderList.join("<br>");
+      res.render('building_saas/unit_price_file/index.html',
+        {
+          userAccount: req.session.userAccount,
+          userID: req.session.sessionUser.id,
+          unitPriceFileID:unitPriceFileID,
+          projectID:projectID,
+          versionName: req.session.compilationVersion,
+          unitFileName:unitPriceFile.name,
+          rootProjectName:project.name,
+          taxType:project.property.taxType,
+          region:project.property.region,
+          overWriteUrl:req.session.sessionCompilation.overWriteUrl,
+          usedTenderList:usedTenderList,
+          usedTenderString:usedTenderString,
+          unitpriceList:JSON.stringify(unitpriceList),
+          gljTypeMap:JSON.stringify(gljTypeMap),
+          mixRatioMap:JSON.stringify(mixRatioMap),
+          LicenseKey:config.getLicenseKey(process.env.NODE_ENV)
+        });
+    },
+    addMixRatio:async function(req,res){
+      let result={
+        error:0
+    };
+    try {
+        let data = req.body.data;
+        data = JSON.parse(data);
+        let gljList = data.gljList, parentInfo = data.parentInfo,mixRatios = [],gljCodes=[];
+
+        if(gljList.length > 0){
+          for(let newProjectGLJ of gljList){
+              let mixRatio = {
+                  glj_id:newProjectGLJ.glj_id,
+                  consumption:0,
+                  unit_price_file_id:parentInfo.unit_price_file_id,
+                  connect_key:parentInfo.connect_key,
+                  type: newProjectGLJ.type,
+                  code: newProjectGLJ.code,
+                  specs:newProjectGLJ.specs,
+                  name:newProjectGLJ.name,
+                  unit:newProjectGLJ.unit,
+                  model:newProjectGLJ.model
+              };
+              mixRatios.push(mixRatio);
+              gljCodes.push(newProjectGLJ.code);
+          }
+          let [unitPriceMap,newUnitPriceList] = await unit_price_facade.getUnitPriceData(gljList,gljCodes,parentInfo.unit_price_file_id); 
+          await unit_price_facade.setIDfromCounter("mix_ratio",mixRatios);    
+          await mixRatioModel.insertMany(mixRatios);
+          result.data = {mixRatios:mixRatios,newUnitPriceList:newUnitPriceList};
+        }
+       
+    }catch (err){
+        logger.err(err);
+        result.error=1;
+        result.message = err.message;
+    }
+      res.json(result);
+    }
+}
+
+
+// engineerID = req.params.engineerID;

+ 162 - 0
modules/unit_price_file/facade/unit_price_facade.js

@@ -0,0 +1,162 @@
+module.exports = {
+  getUnitPriceData:getUnitPriceData,
+  setIDfromCounter:setIDfromCounter,
+  getNewProjectGLJFromMissMixratio:getNewProjectGLJFromMissMixratio
+};
+
+let mongoose = require("mongoose");
+let std_glj_lib_gljList_model = mongoose.model('std_glj_lib_gljList');
+let unitPriceModel = mongoose.model('unit_price');
+let counterModel =  mongoose.model('counter');
+
+async function setIDfromCounter(name,list,map,keyfield){//map,keyfield
+
+  let update = {$inc: {sequence_value: list.length}};
+  let condition = {_id: name};
+  let options = {new: true};
+
+  // 先查找更新
+  let counter = await counterModel.findOneAndUpdate(condition, update, options);
+  let firstID = counter.sequence_value - (list.length - 1);
+  for(let a of list){
+      a.id = firstID;
+      firstID+=1
+      if(map && keyfield){
+        let key = a[keyfield];
+        map[key]?map[key].push(a):map[key]=[a]
+      }
+  }
+
+}
+
+function getProjectGLJNewData(tmp,projectId,ext){
+  let gljData = {
+      glj_id: tmp.ID,
+      repositoryId:tmp.repositoryId,
+      project_id: projectId,
+      code: tmp.code,
+      name: tmp.name,
+      specs: tmp.specs?tmp.specs:'',
+      unit: tmp.unit === undefined ? '' : tmp.unit,
+      type: tmp.gljType,
+      adjCoe:tmp.adjCoe,
+      original_code:tmp.code,
+      materialType: tmp.materialType,   //三材类别
+      materialCoe: tmp.materialCoe,
+      base_price: tmp.basePrice,
+      market_price: tmp.basePrice,
+      from:tmp.from?tmp.from:"std"
+  };
+  if(gljData.from == 'std' && ext && ext.priceField &&( tmp.priceProperty[ext.priceField]!= undefined && tmp.priceProperty[ext.priceField]!=null)){
+    basePrice = scMathUtil.roundTo(tmp.priceProperty[ext.priceField],-6);
+    gljData.base_price = basePrice;
+    gljData.market_price = basePrice;
+  }
+  return gljData;
+}
+
+//根据缺少项目工料机的组成物信息,反向生成对应的项目工料机
+async function getNewProjectGLJFromMissMixratio(projectID,lessMix,projectGLJMap,newProjectGLJList,ext){
+  let lessIDList=[];
+  let uniqMap ={};//去重
+  let lessStdMix = [];//防止组成物中改了名称等,但是通过glj_id取出来的是还没改前的原始数据
+  if(lessMix.length > 0){
+    for(let lm of lessMix){
+      let parentglj = projectGLJMap[lm.connect_key];
+      if(!parentglj) throw `含有组成物工料机${lm.connect_key},没有找到,添加定额失败`;
+      if((parentglj.from == "std" || lm.from == "std") && lm.code!="80CCS"){//车船税特殊处理
+        if(!uniqMap[lm.glj_id]){
+          lessIDList.push(lm.glj_id);
+          uniqMap[lm.glj_id] = lm;
+        }
+        lessStdMix.push(lm);
+      }else {//来自组成物的直接设置    
+        lm.from = 'cpt';
+        lm.gljType = lm.type;
+        let t_mg = getProjectGLJNewData(lm,projectID);
+        newProjectGLJList.push(t_mg);
+        projectGLJMap[getIndex(lm)] = t_mg;
+      }
+    }
+  }
+
+  if(lessIDList.length > 0){
+    let less_stds =  await std_glj_lib_gljList_model.find({'ID':{'$in':lessIDList}}).lean();
+    let less_stds_map = {};
+    for(let les of  less_stds){
+      less_stds_map[les.ID] = les;
+    }
+    for(let t_l_m of lessStdMix){
+      let t_nglj = less_stds_map[t_l_m.glj_id];
+      t_nglj.from = 'std';
+      //防止组成物中改了名称等,但是通过glj_id取出来的是还没改前的原始数据
+      t_nglj.name = t_l_m.name;
+      t_nglj.code = t_l_m.code;
+      t_nglj.gljType = t_l_m.type;
+      t_nglj.specs = t_l_m.specs;
+      t_nglj.unit = t_l_m.unit;
+      let t_np = getProjectGLJNewData(t_nglj,projectID,ext);
+      newProjectGLJList.push(t_np);
+      projectGLJMap[getIndex(t_l_m)] = t_np;
+    }
+  }
+  return newProjectGLJList;
+}
+
+//找到并返回单价文件信息,如果没有自动插入
+async function getUnitPriceData(newProjectGLJList,gljCodes,unitPriceFileId){
+  let unitPriceMap = {};
+  let newUnitPriceList = [];
+  let unitPriceList = await unitPriceModel.find({unit_price_file_id: unitPriceFileId,'code':{'$in':gljCodes}}).lean();
+  for(let u of unitPriceList){
+    unitPriceMap[getIndex(u)]=u;
+  }
+
+  for(let np of newProjectGLJList){
+    let pkey = getIndex(np);
+    if(unitPriceMap[pkey]) continue;
+
+    let insertData = {
+      code: np.code,
+      base_price: np.base_price,
+      market_price: np.market_price,
+      unit_price_file_id: unitPriceFileId,
+      name: np.name,
+      specs:np.specs?np.specs:'',
+      original_code:np.original_code,
+      unit:np.unit?np.unit:'',
+      type: np.type,
+      short_name: np.shortName !== undefined ? np.shortName : '',
+      glj_id: np.glj_id,
+      is_add:0,
+      grossWeightCoe:np.grossWeightCoe,
+      purchaseStorageRate:np.purchaseStorageRate,
+      offSiteTransportLossRate:np.offSiteTransportLossRate,
+      handlingLossRate:np.handlingLossRate
+    };
+    if(np.from=='cpt') insertData.is_add=1;//如果是来自补充工料机,则都添加新增标记
+    if(insertData.code != insertData.original_code) insertData.is_add=1;//添加的时候如果是复制整块来的,可能在源项目中是新增的工料机,这里也要添上(暂时可能还用不到)
+    newUnitPriceList.push(insertData);
+    unitPriceMap[pkey] = insertData;
+  }
+
+
+  if(newUnitPriceList.length > 0){
+    await setIDfromCounter("unit_price",newUnitPriceList);
+    await unitPriceModel.insertMany(newUnitPriceList);
+  } 
+
+  return [unitPriceMap,newUnitPriceList];
+}
+
+function getIndex(obj, pops){
+  let t_index = '';
+  let k_arr = [];
+  if(!pops) pops = ['code','name','specs','unit','type'];
+  for (let p of pops) {
+      let tmpK = (obj[p] == undefined || obj[p] == null || obj[p] == '') ? 'null' : obj[p];
+      k_arr.push(tmpK);
+  }
+  t_index = k_arr.join("|-|");
+  return t_index;
+}

+ 14 - 0
modules/unit_price_file/routes/unit_price_router.js

@@ -0,0 +1,14 @@
+let express = require('express');
+let unitPirceController = require('../controllers/unit_price_controller');
+
+module.exports = function (app) {
+
+    var Router = express.Router();
+    Router.get('/index/:unitPriceFileID', unitPirceController.index);
+    Router.post('/addMixRatio',unitPirceController.addMixRatio);
+    // Router.post('/addGLJ',unitPirceController.addGLJ);
+    // Router.post('/replaceGLJ',unitPirceController.replaceGLJ);
+    
+
+    app.use('/unitPrice',Router);
+}

+ 235 - 0
web/building_saas/unit_price_file/index.html

@@ -0,0 +1,235 @@
+<!DOCTYPE html>
+<html lang="zh-CN">
+
+<head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
+    <meta http-equiv="x-ua-compatible" content="ie=edge">
+    <title>大司空云计价</title>
+
+
+    <link rel="stylesheet" href="/lib/jquery-ui/jquery-ui.css" type="text/css">
+    <link rel="stylesheet" href="/lib/bootstrap/css/bootstrap.min.css">
+    <link rel="stylesheet" href="/lib/bootstrap/css/bootstrap-submenu.css">
+    <link rel="stylesheet" href="/lib/spreadjs/sheets/css/gc.spread.sheets.sc.css" type="text/css">
+    <link rel="stylesheet" href="/web/building_saas/css/main.css">
+    <link rel="stylesheet" href="/web/building_saas/css/custom.css">
+    <link rel="stylesheet" href="/lib/font-awesome/font-awesome.min.css">
+    <link rel="stylesheet" href="/lib/jquery-contextmenu/jquery.contextMenu.css" type="text/css">
+    <link rel="stylesheet" href="/lib/jquery-editable-select/jquery.editable-select.min.css" type="text/css">
+    <!--zTree-->
+    <link rel="stylesheet" href="/lib/ztree/css/zTreeStyle.css" type="text/css">
+    <!--SpreadJs-->
+   <!-- <link rel="stylesheet" href="/lib/jquery-ui/jquery-ui.css" type="text/css">
+    <link rel="stylesheet" href="/lib/spreadjs/sheets/css/gc.spread.sheets.sc.css" type="text/css">-->
+    <link rel="stylesheet" href="/lib/spreadjs/views/gc.spread.views.dataview.10.0.0.css">
+    <!-- jquery.contextmenu -->
+   <!-- <link rel="stylesheet" href="/lib/jquery-contextmenu/jquery.contextMenu.css" type="text/css">-->
+
+    <link rel="shortcut icon" href="/web/building_saas/css/favicon.ico">
+    <link rel="icon" type="image/gif" href="/web/building_saas/css/animated_favicon1.gif">
+    <style type="text/css">
+        .ztree * {
+            font-family: Calibri;
+            font-size: 0.9rem;
+        }
+    </style>
+
+</head>
+<script type="text/javascript">
+  let unitPriceFileID = parseInt('<%- unitPriceFileID %>'); 
+  let userID = '<%- userID %>';
+  let projectID = '<%- projectID %>';
+  let taxType = '<%- taxType %>';
+  let region = '<%- region %>';
+  let unitPriceList = JSON.parse(`<%- unitpriceList %>`);
+  let gljTypeMap = JSON.parse(`<%- gljTypeMap %>`);
+  let mixRatioMap = JSON.parse(`<%- mixRatioMap %>`);
+</script>
+<body oncontextmenu="return false;">  <!--屏蔽input鼠标右键-->
+<!--<div id="toolToastWrap" style="left: 20px; right: 30px; position: fixed; z-index: 10001; top: 100px;">
+    <div id="toolToast" class="toolToast">
+        <span id="tool-toast-content">右键不支持粘贴外部内容,请使用Ctrl+V粘贴。<span id="toolToastBtn">我知道了</span></span>
+    </div>
+</div>-->
+
+    <div class="header">
+         <div class="top-msg clearfix">
+            <div class="alert alert-warning alert-dismissible" role="alert" id="notify" style="display: none">
+                <button type="button" class="close" aria-label="Close" onclick="$('#notify').hide();">
+                  <span aria-hidden="true">&times;</span>
+                </button>
+                <strong id="message"></strong>-
+            </div>
+        </div>
+        <nav class="navbar navbar-expand-lg p-0 d-flex <%= versionName.includes('免费') ? 'free-version' : 'pro-version' %>">
+          <div class="unit_price_header header-logo ">
+            <h5>单价文件编辑器</h5>
+          </div>
+          <div class="navbar-text navbar-crumb px-1 mr-auto" id="fullpath">   
+            <span class="text-muted px-1"></span>
+            <span data-toggle="tooltip" data-placement="bottom" data-original-title="<%= rootProjectName%>"><i class="fa fa-cubes"></i>...</span>
+            <span class="text-muted px-1"></span>
+             <span><i class="fa fa-puzzle-piece"></i></span>
+            <span class="text-truncate" data-toggle="tooltip" data-placement="bottom" data-original-title="<%= unitFileName%>">&nbsp;<%= unitFileName%></span>
+            &nbsp;(<span class="a_color" data-toggle="tooltip" id="pop-used-list"  style="float: none;" data-original-title="" title="<%= usedTenderString%>">与<span id="used-project-count" style="float: none;">1</span>个单位工程同步</span>)
+          </div>
+        </nav>
+    </div>
+    <div class="main">
+        <div class="content" style="margin-left: 0px;">
+          <div class="tab-content">
+              <!--造价书-->
+              <div class="container-fluid">
+                  <div class="row" id="mainRow">
+                      <!--col-lg-12 p-0-->
+                      <div class="main-content" style="width: 100%; display: inline-block" id="main">
+                          <div class="top-content" id="top_div" style="overflow:hidden;">
+                              <div class="main-data-top" id="mainSpread"></div>
+                          </div>
+                          <div class="resize-y" id="mainVerticalResize"></div>
+                          <div class="bottom-content" id="bottom_div">
+                              <ul class="nav nav-tabs" role="tablist" id="bottom_div_ul">  
+                                  <li class="nav-item" id="GLJ_div">
+                                      <a class="nav-link sub-item active" id="linkGLJ" data-toggle="tab" href="#subSpread" role="tab">组成物计算</a>
+                                  </li>                                
+                              </ul>
+                              <!-- Tab panes -->
+                              <div class="tab-content" id="tabCon">
+                                  <div class="tab-pane active" id="subItems" role="tabpanel">
+                                     <div class="main-data-bottom ovf-hidden" id="subSpread" tabindex="0"></div>
+                                  </div>
+                              </div>
+                          </div>
+                      </div>
+                      </div>
+                  </div>
+              </div>
+            </div>
+
+
+        </div>
+    </div>
+   
+   <!--工料机选择窗口-->
+   <div class="modal fade" id="glj_tree_div" data-backdrop="static">
+    <div class="modal-dialog modal-lg" role="document" id="modalCon">
+        <div class="modal-content" style="width: 1020px; left:50%; transform: translate(-50%,0%);">
+            <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>
+                <input type="hidden" id="actionType">
+            </div>
+            <div class="modal-body" style="padding-left: 0; padding-right: 3px; margin-left: 0;">
+                    <div style="width: 32%; float: left;">
+                        &nbsp;
+                        <input type="radio" class="glj-radio" name="glj" value="stdGLJ">标准&nbsp;&nbsp;
+                        <input type="radio" class="glj-radio" name="glj" value="complementaryGLJs">补充&nbsp;&nbsp;
+                        <div  class="modal-auto-height" id="componentTreeDiv" style=" height: 435px; overflow: hidden;">
+                            <!--<div class="print-list">-->
+                            <div style="width: 100%; height: 100%; overflow: auto">
+                                <ul id="gljTree" class="ztree"></ul>
+                            </div>
+                            <!--</div>-->
+                        </div>
+                    </div>
+                    <div style="width:67%; padding-left: 3px; float: left;">
+                        <div id="gljRadios">
+                            <div class="row">
+                                <div class="col-7" style="margin-top: 5px;">
+                                    <!--<input type="radio" class="glj-radio" name="glj" value="allGljs" checked>所有&nbsp;&nbsp;
+                                    <input type="radio" class="glj-radio" name="glj" value="stdGLJ">标准&nbsp;&nbsp;
+                                    <input type="radio" class="glj-radio" name="glj" value="complementaryGLJs">补充&nbsp;&nbsp;-->
+                                </div>
+                                <div class="input-group col-5" style="margin-bottom: 5px;">
+                                    <input type="text" class="form-control form-control-sm" placeholder="请输入筛选编码或名称" value="" id="gljSearchKeyword">
+                                    <!--  <span class="input-group-btn"><button class="btn btn-secondary btn-sm" type="button" id="gljSearch"><i class="fa fa-search" aria-hidden="true"></i></button></span>-->
+                                </div>
+                            </div>
+                            <!-- <div class="form-group"><input id="searchGlj" type="text" class="form-control-sm" placeholder="查询工料机"></div>-->
+                        </div>
+                        <div class="modal-auto-height" style="overflow: hidden;height: 420px" id="gljLibSheet">
+
+                        </div>
+                    </div>
+            </div>
+            <div class="modal-footer" style="position: relative;">
+                <a href="/complementaryGlj" target="_blank" class="btn btn-primary" style="position: absolute; left: 20px">新增人材机</a>
+                <a href="javascript:void(0);" id="glj_selected_conf" class="btn btn-primary">确定</a>
+                <a href="javascript:void(0);" id="replace_next_btn" class="btn btn-primary">下一步</a>
+                <button type="button" id="componentsCacnel" class="btn btn-secondary" data-dismiss="modal">取消</button>
+            </div>
+        </div>
+    </div>
+  </div>
+   
+ 
+   
+    <img src="/web/dest/css/img/folder_open.png" id="folder_open_pic" style="display: none">
+    <img src="/web/dest/css/img/folder_close.png" id="folder_close_pic" style="display: none">
+    <img src="/web/dest/css/img/project.png" id="proj_pic" style="display: none">
+    <img src="/web/dest/css/img/engineering.png" id="eng_pic" style="display: none">
+    <img src="/web/dest/css/img/tender.png" id="tender_pic" style="display: none">
+
+    <img src="/web/dest/css/img/blockLib.png" id="blockLib_pic" style="display: none">
+    <img src="/web/dest/css/img/folder_open.png" id="folder_pic" style="display: none">
+    <img src="/web/dest/css/img/tender.png" id="block_pic" style="display: none">
+
+        <!-- JS. -->
+    <script src="/lib/jquery/jquery-3.2.1.min.js"></script>
+    <script type="text/javascript" src="/lib/jquery-ui/jquery-ui.min.js"></script>
+    <script src = "/lib/spreadjs/sheets/gc.spread.sheets.all.11.1.2.min.js"></script>
+    <script src="/lib/spreadjs/sheets/interop/gc.spread.excelio.11.1.2.min.js"></script>
+    <script>GC.Spread.Sheets.LicenseKey =  '<%- LicenseKey %>';</script>
+    <script type="text/javascript" src="/lib/jquery-ui/jquery-ui-datepickerCN.js"></script>
+    <script type="text/javascript" src="/lib/jquery-contextmenu/jquery.contextMenu.js"></script>
+    <script type="text/javascript" src="/lib/jquery-contextmenu/jquery.ui.position.js"></script>
+    <script src="/lib/spreadjs/views/gc.spread.views.dataview.10.0.0.min.js" type="text/javascript"></script>
+    <script type="text/javascript" src="/lib/ztree/jquery.ztree.core.js"></script>
+    <script type="text/javascript" src="/lib/ztree/jquery.ztree.excheck.js"></script>
+    <!--<script src="/lib/spreadjs/views/common/gc.spread.common.10.0.0.min.js" type="text/javascript"></script>-->
+    <script src="/lib/spreadjs/views/plugins/gc.spread.views.gridlayout.10.0.0.min.js" type="text/javascript"></script>
+    <script src="/lib/js-xlsx/xlsx.core.min.js"></script>
+    <script src="/lib/lz-string/lz-string.min.js"></script>
+    <script type="text/javascript" src="/lib/jspdf/jspdf.min.js"></script>
+    <!-- inject:js -->
+    <script src="/lib/popper/popper.min.js"></script>
+    <script src="/lib/bootstrap/bootstrap.min.js"></script>
+    <script src="/lib/bootstrap/bootstrap-submenu.js"></script>
+    <script src="/web/building_saas/glj/js/socket.io.slim.js"></script>
+    <script src="/public/web/socket/connection.js"></script>
+    <script type="text/javascript" src="/web/building_saas/js/moment.min.js"></script>
+    <script type="text/javascript" src="/web/building_saas/js/message.js"></script>
+    <script type="text/javascript" src="/public/web/scMathUtil.js"></script>
+    <script type="text/javascript" src="/public/web/gljUtil.js"></script>
+    <script type="text/javascript" src="/public/web/PerfectLoad.js"></script>
+    <script type="text/javascript" src="/lib/lodash/lodash.js"></script>
+    <script type="text/javascript" src="/public/web/commonAlert.js"></script>
+    <script type="text/javascript" src="/public/web/headerOpr.js"></script>
+    <script type="text/javascript" src="/public/web/common_ajax.js"></script>
+    <script type="text/javascript" src="/public/common_util.js"></script>
+    <script src="/public/common_constants.js"></script>
+    <script type="text/javascript" src="/public/web/treeDataHelper.js"></script>
+    <script type="text/javascript" src="/public/web/ztree_common.js"></script>
+    <script type="text/javascript" src="/web/building_saas/main/js/models/main_consts.js"></script>
+    <script type="text/javascript" src="/lib/jquery-editable-select/jquery.editable-select.min.js"></script>
+    <script type="text/javascript" src="/public/web/tree_sheet/tree_sheet_helper.js"></script>
+    <script type="text/javascript" src="/public/web/sheet/sheet_data_helper.js"></script>
+    <script type="text/javascript" src="/public/web/sheet/sheet_common.js"></script>
+    <script type="text/javascript" src="/public/web/slideResize.js"></script>
+    <script type="text/javascript" src="/web/building_saas/main/js/views/glj_view_contextMenu.js"></script>
+    <script type="text/javascript" src="/web/building_saas/main/js/views/glj_view.js"></script>
+    <script type="text/javascript" src="/web/building_saas/main/js/views/options_view.js"></script>
+    <script type="text/javascript" src='/web/building_saas/main/js/views/project_glj_view.js'></script>
+    <script type="text/javascript" src="/web/building_saas/unit_price_file/index.js"></script>
+    <!-- endinject -->
+
+    <% if (overWriteUrl != undefined) { %>
+      <script type="text/javascript" src="<%= overWriteUrl%>"></script>
+    <% } %>
+        
+   
+</body>
+</html>

+ 591 - 0
web/building_saas/unit_price_file/index.js

@@ -0,0 +1,591 @@
+
+gljType = gljUtil.gljType;
+let unitPriceObj = {
+  unitPriceMap:{},
+  selectedData : null,
+  setUntiPriceMap:function(){
+    for(let u of unitPriceList){
+      this.unitPriceMap[gljUtil.getIndex(u)] = u;
+    }
+  },
+  mainSpread:null,
+  mainSetting:{
+    header: [
+        {headerName: "编号", headerWidth: 80, dataCode: "code", dataType: "String"},
+        {headerName: "名称", headerWidth: 160, dataCode: "name", dataType: "String"},
+        {headerName: "单位", headerWidth: 45, dataCode: "unit", hAlign: "center", dataType: "String"},
+        {headerName: "规格", headerWidth: 120, dataCode: "specs", hAlign: "left", dataType: "String"},
+        {headerName: "类型", headerWidth: 45, dataCode: "short_name", hAlign: "center", dataType: "String"},
+        {headerName: "定额价", headerWidth: 70, dataCode: "basePrice", hAlign: "right", dataType: "Number",validator:"number"},//decimalField:'glj.unitPrice',
+        {headerName: "预算价", headerWidth: 70, dataCode: "marketPrice", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:"glj.unitPrice"
+        {headerName: "是否\n新增", headerWidth: 50, dataCode: "is_add", hAlign: "center", dataType: "String",cellType:'checkBox'}
+    ],
+    view: {
+        lockColumns: ["code","name","specs","unit","short_name","basePrice"],
+        colHeaderHeight:36
+    },
+    getStyle:function (data,row,activeRow) {
+      if(row == activeRow){//选中黄色显示
+          return {backColor:"#FFFACD"};
+      }
+      return null;
+    }
+  },
+  subSpread:null,
+  subSetting:{
+    header:[
+        {headerName: "编号", headerWidth: 80, dataCode: "code", dataType: "String"},
+        {headerName: "名称", headerWidth: 240, dataCode: "name", dataType: "String"},
+        {headerName: "规格", headerWidth: 190, dataCode: "specs", dataType: "String"},
+        {headerName: "单位", headerWidth: 45, dataCode: "unit", hAlign: "center", dataType: "String"},
+        {headerName: "类型", headerWidth: 45, dataCode: "short_name", hAlign: "center", dataType: "String"},
+        {headerName: "定额价", headerWidth: 80, dataCode: "basePrice", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:'glj.unitPrice'
+        {headerName: "预算价", headerWidth: 80, dataCode: "marketPrice", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:"glj.unitPrice"
+        {headerName: "消耗量", headerWidth: 80, dataCode: "consumption", hAlign: "right", dataType: "Number",validator:"number",tofix:3}
+    ],
+    view: {
+        lockColumns: [0,1,2,3,4,5,6],
+        rowHeaderWidth: 25
+    }
+  },
+  initMainSpread:function () {
+    if(this.mainSpread) return this.mainSpread.refresh();
+    this.mainSpread = SheetDataHelper.createNewSpread($("#mainSpread")[0]);
+    sheetCommonObj.spreadDefaultStyle(this.mainSpread);
+    this.mainSheet = this.mainSpread.getSheet(0);
+    sheetCommonObj.initSheet(this.mainSheet, this.mainSetting, 30);
+    this.mainSheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onMainSelectionChange);
+    this.mainSpread.bind(GC.Spread.Sheets.Events.RangeChanged, this.onMainRangeChange);
+    this.mainSheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onMainValueChange);
+    this.mainSheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onMainEditStarting);
+  },
+  showMainDatas:function(){
+    unitPriceList = gljUtil.sortProjectGLJ(unitPriceList);
+    this.setData(unitPriceList);
+    let sel = this.mainSheet.getSelections()[0];
+    let oldData = this.selectedData;
+    sheetCommonObj.showData(this.mainSheet, this.mainSetting,unitPriceList);
+    this.mainSheet.setRowCount(unitPriceList.length);
+    sel.row =  oldData?_.findIndex(unitPriceList,{'id':oldData.id}):sel.row ;
+    this.mainSheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
+  
+  },
+  getShortNameByType : function (type) {
+    return gljTypeMap["typeId" + type]?gljTypeMap["typeId" + type].shortName:'';
+  },
+  setData:function(list){
+    for(let l of list){
+      l.bgColour = "white";
+      l.basePrice = this.getPrice('base_price',l);
+      l.marketPrice = this.getPrice('market_price',l);
+      l.short_name = this.getShortNameByType(l.type);
+      if(l.base_price == l.market_price){//如果定额价等于市场价时,改底色。 优先度低于有组成物时的底色
+        l.bgColour = "#C4CAFB";
+      }
+      let lindex = gljUtil.getIndex(l);
+      if (gljUtil.notEditType.indexOf(l.type) >= 0 && mixRatioMap[lindex] && mixRatioMap[lindex].length>0) {//有组成物时
+        l.bgColour = "#E0E0E0";
+      }
+    }
+  },
+  getSelectedUnitPrice:function () {
+    let me = this,data = null;
+    let sheet = me.mainSpread.getActiveSheet();
+    let sel = sheet.getSelections()[0];
+        let srow = sel.row == -1||sel.row == ""?0:sel.row;
+        if(unitPriceList.length>srow){
+            data = unitPriceList[srow];
+        }
+    return data;
+  },
+  onMainSelectionChange:function(sender,args){
+    let me = unitPriceObj;
+    let newSel = args.newSelections[0];
+    let oldSel = args.oldSelections?args.oldSelections[0]:{};
+    args.sheet.suspendPaint();
+    args.sheet.suspendEvent();
+    if(newSel.row != oldSel.row){
+      let style = me.getSelStyle(true,{});
+      args.sheet.setStyle(newSel.row, -1, style);
+      let orow = oldSel.row==''||oldSel.row==-1?0:oldSel.row;
+      if(unitPriceList[orow]){
+        let tstyle = me.getSelStyle(false,{},unitPriceList[orow].bgColour);
+        args.sheet.setStyle(orow, -1, tstyle);
+        me.showSubDatas();
+        me.selectedData = unitPriceList[newSel.row];
+      }
+    }else{
+      args.sheet.repaint();
+    }
+    args.sheet.resumeEvent();
+    args.sheet.resumePaint();
+
+  },
+  onMainEditStarting:function(sender, args){
+    let me = unitPriceObj;
+    let row = args.row;
+    let col = args.col;
+    if(me.mainEditChecking(row,col)==false){
+        args.cancel = true;
+    }
+  },
+  mainEditChecking:function(row,col,isPaste=false){
+    let me = unitPriceObj;
+    if(row>=unitPriceList.length) return false;
+    let data = unitPriceList[row];
+    let setting = me.mainSetting;
+    let dataCode = setting.header[col].dataCode;
+    if(isPaste == false &&dataCode=='is_add'){//除了粘贴,拖动填充等操作,其它的都不能编辑
+      return false;
+    }
+    if(dataCode=='marketPrice'){
+      let uindex = gljUtil.getIndex(data);
+      if(mixRatioMap[uindex] && mixRatioMap[uindex].length > 0) return false;//有组成物的不能编辑
+      if(data.calcMaterial == 1) return false //有材料计算时不能修改
+    }
+    return true;
+  },
+  onMainValueChange:function(e,info){
+    let me = unitPriceObj;
+    let value = info.newValue;
+    if(info.newValue === undefined){
+      return;
+    }
+    if(value && !sheetCommonObj.checkData(info.col,me.mainSetting,value)) {
+      alert('输入的数据类型不对,请重新输入!');
+      return me.showMainDatas();
+    }
+    me.batchUpdateUnitPrice([{row:info.row,col:info.col,value:value}]);
+  },
+  onMainRangeChange:function(sender,info){
+    let me = unitPriceObj;
+    let canChange = true;
+    let changeInfo = [];
+    for(let c of info.changedCells){
+      let value=  info.sheet.getCell(c.row, c.col).text();
+      changeInfo.push({row:c.row,col:c.col,value:value});
+      if(me.mainEditChecking(c.row,c.col,true)==false){//如果不能编辑
+        canChange = false;
+        break;
+      }
+      if (!sheetCommonObj.checkData(c.col,me.mainSetting,value)) {
+          alert('输入的数据类型不对,请重新输入!');
+          canChange = false;
+          break;
+      }
+    }
+    if(canChange == false) return me.showMainDatas();
+    me.batchUpdateUnitPrice(changeInfo);
+  },
+  batchUpdateUnitPrice:async function(changeInfo){
+    let me = unitPriceObj;
+    let updateData = [];
+    let newValueMap = {};
+    let refreshList = [];
+    try {
+      for(let ci of changeInfo){
+        let dataCode = me.mainSetting.header[ci.col].dataCode;
+        let recode = unitPriceList[ci.row];
+        let ndata = newValueMap[recode.id]?newValueMap[recode.id]:{unit_price:recode};
+        if(dataCode=='basePrice'||dataCode=='marketPrice'){
+            let editField = dataCode === 'basePrice'?"base_price":"market_price";
+            let newValue = ci.value;
+            if(recode && recode[editField]!=newValue){
+                newValue= scMathUtil.roundForObj(ci.value,3); 
+                ndata['field'] = editField;
+                ndata['newval'] = newValue;
+                newValueMap[recode.id]=ndata;
+            }
+        }else{
+          let ext = {};
+          if(dataCode === 'is_add'){
+            value = ci.value == true?1:0;
+          }
+          ext[dataCode] = value;
+          ndata['ext'] = ext;
+          newValueMap[recode.id]=ndata;
+        }
+      }
+      for(let key in newValueMap){
+        updateData.push(newValueMap[key]);
+        refreshList.push(newValueMap[key].unit_price)
+      }
+      if(updateData.length > 0){
+        $.bootstrapLoading.start();
+        let result = await ajaxPost("/glj/batchUpdatePrices",updateData);
+        for(let r of refreshList){
+          let rdata = newValueMap[r.id];
+          if(rdata.field) r[rdata.field] = rdata.newval;
+          if(rdata.ext){
+            for(let ekey in rdata.ext){
+              r[ekey] = rdata.ext[ekey];
+            }
+          }
+           
+        }
+        for(let r of result){
+          let pdata = r.updateOne.filter;
+          let set = r.updateOne.update.$set;
+          for(let skey in set){
+              let pindex = gljUtil.getIndex(pdata);
+              me.unitPriceMap[pindex][skey] = set[skey];
+          }
+        }
+      }
+    } catch (error) {
+        console.log(error);
+        alert(error);
+    }
+    $.bootstrapLoading.end();
+    me.onUnitPriceChange();
+
+  },
+
+  initSubSpread:function () {
+    if(this.subSpread) return this.subSpread.refresh();
+    this.subSpread = SheetDataHelper.createNewSpread($("#subSpread")[0]);
+    sheetCommonObj.spreadDefaultStyle(this.subSpread);
+    this.subSheet = this.subSpread.getSheet(0);
+    sheetCommonObj.initSheet(this.subSheet, this.subSetting, 30);
+    this.subSheet.bind(GC.Spread.Sheets.Events.RangeChanged, this.onSubRangeChange);
+    this.subSheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onSubValueChange);
+    this.initSubRightClick();
+  },
+  showSubDatas:function(){
+    let parentData = this.getSelectedUnitPrice();
+    this.mixRatioList = mixRatioMap[gljUtil.getIndex(parentData)];
+    this.mixRatioList = this.mixRatioList?this.mixRatioList:[];
+    this.setMixRatioData(this.mixRatioList);
+    let sel = this.subSheet.getSelections()[0];
+    this.subSheet.setRowCount(0);
+    sheetCommonObj.showData(this.subSheet, this.subSetting,this.mixRatioList);
+    this.subSheet.setRowCount(this.mixRatioList.length);
+    this.subSheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
+  },
+  onSubValueChange:function(sender,info){
+    let me = unitPriceObj;
+    let value = info.newValue;
+    if(info.newValue === undefined){
+      return;
+    }
+    if(value && !sheetCommonObj.checkData(info.col,me.mainSetting,value)) {
+      alert('输入的数据类型不对,请重新输入!');
+      return me.showMainDatas();
+    }
+    me.batchUpdateConsumption([{row:info.row,col:info.col,value:value}]);
+    
+  },
+  onSubRangeChange:function(sender,info){
+    let me = unitPriceObj;
+    let changeInfo=[];
+    let canChange = true;
+    for(let c of info.changedCells){
+      let value = info.sheet.getCell(c.row, c.col).text();
+      if(_.isEmpty(value)) value = 0;
+      if (!sheetCommonObj.checkData(c.col,me.subSetting,value)) {
+          alert('输入的数据类型不对,请重新输入!');
+          canChange = false;
+          break;
+      }else {
+          changeInfo.push({row:c.row,col:c.col,value:value});
+      }
+    }
+    if(canChange == false) me.showSubDatas();
+    me.batchUpdateConsumption(changeInfo);
+  },
+  calcParentPrice:function(list,updateMap,deleteID){
+    let parentMarketPrice = 0;
+    for(let sub of list){
+      if(deleteID && sub.id == deleteID) continue
+      let marketPrice = scMathUtil.roundForObj(sub.marketPrice,6);
+      let basePrice = scMathUtil.roundForObj(sub.basePrice,6);
+      let consumption =  updateMap[sub.id]?updateMap[sub.id].consumption:scMathUtil.roundForObj(sub.consumption,3);
+      parentMarketPrice = scMathUtil.roundForObj(marketPrice*consumption + parentMarketPrice,6);
+     // parentBasePrice = scMathUtil.roundForObj(basePrice*consumption + parentBasePrice,getDecimal("process"));
+    }
+    parentMarketPrice = scMathUtil.roundForObj(parentMarketPrice,2);
+    return parentMarketPrice;
+  },
+
+  deleteMixRatio:async function(row){
+    let me = this, deleteRecode = me.mixRatioList[row];
+    let parentMarketPrice = me.calcParentPrice(me.mixRatioList,{},deleteRecode.id);
+    let parentData = me.getSelectedUnitPrice();
+    let updateData = {id: deleteRecode.id,connect_key:gljUtil.getIndex(parentData)};
+    updateData.parent = {connect_key:gljUtil.getIndex(parentData),query:{id:parentData.id},doc:{market_price: parentMarketPrice}};
+    try {
+      $.bootstrapLoading.start();
+      await ajaxPost("/glj/delete-ratio",{id: updateData.id,parent:updateData.parent,unitPrice:updateData.unitPrice});
+      let mlist =  mixRatioMap[updateData.connect_key];
+      _.remove(mlist,{id:updateData.id});
+      if(updateData.parent){
+        let pglj = me.unitPriceMap[updateData.parent.connect_key];
+        if(pglj) gljUtil.setProperty(pglj,updateData.parent.doc);
+      }
+
+    } catch (error) {
+      alert(error);
+      console.log(error);
+    }
+
+    $.bootstrapLoading.end();
+    me.onUnitPriceChange();
+  },
+  batchUpdateConsumption:async function(changeInfo){
+    let me = unitPriceObj;
+    let updateMap = {},updateData = [],parentBasePrice = 0,parentMarketPrice = 0;
+    let parentKey = '',unit_price_file_id=null;
+    for(let c of changeInfo){
+      let record = me.mixRatioList[c.row];
+      let value =  scMathUtil.roundForObj(c.value,3);
+      updateMap[record.id] = {consumption: value,record:record};
+      updateData.push({type:'mix_ratio',connect_key:record.connect_key,query:{id:record.id},doc:{consumption:scMathUtil.roundToString(value,3)}});
+      parentKey = record.connect_key;
+      unit_price_file_id = record.unit_price_file_id;
+    }
+    
+    parentMarketPrice = me.calcParentPrice(me.mixRatioList,updateMap);
+    
+    let parentData = me.getSelectedUnitPrice();
+    if(parentData){
+      updateData.push({type:'unitPrice',connect_key:gljUtil.getIndex(parentData),query:{id:parentData.id},doc:{market_price:parentMarketPrice}});
+    }
+    if(updateData.length > 0){
+      try {
+        $.bootstrapLoading.start();
+        let result = await ajaxPost("/glj/batchUpdateConsumption",updateData);
+        for(let up of updateData){
+          if(up.type == 'unitPrice'){
+            let nu = me.unitPriceMap[up.connect_key];
+            if(nu) gljUtil.setProperty(nu,up.doc);
+          }else{
+            let nlist = mixRatioMap[up.connect_key];
+            for(let nc of nlist){
+                if(nc.id == up.query.id){
+                  gljUtil.setProperty(nc,up.doc);
+                }
+            } 
+          }
+        }
+      } catch (error) {
+        alert(error);
+        console.log(error);
+      }
+    }
+    $.bootstrapLoading.end();
+    me.onUnitPriceChange();
+  },
+  setMixRatioData:function(mixRatioList){
+    for(let m of mixRatioList){
+      m.short_name = this.getShortNameByType(m.type);
+      let mu = this.unitPriceMap[gljUtil.getIndex(m)];
+      if(mu){
+        m.basePrice = this.getPrice("base_price",mu);
+        m.marketPrice = this.getPrice("market_price",mu);
+      }else{
+        console.log("组成物的单价信息未找到---"+m.code);
+      }
+    }
+  },
+  getPrice:function(pricefield,unitprice){
+    let quantity = 3;
+    let unitPriceHasMix = 2;
+    let unitPrice = 3;
+    let process_decimal = 6;
+    let uIndex = gljUtil.getIndex(unitprice);
+    if(mixRatioMap[uIndex] && mixRatioMap[uIndex].length > 0){
+      let total = unitprice[pricefield];
+      if(pricefield == "market_price"){
+        total = 0;
+        for(let m of mixRatioMap[uIndex]){
+          let mu = unitPriceObj.unitPriceMap[gljUtil.getIndex(m)];
+          let price_m =  unitPriceObj.getPrice(pricefield,mu);
+          let temP = scMathUtil.roundForObj(price_m * scMathUtil.roundForObj(m.consumption,quantity),process_decimal);
+          total = scMathUtil.roundForObj(temP+total,process_decimal);
+        }
+      }
+      return scMathUtil.roundForObj(unitprice[pricefield],unitPriceHasMix);
+    }else{
+      return scMathUtil.roundForObj(unitprice[pricefield],unitPrice);
+    }
+  },
+  getSelStyle: function (selected,settingStyle,rcolor) {
+    let style = new GC.Spread.Sheets.Style();
+    if(settingStyle){
+        for(let key in settingStyle){
+            style[key] = settingStyle[key];
+        }
+    }
+    style.borderLeft = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
+    style.borderTop = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
+    style.borderRight = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
+    style.borderBottom = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
+    let selectedColor = "#FFFACD",
+        recColor = rcolor?rcolor:'White';
+    style.backColor = selected ? selectedColor : recColor;
+    return style;
+  },
+  initSubRightClick:function(){
+    let me = this;
+    $.contextMenu({
+      selector: '#subSpread',
+      build: function ($trigger, e) {
+          me.rightClickTarget = SheetDataHelper.safeRightClickSelection($trigger, e, me.subSpread);
+          return me.rightClickTarget.hitTestType === GC.Spread.Sheets.SheetArea.viewport ||
+              me.rightClickTarget.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
+      },
+      items: {
+          "deleteMixRatio": {
+              name: "删除",
+              icon: 'fa-trash-o',
+              disabled: function () {
+                  return me.rightClickTarget.row === undefined;
+              },
+              callback: function (key, opt) {
+                  let row = me.rightClickTarget.row;
+                  me.deleteMixRatio(row);
+              },
+              visible: function(key, opt){
+                  let projectGLJ = me.getSelectedUnitPrice();
+                  return  projectGLJ;
+              }
+          },
+          "addMixRatio":{
+              name: '添加',
+              icon: 'fa-sign-in',
+              disabled: function () {
+                let projectGLJ = me.getSelectedUnitPrice();
+                return !_.includes(compositionTypes,projectGLJ.type);
+              },
+              callback: function (key, opt) {
+                   projectGljObject.selectedProjectGLJ = me.getSelectedUnitPrice();
+                   getGLJData('unitPriceAddMix',me.getGLJDataPaging);
+              },
+              visible: function(key, opt){
+                  let projectGLJ = me.getSelectedUnitPrice();
+                  return  projectGLJ ;
+              }
+          }
+      }
+     });
+  },
+  addMixRatio:async function(){
+     let me = this;
+    for(let mix of me.mixRatioList){
+      let m_key = gljUtil.getIndex(mix);
+      _.remove(gljOprObj.GLJSelection,n =>{
+        return m_key == n;
+      });   
+    }
+
+    let result = await projectGljObject.addMixRatioFromLib(gljOprObj.GLJSelection)
+    if(result.mixRatios && result.mixRatios.length > 0){
+      let mList = mixRatioMap[result.mixRatios[0].connect_key];
+      if(mList){
+        mixRatioMap[result.mixRatios[0].connect_key] = mixRatioMap[result.mixRatios[0].connect_key].concat(result.mixRatios);
+      }
+    }
+    for(let u of result.newUnitPriceList){
+      me.unitPriceMap[gljUtil.getIndex(u)] = u;
+      unitPriceList.push(u);
+    }
+    me.onUnitPriceChange();
+  },
+
+  onUnitPriceChange:async function(){
+    unitPriceObj.showMainDatas();
+    unitPriceObj.showSubDatas();
+    try {
+      await ajaxPost("/project/markUpdateProject",{updateInfo:{unitFileID:unitPriceFileID,isInclude:true},type:"unitFile"});
+      socket.emit('unitFileChangeNotify', {projectID:_.isEmpty(projectID)?null:parseInt(projectID),'unitFileID':unitPriceFileID,userID:userID});
+    } catch (error) {
+      console.log(error)
+      alert(error)
+    }
+  }, 
+  getGLJDataPaging : function (condition, cb) {
+    gljOprObj.loadingPagination = true;
+    CommonAjax.post('/rationGlj/getGLJDataPaging', {condition}, function (data) {
+        gljOprObj.curPageTotal = data.total;
+        data.complementaryGLJs.forEach(glj => {
+            glj.isComplementary = true;
+        });
+        const gljType = condition.type === gljOprObj.pagingType.stdGLJ
+            ? 'stdGLJ'
+            : 'complementaryGLJs';
+        const newData = data[gljType];
+        // 添加组成物,类型为主材时,需要排除自身
+        if (projectGljObject.selectedProjectGLJ.type === gljType.MAIN_MATERIAL) {
+            const pIndex = gljOprObj.getIndex(projectGljObject.selectedProjectGLJ, gljKeyArray);
+            const delIndex = newData.findIndex(item => gljOprObj.getIndex(item, gljLibKeyArray) === pIndex);
+            if (!~delIndex) {
+                newData.splice(delIndex, 1);
+            }
+        }
+        if (condition.init) {
+            gljOprObj.treeData = data.treeData;
+            gljOprObj.distTypeTree = gljOprObj.getComboData(data.distTypeTree);
+        }
+        // 需要重置当前页面数据(点击了分类树、搜索等等)
+        if (condition.reset) {
+            gljOprObj.stdGLJ = data.stdGLJ;
+            gljOprObj.complementaryGLJs = data.complementaryGLJs;
+            gljOprObj.AllRecode = [...gljOprObj.stdGLJ, ...gljOprObj.complementaryGLJs];
+        } else {
+            gljOprObj[gljType].splice(condition.index, 0, ...newData);
+            gljOprObj.AllRecode.splice(condition.index, 0, ...newData);
+        }
+        // 根据缓存选中数据,设置人材机是否选中
+        newData.forEach(item => {
+            const connectKey = gljOprObj.getIndex(item, gljLibKeyArray);
+            if (gljOprObj.GLJSelection.includes(connectKey)) {
+                item.select = 1;
+            }
+        });
+        // 设置人材机类型名称
+        gljOprObj.setTypeName(gljOprObj.distTypeTree.comboDatas, newData);
+        if (data.priceProperties && data.priceProperties.length > 0) {
+            let tregion = '全省';
+            if(!_.isEmpty(region)) tregion = region;
+            let tmp = _.find(data.priceProperties, {region: tregion, taxModel: parseInt(taxType)});
+            if (tmp) {
+                let dataCode = tmp.price.dataCode;
+                let allData = data.stdGLJ.concat(data.complementaryGLJs);
+                for (let glj of allData) {
+                    if (glj.priceProperty && gljUtil.isDef(glj.priceProperty[dataCode])) {
+                        glj.basePrice = glj.priceProperty[dataCode];
+                    }
+                }
+            }
+        }
+        cb(data[gljType]);
+        gljOprObj.loadingPagination = false;
+    }, function () {
+        if ($.bootstrapLoading.isLoading()) {
+            $.bootstrapLoading.end();
+        }
+    });
+  }
+}
+
+
+
+function initPageHeight(){
+  let headerHeight = $(".header").height();
+  $(".main-data-top").height($(window).height()*0.6-headerHeight);
+  $(".main-data-bottom").height($(window).height()-headerHeight-$(".main-data-top").height()-$(".nav-item").height());
+}
+function initPage(){
+  $('[data-toggle="tooltip"]').tooltip({html: true});
+  initPageHeight();
+  unitPriceObj.initMainSpread();
+  unitPriceObj.initSubSpread();
+  unitPriceObj.showMainDatas();
+  unitPriceObj.showSubDatas();
+  socketObject.connect("unitPrice");
+}
+
+unitPriceObj.setUntiPriceMap();
+initPage();
+$(window).resize(initPage);
+

+ 9 - 9
web/over_write/js/chongqing_2018.js

@@ -49,16 +49,16 @@ if(typeof materialComponent !== 'undefined'){
 // CSL, 2018-08-21 计算程序、基数 的覆盖。---------------------------------------------------------------------------------
 let isCQ2018 = true;
 
-if(typeof baseMaterialTypes !== 'undefined'){
-    baseMaterialTypes.push(gljType.OTHER_MATERIAL);
-    // allMaterialTypes.delete(gljType.EQUIPMENT);  新规定里重庆材料类型里需要包含设备费。
-    baseMachineTypes.delete(gljType.MACHINE_COMPOSITION);
-    baseMachineTypes.push(gljType.INSTRUMENT, gljType.FUEL_POWER_FEE, gljType.DEPRECIATION_FEE,
-        gljType.INSPECTION_FEE, gljType.MAINTENANCE, gljType.DISMANTLING_FREIGHT_FEE,
-        gljType.VERIFICATION_FEE, gljType.OTHER_FEE, gljType.OTHER_MACHINE_USED);
-    baseMachineMasterTypes.push(gljType.INSTRUMENT);
-}
+if(typeof baseMaterialTypes !== 'undefined') baseMaterialTypes.push(gljType.OTHER_MATERIAL);
 
+if(typeof baseMachineMasterTypes !== 'undefined') baseMachineMasterTypes.push(gljType.INSTRUMENT);
+if(typeof baseMachineTypes !== 'undefined'){
+  _.pull(baseMachineTypes,gljType.MACHINE_COMPOSITION);
+  //baseMachineTypes.delete(gljType.MACHINE_COMPOSITION);
+  baseMachineTypes.push(gljType.INSTRUMENT, gljType.FUEL_POWER_FEE, gljType.DEPRECIATION_FEE,
+      gljType.INSPECTION_FEE, gljType.MAINTENANCE, gljType.DISMANTLING_FREIGHT_FEE,
+      gljType.VERIFICATION_FEE, gljType.OTHER_FEE, gljType.OTHER_MACHINE_USED);
+}
 
 function overwriteRationCalcBases (taxType){
     if (rationCalcBases){