Browse Source

找回toast代码,因覆盖global.js导致丢失

MaiXinRong 7 years ago
parent
commit
3225f55a24
3 changed files with 26 additions and 3 deletions
  1. 23 1
      app/public/js/global.js
  2. 2 2
      app/public/js/path_tree.js
  3. 1 0
      app/service/ledger.js

+ 23 - 1
app/public/js/global.js

@@ -46,6 +46,28 @@ $(".bg-nav > li > a").click(function() {
           }
       }
   });
+});
 
+/**
+ * 提示框
+ *
+ * @param string message
+ * @param string type
+ * @param string icon
+ * @return void
+ */
+function toast(message, type, icon)
+{
+    var toast = $(".toast");
+    toast.addClass(type);
+    toast.children('.message').html(message);
+    var iconClass = 'fa-' + icon;
+    toast.children('.icon').addClass(iconClass);
+    toast.fadeIn(500);
 
-});
+    setTimeout(function() {
+        toast.fadeOut('fast');
+        toast.children('.message').text('');
+        toast.children('.icon').removeClass(iconClass);
+    }, 3000);
+}

+ 2 - 2
app/public/js/path_tree.js

@@ -20,11 +20,11 @@ const createNewPathTree = function (setting) {
                         successCallback(result.data);
                     }
                 } else {
-                    alert('error: ' + result.message, 'error', 'exclamation-circle');
+                    toast('error: ' + result.message, 'error', 'exclamation-circle');
                 }
             },
             error: function(jqXHR, textStatus, errorThrown){
-                alert('error ' + textStatus + " " + errorThrown, 'error', 'exclamation-circle');
+                toast('error ' + textStatus + " " + errorThrown, 'error', 'exclamation-circle');
             }
         });
     };

+ 1 - 0
app/service/ledger.js

@@ -645,6 +645,7 @@ module.exports = app => {
             this.transaction = await this.db.beginTransaction();
             const newFullPath = selectData.full_path.replace(selectData.ledger_pid + '.', '');
             try {
+                // 选中节点--父节点 选中节点为firstChild时,修改is_leaf
                 if (selectData.order === 1) {
                     this.transaction.update(this.tableName, {
                         id: parentData.id,