Bladeren bron

批量添加至其他类别

MaiXinRong 5 maanden geleden
bovenliggende
commit
a95c3a0d5a
2 gewijzigde bestanden met toevoegingen van 33 en 1 verwijderingen
  1. 32 1
      app/public/js/file_detail.js
  2. 1 0
      app/view/file/file_modal.ejs

+ 32 - 1
app/public/js/file_detail.js

@@ -1330,7 +1330,8 @@ $(document).ready(function() {
                 }
                 self.syncFiling(self.curFiling, selectFilingId);
                 toastr.success('同步成功');
-                $('[name=cbft]').removeAttr('checked');
+                self.permissionTree.nodes.forEach(x => { x.check = false; });
+                SpreadJsObj.reloadColData(self.sheet, 1);
                 $('#filing-select-all')[0].checked = false;
             });
             $('#batch-del-filing').click(() => {
@@ -1344,6 +1345,27 @@ $(document).ready(function() {
                 self.delFiling(self.curFiling, userId);
                 self.loadCurFiling();
             });
+            $('#batch-add-filing').click(() => {
+                const selectFilingId = [];
+                self.permissionTree.nodes.forEach(x => { if (x.check && (!x.children || x.children.length === 0)) selectFilingId.push(x.filing_type); });
+                if (selectFilingId.length === 0) {
+                    toastr.warning('请先选择文档类别');
+                    return;
+                }
+                const selectUser = $('[name=ftu-check]:checked');
+                if (selectUser.length === 0) {
+                    toastr.warning('请先选择用户');
+                    return;
+                }
+                const userId = [];
+                selectUser.each((i, x) => { userId.push(x.getAttribute('uid')); });
+                self.batchAddFiling(selectFilingId, userId);
+                self.loadCurFiling();
+                toastr.success('批量添加成功');
+                self.permissionTree.nodes.forEach(x => { x.check = false; });
+                SpreadJsObj.reloadColData(self.sheet, 1);
+                $('#filing-select-all')[0].checked = false;
+            });
             $('body').on('click', '[name=del-filing]', function() {
                 const id = this.getAttribute('uid');
                 self.delFiling(self.curFiling, id);
@@ -1467,6 +1489,15 @@ $(document).ready(function() {
                 if (pu.filing_type.indexOf(filingId) >= 0) pu.filing_type.splice(pu.filing_type.indexOf(filingId), 1);
             }
         }
+        batchAddFiling(filingIds, userId) {
+            for (const pu of this.permissionUser) {
+                if (userId.indexOf(pu.id) < 0) continue;
+
+                filingIds.forEach(fid => {
+                    if (pu.filing_type.indexOf(fid) < 0) pu.filing_type.push(fid);
+                });
+            }
+        }
         savePermission() {
             const self = this;
             const data = this.permissionUser.map(x => {

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

@@ -26,6 +26,7 @@
                                 </div>
                             </div>
                             <div class="p-2"><a href="javascript: void(0);" id="batch-del-filing" class="text-danger">批量删除</a></div>
+                            <div class="p-2"><a href="javascript: void(0);" id="batch-add-filing">批量添加至其他类别</a></div>
                             <div class="p-2"><a href="javascript: void(0);" id="sync-filing">同步授权至其他类别</a></div>
                         </div>
                         <div class="modal-height-400 scroll-y">