Преглед изворни кода

feat: 新增批量移动文档功能

yusheng пре 1 месец
родитељ
комит
48edf7e920

+ 42 - 55
src/api/doc-manage/index.js

@@ -22,12 +22,13 @@ export async function directorySaveAPI(data) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
 /**
  * 修改
  * @data data
  */
 export async function directoryUpdateAPi(data) {
-  data.authority = data.authority || 0
+  data.authority = data.authority || 0;
   const res = await request.post('/fm/directory/update', data);
   if (res.data.code == 0) {
     return res.data.data;
@@ -58,7 +59,6 @@ export async function directoryDeleteAPI(data) {
   return Promise.reject(new Error(res.data.message));
 }
 
-
 /**
  * 检入
  * @data data
@@ -82,7 +82,6 @@ export async function checkOut(data) {
   return Promise.reject(new Error(res.data.message));
 }
 
-
 /**
  * 发布版本
  * @data data
@@ -95,11 +94,14 @@ export async function fileVersion(data) {
   return Promise.reject(new Error(res.data.message));
 }
 
-
-
-
-
-
+//移动
+export async function batchMove(data) {
+  const res = await request.post('/fm/file/batchMove', data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
 
 /**
  * 版本详情
@@ -139,7 +141,7 @@ export async function queryRecycle(id) {
  * 工作流
  * @id id
  */
- export async function queryProcess(id) {
+export async function queryProcess(id) {
   const res = await request.get(`/fm/file_operation_log/queryProcess/${id}`);
   if (res.data.code == 0) {
     return res.data.data;
@@ -147,7 +149,6 @@ export async function queryRecycle(id) {
   return Promise.reject(new Error(res.data.message));
 }
 
-
 /**
  * 个人工作区创建文件夹
  */
@@ -159,11 +160,6 @@ export async function validationPersonal() {
   return Promise.reject(new Error(res.data.message));
 }
 
-
-
-
-
-
 /**
  * 收发管理
  */
@@ -187,7 +183,6 @@ export async function sendUpdate(data) {
   return Promise.reject(new Error(res.data.message));
 }
 
-
 export async function sendPage(data) {
   const res = await request.post('/fm/release_management/page', data);
   if (res.data.code == 0) {
@@ -204,11 +199,10 @@ export async function releasePage(data) {
   return Promise.reject(new Error(res.data.message));
 }
 
-
 /*
-* 回收文档
-* @data data
-*/
+ * 回收文档
+ * @data data
+ */
 export async function receiveSave(data) {
   const res = await request.post('/fm/recycle_management/save', data);
   if (res.data.code == 0) {
@@ -232,7 +226,6 @@ export async function recyclePage(data) {
   return Promise.reject(new Error(res.data.message));
 }
 
-
 /**
  * 签收
  */
@@ -255,29 +248,27 @@ export async function allSignFor(data) {
   return Promise.reject(new Error(res.data.message));
 }
 
-
-
 /**
  * 回收权限
  */
 export async function recycleAuthority(data) {
-  const res = await request.post(`/fm/release_management/RecycleAuthority  `, data);
+  const res = await request.post(
+    `/fm/release_management/RecycleAuthority  `,
+    data
+  );
   if (res.data.code == 0) {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
 }
 
-
-
-
 /**
-* 查询文件数据
-* @data data
-*/
+ * 查询文件数据
+ * @data data
+ */
 export async function filePageAPI(data) {
   if (!data.lcyStatus) {
-    return true
+    return true;
   }
   const res = await request.post('/fm/file/page', data);
   if (res.data.code == 0) {
@@ -301,7 +292,7 @@ export async function fileSaveAPI(data) {
  * @data data
  */
 export async function fileUpdateAPI(data) {
-  data.authority = data.authority || 0
+  data.authority = data.authority || 0;
   const res = await request.put('/fm/file/update', data);
   if (res.data.code == 0) {
     return res.data.data;
@@ -345,9 +336,9 @@ export async function fileDeleteAPI(data) {
 }
 
 /**
-* 操作日志
-* @data data
-*/
+ * 操作日志
+ * @data data
+ */
 export async function actionPage(data) {
   const res = await request.post('/fm/file_operation_log/page', data);
   if (res.data.code == 0) {
@@ -356,10 +347,6 @@ export async function actionPage(data) {
   return Promise.reject(new Error(res.data.message));
 }
 
-
-
-
-
 /**
  * 回收站
  * @data data
@@ -394,16 +381,15 @@ export async function recycleDeleteAPI(id) {
  * 删除
  * @id id
  */
- export async function sendDeleteAPI(data) {
-  console.log(data,'id')
-  const res = await request.delete(`/fm/release_management/delete`,{data});
+export async function sendDeleteAPI(data) {
+  console.log(data, 'id');
+  const res = await request.delete(`/fm/release_management/delete`, { data });
   if (res.data.code == 0) {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
 }
 
-
 /**
  * 归档
  * @data data
@@ -419,7 +405,7 @@ export async function updateLcyStatus(data) {
  * 取消归档
  * @data data
  */
- export async function noUpdateLcyStatus(data) {
+export async function noUpdateLcyStatus(data) {
   const res = await request.post('/fm/file/noUpdateLcyStatus', data);
   if (res.data.code == 0) {
     return res.data.data;
@@ -430,7 +416,7 @@ export async function updateLcyStatus(data) {
  * 排序
  * @data data
  */
- export async function moveDirectory(data) {
+export async function moveDirectory(data) {
   const res = await request.post('/fm/directory/moveDirectory', data);
   if (res.data.code == 0) {
     return res.data.data;
@@ -438,24 +424,25 @@ export async function updateLcyStatus(data) {
   return Promise.reject(new Error(res.data.message));
 }
 // 编码方案
-export async function listCode(data={}) {
-  console.log(data?.parentId,'data?.parentId')
-   
-  const res = await request.get(`/main/business_code_category/listCode/${data.id||'0'}`+'?parentId='+(data.parentId||''));
+export async function listCode(data = {}) {
+  console.log(data?.parentId, 'data?.parentId');
+
+  const res = await request.get(
+    `/main/business_code_category/listCode/${data.id || '0'}` +
+      '?parentId=' +
+      (data.parentId || '')
+  );
   if (res.data.code == 0) {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
 }
 
-
-
-
 /**
  * 获取信息详情
  */
 export async function sendGetById(id) {
-  const res = await request.get(`/fm/release_management/getById/`+id, {});
+  const res = await request.get(`/fm/release_management/getById/` + id, {});
   if (res.data.code == 0) {
     return res.data.data;
   }
@@ -465,8 +452,8 @@ export async function sendGetById(id) {
 /**
  * 获取信息详情
  */
- export async function recycleGetById(id) {
-  const res = await request.get(`/fm/recycle_management/getById/`+id, {});
+export async function recycleGetById(id) {
+  const res = await request.get(`/fm/recycle_management/getById/` + id, {});
   if (res.data.code == 0) {
     return res.data.data;
   }

+ 43 - 1
src/views/doc/components/file-table-list.vue

@@ -236,6 +236,19 @@
         >
           移动
         </el-button>
+        <el-button
+          type="primary"
+          v-if="lcyStatus == 1 && fileType === 0"
+          @click.native="
+            moveAll({
+              power: 'edit',
+              dataKey: 'current',
+              isArr: true
+            })
+          "
+        >
+          批量移动
+        </el-button>
         <fileSearch @search="reload" style="margin-left: 20px"></fileSearch>
         <!-- </div> -->
       </template>
@@ -368,6 +381,7 @@
       :fileType="fileType"
     />
     <move ref="moveRef" @done="reload" />
+    <moveAll ref="moveAllRef" @done="reload"></moveAll>
 
     <file-editAll
       ref="fileEditAllRef"
@@ -401,6 +415,7 @@
   import fileEdit from './file-edit.vue';
   import fileEditAll from './file-editAll.vue';
   import move from './move.vue';
+  import moveAll from './moveAll.vue';
 
   import Info from './info.vue';
   import folderInfo from './folderInfo.vue';
@@ -446,7 +461,7 @@
       bpm,
       sendEdit,
       browse,
-      move
+      move,moveAll
     },
     props: {
       // 上级
@@ -1048,6 +1063,33 @@
         }
         this.$refs.moveRef.open(this.selection[0]);
       },
+      moveAll(powerData) {
+        let fileNames = [];
+        let checkOutUserNames = [];
+        if (!this.selection.length) {
+          this.$message.warning('请至少选择一条数据');
+          return;
+        }
+        if (this.powerFn(powerData)) {
+          return;
+        }
+        this.selection.forEach((item) => {
+          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;
+        }
+        this.$refs.moveAllRef.open(this.selection.map(item=>item.id).toString())
+      },
       getTableList() {
         return JSON.parse(JSON.stringify(this.selection));
       }

+ 151 - 0
src/views/doc/components/moveAll.vue

@@ -0,0 +1,151 @@
+<!-- 用户编辑弹窗 -->
+<template>
+  <ele-modal
+    width="500px"
+    :visible.sync="showEditFlag"
+    :close-on-click-modal="false"
+    custom-class="ele-dialog-form"
+    append-to-body
+    @close="cancel"
+    :title="title"
+    ref="Emodal"
+  >
+    <el-form ref="form" :model="form" :rules="rules" label-width="82px">
+      <el-row :gutter="15">
+        <el-col :span="24">
+          <el-form-item label="目标位置" prop="directoryId">
+            <el-cascader
+              style="width: 100%"
+              v-model="form.directoryId"
+              :options="folderList"
+              :props="{
+                value: 'id',
+                label: 'name',
+                children: 'sonDirectoryList',
+                emitPath: false,
+                checkStrictly: true
+              }"
+            ></el-cascader>
+          </el-form-item>
+        </el-col>
+      </el-row>
+    </el-form>
+    <template v-slot:footer>
+      <el-button @click="cancel">取消</el-button>
+      <el-button
+        type="primary"
+        v-loading.fullscreen.lock="loading"
+        @click="save"
+      >
+        确认
+      </el-button>
+    </template>
+  </ele-modal>
+</template>
+
+<script>
+  import { batchMove, getDocTreeListAPI } from '@/api/doc-manage';
+  import { setFolderList } from '../util.js';
+  import { mapGetters } from 'vuex';
+
+  export default {
+    data() {
+      const defaultForm = {
+        directoryId: ''
+      };
+      return {
+        rules: {
+          directoryId: [{ required: true, message: '请选择', trigger: 'blur' }]
+        },
+        folderList: [],
+        defaultForm,
+        // 表单数据
+        form: { ...defaultForm },
+        ids: '',
+        // 提交状态
+        loading: false,
+        showEditFlag: false,
+        title: '',
+        type: ''
+      };
+    },
+    computed: {
+      // 是否开启响应式布局
+      styleResponsive() {
+        return this.$store.state.theme.styleResponsive;
+      },
+      ...mapGetters(['user'])
+    },
+    created() {
+      getDocTreeListAPI({
+        type: 0,
+        currentUserId: this.user.info.userId
+      }).then((res) => {
+        this.folderList = res;
+        setFolderList(this.folderList); //权限过滤
+      });
+    },
+    methods: {
+      async open(ids) {
+        this.ids = ids;
+        this.title = '移动文档';
+        this.showEditFlag = true;
+      },
+
+      /* 保存编辑 */
+      save() {
+        this.$refs.form.validate(async (valid) => {
+          if (!valid) {
+            return false;
+          }
+
+          this.form.fileType = 0;
+
+          this.loading = true;
+          batchMove({
+            ids: this.ids,
+            directoryId: this.form.directoryId
+          })
+            .then(async (msg) => {
+              this.loading = false;
+              this.cancel();
+              this.$emit('done');
+            })
+            .catch((e) => {
+              this.loading = false;
+            });
+        });
+      },
+      cancel() {
+        this.form = { ...this.defaultForm };
+        this.$refs.form.clearValidate();
+        this.showEditFlag = false;
+      }
+    }
+  };
+</script>
+<style scoped lang="scss">
+  .aaa {
+    width: 100%;
+
+    ::v-deep .upload-demo {
+      width: 100%;
+
+      .el-upload--text {
+        width: 100%;
+
+        button {
+          width: 100%;
+          background: #ffffff;
+          border: 1px solid #dbdbdb;
+          border-radius: 5px;
+        }
+      }
+
+      .el-upload-list {
+        transform: translate(10px, -39px);
+        position: absolute;
+      }
+    }
+  }
+</style>