فهرست منبع

Merge branch 'master' of http://192.168.1.12:3000/SmartCost/ConstructionCost

TonyKang 7 سال پیش
والد
کامیت
353149513e

+ 2 - 0
modules/all_models/std_glj.js

@@ -27,6 +27,8 @@ const std_glj = new Schema({
     shortName: String,
     unit: String,
     adjCoe: Number,
+    materialType: String,
+    materialCoe: Number,
     component: [std_gljComponent]
 },{versionKey: false});
 

+ 102 - 71
public/scHintBox.html

@@ -7,22 +7,21 @@
         3、有三个按钮的多分支选择询问框。
         4、输入文本值对话框。
 ----------------------------------------------------------------------------------------------------------------------->
-
-<div class="modal fade" id="hintBox" data-backdrop="static">
+<div class="modal fade" id="hintBox_form" data-backdrop="static">
     <div class="modal-dialog" role="document">
         <div class="modal-content">
-
             <div class="modal-header">
-                <h5 class="modal-title" id="hintBox_title">标题</h5>
+                <h5 id="hintBox_title" class="modal-title">标题</h5>
                 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                     <span aria-hidden="true">&times;</span>
                 </button>
             </div>
 
             <div class="modal-body">
-                <div id = "hintBox_info" style="margin:5px 10px 10px 10px;">提示明细</div>
+                <div id = "hintBox_caption" style="margin:5px 10px 10px 10px;">提示明细</div>
                 <div style="margin:5px 10px 5px 10px;">
-                    <input type="text" class="form-control" value="" id="hintBox_value"/>
+                    <input id="hintBox_value" type="text" class="form-control" value="" />
+                    <p id="hintBox_error" style="margin-top:7px; color:red; display:none;">“xxx”已存在!</p>
                 </div>
             </div>
 
@@ -36,78 +35,110 @@
 </div>
 
 <script>
-    G_HINTBOX_VALUE = null;
-    hintBoxButtonType = {yes: 1, yesNo: 2, yesNoCancel: 3};
-    function speFont(str){
-        return `<span style='color:red;font-weight:bold;font-size:15px'> ${str} </span>`;
-    };
-
-    function hintBox(title, caption, btnType, doYes, doNo) {
-        $('#hintBox_title').text(title);
-        $('#hintBox_info').html(caption);
+    const hintBox = {
+        test: false,
+        value: null,
+        btnType: {yes: 1, yesNo: 2, yesNoCancel: 3},
+        init: function (){
+            // 事件类
+            $("#hintBox_value").unbind();
+            $("#hintBox_btn_yes").unbind();
+            $('#hintBox_btn_no').unbind();
+            $('#hintBox_btn_cancel').unbind();
+
+            $("#hintBox_value").keyup(
+                function (event) {
+                    hintBox.value = $('#hintBox_value').val();
+                    if (event.keyCode === 13) {
+                        $('#hintBox_btn_yes').click();
+                        return false;
+                    }
+                }
+            );
+            $('#hintBox_btn_cancel').click(
+                function () {
+                    if (!hintBox.test)
+                        $.bootstrapLoading.end();
+                    return;
+                }
+            );
+
+            // 显示类
+            $('#hintBox_caption').hide();
+            $('#hintBox_value').hide();
+            $('#hintBox_error').hide();
+            $('#hintBox_btn_yes').hide();
+            $('#hintBox_btn_no').hide();
+            $('#hintBox_btn_cancel').hide();
+        },
+        font: function(str){
+            return `<span style='color:red;font-weight:bold;font-size:15px'> ${str} </span>`;
+        },
+        error: function (err) {   // 注意:该方法只能用在valueBox()的doOK回调函数中。
+            $('#hintBox_error').text(err);
+            $('#hintBox_error').show(200);
+            $("#hintBox_value").focus();
+            $("#hintBox_value").select();
+        },
+        infoBox: function (title, caption, btnType, doYes, doNo) {
+            this.init();
+            $('#hintBox_title').text(title);
+            $('#hintBox_caption').html(caption);
+            $('#hintBox_caption').show();
+
+            switch (btnType) {
+                case this.btnType.yes:
+                    $('#hintBox_btn_yes').text('确定');
+                    $('#hintBox_btn_yes').show();
+                    break;
+                case this.btnType.yesNo:
+                    $('#hintBox_btn_yes').text('是');
+                    $('#hintBox_btn_no').text('否');
+                    $('#hintBox_btn_yes').show();
+                    $('#hintBox_btn_no').show();
+                    break;
+                case this.btnType.yesNoCancel:
+                    $('#hintBox_btn_yes').text('是');
+                    $('#hintBox_btn_no').text('否');
+                    $('#hintBox_btn_cancel').text('取消');
+                    $('#hintBox_btn_yes').show();
+                    $('#hintBox_btn_no').show();
+                    $('#hintBox_btn_cancel').show();
+                    break;
+            }
 
-        $('#hintBox_value').hide();
-        $('#hintBox_info').show();
-        $('#hintBox_btn_yes').show();
-        $('#hintBox_btn_yes').text('是');
-        $("#hintBox_btn_yes").unbind();
-        $('#hintBox_btn_no').show();
-        $('#hintBox_btn_no').text('否');
-        $('#hintBox_btn_no').unbind();
-        $('#hintBox_btn_cancel').show();
-        $('#hintBox_btn_cancel').text('取消');
-        $('#hintBox_btn_cancel').unbind();
+            if (doYes){
+                $('#hintBox_btn_yes').click(doYes);
+            }
 
-        switch (btnType) {
-            case hintBoxButtonType.yes:
-                $('#hintBox_btn_yes').text('确定');
-                $('#hintBox_btn_no').hide();
-                $('#hintBox_btn_cancel').hide();
-                break;
-            case hintBoxButtonType.yesNo:
-                $('#hintBox_btn_cancel').hide();
-                break;
-        }
+            if (doNo){
+                $('#hintBox_btn_no').click(doNo);
+            }
 
-        if (doYes){
-            $('#hintBox_btn_yes').click(doYes);
-        }
+            $("#hintBox_form").modal('show');
 
-        if (doNo){
-            $('#hintBox_btn_no').click(doNo);
-        }
+        },
+        valueBox: function (title, value, doOK) {
+            this.init();
+            $('#hintBox_title').text(title);
+            this.value = value;
+            $('#hintBox_value').show();
+            $('#hintBox_value').val(value);
+            $("#hintBox_value").focus();
+            $("#hintBox_value").select();
 
-        $('#hintBox_btn_cancel').click(
-            function () {return;}
-        );
+            $('#hintBox_btn_yes').text('确定');
+            $('#hintBox_btn_yes').show();
+            $('#hintBox_btn_yes').click(doOK);   // doOK不能给参数
 
-        $("#hintBox").modal({show:true});
+            $("#hintBox_form").modal('show');
+        }
     };
 
-    function hintBoxValue(title, value, doYes) {
-        $('#hintBox_title').text(title);
-
-        $('#hintBox_info').hide();
-        G_HINTBOX_VALUE = value;
-
-        $('#hintBox_value').show();
-        $('#hintBox_value').val(value);
-        $("#hintBox_value").unbind();
-        $("#hintBox_value").change(
-            function () {
-                G_HINTBOX_VALUE = $('#hintBox_value').val();
-            }
-        );
-
-        $('#hintBox_btn_yes').show();
-        $('#hintBox_btn_yes').text('确定');
-        $('#hintBox_btn_yes').unbind();
-        $('#hintBox_btn_yes').click(doYes);   // doYes不能给参数
-
-        $('#hintBox_btn_no').hide();
-        $('#hintBox_btn_cancel').hide();
-
-        $("#hintBox").modal({show:true});
-    };
+    $('#hintBox_form').on('hide.bs.modal', function() {
+        if (!hintBox.test)
+            $.bootstrapLoading.end();
+        return;
+    });
 </script>
 

+ 0 - 7
web/building_saas/main/html/calc_program_manage.html

@@ -25,13 +25,6 @@
             </div>
         </div>
     </div>
-
-    <script>
-        !function loadHintBox(){
-            $("body").append('<div id = "div_hintBox"></div>');
-            $("#div_hintBox").load("../../../../public/scHintBox.html");
-        }();
-    </script>
 </body>
 
 

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

@@ -1187,6 +1187,13 @@
            // autoFlashHeight();
         </script>
 
+        <script>
+            !function loadHintBox(){
+                $("body").append('<div id = "hintBox_container"></div>');
+                $("#hintBox_container").load("../../../../public/scHintBox.html");
+            }();
+        </script>
+
         <SCRIPT type="text/javascript">
             <!--
 //            var zNodes =[

+ 15 - 13
web/building_saas/main/js/models/calc_program.js

@@ -755,7 +755,7 @@ let analyzer = {
         let expr = me.standard(dispExpr);
         let invalidChars = /[^0-9\u4e00-\u9fa5\+\-\*\/\(\)\.\[\]FL%]/g;
         if (invalidChars.test(expr)){
-            alert('表达式中含有无效的字符!');
+            hintBox.infoBox('系数提示','表达式中含有无效的字符!',1);
             return false;
         };
 
@@ -764,26 +764,26 @@ let analyzer = {
         let pattBase = new RegExp(/\[[\u4E00-\u9FA5]+\]/gi);
         let arrBase = expr.match(pattBase);
         if (arrCn && !arrBase){
-            alert('定额基数必须用中括号[]括起来!');
+            hintBox.infoBox('系统提示', '定额基数必须用中括号[]括起来!', 1);
             return false;
         };
         if (arrCn && arrBase && (arrCn.length != arrBase.length)){
             for (let cn of arrCn){
                 let tempBase = `[${cn}]`;
                   if (!arrBase.includes(tempBase)){
-                      alert(`定额基数“${cn}”必须用中括号[]括起来!`);
+                      hintBox.infoBox('系统提示', `定额基数“${cn}”必须用中括号[]括起来!`, 1);
                       return false;
                   }
             };
             // 这里要加一个保险。因为上面的 for 循环在“主材费 + [主材费]” 情况下有Bug
-            alert('定额基数必须用中括号[]括起来!');
+            hintBox.infoBox('系统提示', '定额基数必须用中括号[]括起来!', 1);
             return false;
         };
         if (arrBase){
             for (let base of arrBase){
                 let baseName = base.slice(1, -1);
                 if (!rationCalcBases[baseName]){
-                    alert('定额基数 [' + baseName + '] 末定义!');
+                    hintBox.infoBox('系统提示', '定额基数 [' + baseName + '] 末定义!', 1);
                     return false;
                 }
             };
@@ -793,14 +793,15 @@ let analyzer = {
         for (let F of arrF){
             let num = F.slice(1);
             if (num > template.calcItems.length){
-                alert('表达式中 “F'+ num +'” 行号引用错误!');
+                let s = hintBox.font('F'+num);
+                hintBox.infoBox('系统提示', `表达式中 “${s}” 行号引用错误!`, 1);
                 return false;
             };
         };
 
         let expression = me.getExpression(expr, template);
         if (me.isCycleCalc(expression, itemID, template)){
-            alert('表达式中有循环计算!');
+            hintBox.infoBox('系统提示', '表达式中有循环计算!', 1);
             return false;
         }
 
@@ -944,11 +945,12 @@ let analyzer = {
     },
     fieldNameIsUsed: function(template, fieldName){
         let fieldNameEn = projectObj.project.calcProgram.compiledFeeTypeMaps[fieldName];
-        for (let item of template.calcItems){
-              if (item.fieldName == fieldNameEn){
-                  return true;
-              }
-        };
+        for (var i = 0; i < template.calcItems.length; i++) {
+            if (template.calcItems[i].fieldName == fieldNameEn){
+                template.fieldNameTempUsed = i;
+                return true;
+            }
+        }
         return false;
     }
 };
@@ -972,7 +974,7 @@ let executeObj = {
             return calcTools.marketPriceToBase(me.treeNode, baseName)
         else{
             if (!rationCalcBases[baseName]){
-                alert('定额基数“' + baseName + '”末定义,计算错误。 (模板 ' + me.template.ID + ',规则 ' + me.tempCalcItem.ID +')');
+                hintBox.infoBox('系统提示', '定额基数“' + baseName + '”末定义,计算错误。 (模板 ' + me.template.ID + ',规则 ' + me.tempCalcItem.ID +')', 1);
                 return 0;
             }
             else

+ 38 - 38
web/building_saas/main/js/views/calc_program_manage.js

@@ -115,20 +115,23 @@ let calcProgramManage = {
                 return;
             }
 
-            if (analyzer.fieldNameIsUsed(me.getSelectionInfo().template, args.newValue)){
+            let template = me.getSelectionInfo().template;
+            if (analyzer.fieldNameIsUsed(template, args.newValue)){
                 let sheet = me.detailSpread.getActiveSheet();
                 sheet.suspendEvent();
                 sheet.setValue(args.row, args.col, args.oldValue);
                 sheet.resumeEvent();
                 $.bootstrapLoading.end();
-                alert(`“${args.newValue}” 已被其它行使用,不允许重复选择!`);
+                let s = hintBox.font(template.fieldNameTempUsed + 1);
+                hintBox.infoBox('系统提示', `“${args.newValue}” 已被第 ${s} 行使用,不允许重复选择!`, 1);
+                delete template.fieldNameTempUsed;
                 return;
             }
 
             curCalcItem.fieldName = projectObj.project.calcProgram.compiledFeeTypeMaps[args.newValue];
         }
         else if (dataCode == 'dispExprUser'){  // 除非直接改单元格,弹窗不会走这里
-            alert('用户修改dispExprUser值,触发onDetailEditEnded事件。');
+            hintBox.infoBox('系统提示', '用户直接在sheet中修改了dispExprUser值,触发onDetailEditEnded事件。', 1);
         };
 
         curCalcItem[dataCode] = args.newValue;
@@ -210,36 +213,39 @@ let calcProgramManage = {
                         let template = calcProgramManage.getSelectionInfo().template;
                         let idx = calcProgramManage.mainSpread.getActiveSheet().getActiveRowIndex();
 
-                        let newName = prompt("请输入新的模板名称:", template.name);
-                        if (!newName || (newName && newName == template.name)) {
-                            $.bootstrapLoading.end();
-                            return;
-                        };
+                        let newName = '';
+                        hintBox.valueBox('请输入新的模板名称:', template.name, function () {
+                            newName = hintBox.value;
 
-                        while (analyzer.templateNameIsExist(newName)){
-                            alert(`“${newName}”已存在,请重新输入!`);
-                            newName = prompt("请输入新的模板名称:", template.name);
-                        };
+                            if (!newName){
+                                hintBox.error(`名称不能为空!`);
+                                return false;
+                            };
 
-                        if (!newName || (newName && newName == template.name)) {
-                            $.bootstrapLoading.end();
-                            return;
-                        };
+                            if (newName == template.name) {
+                                $.bootstrapLoading.end();
+                                return;
+                            }
 
-                        template.name = newName;
+                            if (analyzer.templateNameIsExist(newName)){
+                                hintBox.error(`“${newName}” 已存在,请重新输入!`);
+                                return false;
+                            };
 
-                        let data = {
-                            'projectID': projectObj.project.ID(),
-                            'ID': template.ID,
-                            'name': template.name
-                        };
-                        calcProgramManage.updateTemplate(data, function (rst) {
-                            if (rst){
-                                projectObj.project.calcProgram.compileTemplateMaps();
-                                sheetCommonObj.showData(calcProgramManage.mainSpread.getSheet(0), calcProgramManage.mainSetting, calcProgramManage.datas);
-                            }
+                            template.name = newName;
+                            let data = {
+                                'projectID': projectObj.project.ID(),
+                                'ID': template.ID,
+                                'name': template.name
+                            };
+                            calcProgramManage.updateTemplate(data, function (rst) {
+                                if (rst){
+                                    projectObj.project.calcProgram.compileTemplateMaps();
+                                    sheetCommonObj.showData(calcProgramManage.mainSpread.getSheet(0), calcProgramManage.mainSetting, calcProgramManage.datas);
+                                    $.bootstrapLoading.end();
+                                }
+                            });
                         });
-                        $.bootstrapLoading.end();
                     }
                 },
                 "spr1": '--------',
@@ -256,7 +262,7 @@ let calcProgramManage = {
                         let template = calcProgramManage.getSelectionInfo().template;
                         if (analyzer.templateIsUsed(template.ID)) {
                             $.bootstrapLoading.end();
-                            alert(`计算模板“${template.name}”已被使用,不允许删除!`);
+                            hintBox.infoBox('系统提示', `计算模板“${template.name}”已被使用,不允许删除!`, 1);
                             return;
                         }
                         let data = {
@@ -322,13 +328,6 @@ let calcProgramManage = {
                     name: '删除行',
                     icon: 'fa-remove',
                     callback: function () {
-                        // function cbYes() {alert('你点击了yes按键');};
-                        // function cbNo() {alert('你点击了no按键');}
-                        // function cbOK() {alert(`你输入的值为:${G_HINTBOX_VALUE}`);};
-                        //
-                        // // hintBox('操作确认', '确定要删除当前节点吗?', 2, cbYes, cbNo);
-                        // hintBoxValue('请输入新名称:', '我的模板1', cbOK);
-                        // return;
                         $.bootstrapLoading.start();
                         let template = calcProgramManage.getSelectionInfo().template;
                         let idx = calcProgramManage.detailSpread.getActiveSheet().getActiveRowIndex();
@@ -336,13 +335,14 @@ let calcProgramManage = {
 
                         if (item.fieldName == 'common'){
                             $.bootstrapLoading.end();
-                            alert(`费用类别为“工程造价”的行不允许删除!`);
+                            hintBox.infoBox('系统提示', `费用类别为“工程造价”的行不允许删除!`, 1);
                             return;
                         };
 
                         if (analyzer.calcItemIsUsed(template, item)){
                             $.bootstrapLoading.end();
-                            alert(`第 ${idx + 1} 行“${item.name}”已被第 ${item.tempUsed + 1} 行引用,不允许删除!`);
+                            let s = hintBox.font(item.tempUsed + 1);
+                            hintBox.infoBox('系统提示', `第 ${idx + 1} 行“${item.name}”已被第 ${s} 行引用,不允许删除!`, 1);
                             delete item.tempUsed;
                             return;
                         };

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

@@ -144,7 +144,7 @@ let labourCoeView = {
             me.sheet.suspendEvent();
             cell.value(oValue);  // 屏蔽事件,否则这句会导致死循环
             me.sheet.resumeEvent();
-            alert('当前输入的数据类型不正确,请重新输入。');
+            hintBox.infoBox('系统提示', '当前输入的数据类型不正确,请重新输入。', 1);
         }
     }
 };

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

@@ -61,14 +61,14 @@ var sideToolsObj = {
             loadSize(sideResizeEles, 'width', function(){
                 refreshSubSpread();
                 if(id === 'stdRationTab'){//定额库
-                    autoFlashHeight();
+                    //autoFlashHeight();
                     loadSize(rationLibResizeEles, 'height', function(){
                         rationLibObj.refreshSpread();;//subSpread、jobSpread、itemSpread显示问题
                     });
                 }
                 else{//清单库
                     loadSize(billsLibResizeEles, 'height', function(){
-                        autoFlashHeight();
+                        //autoFlashHeight();
                         billsLibObj.refreshBillsSpread();
                         billsLibObj.refreshBillsRelaSpread();
                     });
@@ -81,6 +81,7 @@ var sideToolsObj = {
             tabPanel.hide();
             refreshSubSpread();
         }
+        autoFlashHeight();
     }
 };
 

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

@@ -1095,6 +1095,7 @@ $(document).ready(function() {
             alert('请选择需要重命名的数据');
             return false;
         }
+        $('#rename-name').val(projTreeObj.tree.selected.data.name ? projTreeObj.tree.selected.data.name : '');
         $('#rename-dialog').modal('show');
     });