Browse Source

feat: 文件表格列表增加批量删除功能并优化操作列交互

yusheng 5 months ago
parent
commit
e3866034b4
1 changed files with 94 additions and 49 deletions
  1. 94 49
      src/views/doc/components/file-table-list.vue

+ 94 - 49
src/views/doc/components/file-table-list.vue

@@ -190,6 +190,21 @@
         >
           废止
         </el-button>
+        <el-popconfirm
+          class="ele-action"
+          title="确定要删除选中的文档吗?"
+          @confirm="
+            removeAll({
+              power: 'del',
+              dataKey: 'current',
+              isArr: true
+            })
+          "
+        >
+          <template v-slot:reference>
+            <el-button type="danger">批量删除</el-button>
+          </template>
+        </el-popconfirm>
         <el-button
           v-if="fileType === 0 && lcyStatus != 4"
           type="primary"
@@ -240,47 +255,45 @@
 
       <!-- 操作列 -->
       <template v-slot:action="{ row }">
-        <el-dropdown
-          trigger="click"
+        <el-link
           v-if="
             lcyStatus == 1 &&
             (row.reviewStatus == 0 || row.reviewStatus == 3) &&
             row.status == 0
           "
+          type="primary"
+          :underline="false"
+          icon="el-icon-edit"
+          @click.native="
+            openEdit('edit', row, {
+              power: 'revise',
+              dataKey: 'current',
+              isArr: false
+            })
+          "
         >
-          <el-link type="primary" :underline="false" icon="el-icon-edit">
-            编辑
-          </el-link>
-          <el-dropdown-menu slot="dropdown">
-            <el-dropdown-item
-              @click.native="
-                openEdit('edit', row, {
-                  power: 'revise',
-                  dataKey: 'current',
-                  isArr: false
-                })
-              "
-              >修改</el-dropdown-item
-            >
-            <el-dropdown-item>
-              <el-popconfirm
-                class="ele-action"
-                title="确定要删除此文档吗?"
-                @confirm="
-                  remove(row, {
-                    power: 'del',
-                    dataKey: 'current',
-                    isArr: false
-                  })
-                "
-              >
-                <template v-slot:reference>
-                  <el-link type="danger" :underline="false"> 删除 </el-link>
-                </template>
-              </el-popconfirm>
-            </el-dropdown-item>
-          </el-dropdown-menu>
-        </el-dropdown>
+          修改
+        </el-link>
+        <el-popconfirm
+          v-if="
+            lcyStatus == 1 &&
+            (row.reviewStatus == 0 || row.reviewStatus == 3) &&
+            row.status == 0
+          "
+          class="ele-action"
+          title="确定要删除此文档吗?"
+          @confirm="
+            remove(row, {
+              power: 'del',
+              dataKey: 'current',
+              isArr: false
+            })
+          "
+        >
+          <template v-slot:reference>
+            <el-link type="danger" :underline="false"> 删除 </el-link>
+          </template>
+        </el-popconfirm>
       </template>
     </ele-pro-table>
     <el-tabs
@@ -726,12 +739,9 @@
             this.$message.warning('请先检出在修改');
             return;
           }
-          if (isCheckOut(this.current)) {
+          if (isCheckOut(row)) {
             this.$message.warning(
-              this.current.name +
-                '已被' +
-                this.current.checkOutUserName +
-                '检出 无法修改'
+              row.name + '已被' + row.checkOutUserName + '检出 无法修改'
             );
             return;
           }
@@ -904,7 +914,7 @@
         });
       },
       noUpdateLcyStatus(powerData) {
-        if (this.selection.length == 0 || this.selection.length.length > 1) {
+        if (this.selection.length == 0 || this.selection.length > 1) {
           this.$message.warning('请选择一条数据');
           return;
         }
@@ -922,6 +932,46 @@
       //   this.rowClick(this.current)
       // },
       /* 删除 */
+      removeAll(powerData) {
+        let fileNames = [];
+        let checkOutUserNames = [];
+        if (!this.selection.length) {
+          this.$message.warning('请至少选择一条数据');
+          return;
+        }
+        if (this.powerFn(powerData)) {
+          return;
+        }
+        this.selection.forEach((item) => {
+          if (!item.checkOutUserName) {
+            fileNames.push(item.name + '未检出,请先检出在删除');
+          }
+          if (isCheckOut(item)) {
+            checkOutUserNames.push(
+              item.name + '已被' + item.checkOutUserName + '检出 无法删除'
+            );
+          }
+        });
+        if (fileNames.length) {
+          this.$message.warning(fileNames.toString());
+          return;
+        }
+        if (checkOutUserNames.length) {
+          this.$message.warning(checkOutUserNames.toString());
+          return;
+        }
+        const loading = this.$loading({ lock: true });
+        fileDeleteAPI(this.selection.map((item) => item.id))
+          .then((msg) => {
+            loading.close();
+            this.$message.success('操作成功');
+            this.reload();
+          })
+          .catch((e) => {
+            loading.close();
+            // this.$message.error(e.message);
+          });
+      },
       remove(row, powerData) {
         if (this.powerFn(powerData, row)) {
           return;
@@ -931,12 +981,9 @@
           return;
         }
 
-        if (isCheckOut(this.current)) {
+        if (isCheckOut(row)) {
           this.$message.warning(
-            this.current.name +
-              '已被' +
-              this.current.checkOutUserName +
-              '检出 无法删除'
+            row.name + '已被' + row.checkOutUserName + '检出 无法删除'
           );
           return;
         }
@@ -1004,12 +1051,10 @@
     display: contents;
   }
   .my-cascader {
-  
-
     :deep(.el-input__inner) {
       border: none;
       background: none;
-        cursor: inherit;
+      cursor: inherit;
     }
     :deep(.el-input__suffix) {
       display: none;