Răsfoiți Sursa

feat(organization): 添加组织结构导出功能

liujt 6 luni în urmă
părinte
comite
9815774bab

+ 17 - 0
src/api/system/organization/index.js

@@ -1,4 +1,5 @@
 import request from '@/utils/request';
+import { download } from '@/utils/file';
 
 /**
  * 查询机构列表
@@ -171,3 +172,19 @@ export async function getCurrentUserAuthorityDeptAPI() {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+
+/**
+ * 组织结构导出
+ * @param
+ */
+export async function exportGroupsAPI() {
+  const res = await request.post(
+    '/main/group/exportGroups',
+    {},
+    {
+      responseType: 'blob'
+    }
+  );
+  download(res.data, '组织机构列表.xlsx');
+}

+ 17 - 1
src/views/enterpriseModel/dept/index.vue

@@ -31,6 +31,15 @@
             折叠全部
           </el-button>
           <!-- <el-button type="primary" size="mini" icon="el-icon-upload2" plain @click="uploadFile">导入</el-button> -->
+           <el-button
+            size="small"
+            type="primary"
+            icon="el-icon-download"
+            class="ele-btn-icon"
+            @click="exportData"
+          >
+            导出
+          </el-button>
         </template>
         <!-- 标题列 -->
         <template v-slot:name="{ row }">
@@ -123,7 +132,8 @@ import importDialog from '@/components/upload/import-dialog.vue';
 
 import {
   listOrganizations,
-  removeOrganization
+  removeOrganization,
+  exportGroupsAPI
 } from '@/api/system/organization';
 
 export default {
@@ -275,6 +285,12 @@ export default {
     foldAll() {
       this.$refs.table.toggleRowExpansionAll(false);
     },
+    // 导出数据
+    exportData() {
+      exportGroupsAPI().then(() => {
+        // this.$message.success('导出成功');
+      });
+    },
     /* 显示编辑 */
     openEdit(item) {
       this.editData = item;