chenshilong 7 years atrás
parent
commit
28a3b6f45b
2 changed files with 68 additions and 67 deletions
  1. 60 59
      public/scHintBox.html
  2. 8 8
      web/building_saas/main/js/views/calc_program_manage.js

+ 60 - 59
public/scHintBox.html

@@ -36,6 +36,7 @@
 
 <script>
     const hintBox = {
+        test: false,
         value: null,
         btnType: {yes: 1, yesNo: 2, yesNoCancel: 3},
         init: function (){
@@ -44,7 +45,8 @@
             $("#hintBox_btn_yes").unbind();
             $('#hintBox_btn_no').unbind();
             $('#hintBox_btn_cancel').unbind();
-            $("#hintBox_value").keypress(
+
+            $("#hintBox_value").keyup(
                 function (event) {
                     hintBox.value = $('#hintBox_value').val();
                     if (event.keyCode === 13) {
@@ -55,7 +57,8 @@
             );
             $('#hintBox_btn_cancel').click(
                 function () {
-                    $.bootstrapLoading.end();
+                    if (!hintBox.test)
+                        $.bootstrapLoading.end();
                     return;
                 }
             );
@@ -70,73 +73,71 @@
         },
         font: function(str){
             return `<span style='color:red;font-weight:bold;font-size:15px'> ${str} </span>`;
-        }
-    };
-
-    function hintBoxInfo(title, caption, btnType, doYes, doNo) {
-        hintBox.init();
-        $('#hintBox_title').text(title);
-        $('#hintBox_caption').html(caption);
-        $('#hintBox_caption').show();
-
-        switch (btnType) {
-            case hintBox.btnType.yes:
-                $('#hintBox_btn_yes').text('确定');
-                $('#hintBox_btn_yes').show();
-                break;
-            case hintBox.btnType.yesNo:
-                $('#hintBox_btn_yes').text('是');
-                $('#hintBox_btn_no').text('否');
-                $('#hintBox_btn_yes').show();
-                $('#hintBox_btn_no').show();
-                break;
-            case hintBox.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;
-        }
+        },
+        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();
 
-        if (doYes){
-            $('#hintBox_btn_yes').click(doYes);
-        }
+            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;
+            }
 
-        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);
+            }
 
-    function hintBoxValue(title, value, doOK) {
-        hintBox.init();
-        $('#hintBox_title').text(title);
-        hintBox.value = value;
-        $('#hintBox_value').show();
-        $('#hintBox_value').val(value);
-        $("#hintBox_value").focus();
-        $("#hintBox_value").select();
+            $("#hintBox_form").modal('show');
 
-        $('#hintBox_btn_yes').text('确定');
-        $('#hintBox_btn_yes').show();
-        $('#hintBox_btn_yes').click(doOK);   // doOK不能给参数
+        },
+        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_form").modal('show');
-    };
+            $('#hintBox_btn_yes').text('确定');
+            $('#hintBox_btn_yes').show();
+            $('#hintBox_btn_yes').click(doOK);   // doOK不能给参数
 
-    // 注意:该方法只能用在hintBoxValue()的doOK回调函数中。
-    function hintBoxError (error) {
-        $('#hintBox_error').text(error);
-        $('#hintBox_error').show(200);
-        $("#hintBox_value").focus();
-        $("#hintBox_value").select();
+            $("#hintBox_form").modal('show');
+        }
     };
 
     $('#hintBox_form').on('hide.bs.modal', function() {
-        $.bootstrapLoading.end();
+        if (!hintBox.test)
+            $.bootstrapLoading.end();
         return;
     });
 </script>

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

@@ -123,7 +123,7 @@ let calcProgramManage = {
                 sheet.resumeEvent();
                 $.bootstrapLoading.end();
                 let s = hintBox.font(template.fieldNameTempUsed + 1);
-                hintBoxInfo('系统提示', `“${args.newValue}” 已被第 ${s} 行使用,不允许重复选择!`, 1);
+                hintBox.infoBox('系统提示', `“${args.newValue}” 已被第 ${s} 行使用,不允许重复选择!`, 1);
                 delete template.fieldNameTempUsed;
                 return;
             }
@@ -131,7 +131,7 @@ let calcProgramManage = {
             curCalcItem.fieldName = projectObj.project.calcProgram.compiledFeeTypeMaps[args.newValue];
         }
         else if (dataCode == 'dispExprUser'){  // 除非直接改单元格,弹窗不会走这里
-            hintBoxInfo('系统提示', '用户直接在sheet中修改了dispExprUser值,触发onDetailEditEnded事件。', 1);
+            hintBox.infoBox('系统提示', '用户直接在sheet中修改了dispExprUser值,触发onDetailEditEnded事件。', 1);
         };
 
         curCalcItem[dataCode] = args.newValue;
@@ -214,11 +214,11 @@ let calcProgramManage = {
                         let idx = calcProgramManage.mainSpread.getActiveSheet().getActiveRowIndex();
 
                         let newName = '';
-                        hintBoxValue('请输入新的模板名称:', template.name, function () {
+                        hintBox.valueBox('请输入新的模板名称:', template.name, function () {
                             newName = hintBox.value;
 
                             if (!newName){
-                                hintBoxError(`名称不能为空!`);
+                                hintBox.error(`名称不能为空!`);
                                 return false;
                             };
 
@@ -228,7 +228,7 @@ let calcProgramManage = {
                             }
 
                             if (analyzer.templateNameIsExist(newName)){
-                                hintBoxError(`“${newName}” 已存在,请重新输入!`);
+                                hintBox.error(`“${newName}” 已存在,请重新输入!`);
                                 return false;
                             };
 
@@ -262,7 +262,7 @@ let calcProgramManage = {
                         let template = calcProgramManage.getSelectionInfo().template;
                         if (analyzer.templateIsUsed(template.ID)) {
                             $.bootstrapLoading.end();
-                            hintBoxInfo('系统提示', `计算模板“${template.name}”已被使用,不允许删除!`, 1);
+                            hintBox.infoBox('系统提示', `计算模板“${template.name}”已被使用,不允许删除!`, 1);
                             return;
                         }
                         let data = {
@@ -335,14 +335,14 @@ let calcProgramManage = {
 
                         if (item.fieldName == 'common'){
                             $.bootstrapLoading.end();
-                            hintBoxInfo('系统提示', `费用类别为“工程造价”的行不允许删除!`, 1);
+                            hintBox.infoBox('系统提示', `费用类别为“工程造价”的行不允许删除!`, 1);
                             return;
                         };
 
                         if (analyzer.calcItemIsUsed(template, item)){
                             $.bootstrapLoading.end();
                             let s = hintBox.font(item.tempUsed + 1);
-                            hintBoxInfo('系统提示', `第 ${idx + 1} 行“${item.name}”已被第 ${s} 行引用,不允许删除!`, 1);
+                            hintBox.infoBox('系统提示', `第 ${idx + 1} 行“${item.name}”已被第 ${s} 行引用,不允许删除!`, 1);
                             delete item.tempUsed;
                             return;
                         };