Browse Source

单价文件编辑

zhangweicheng 5 years ago
parent
commit
5806658158

+ 32 - 0
config/gulpConfig.js

@@ -296,6 +296,38 @@ module.exports = {
         'public/web/common_ajax.js',
         'web/building_saas/complementary_ration_lib/js/global.js',
         'web/building_saas/complementary_ration_lib/js/installation.js'
+    ],
+    unitPrice_css:[],
+    unitPrice_jspaths:[
+      "lib/popper/popper.min.js",
+      "lib/bootstrap/bootstrap.min.js",
+      "lib/bootstrap/bootstrap-submenu.js",
+      "web/building_saas/glj/js/socket.io.slim.js",
+      "public/web/socket/connection.js",
+      "web/building_saas/js/moment.min.js",
+      "web/building_saas/js/message.js",
+      "public/web/scMathUtil.js",
+      "public/web/gljUtil.js",
+      "public/web/PerfectLoad.js",
+      "lib/lodash/lodash.js",
+      "public/web/commonAlert.js",
+      "public/web/headerOpr.js",
+      "public/web/common_ajax.js",
+      "public/common_util.js",
+      "public/common_constants.js",
+      "public/web/treeDataHelper.js",
+      "public/web/ztree_common.js",
+      "web/building_saas/main/js/models/main_consts.js",
+      "lib/jquery-editable-select/jquery.editable-select.min.js",
+      "public/web/tree_sheet/tree_sheet_helper.js",
+      "public/web/sheet/sheet_data_helper.js",
+      "public/web/sheet/sheet_common.js",
+      "public/web/slideResize.js",
+      "web/building_saas/main/js/views/glj_view_contextMenu.js",
+      "web/building_saas/main/js/views/glj_view.js",
+      "web/building_saas/main/js/views/options_view.js",
+      'web/building_saas/main/js/views/project_glj_view.js',
+      "web/building_saas/unit_price_file/index.js",
     ]
 }
 

+ 21 - 10
gulpfile.js

@@ -38,7 +38,7 @@ let commonOptions={
 
 let headerOptions={
     version:version,
-    scriptsDest:'web/dest/scripts',
+    scriptsDest:scriptsDest,
     concatName:'header.all.min',
     srcHtml:'web/src/html/common/header.html',
     htmlDest:'web/common/html',
@@ -48,7 +48,7 @@ let headerOptions={
 
 let loginOptions={
     version:version,
-    scriptsDest:'web/dest/scripts',
+    scriptsDest:scriptsDest,
     jspaths:login_jspaths,
     concatName:'login.all.min',
     srcHtml:'web/src/html/login/login.html',
@@ -61,7 +61,7 @@ let loginOptions={
 
 let pmOptions={
     version:version,
-    scriptsDest:'web/dest/scripts',
+    scriptsDest:scriptsDest,
     jspaths:pm_jspaths,
     csspaths:pm_csspaths,
     concatName:'pm.all.min',
@@ -75,7 +75,7 @@ let pmOptions={
 
 let mainOptions={
     version:version,
-    scriptsDest:'web/dest/scripts',
+    scriptsDest:scriptsDest,
     jspaths:main_jspaths,
     csspaths:main_csspaths,
     concatName:'main.all.min',
@@ -89,7 +89,7 @@ let mainOptions={
 
 let compleGljOptions = {
     version: version,
-    scriptsDest: 'web/dest/scripts',
+    scriptsDest: scriptsDest,
     jspaths: compleGlj_jspaths,
     csspaths: compleGlj_csspaths,
     concatName: 'compleGlj.all.min',
@@ -105,7 +105,7 @@ let compleGljOptions = {
 
 let compleRation_rationOptions = {
     version: version,
-    scriptsDest: 'web/dest/scripts',
+    scriptsDest: scriptsDest,
     jspaths: compleRation_ration_jspaths,
     csspaths: compleRation_ration_csspaths,
     concatName: 'compleRation_ration.all.min',
@@ -122,7 +122,7 @@ let compleRation_rationOptions = {
 
 let compleRation_gljOptions = {
     version: version,
-    scriptsDest: 'web/dest/scripts',
+    scriptsDest: scriptsDest,
     jspaths: compleRation_glj_jspaths,
     csspaths: compleRation_glj_csspaths,
     concatName: 'compleRation_glj.all.min',
@@ -139,7 +139,7 @@ let compleRation_gljOptions = {
 
 let compleRation_coeOptions = {
     version: version,
-    scriptsDest: 'web/dest/scripts',
+    scriptsDest: scriptsDest,
     jspaths: compleRation_coe_jspaths,
     csspaths: compleRation_coe_csspaths,
     concatName: 'compleRation_coe.all.min',
@@ -156,7 +156,7 @@ let compleRation_coeOptions = {
 
 let compleRation_instOptions = {
     version: version,
-    scriptsDest: 'web/dest/scripts',
+    scriptsDest: scriptsDest,
     jspaths: compleRation_inst_jspaths,
     csspaths: compleRation_inst_csspaths,
     concatName: 'compleRation_inst.all.min',
@@ -364,6 +364,17 @@ gulp.task('compleRation_inst', ['compleRation_inst_inject'], function () {
     return htmlmin(compleRation_instOptions);
 });
 
+gulp.task('unitPrice_minify', function (){
+  return minify(unitPriceOptions);
+});
+
+gulp.task('unitPrice_inject',['unitPrice_minify'],function (){
+  return inject(unitPriceOptions);
+})
+
+gulp.task('unit_price',['unitPrice_inject'], function (){
+  return htmlmin(unitPriceOptions);
+});
 
 
-gulp.task('build',['header','login','pm','main', 'compleGlj', 'compleRation_ration', 'compleRation_glj', 'compleRation_coe', 'compleRation_inst']);
+gulp.task('build',['header','login','pm','main', 'compleGlj', 'compleRation_ration', 'compleRation_glj', 'compleRation_coe', 'compleRation_inst','unit_price']);

+ 4 - 1
modules/all_models/unit_price_file.js

@@ -11,7 +11,10 @@ let Schema = mongoose.Schema;
 let collectionName = 'unit_price_file';
 let modelSchema = {
     // 自增id
-    id: Number,
+    id: {
+      type: Number,
+      index: true
+    },
     // 标段id
     project_id: {
         type: Number,

+ 4 - 0
modules/glj/controllers/glj_controller.js

@@ -230,6 +230,10 @@ class GLJController extends BaseController {
      * @return {void}
      */
     async deleteMixRatio(request, response) {
+        if(request.body.data){
+          let data = request.body.data;
+          request.body = JSON.parse(data);
+        }
         let id = request.body.id;
         id = parseInt(id);
         let responseData = {

+ 17 - 34
modules/glj/models/glj_list_model.js

@@ -11,13 +11,12 @@ import CounterModel from "./counter_model";
 import UnitPriceModel from "./unit_price_model";
 import UnitPriceFileModel from "./unit_price_file_model";
 import GLJTypeConst from "../../common/const/glj_type_const";
-import RationGLJFacade from "../../ration_glj/facade/ration_glj_facade";
 import STDGLJLibGLJListModel from "../../common/std/std_glj_lib_glj_list_model";
 import MixRatioModel from "./mix_ratio_model";
 import GljModel from "../../complementary_glj_lib/models/gljModel";
 const ProjectModel = require('../../pm/models/project_model').project;
 const scMathUtil = require('../../../public/scMathUtil').getUtil();
-import decimal_facade from "../../main/facade/decimal_facade";
+import unitPriceFacade from "../../unit_price_file/facade/unit_price_facade";
 let gljCollectionName = 'glj_list';
 let GLJSchemas = mongoose.model(gljCollectionName);
 let _ = require("lodash");
@@ -90,7 +89,7 @@ class GLJListModel extends BaseModel {
             // 首先获取对应标段下所有的项目工料机数据
             let condition = {project_id: projectId};
             let fields = {_id: 0};
-            gljData = await this.db.find(condition, fields);
+            gljData = await this.model.find(condition, fields).lean();
             // 没有数据则直接返回空
             if (gljData.length <= 0) {
                 throw '无数据';
@@ -99,35 +98,19 @@ class GLJListModel extends BaseModel {
             // 获取标段设置的单价文件数据
             let unitPriceModel = new UnitPriceModel();
             unitPriceList = await unitPriceModel.getDataByFileId(unitPriceFileId);
-            // 整理获取工料机ID list
-            let gljIdList = [];
-            for(let tmp of gljData) {
-                gljIdList.push(tmp.id);
-                let c_key = this.getIndex(tmp,['code','name','specs','unit','type']);
-                keyMap[tmp.id] = c_key; //工料机ID和连接key的对照表;
-            }
-            // 从定额工料机库中获取消耗量
-            condition = {
-                projectID: projectId
-               // projectGLJIDList: gljIdList 这里是取所有项目工料机,所以也是取所有定额工料机,不需要根据项目工料机ID再过滤
-            };
-            //为了提高性成计算消耗量功能改成了在前端计算
-            // 整理获取有组成物的项目工料机的数据
             let connect_keys = [];
             for(let tmp of gljData) {
-                // 有组成物的类型才查找
-                let key = keyMap[tmp.id];
+                let c_key = this.getIndex(tmp,['code','name','specs','unit','type']);
                 if(this.ownCompositionTypes.indexOf(tmp.type)!=-1){
-                    connect_keys.push(key);
-                }
-                /*if (tmp.type === GLJTypeConst.CONCRETE || tmp.type === GLJTypeConst.MORTAR ||
-                    tmp.type === GLJTypeConst.MIX_RATIO || tmp.type === GLJTypeConst.GENERAL_MACHINE|| tmp.type === GLJTypeConst.MAIN_MATERIAL){
-                    connect_keys.push(key);
-                }*/
+                  connect_keys.push(c_key);
+               }
+               keyMap[c_key] = tmp; //项目工料机连接key和工料机的对照表;
             }
+        
             // 查找组成物的消耗量
             let totalComposition = {};
             let mixRatioData = {};
+            let missMaxRatio = [];//由于共享单价文件,单价文件编辑器造成的,存在组成物和对应的单价,但是项目工料机不存的情况
             if (connect_keys.length > 0) {
                 let mixRatioModel = new MixRatioModel();
                 condition = {connect_key: {"$in": connect_keys}, unit_price_file_id: unitPriceFileId};
@@ -135,15 +118,6 @@ class GLJListModel extends BaseModel {
                 for (let tmp of mixRatioList) {
                    let t_index = tmp.connect_key;
                    let m_index = this.getIndex(tmp,['code','name','specs','unit','type']);
-                   /*
-                    let consumption=parseFloat(tmp.consumption);
-                    let r_quantity = quantityList[t_index]?quantityList[t_index]:0;
-                   if(quantityList[m_index]!==undefined){
-                       quantityList[m_index]=quantityList[m_index]+r_quantity*consumption;
-                   }else {
-                       quantityList[m_index] = r_quantity*consumption;
-                   }
-                    quantityList[m_index] = scMathUtil.roundTo(quantityList[m_index],-quantity_decimal);*/
                     if (mixRatioData[t_index] !== undefined) {
                         mixRatioData[t_index].push(tmp);
                     } else {
@@ -159,8 +133,17 @@ class GLJListModel extends BaseModel {
                     } else {
                         mixRatioConnectData[m_index] = [tmp.connect_key];
                     }
+                    //检查该组成物对应的项目工料机是否存在  
+                    if(!keyMap[m_index]) missMaxRatio.push(tmp);//这里可能会有重复,但是后面的添加操作中会去重 
                 }
             }
+
+            if(missMaxRatio.length > 0){
+              let newList =  await unitPriceFacade.getNewProjectGLJFromMissMixratio(projectId,missMaxRatio,keyMap,[]);
+              await unitPriceFacade.setIDfromCounter("glj_list",newList);
+              await this.model.insertMany(newList);
+              gljData=gljData.concat(newList);         
+            }
             // 组合单价数据
             gljData = this.combineData(gljData, unitPriceList, {}, mixRatioData, totalComposition);
             // 排序

+ 12 - 8
modules/glj/models/unit_price_model.js

@@ -294,24 +294,28 @@ class UnitPriceModel extends BaseModel {
         let tasks = [];
         let parentTask = [];
         let newValueMap = {};
+        let needCheckDatas= [];
         for(let d of data){//第一次循环生成更新提交的记录,并生成一个新值的映射表,为更新父节点使用
             let condition = {id:d.unit_price.id,unit_price_file_id:d.unit_price.unit_price_file_id};
-            let doc = {};
-            doc[d.field]=d.newval;
-            newValueMap[d.unit_price.id] = doc;
+            let doc = d.ext?d.ext:{};
+            if(d.field){//共用接口后有可能只更新其它属性,不更新价格
+              doc[d.field]=d.newval;
+              newValueMap[d.unit_price.id] = doc;
+              needCheckDatas.push(d);
+            }
             tasks.push(this.generateUpdateTask(condition,doc));
         }
-        for(let d of data){//第二次更新父节点
-           let rList = await this.checkAndUpdateParent(d.unit_price,d.field,d.project_id,newValueMap,true);
-           parentTask = parentTask.concat(rList);
-        }
+        for(let d of needCheckDatas){//第二次更新父节点
+          let rList = await this.checkAndUpdateParent(d.unit_price,d.field,d.project_id,newValueMap,true);
+          parentTask = parentTask.concat(rList);
+       }
         tasks = tasks.concat(parentTask);
         tasks.length>0?this.model.bulkWrite(tasks):'';
         return parentTask;
     }
 
     async updateParentUnitPrice(mixRatio,fieid,project_id,newValueMap,batchUpdate){//batchUpdate 批量更新标记,如果true,只生成task
-        let  decimalObject =await decimal_facade.getProjectDecimal(project_id);
+        let  decimalObject =project_id?await decimal_facade.getProjectDecimal(project_id):null
         let quantity_decimal = (decimalObject&&decimalObject.glj&&decimalObject.glj.quantity)?decimalObject.glj.quantity:3;
         let price_decimal = (decimalObject&&decimalObject.glj&&decimalObject.glj.unitPrice)?decimalObject.glj.unitPrice:2;
         //查找该工料机所有组成物

+ 1 - 1
modules/pm/models/project_model.js

@@ -677,7 +677,7 @@ ProjectsDAO.prototype.getTenderByUnitPriceFileId = async function (unitPriceFile
 
     //let condition = {projType: 'Tender', "property.unitPriceFile.id": unitPriceFileId};
     let condition = {"property.unitPriceFile.id": unitPriceFileId,deleteInfo:null};
-    result = await Projects.find(condition,['name','property']);
+    result = await Projects.find(condition,['ID','name','property']);
 
     return result;
 };

+ 10 - 1
public/web/gljUtil.js

@@ -595,13 +595,22 @@ let gljUtil = {
     },
     setProperty:function(Obj,updateData) {
         for(let ukey in updateData){
-            if(_.isObject(updateData[ukey]) && _.isObject(Obj[ukey])){
+            if(_.isObject(updateData[ukey]) && _.isObject(Obj[ukey])&&!_.isArray(updateData[ukey])){
                 setProperty(Obj[ukey],updateData[ukey]);
             }else {
                 Obj[ukey] = updateData[ukey];
             }
         }
     },
+    sortProjectGLJ:function(jsonData) {
+      if (jsonData.length > 0) {
+          jsonData = _.sortByAll(jsonData, [function (item) {
+            let unit_price = item.unit_price?item.unit_price:item;
+            return _.indexOf(gljTypeSeq,unit_price.type);
+          }, 'code']);
+      }
+      return jsonData
+  },
     fixedFlag : {
         // 分部分项工程
         SUB_ENGINERRING: 1,

+ 8 - 4
public/web/socket/connection.js

@@ -15,11 +15,15 @@ socketObject={
               me.roomInfo={
                   userID:userID
               };
+          }else if(from == 'unitPrice'){
+            me.roomInfo = {
+              unitFile:unitPriceFileID
+            }
           }else {
-              me.roomInfo={
-                  feeRate:me.getFeeRateRoomID(),
-                  unitFile:me.getUnitFileRoomID()
-              };
+            me.roomInfo={
+                feeRate:me.getFeeRateRoomID(),
+                unitFile:me.getUnitFileRoomID()
+            };
           }
           socket.emit('join', me.roomInfo);
           if(me.messages.length > 0){//发送缓存消息;

+ 5 - 0
web/building_saas/css/custom.css

@@ -472,4 +472,9 @@ input.text-right{
 .poj-list {
     height: 1000px; 
     background: #f7f7f9;
+}
+.unit_price_header{
+  padding-top:6px;
+  margin-left: 50px;
+  margin-right: 100px !important;
 }

+ 11 - 1
web/building_saas/css/style.css

@@ -1,4 +1,6 @@
-/*
+
+*/
+/*
 01 -  Global styles
 */
 html,
@@ -101,6 +103,14 @@ background-color: #f5f5f5;
 color: #000000;
 font-size: 18px;
 }
+.btn-danger{
+  background: #ff6501;
+  border-color: #ff6501;
+}
+.btn-danger:hover{
+  background-color: #d95e0e;
+  border-color: #d95e0e;
+}
 /*02 Header*/
 div#header-sticky-wrapper {
 position: absolute;

+ 3 - 1
web/building_saas/glj/html/project_glj.html

@@ -7,7 +7,9 @@
     <div class="form-inline py-1">
         <label class="mx-2">使用单价文件:<span id="current-name"></span>(<label class="a_color" id="pop-used-list" data-original-title="" title="">与<span id="used-project-count">0</span>个单位工程同步</label>)
             <a class="btn btn-sm ml-1" href="#" data-toggle="modal" data-target="#change-unitFile"><i class="fa fa-exchange"></i> 选择其他</a>
-            <a class="btn btn-sm ml-1" href="#" data-toggle="modal" data-target="#unitFile-save-as"><i class="fa fa-files-o"></i> 另存单独用</a></label>
+            <a class="btn btn-sm ml-1" href="#" data-toggle="modal" data-target="#unitFile-save-as"><i class="fa fa-files-o"></i> 另存单独用</a>
+            <a class="btn btn-sm ml-1" id="editUnitFile" href="/unitPrice/index/123" target="_"> 编辑单价文件</a>
+        </label>
         <select class="form-control form-control-sm" style="width: auto; font-size: .875rem ;color: #007bff" id="adjustType">
             <option value="priceInfo" selected>造价信息差额调整法</option>
             <option value="priceCoe">价格指数调整法</option>

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

@@ -529,7 +529,7 @@ let ration_glj = {
                     : 'complementaryGLJs';
                 const newData = data[gljType];
                 // 添加组成物,类型为主材时,需要排除自身
-                if (actionType === 'addMix' && projectGljObject.selectedProjectGLJ.type === gljType.MAIN_MATERIAL) {
+                if ((actionType === 'addMix' || actionType === 'unitPriceAddMix') && 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) {

+ 33 - 28
web/building_saas/main/js/views/glj_view.js

@@ -390,35 +390,38 @@ var gljOprObj = {
         }
     },
     onCheckBoxClick: function (sender, args) {
+      if(typeof projectObj != 'undefined'){  
         let selected = projectObj.project.mainTree.selected;
         if(selected.sourceType == ModuleNames.ration_glj){//选中的是工料机时不可编辑
             return ;
         }
-        let checkboxValue = args.sheet.getCell(args.row, args.col).value();
-        if(args.sheetName == 'rationInstallSheet' && checkboxValue){
-            return;
-        }
         if(gljOprObj.isInstallationNode(selected)==true || OVER_HEIGHT.isOverHeight(selected)){
-            return;
-        }
-        let newval = checkboxValue? 0:1;
-        args.sheet.getCell(args.row, args.col).value(newval);
-        if (args.sheetName == 'ration_glj') {
-            gljOprObj.updateIsEstimate(args,newval);
-        }  else if (args.sheetName == 'quantity_detail') {
-            projectObj.project.quantity_detail.isSummationUpdate(args, gljOprObj.detailData, newval);
-        } else if (args.sheetName == 'glj_lib') {
-            if (gljOprObj.gljLibSheetSetting.header[args.col].readOnly) {
-                args.sheet.getCell(args.row, args.col).value(checkboxValue);
-                return;
-            }
-            if(gljOprObj.gljLibSheetSetting.header[args.col].dataCode === 'select'){
-                gljOprObj.setGLJSelection(args, newval);
-            }
-        }else if(args.sheetName == 'rationInstallSheet'){
-            args.newValue = newval;
-            installationFeeObj.onRationInstallValueChange(sender,args);
+          return;
         }
+      }
+
+      let checkboxValue = args.sheet.getCell(args.row, args.col).value();
+      if(args.sheetName == 'rationInstallSheet' && checkboxValue){
+          return;
+      }
+      let newval = checkboxValue? 0:1;
+      args.sheet.getCell(args.row, args.col).value(newval);
+      if (args.sheetName == 'ration_glj') {
+          gljOprObj.updateIsEstimate(args,newval);
+      }  else if (args.sheetName == 'quantity_detail') {
+          projectObj.project.quantity_detail.isSummationUpdate(args, gljOprObj.detailData, newval);
+      } else if (args.sheetName == 'glj_lib') {
+          if (gljOprObj.gljLibSheetSetting.header[args.col].readOnly) {
+              args.sheet.getCell(args.row, args.col).value(checkboxValue);
+              return;
+          }
+          if(gljOprObj.gljLibSheetSetting.header[args.col].dataCode === 'select'){
+              gljOprObj.setGLJSelection(args, newval);
+          }
+      }else if(args.sheetName == 'rationInstallSheet'){
+          args.newValue = newval;
+          installationFeeObj.onRationInstallValueChange(sender,args);
+      }
     },
     onCellDoubleClick:function (sender, args) {
         // 含组成物的材料市场价改为只读,改为双击无反应不提示
@@ -1183,7 +1186,7 @@ var gljOprObj = {
                 unit: selected.unit,
                 gljType: selected.type
             };
-        } else if (actionType === 'addMix') {
+        } else if (actionType === 'addMix'|| actionType === 'unitPriceAddMix') {
             condition.queryExtend = projectGljObject.getQueryExtForMixRatio();
         }
         if (init) {
@@ -1222,7 +1225,7 @@ var gljOprObj = {
         }
         if ($('#actionType').val() == 'replace' || $('#actionType').val() == 'm_replace') {
             me.filterLibGLJByType();
-        }else if($('#actionType').val() == 'addMix'){
+        }else if($('#actionType').val() == 'addMix' || $('#actionType').val() == 'unitPriceAddMix'){
             projectGljObject.filterLibGLJForMixRatio();
         }
         //文本筛选
@@ -1245,7 +1248,7 @@ var gljOprObj = {
         }
     },
     setGLJSelection: function (args, newVal) {
-        if ($('#actionType').val() == 'add' || $('#actionType').val() == 'insert'|| $('#actionType').val() == 'addMix') {
+        if ($('#actionType').val() == 'add' || $('#actionType').val() == 'insert'|| $('#actionType').val() == 'addMix'|| $('#actionType').val() == 'unitPriceAddMix') {
             this.addGLJsSelection(args, newVal);
         } else {
             this.replaceGLJSelection(args, newVal);
@@ -1754,7 +1757,7 @@ $(function () {
             selected,
             connect_key;
         const actionType = $('#actionType').val();
-        const addActions = ['add', 'insert', 'addMix'];
+        const addActions = ['add', 'insert', 'addMix','unitPriceAddMix'];
         const replaceActions = ['m_replace', 'replace'];
         if (addActions.includes(actionType)) {//插入,添加,添加组成物(项目人材机页面)
             gljOprObj.GLJSelection = [];
@@ -1778,7 +1781,7 @@ $(function () {
             gljOprObj.gljLibSheet.setActiveCell(index, 0);
             gljOprObj.initSelection({row: index});
             gljOprObj.gljLibSpresd.focus(true);
-        } else if (actionType === 'add' || actionType === 'addMix') {
+        } else if (actionType === 'add' || actionType === 'addMix'|| actionType === 'unitPriceAddMix') {
             gljOprObj.locateZTree(null);
             sheetCommonObj.appendData(gljOprObj.gljLibSheet, 0, 0, gljOprObj.gljLibSheetSetting, gljOprObj.AllRecode);
             gljOprObj.gljLibSheet.showRow(0, GC.Spread.Sheets.VerticalPosition.top);
@@ -1824,6 +1827,8 @@ $(function () {
             gljOprObj.doMReplaceGLJ();
         }else if($('#actionType').val() == 'addMix'){
             projectGljObject.addMixRatio();
+        }else if($('#actionType').val() == 'unitPriceAddMix'){
+          unitPriceObj.addMixRatio();
         }
         $("#glj_tree_div").modal('hide');
     })

+ 3 - 2
web/building_saas/main/js/views/glj_view_contextMenu.js

@@ -435,7 +435,7 @@ var gljContextMenu = {
     }
 }
 
-function getGLJData(actionType) {
+function getGLJData(actionType,getLibFunc) {
     $('#actionType').val(actionType);
     // 清除选中人材机缓存数据
     gljOprObj.GLJSelection = [];
@@ -450,7 +450,8 @@ function getGLJData(actionType) {
     const reset = true;
     const condition = gljOprObj.getPagingCondition(init, reset, location, 0);
     console.time('getGLJData');
-    projectObj.project.ration_glj.getGLJDataPaging(condition, function (result) {
+    if(!getLibFunc)getLibFunc = projectObj.project.ration_glj.getGLJDataPaging;
+    getLibFunc(condition, function (result) {
         gljOprObj.initClassTree('std', gljOprObj.treeData.std);
         $('#modalCon').width($(window).width()*0.5);
         $("input[name='glj']").get(0).checked=true;

+ 6 - 6
web/building_saas/main/js/views/options_view.js

@@ -10,7 +10,7 @@ let optionsOprObj = {
         let me = this;
         me.options = projectOptins;
         let gOpts = me.options[me.optionsTypes.GENERALOPTS];
-        if(isDef(gOpts)){
+        if(gljUtil.isDef(gOpts)){
             for(let attr in gOpts){
                 me[attr].prop('checked', gOpts[attr]);
             }
@@ -24,19 +24,19 @@ let optionsOprObj = {
     },
     //更新optionsOprObj对象options数据
     updateOptions: function (options, updateObj) {
-        if(isDef(options[updateObj.type])){
+        if(gljUtil.isDef(options[updateObj.type])){
             options[updateObj.type][updateObj.opt] = updateObj.value;
         }
     },
     getOptsByType: function (options, type) {
-        return isDef(options[type]) ? options[type] : null;
+        return gljUtil.isDef(options[type]) ? options[type] : null;
     },
     getOption: function (type, optionName) {
-        if(!isDef(optionName)){
-            return isDef(this.options[type]) ? this.options[type] : null;
+        if(!gljUtil.isDef(optionName)){
+            return this.options&&gljUtil.isDef(this.options[type]) ? this.options[type] : null;
         }
         else {
-            return isDef(this.options[type][optionName])
+            return this.options&&gljUtil.isDef(this.options[type][optionName])
                 ? this.options[type][optionName]
                     : optionName === this.optionsTypes.GENERALOPTS
                     ? true

+ 90 - 47
web/building_saas/main/js/views/project_glj_view.js

@@ -135,6 +135,7 @@ let projectGljObject={
         $("#current-name").text(me.usedUnitPriceInfo.name);
         let usedCount = me.usedTenderList.length <= 0 ? 1 : me.usedTenderList.length;
         $("#used-project-count").text(usedCount);
+        $("#editUnitFile").attr("href",`/unitPrice/index/${me.usedUnitPriceInfo.id}`)
     },
     getUsedTenderInfo:function() {
         return "人材机单价的变化,将自动影响以下单位工程造价:<br>"+projectGljObject.usedTenderList.join("<br>");
@@ -177,7 +178,7 @@ let projectGljObject={
             });
         }
     },
-    addMixRatio:function () {
+    addMixRatio:async function () {
         let me = this, projectGLJ = projectObj.project.projectGLJ;
         let tdatas = me.mixRatioData;
         if(me.subList.length > 0) tdatas = me.subList;
@@ -186,15 +187,85 @@ let projectGljObject={
             let t_index = gljOprObj.GLJSelection.indexOf(m_key);
             t_index != -1?gljOprObj.GLJSelection.splice(t_index,1):'';
         }
-        projectGLJ.addMixRatio(gljOprObj.GLJSelection,function (mixRatios) {
-            me.showMixRatioData();//这里添加的组成物的消耗量默认都是0,所以对父工料机的价格不会有影响,不用触发计算
-            projectGLJ.loadData(function () {
-                me.showProjectGljData();
-                gljOprObj.showRationGLJSheetData();
-                me.onUnitFileChange(me.selectedProjectGLJ);
-            });
+        await me.addMixRatioFromLib(gljOprObj.GLJSelection,()=>{
+          me.showMixRatioData();//这里添加的组成物的消耗量默认都是0,所以对父工料机的价格不会有影响,不用触发计算
+          projectGLJ.loadData(function () {
+              me.showProjectGljData();
+              gljOprObj.showRationGLJSheetData();
+              me.onUnitFileChange(me.selectedProjectGLJ);
+          });
         });
     },
+    addMixRatioFromLib:async function(selections,callback){
+      let gljList = [],allGLJ = gljOprObj.AllRecode;
+      let url = "/glj/add-ratio";
+      let result = null;
+      if(selections.length == 0) {
+          return;
+      }
+      try {
+        for(let glj of allGLJ){
+        let i_key = gljUtil.getIndex(glj,gljLibKeyArray);
+        if(_.includes(selections,i_key)){
+            let pglj = {
+                glj_id: glj.ID,
+                name: glj.name,
+                code: glj.code,
+                original_code: glj.code,
+                unit: glj.unit,
+                specs: glj.specs,
+                base_price: glj.basePrice,
+                market_price: glj.basePrice,
+                shortName: glj.shortName,
+                type: glj.gljType,
+                model:glj.model,
+                adjCoe: glj.adjCoe,
+                from:'std',
+                repositoryId:glj.repositoryId,
+                materialType:glj.materialType,
+                materialCoe:glj.materialCoe,
+                grossWeightCoe:glj.grossWeightCoe,
+                purchaseStorageRate:glj.purchaseStorageRate,
+                offSiteTransportLossRate:glj.offSiteTransportLossRate,
+                handlingLossRate:glj.handlingLossRate
+            };
+            if(typeof projectObj !== 'undefined')  pglj.project_id = projectObj.project.ID();
+            if (glj.hasOwnProperty("compilationId")) {
+                pglj.from = "cpt";
+                if (glj.code.indexOf('-') != -1) {//这条工料机是用户通过修改名称、规格、型号等保存到补充工料机库的
+                    pglj.original_code = glj.code.split('-')[0];//取-前的编号作为原始编号
+                }
+            }
+            gljList.push(pglj);
+          }
+        }
+        gljList = _.sortByAll(gljList, ['type', 'code']);
+        if(gljList.length == 0) return;
+        let parentInfo ={};
+        if(typeof unitPriceObj !== 'undefined'){
+          url = "/unitPrice/addMixRatio";
+          pdata = unitPriceObj.getSelectedUnitPrice();
+          parentInfo = {
+            unit_price_file_id:pdata.unit_price_file_id,
+            connect_key:gljUtil.getIndex(pdata)
+          };
+        }else{
+          parentInfo = {
+            unit_price_file_id:projectObj.project.property.unitPriceFile.id,
+            connect_key:gljOprObj.getIndex(projectGljObject.selectedProjectGLJ,gljKeyArray)
+          };
+        }
+
+        $.bootstrapLoading.start();
+        result= await ajaxPost(url,{gljList:gljList,parentInfo:parentInfo})
+        if(callback) callback(result);
+      } catch (error) {
+        alert(error);
+        console.log(error);
+      }
+      $.bootstrapLoading.end();
+      return result;
+    },
     showMixRatioData:function () {
         let me = this,gljId = null,gljType = null;
         if(!me.projectGljSpread) return;
@@ -313,9 +384,11 @@ let projectGljObject={
           let style = gljOprObj.getSelStyle(true,{});
           me.projectGljSheet.setStyle(newSel.row, -1, style);
           let orow = oldSel.row==''||oldSel.row==-1?0:oldSel.row;
-          let tstyle = gljOprObj.getSelStyle(false,{},me.projectGljSheetData[orow].bgColour);
-          me.projectGljSheet.setStyle(orow, -1, tstyle);
-          me.projectGljRowChang();
+          if(me.projectGljSheetData[orow]){
+            let tstyle = gljOprObj.getSelStyle(false,{},me.projectGljSheetData[orow].bgColour);
+            me.projectGljSheet.setStyle(orow, -1, tstyle);
+            me.projectGljRowChang();
+          }
         }else{
           me.projectGljSheet.repaint();
         }
@@ -376,14 +449,15 @@ let projectGljObject={
         let me = projectGljObject;
         let canChange = true;
         let changeInfo=[];
-        if (info.action == GC.Spread.Sheets.RangeChangedAction.clear) {
+       /*  if (info.action == GC.Spread.Sheets.RangeChangedAction.clear) {
             info.newValue = 0;
             me.onMixRatioValueChange(sender,info);
             info.sheet.getCell(info.row, info.col).text(0);
             return ;
-        }
+        } */
         for(let c of info.changedCells){
             let value = info.sheet.getCell(c.row, c.col).text();
+            if(_.isEmpty(value)) value = 0;
             if (!me.checkData(c.col,me.mixRatioSetting,value)) {
                 alert('输入的数据类型不对,请重新输入!');
                 canChange = false;
@@ -392,12 +466,8 @@ let projectGljObject={
                 changeInfo.push({row:c.row,col:c.col,value:value});
             }
         }
-        if(canChange == false){//数据类型不对
-            me.showMixRatioData();
-        }
-        if(changeInfo.length > 0){
-            me.batchUpdateConsumption(changeInfo);
-        }
+        if(canChange == false) me.showMixRatioData(); //数据类型不对
+        if(changeInfo.length > 0) me.batchUpdateConsumption(changeInfo);
     },
     batchUpdateProjectGLJ:function(changeInfo,sheetName){
         let projectGLJ = projectObj.project.projectGLJ;
@@ -822,18 +892,7 @@ let projectGljObject={
             return false;
         }
         value = scMathUtil.roundToString(value,getDecimal("glj.quantity"));
-        let [parentMarketPrice, parentBasePrice] = me.getCompositionSumPrice('modify', row, value);
-        let updateData ={id: recode.mix_ratio_id, field: 'mix_ratio.' + dataCode, value: value, market_price: parentMarketPrice, base_price: parentBasePrice};
-        let prow = parentSheet.getActiveRowIndex();//取父机械或组成物的下标
-        let prowData = parentSheet.name() == 'projectGljSheet'?me.projectGljSheetData[prow]:me.materialTree.items[prow].data;
-        composition.updateConsumption(updateData,recode,prowData.id,function (sid) {
-            /* if(parentSheet.name() == 'projectGljSheet'){ 之前是单行刷新,父工料机与组成物对应的工料机分开刷,发现这样比整个刷新慢所以先整个刷新,当以后数据量大的时候再测试
-             me.refreshProjectGljRowByID(sid);
-             }*/
-            projectObj.project.projectGLJ.calcQuantity();
-            me.refreshParentData(prow,prowData.id,sid);
-            me.onUnitFileChange(recode);
-        });
+        me.batchUpdateConsumption([{row:row,col:col,value}]);
     },
     refreshParentData:function (row,pid,sid) {
         let me = this;
@@ -1035,22 +1094,6 @@ let projectGljObject={
     },
     checkData : function(col,setting, value) {
         return sheetCommonObj.checkData(col,setting, value);
-     /*   let result = true;
-        let validator = setting.header[col].validator !== undefined ? setting.header[col].validator : null;
-        if (validator === null) {
-            return result;
-        }
-        switch (validator) {
-            case 'number':
-                let regular = /^\d+(\.\d+)?$/;
-                result = regular.test(value);
-                break;
-            case 'boolean':
-                let booleanValue = [true, false];
-                result = booleanValue.indexOf(value) >= 0;
-                break;
-        }
-        return result;*/
     },
     getProjectGLJSelected:function () {
         let me = projectGljObject;

+ 2 - 1
web/building_saas/pm/js/pm_newMain.js

@@ -4529,7 +4529,8 @@ function set_file_table(target, poj_tenders, fileList, type){
         let fileId = type === fileType.unitPriceFile ? fileList[i].id : fileList[i].ID;
         let usedObj = getUsedObj(poj_tenders, fileId, type);
         let usedHtml = usedObj.usedCount > 0 ?  '<td class="text-center"><a href="javascript:void(0);">' + usedObj.usedCount + '</a></td>' : '<td class="text-center">' + usedObj.usedCount + '</td>';
-        let hoverHtml = '<p style="display: none; height: 14px;"><a class="btn btn-sm" href="javascript:void(0);" data-toggle="modal" data-target="#del-wj">删除</a><a class="btn btn-sm" href="javascript:void(0);">重命名</a></p></div>';
+        let unitPriceEditHtml = type === fileType.unitPriceFile? `<a class="btn btn-sm" href="/unitPrice/index/${fileId}" target="_">编辑</a>`:"";
+        let hoverHtml = `<p style="display: none; height: 14px;"><a class="btn btn-sm" href="javascript:void(0);" data-toggle="modal" data-target="#del-wj">删除</a><a class="btn btn-sm" href="javascript:void(0);">重命名</a>${unitPriceEditHtml}</p></div>`;
         let renHtml = '<div class="input-group" style="display: none;">'
             + '<input class="form-control form-control-sm" value="">'
 

+ 8 - 8
web/users/html/index.html

@@ -8,7 +8,7 @@
       <link rel="stylesheet" href="/lib/bootstrap/css/bootstrap.min.css">
       <link rel="stylesheet" href="/web/building_saas/css/all.css">
       <link rel="stylesheet" href="/web/building_saas/css/style.css">
-      <title>大司空云计价 - 正版软件永久免费</title>
+      <title>大司空云计价 - 远程办公,用免费正版市政计价软件</title>
       <link rel="shortcut icon" href="/web/building_saas/css/favicon.ico" />
    </head>
    <body>
@@ -20,10 +20,10 @@
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarLexar" aria-controls="navbarLexar" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
                </button>
-               <div class="collapse navbar-collapse" id="navbarLexar">      
+               <div class="collapse navbar-collapse" id="navbarLexar">
                <ul class="navbar-nav ml-auto">
                      <li class="nav-item active">
-                        <a class="btn btn-primary my-3" href="/login">登录软件</a>
+                        <a class="btn btn-danger my-3" href="/login">登录软件</a>
                      </li>
                   </ul>
                </div>
@@ -35,10 +35,10 @@
          <div class="container text-center">
             <h1 class="text-white mb-4 f-50 ">大司空市政云计价,正版软件永久免费</h1>
             <p class="lead text-white mb-5">跨平台,打开浏览器即可使用,全新在线计价体验。
-            <!-- <div class="btn_hero mb-5">
-               <a href="#" class="btn btn-primary btn-round mr-2">GET THIS APP</a>
-               <a href="#" class="btn btn-outline-primary btn-round ml-2">TRY IT FOR FREE</a>
-            </div> -->
+            <div class="btn_hero">
+               <a href="/login" class="btn btn-danger mr-2">登录软件</a>
+               <a href="https://smartcost.com.cn/contact2" target="_blank" class="btn btn-primary ml-2">联系客服</a>
+            </div>
             <div class="home-desk mt-5">
                <div class="container pt-5">
                   <img src="/web/users/images/home-desk.png" alt="" class="img-fluid mx-auto  d-block">
@@ -351,7 +351,7 @@
                      <div class="footer_bottom text-center">
                         Copyright@珠海纵横创新软件有限公司 all rights reserved <a href="http://www.miitbeian.gov.cn" target="_blank">粤ICP备14032472号</a>
                      </div>
-                     <div style="position:fixed;right:-100px"><script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? "https://" : "http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1278513319'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "v1.cnzz.com/stat.php%3Fid%3D1278513319%26show%3Dpic1' type='text/javascript'%3E%3C/script%3E"));</script></div>
+                     <div><script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? "https://" : "http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1278513319'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "v1.cnzz.com/stat.php%3Fid%3D1278513319%26show%3Dpic1' type='text/javascript'%3E%3C/script%3E"));</script></div>
                   </div>
                </div>
             </div>