zhongzewei 7 éve
szülő
commit
858254431d

+ 0 - 1
modules/complementary_glj_lib/controllers/gljController.js

@@ -13,7 +13,6 @@ let callback = function(req, res, err, message, data){
 
 class GljController extends BaseController{
     async redirectGlj(req, res){
-        console.log(req.s)
         let gljLibId = null, engineeringId, sessionCompilation = req.session.sessionCompilation,
             rationValuation = sessionCompilation.ration_valuation,
             billValuation = sessionCompilation.bill_valuation,

+ 1 - 1
modules/ration_repository/controllers/ration_controller.js

@@ -2,7 +2,7 @@
  * Created by Tony on 2017/5/2.
  */
 
-var rationItem = require('../models/ration_item');
+var rationItem = require('../models/ration_item').Dao;
 var callback = function(req, res, err, message, data){
     res.json({error: err, message: message, data: data});
 };

+ 1 - 1
modules/ration_repository/controllers/ration_repository_controller.js

@@ -1,7 +1,7 @@
 /**
  * Created by Tony on 2017/4/20.
  */
-var rationRepository = require("../models/repository_map");
+var rationRepository = require("../models/repository_map").Dao;
 
 var callback = function(req, res, err, message, data){
     res.json({error: err, message: message, data: data});

+ 1 - 1
modules/ration_repository/controllers/ration_section_tree_controller.js

@@ -2,7 +2,7 @@
  * Created by Tony on 2017/4/21.
  */
 
-var rationChapterTreeData = require('../models/ration_section_tree');
+var rationChapterTreeData = require('../models/ration_section_tree').Dao;
 var callback = function(req,res,err,message, data){
     res.json({error: err, message: message, data: data});
 }

+ 2 - 2
modules/ration_repository/controllers/search_controller.js

@@ -1,8 +1,8 @@
 /**
  * Created by Mai on 2017/6/5.
  */
-var rationItem = require('../models/ration_item');
-let rationChapter = require('../models/ration_section_tree');
+var rationItem = require('../models/ration_item').Dao;;
+let rationChapter = require('../models/ration_section_tree').Dao;
 let asyncTool = require('async');
 var callback = function(req, res, err, message, data){
     res.json({error: err, message: message, data: data});

+ 1 - 1
modules/ration_repository/models/glj_repository.js

@@ -33,7 +33,7 @@ var gljSchema = mongoose.Schema({
 });
 var gljTypeModel = db.model("std_ration_lib_glj_type",gljTypeSchema, "std_ration_lib_glj_type");
 var gljItemModel = mongoose.model("std_glj_lib_gljList");
-var repositoryMap = require('./repository_map');
+var repositoryMap = require('./repository_map').Dao;
 var counter = require('../../../public/counter/counter');
 
 var gljItemDAO = function(){};

+ 5 - 1
modules/ration_repository/models/ration_item.js

@@ -213,5 +213,9 @@ rationItemDAO.prototype.updateRationItems = function(rationLibId, sectionId, ite
     });
 };
 
-module.exports = new rationItemDAO()
+module.exports = {
+    Dao: new rationItemDAO(),
+    Model: rationItemModel
+};
+//module.exports = new rationItemDAO()
 

+ 5 - 1
modules/ration_repository/models/ration_section_tree.js

@@ -117,4 +117,8 @@ rationChapterTreeDAO.prototype.getRationChapter = function (repId, chapterID, ca
     }
 }
 
-module.exports = new rationChapterTreeDAO()
+module.exports = {
+    Model: rationChapterTreeModel,
+    Dao: new rationChapterTreeDAO()
+};
+//module.exports = new rationChapterTreeDAO()

+ 5 - 1
modules/ration_repository/models/repository_map.js

@@ -117,4 +117,8 @@ rationRepositoryDao.prototype.deleteRationLib = function(rationName,callback){
     });
 }
 
-module.exports = new rationRepositoryDao();
+module.exports = {
+    Dao: new rationRepositoryDao(),
+    Model: rationRepository
+}
+//module.exports = new rationRepositoryDao();

+ 69 - 6
web/building_saas/main/html/main.html

@@ -555,9 +555,9 @@
         </div>
     </div>
     <!--工料机选择窗口-->
-    <div class="modal fade" id="glj_tree_div" data-backdrop="static">
+    <!--<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" >
+            <div class="modal-content" style="width: 910px;">
                 <div class="modal-header">
                     <h5 class="modal-title">请选择工料机</h5>
                     <button type="button" class="close" data-dismiss="modal" aria-label="Close">
@@ -567,8 +567,50 @@
                 </div>
                 <div class="modal-body">
                     <div class="row">
-                        <div class="col-4">
-                            <div  class="modal-auto-height" id="componentTreeDiv" style="overflow: hidden">
+                        <div class="col-4" >
+                            <div  class="modal-auto-height" id="componentTreeDiv" style="overflow: hidden;">
+                                &lt;!&ndash;<div class="print-list">&ndash;&gt;
+                                <div style="width: 100%; height: 100%; overflow: auto">
+                                    <ul id="gljTree" class="ztree"></ul>
+                                </div>
+                                &lt;!&ndash;</div>&ndash;&gt;
+                            </div>
+                        </div>
+                        <div class="col-8">
+                            <div class="row">
+                                <div class="col-12" id="gljRadios">
+                                    <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;
+                                    &lt;!&ndash; <div class="form-group"><input id="searchGlj" type="text" class="form-control-sm" placeholder="查询工料机"></div>&ndash;&gt;
+                                </div>
+                                <div class="modal-auto-height col-12" style="overflow: hidden" id="gljLibSheet">
+
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+                <div class="modal-footer">
+                    <button type="button" id="componentsCacnel" class="btn btn-secondary" data-dismiss="modal">取消</button>
+                    <a href="javascript:void(0);" id="glj_selected_conf" class="btn btn-primary">确定</a>
+                </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: 910px;">
+                <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">
+                        <div style="width: 33%; float: left;">
+                            <div  class="modal-auto-height" id="componentTreeDiv" style=" height: 415px; overflow: hidden;">
                                 <!--<div class="print-list">-->
                                 <div style="width: 100%; height: 100%; overflow: auto">
                                     <ul id="gljTree" class="ztree"></ul>
@@ -576,7 +618,7 @@
                                 <!--</div>-->
                             </div>
                         </div>
-                        <div class="col-8">
+                        <div style="width:67%; padding-left: 8px; float: left;">
                             <div class="row">
                                 <div class="col-12" id="gljRadios">
                                     <input type="radio" class="glj-radio" name="glj" value="allGljs" checked>所有工料机&nbsp;&nbsp;
@@ -589,7 +631,6 @@
                                 </div>
                             </div>
                         </div>
-                    </div>
                 </div>
                 <div class="modal-footer">
                     <button type="button" id="componentsCacnel" class="btn btn-secondary" data-dismiss="modal">取消</button>
@@ -684,6 +725,26 @@
             </div>
         </div>
     </div>
+    <!--弹出补充定额库-->
+    <div class="modal fade" id="comple-ration" 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-auto-height">
+                    <table class="table table-hover table-bordered">
+                        <thead><tr><th>定额库名称</th></tr></thead>
+                        <tbody id="comple_ration_table">
+                        </tbody>
+                    </table>
+                </div>
+            </div>
+        </div>
+    </div>
         <!-- JS. -->
         <script type="text/javascript" src="/lib/spreadjs/sheets/gc.spread.sheets.all.10.0.1.min.js"></script>
 
@@ -805,6 +866,8 @@
         <script type="text/javascript" src="/web/building_saas/main/js/views/sub_fee_rate_views.js"></script>
         <script type="text/javascript" src="/web/building_saas/main/js/views/calc_base_view.js"></script>
         <script type="text/javascript" src="/web/building_saas/main/js/views/project_property_labour_coe_view.js"></script>
+        <script type="text/javascript" src="/web/building_saas/complementary_ration_lib/js/main.js"></script>
+         <script type="text/javascript" src="/public/web/storageUtil.js"></script>
         <!-- endinject -->
 
         <script type="text/javascript">

+ 34 - 8
web/building_saas/main/js/models/calc_base.js

@@ -201,7 +201,7 @@ let cbTools = {
         }
         function getBase(node){
             if(node && node.children.length === 0){
-                if(cbTools.isDef(node.data.calcBase)){
+                if(cbTools.isDef(node.data.calcBase) && node.data.calcBase !== ''){
                     let figures = cbParser.getFigure(node.data.calcBase);
                     tempBases = tempBases.concat(figures);
                 }
@@ -435,12 +435,23 @@ let cbAnalyzer = {
     },
     //输入合法性
     inputLegal: function (exp) {
-        let ilegalRex = /[^0-9,\u4e00-\u9fa5,\+,\-,\/,\*,\(,\),.]/g;
+        let ilegalRex = /[^0-9,\u4e00-\u9fa5,\+,\-,\/,\*,\(,\),.,{,}]/g;
         return !ilegalRex.test(exp);
     },
     //基数合法性、存在性
     baseLegal: function (baseFigures, exp) {
+        //保证中文表达式在{}里
+        let cnExps = cbParser.getCN(exp);
         let expFigures = cbParser.getFigure(exp);
+        if(cnExps.length !== expFigures.length){
+            return false;
+        }
+        for(let i = 0, len = cnExps.length; i < len; i++){
+            if(cnExps[i] !== expFigures[i]){
+                return false;
+            }
+        }
+        //基数存在性
         for(let i = 0, len = expFigures.length; i < len; i++){
             if(cbTools.isUnDef(baseFigures[expFigures[i]])){
                 return false;
@@ -485,9 +496,11 @@ let cbAnalyzer = {
         }
     },
     //四则运算合法性,前端控制不允许重复出现运算符,这里主要判断()的使用问题,这里再判断一次
-    arithmeticLeagl: function (exp) {
+    arithmeticLegal: function (exp) {
         let ilegalRex = /[\+,\-,\*,\/]{2}/g;
-        return !ilegalRex.test(exp);
+        let rex2 = /[{]{2}/g;
+        let rex3 = /[}]{2}/g;
+        return !ilegalRex.test(exp) && !rex2.test(exp) && !rex3.test(exp);
     },
     //
     legalExp: function (node) {
@@ -495,7 +508,7 @@ let cbAnalyzer = {
         if(this.inputLegal(exp)){
             if(this.baseLegal(cbTools.getFigure(node), exp)){
                 if(!this.cycleCalc(node, cbTools.getFigure(node), exp)){
-                    if(this.arithmeticLeagl(exp)){
+                    if(this.arithmeticLegal(exp)){
                         return exp;
                     }
                 }
@@ -508,8 +521,8 @@ let cbAnalyzer = {
 
 //输入式转换器
 let cbParser = {
-    //获取表达式中的基数
-    getFigure: function(expr){
+    //获取表达式中的中文式,没有{}需求时
+    getCN: function(expr){
         let rst = [];
         let cnRex = /[^\u4e00-\u9fa5]/;
         let temp = expr.split(cnRex);
@@ -520,6 +533,18 @@ let cbParser = {
         }
         return rst;
     },
+    //获取表达式中的基数
+    getFigure: function(expr){
+        let rst = [];
+        let rex = /\{([^}]*)\}/g;
+        let temp = expr.match(rex);
+        if(cbTools.isDef(temp)){
+            for(let i = 0, len = temp.length; i < len; i++){
+                rst.push(temp[i].replace(/[{,}]/g, ''));
+            }
+        }
+        return rst;
+    },
 
     //将表达式转换为可编译的表达式
     toCompileExpr: function(v){
@@ -533,6 +558,8 @@ let cbParser = {
             exp.orgExp = strs[i];
             exps.push(exp);
         }
+        //去{}
+        v = v.replace(/[{, }]/g, '');
         for(let i = 0, len = exps.length;i < len; i++){
             exps[i].compileExp = '$CBC.base(\'' + exps[i].orgExp;
             exps[i].compileExp = exps[i].compileExp + '\')';
@@ -599,7 +626,6 @@ let calcBase = {
             if(!cbTools.isDef(exp)){
                 throw '表达式不正确';
             }
-
             //输入式转换表达式
             let compileExp = $CBP.toCompileExpr(exp);
 

+ 7 - 7
web/building_saas/main/js/views/calc_base_view.js

@@ -8,7 +8,6 @@ let calcBaseView = {
     //可用计算基数的清单固定列映射(与fixedFlag)
     inputExpr: $('#calcBaseExp'),
     confirmBtn: $('#calcBaseConf'),
-    noBaseBills: [1, 3],
     editingCell: null,
     workBook: null,
     setting:{
@@ -24,7 +23,6 @@ let calcBaseView = {
             allowUserDragFill: false,
             scrollbarMaxAlign : true
         },
-        dateRows: [],
         locked: {
             rows: [],
             cols: [0, 1]
@@ -96,7 +94,7 @@ let calcBaseView = {
     onCellDoubleClick: function (sender, args) {
         let me = calcBaseView;
         if(args.col === 0){
-            let baseFigure = args.sheet.getValue(args.row, args.col);
+            let baseFigure = '{' + args.sheet.getValue(args.row, args.col) + '}';
             if(baseFigure.trim() !== ''){
                 //在光标后面插入
                 let insertStr = me.insertStr(baseFigure);
@@ -148,9 +146,11 @@ let calcBaseView = {
     },
 
     //四则运算符控制,不可连续出现: ++ +*...
-    arithmeticLeagl: function (v) {
+    arithmeticLegal: function (v) {
         let rex = /[\+,\-,\*,\/]{2}/g;
-        return !rex.test(v);
+        let rex2 = /[{]{2}/g;
+        let rex3 = /[}]{2}/g;
+        return !rex.test(v) && !rex2.test(v) && !rex3.test(v);
     },
 
     //运算符点击显示到运算窗口
@@ -160,7 +160,7 @@ let calcBaseView = {
             operators[i].bind('click', function () {
                 let v = $(this)[0].textContent;
                 let insertStr = me.insertStr(v);
-                if(me.arithmeticLeagl(insertStr)){
+                if(me.arithmeticLegal(insertStr)){
                     me.inputExpr.val(insertStr);
                 }
                 me.inputExpr.focus();
@@ -184,7 +184,7 @@ let calcBaseView = {
     inputControl: function () {
         let me = calcBaseView;
         me.inputExpr.keydown(function (e) {
-            if(!me.arithmeticLeagl(me.inputExpr.val() + e.key)){
+            if(!me.arithmeticLegal(me.inputExpr.val() + e.key)){
                 return false;
             }
         });

+ 36 - 25
web/building_saas/main/js/views/character_content_view.js

@@ -78,27 +78,31 @@ let contentOprObj = {
         sheet.addRows(sheet.getRowCount(), 1);
         sheet.getCell(sheet.getRowCount() - 1, 1).cellType(checkBox);
     },
-    upMove: function (rowIdx) {
+    upMove: function (cell) {
         let me = contentOprObj;
-        let thisObj = me.currentCache[rowIdx],
-            preObj = me.currentCache[rowIdx - 1],
+        let thisObj = me.currentCache[cell.row],
+            preObj = me.currentCache[cell.row - 1],
             temp, contentTxt;
         temp = thisObj.serialNo;
         thisObj.serialNo = preObj.serialNo;
         preObj.serialNo = temp;
         me.sortCache(me.currentCache);
-        me.save();
+        me.save(function () {
+            me.workBook.getSheet(0).setActiveCell(cell.row - 1, cell.col);
+        });
     },
-    downMove: function (rowIdx) {
+    downMove: function (cell) {
         let me = contentOprObj;
-        let thisObj = me.currentCache[rowIdx],
-            nextObj = me.currentCache[rowIdx + 1],
+        let thisObj = me.currentCache[cell.row],
+            nextObj = me.currentCache[cell.row + 1],
             temp, contentTxt;
         temp = thisObj.serialNo;
         thisObj.serialNo = nextObj.serialNo;
         nextObj.serialNo = temp;
         me.sortCache(me.currentCache);
-        me.save();
+        me.save(function () {
+            me.workBook.getSheet(0).setActiveCell(cell.row + 1, cell.col);
+        });
     },
     deleteContent: function (rowIdx) {
         let me = contentOprObj;
@@ -117,11 +121,11 @@ let contentOprObj = {
         me.currentCache.push(newObj);
 
     },
-    save: function () {
+    save: function (callback) {
         let me = contentOprObj;
         let contentTxt = me.getColData(me.currentCache);
         let txtObj =  {field: 'jobContentText', text: contentTxt ? contentTxt : ''};
-        pageCCOprObj.updateCharacterContent(pageCCOprObj.currentFindSet, {field: 'jobContent', updateArr: me.currentCache}, txtObj, contentOprObj);
+        pageCCOprObj.updateCharacterContent(pageCCOprObj.currentFindSet, {field: 'jobContent', updateArr: me.currentCache}, txtObj, contentOprObj, callback);
     },
     onEditEnded: function (sender, args) {
         let me = contentOprObj;
@@ -245,11 +249,11 @@ let contentOprObj = {
                                 me.deleteContent(target.row);
                             }},
                             "upMove": {name: "上移", disabled: upDis, icon: "fa-arrow-up", callback: function (key, opt) {
-                                me.upMove(target.row);
+                                me.upMove({row: target.row, col: target.col});
 
                             }},
                             "downMove": {name: "下移", disabled: downDis, icon: "fa-arrow-down", callback: function (key, opt) {
-                                me.downMove(target.row);
+                                me.downMove({row: target.row, col: target.col});
                             }}
                         }
                     };
@@ -388,27 +392,31 @@ let characterOprObj = {
         sheet.getCell(rowIdx, 1).cellType(combo);
         sheet.getCell(rowIdx, 2).cellType(checkBox);
     },
-    upMove: function (rowIdx) {
+    upMove: function (cell) {
         let me = characterOprObj;
-        let thisObj = me.currentCache[rowIdx],
-            preObj = me.currentCache[rowIdx - 1],
+        let thisObj = me.currentCache[cell.row],
+            preObj = me.currentCache[cell.row - 1],
             temp;
         temp = thisObj.serialNo;
         thisObj.serialNo = preObj.serialNo;
         preObj.serialNo = temp;
         contentOprObj.sortCache(me.currentCache);
-        me.save();
+        me.save(function () {
+            me.workBook.getSheet(0).setActiveCell(cell.row - 1, cell.col);
+        });
     },
-    downMove: function (rowIdx) {
+    downMove: function (cell) {
         let me = characterOprObj;
-        let thisObj = me.currentCache[rowIdx],
-            nextObj = me.currentCache[rowIdx + 1],
+        let thisObj = me.currentCache[cell.row],
+            nextObj = me.currentCache[cell.row + 1],
             temp;
         temp = thisObj.serialNo;
         thisObj.serialNo = nextObj.serialNo;
         nextObj.serialNo = temp;
         contentOprObj.sortCache(me.currentCache);
-        me.save();
+        me.save(function () {
+            me.workBook.getSheet(0).setActiveCell(cell.row + 1, cell.col);
+        });
     },
     deleteCharacter: function (rowIdx) {
         let me = characterOprObj;
@@ -488,11 +496,11 @@ let characterOprObj = {
             me.currentCache.push(newCharacter);
         }
     },
-    save: function () {
+    save: function (callback) {
         let me = characterOprObj;
         let characterTxt = me.getColData(me.currentCache);
         let txtObj =  {field: 'itemCharacterText', text: characterTxt ? characterTxt : ''};
-        pageCCOprObj.updateCharacterContent(pageCCOprObj.currentFindSet, {field: 'itemCharacter', updateArr: me.currentCache}, txtObj, characterOprObj);
+        pageCCOprObj.updateCharacterContent(pageCCOprObj.currentFindSet, {field: 'itemCharacter', updateArr: me.currentCache}, txtObj, characterOprObj, callback);
     },
     onEditStart: function (sender, args) {
         let me = characterOprObj;
@@ -621,10 +629,10 @@ let characterOprObj = {
                                 me.deleteCharacter(target.row);
                             }},
                             "upMove": {name: "上移", disabled: upDis, icon: "fa-arrow-up", callback: function (key, opt) {
-                                me.upMove(target.row);
+                                me.upMove({row: target.row, col: target.col});
                             }},
                             "downMove": {name: "下移", disabled: downDis, icon: "fa-arrow-down", callback: function (key, opt) {
-                                me.downMove(target.row);
+                                me.downMove({row: target.row, col: target.col});
                             }}
                         }
                     };
@@ -725,7 +733,7 @@ let pageCCOprObj = {
         projectObj.mainSpread.focus(true);
     },
     //更新特征及内容数据
-    updateCharacterContent: function (findSet, updateObj, txtObj, oprObj) {
+    updateCharacterContent: function (findSet, updateObj, txtObj, oprObj, callback) {
         let me = pageCCOprObj, updateCol;
         if(txtObj){
             updateCol = txtObj.field === 'itemCharacterText' ? 4 : 5;//更新清单行特征列或内容列
@@ -751,6 +759,9 @@ let pageCCOprObj = {
                 let activeCell = projectObj.mainSpread.getActiveSheet().getSelections()[0];
                 projectObj.mainSpread.getActiveSheet().setValue(activeCell.row, updateCol, txtObj.text + ''); //刷新输出显示
                 projectObj.mainSpread.getActiveSheet().autoFitRow(activeCell.row);
+                if(callback){
+                    callback();
+                }
             }
         });
     },

+ 2 - 2
web/building_saas/main/js/views/glj_view.js

@@ -225,8 +225,8 @@ var gljOprObj = {
                 vAlign: "center"
             },
             {
-                headerName: "计量单位",
-                headerWidth: 80,
+                headerName: "单位",
+                headerWidth: 40,
                 dataCode: "unit",
                 dataType: "String",
                 hAlign: "center",

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

@@ -105,7 +105,7 @@ function toUpdateDecimal(orgV, newV){
 function setDecimal(_digits, data){
     if(isDef(data)){
         for(let attr in data){
-            _digits[attr] = data[attr] || defaultDecimal['_def'][attr]['data'];
+            _digits[attr] = returnV(data[attr], defaultDecimal['_def'][attr]['data']);
         }
     }
     else {