Przeglądaj źródła

fix:回收站添加批量

tanzx 2 dni temu
rodzic
commit
05d2d48287
2 zmienionych plików z 49 dodań i 2 usunięć
  1. 11 0
      src/api/doc-manage/index.js
  2. 38 2
      src/views/doc/recycleBin/index.vue

+ 11 - 0
src/api/doc-manage/index.js

@@ -389,6 +389,17 @@ export async function recycleDeleteAPI(id) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+/**
+ * 回收站批量删除
+ * @ids 回收站记录 id 集合
+ */
+export async function recycleDeleteBatchAPI(ids) {
+  const res = await request.post(`/fm/recycle_bin/deleteBatch`, ids);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
 /**
  * 删除
  * @id id

+ 38 - 2
src/views/doc/recycleBin/index.vue

@@ -2,6 +2,16 @@
   <div class="ele-body">
     <el-card shadow="never">
       <search ref="search" @search="search"></search>
+      <el-popconfirm
+        class="ele-action"
+        v-if="canDeleteSelection"
+        title="确定要彻底删除选中的回收站记录吗?删除后不可恢复!"
+        @confirm="removeBatch"
+      >
+        <template v-slot:reference>
+          <el-button type="danger">批量删除</el-button>
+        </template>
+      </el-popconfirm>
       <ele-pro-table
         ref="table"
         :columns="columns"
@@ -70,7 +80,8 @@
     recycleBinPage,
     getDocTreeListAPI,
     revoke,
-    recycleDeleteAPI
+    recycleDeleteAPI,
+    recycleDeleteBatchAPI
   } from '@/api/doc-manage';
   export default {
     mixins: [dictMixins, tableColumnsMixin],
@@ -86,7 +97,15 @@
         tabMixinsInit: false,
         cacheKeyUrl: 'fm-2611241029-doc-recycleBin',
         folderList: [],
+        selection: [],
         columns: [
+          {
+            width: 45,
+            type: 'selection',
+            columnKey: 'selection',
+            align: 'center',
+            fixed: 'left'
+          },
           {
             width: 45,
             type: 'index',
@@ -170,7 +189,15 @@
       });
     },
     computed: {
-      ...mapGetters(['user'])
+      ...mapGetters(['user']),
+      // 仅当勾选记录全部为当前用户所删(delUserId 为空视为历史数据放行)时显示批量删除
+      canDeleteSelection() {
+        if (!this.selection || !this.selection.length) return false;
+        const uid = this.user?.info?.userId;
+        return this.selection.every(
+          (row) => !row.delUserId || String(row.delUserId) === String(uid)
+        );
+      }
     },
     methods: {
       // ele-pro-table 列变化 → 转换为 slim 格式后同步到后端
@@ -284,6 +311,15 @@
           })
           .catch((e) => {});
       },
+      removeBatch() {
+        const ids = this.selection.map((row) => row.id);
+        recycleDeleteBatchAPI(ids)
+          .then(() => {
+            this.$message.success('删除成功');
+            this.done();
+          })
+          .catch((e) => {});
+      },
       revoke(row) {
         revoke({
           fileId: row.fileId,