Kaynağa Gözat

删除分类,按钮调整

MaiXinRong 2 yıl önce
ebeveyn
işleme
81ad4dada9
2 değiştirilmiş dosya ile 24 ekleme ve 14 silme
  1. 24 13
      app/public/js/file_detail.js
  2. 0 1
      app/view/file/file.ejs

+ 24 - 13
app/public/js/file_detail.js

@@ -117,11 +117,12 @@ $(document).ready(function() {
                 self.filingTree.addNodes(node, -1, [{ id: newNode.id, tree_pid: newNode.tree_pid, name: newNode.name, spid: newNode.spid, source_node: newNode}]);
             });
         }
-        delFiling(node) {
+        delFiling(node, callback) {
             const self = this;
             postData('filing/del', { id: node.id }, function(result) {
                 self.dragTree.loadPostData(result);
                 self.filingTree.removeNode(node);
+                if (callback) callback();
             });
         }
         async renameFiling(node, newName) {
@@ -247,7 +248,10 @@ $(document).ready(function() {
         },
         edit: {
             enable: true,
-            showRemoveBtn: false,
+            showRemoveBtn: function(treeId, treeNode) {
+                if (!canFiling) return false;
+                return !treeNode.source_node.is_fixed;
+            },
             showRenameBtn: function(treeId, treeNode) {
                 if (!canFiling) return false;
                 return !treeNode.source_node.is_fixed;
@@ -256,7 +260,8 @@ $(document).ready(function() {
             drag: {
                 isCopy: false,
                 isMove: false,
-            }
+            },
+            editNameSelectAll: true,
         },
         callback: {
             onClick: async function (e, key, node) {
@@ -274,6 +279,10 @@ $(document).ready(function() {
             onRename: function(e, key, node, isCancel) {
                 node.name = node.name + (node.source_node.total_file_count > 0 ? `(${node.source_node.total_file_count})` : '');
                 filingObj.filingTree.updateNode(node);
+            },
+            beforeRemove: function(e, key, node, isCancel) {
+                $('#del-filing').modal('show');
+                return false;
             }
         }
     };
@@ -297,17 +306,19 @@ $(document).ready(function() {
 
         filingObj.addChildFiling(filingObj.curFiling);
     });
-    $('#del-filing-btn').click(() => {
-        if (!filingObj.curFiling) return;
-        if (filingObj.curFiling.source_node.is_fixed) {
-            toastr.error('固定分类不可删除');
-            return;
-        }
-
-        $('#del-filing').modal('show');
-    });
+    // $('#del-filing-btn').click(() => {
+    //     if (!filingObj.curFiling) return;
+    //     if (filingObj.curFiling.source_node.is_fixed) {
+    //         toastr.error('固定分类不可删除');
+    //         return;
+    //     }
+    //
+    //     $('#del-filing').modal('show');
+    // });
     $('#del-filing-ok').click(() => {
-        filingObj.delFiling(filingObj.curFiling);
+        filingObj.delFiling(filingObj.curFiling, function() {
+            $('#del-filing').modal('hide');
+        });
     });
     $('#add-file-ok').click(() => {
         const input = $('#upload-file');

+ 0 - 1
app/view/file/file.ejs

@@ -17,7 +17,6 @@
                         <% if (canFiling) { %>
                         <div class="p-2"><a href="javascript: void(0);" id="add-slibing">添加同级</a></div>
                         <div class="p-2"><a href="javascript: void(0);" id="add-child">添加子级</a></div>
-                        <div class="p-2"><a href="javascript: void(0);" id="del-filing-btn" class="text-danger">删除</a></div>
                         <% } else { %>
                         <div class="p-2 ml-2">分类目录</div>
                         <% } %>