2213980799@qq.com пре 1 година
родитељ
комит
3e2657dea9

+ 21 - 9
src/api/system/file/index.js

@@ -5,7 +5,7 @@ import { download } from '@/utils/file';
  * 上传文件
  * @param file 文件
  */
-export async function uploadFile (data) {
+export async function uploadFile(data) {
   const formData = new FormData();
   formData.append('multiPartFile', data.multiPartFile);
   formData.append('module', data.module);
@@ -19,7 +19,7 @@ export async function uploadFile (data) {
  * 导入文件 批量
  * @param file 文件
  */
-export async function uploadBatch (data) {
+export async function uploadBatch(data) {
   const formData = new FormData();
   data.multiPartFiles.forEach((item, index) => {
     formData.append(`multiPartFiles`, item);
@@ -37,7 +37,7 @@ export async function uploadBatch (data) {
 /**
  * 获取文件路径
  */
-export async function getPathAddress () {
+export async function getPathAddress() {
   const res = await request.post('/main/file/getPathAddress');
   if (res.data.code === '0') {
     return res.data.data;
@@ -47,7 +47,7 @@ export async function getPathAddress () {
 /**
  * 获取文件
  */
-export async function getFile (params, fileName) {
+export async function getFile(params, fileName) {
   const res = await request.get('/main/file/getFile', {
     params,
     responseType: 'blob'
@@ -59,11 +59,23 @@ export async function getFile (params, fileName) {
   // }
   // return Promise.reject();
 }
-
+/**
+ * 下载模板
+ */
+export async function downLoadTemplate() {
+  const res = await request.post('/main/user/downLoadTemplate',{}, {
+    responseType: 'blob'
+  });
+  download(res.data, '员工档案导入模板.xlsx');
+  // if (res.data.code === '0') {
+  //   return res.data.data;
+  // }
+  // return Promise.reject();
+}
 /**
  * 删除文件
  */
-export async function removeFile (data) {
+export async function removeFile(data) {
   const res = await request.post(
     `/main/file/delete?fileId=${data.fileId}`,
     data
@@ -76,7 +88,7 @@ export async function removeFile (data) {
 /**
  * 文件列表
  */
-export async function getFileList (data) {
+export async function getFileList(data) {
   const res = await request.post(`/main/file/list`, data);
   if (res.data.code === '0') {
     return res.data.data;
@@ -88,7 +100,7 @@ export async function getFileList (data) {
  * 导入文件 批量
  * @param file 文件
  */
-export async function importBatch (data) {
+export async function importBatch(data) {
   const formData = new FormData();
   data.multiPartFiles.forEach((item, index) => {
     formData.append(`multiPartFiles`, item);
@@ -104,7 +116,7 @@ export async function importBatch (data) {
 }
 
 // 导入pbom
-export async function importPBom (data) {
+export async function importPBom(data) {
   const formData = new FormData();
   data.multiPartFiles.forEach((item, index) => {
     formData.append(`multiPartFiles`, item);

+ 13 - 0
src/api/system/user/index.js

@@ -1,4 +1,5 @@
 import request from '@/utils/request';
+import { download } from '@/utils/file';
 
 /**
  * 分页查询用户
@@ -15,6 +16,18 @@ export async function pageUsers(params) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+/**
+ * 分页查询用户
+ * @param params 导出员工数据
+ */
+ export async function exportUsers(data) {
+  const res = await request.post(
+    '/main/user/exportUsers',data,{
+      responseType: 'blob'
+    }
+  );
+  download(res.data,'员工档案.xlsx')
+}
 
 // 修改用户信息
 export async function putUsers(params) {

+ 87 - 76
src/components/upload/import-dialog.vue

@@ -13,9 +13,16 @@
           <el-button icon="el-icon-plus" size="small" type="primary"
             >文件上传</el-button
           >
-          <div slot="tip" class="el-upload__tip"
-            >只能上传excel文件,或批量上传打包成zip、rar压缩文件,单文件不超过10mb</div
-          >
+          <div slot="tip" class="el-upload__tip">
+            只能上传excel文件,点击
+            <el-link
+              type="primary"
+              :underline="false"
+              @click="downLoadTemplate()"
+            >
+              下载模板</el-link
+            >
+          </div>
         </el-upload>
       </el-form-item>
       <el-form-item label="上传列表">
@@ -35,86 +42,90 @@
 </template>
 
 <script>
-  import { importBatch } from '@/api/system/file/index.js';
+import { importBatch,downLoadTemplate } from '@/api/system/file/index.js';
 
-  export default {
-    props: {
-      // eslint-disable-next-line vue/require-prop-type-constructor
-      defModule: ''
+export default {
+  props: {
+    // eslint-disable-next-line vue/require-prop-type-constructor
+    defModule: ''
+  },
+  //注册组件
+  data() {
+    return {
+      showViewer: false, // 显示查看器
+      dialogVisible: false,
+      uploadShow: false,
+      module: '',
+      attaments: [], //上传文件
+      file: ''
+    };
+  },
+  created() {},
+  methods: {
+    open() {
+      this.attaments = [];
+      this.module = '';
+      this.dialogVisible = true;
     },
-    //注册组件
-    data() {
-      return {
-        showViewer: false, // 显示查看器
-        dialogVisible: false,
-        uploadShow: false,
-        module: '',
-        attaments: [], //上传文件
-        file: ''
-      };
+    //删除附件
+    delFileList(index) {
+      this.attaments.splice(index, 1);
     },
-    created() {},
-    methods: {
-      open() {
-        this.attaments = [];
-        this.module = '';
-        this.dialogVisible = true;
-      },
-      //删除附件
-      delFileList(index) {
-        this.attaments.splice(index, 1);
-      },
-      //上传限制
-      beforeUpload(file) {
-        const isLt10M = file.size / 1024 / 1024 < 10;
-        if (!isLt10M) {
-          this.$message.error('导入单文件大小不能超过 10MB!');
-        }
-        return isLt10M;
-      },
-      //图片上传
-      handlSuccess(param) {
-        this.file = param.file;
-        this.attaments.push(param.file);
-      },
-      // 文件上传
-      async upload() {
-        if (this.attaments.length == 0) {
-          return this.$message.warning('文件不能为空!');
-        }
-        this.module = this.$props.defModule;
-
-        await importBatch({
-          module: this.module,
-          multiPartFiles: this.attaments
-        });
-        this.$message.success('操作成功!');
-        this.dialogVisible = false;
-        this.$emit('success');
+    //上传限制
+    beforeUpload(file) {
+      const isLt10M = file.size / 1024 / 1024 < 10;
+      if (!isLt10M) {
+        this.$message.error('导入单文件大小不能超过 10MB!');
+      }
+      return isLt10M;
+    },
+    //图片上传
+    handlSuccess(param) {
+      this.file = param.file;
+      this.attaments.push(param.file);
+    },
+    // 文件上传
+    async upload() {
+      if (this.attaments.length == 0) {
+        return this.$message.warning('文件不能为空!');
       }
+      this.module = this.$props.defModule;
+
+      await importBatch({
+        module: this.module,
+        multiPartFiles: this.attaments
+      });
+      this.$message.success('操作成功!');
+      this.dialogVisible = false;
+      this.$emit('success');
+    },
+    //下载模板
+    downLoadTemplate(){
+      downLoadTemplate()
     }
-  };
+  }
+};
 </script>
 
 <style lang="scss">
-  .zw-table-header {
-    float: right;
-  }
+.zw-table-header {
+  float: right;
+}
 
-  .imgs-box .imgs-p {
-    height: 30px;
-    background: #f0f3f3;
-    line-height: 30px;
-    width: 372px;
-    margin-bottom: 5px;
-    padding: 0 10px;
-    display: flex;
-    justify-content: space-between;
-  }
-  .zw-criterion-normal {
-    padding: 20px 0 0 0;
-  }
-  .el-main {
-    overflow: hidden;
-  }
+.imgs-box .imgs-p {
+  height: 30px;
+  background: #f0f3f3;
+  line-height: 30px;
+  width: 372px;
+  margin-bottom: 5px;
+  padding: 0 10px;
+  display: flex;
+  justify-content: space-between;
+}
+.zw-criterion-normal {
+  padding: 20px 0 0 0;
+}
+.el-main {
+  overflow: hidden;
+}
 </style>

+ 26 - 7
src/views/system/organization/components/org-user-list.vue

@@ -12,7 +12,7 @@
     >
       <!-- 表头工具栏 -->
       <template v-slot:toolbar>
-        <org-user-search @search="reload">
+        <org-user-search @search="reload" ref="searchRef">
           <el-button
             size="small"
             type="primary"
@@ -30,6 +30,14 @@
             @click="uploadFile"
             >导入</el-button
           >
+          <el-button
+            type="primary"
+            size="mini"
+            icon="el-icon-download"
+            plain
+            @click="exportUsers"
+            >导出</el-button
+          >
         </org-user-search>
       </template>
       <!-- 角色列 -->
@@ -46,7 +54,7 @@
       </template>
 
       <template v-slot:name="{ row }">
-        <el-link type="primary" :underline="false" @click="openEdit(row,true)">
+        <el-link type="primary" :underline="false" @click="openEdit(row, true)">
           {{ row.name }}</el-link
         >
       </template>
@@ -111,7 +119,13 @@
       @done="reload"
       ref="userEditRef"
     />
-    <addUsers :visible.sync="showEdit1" @done="reload" :data="null" ref="userEdit" :organizationList="organizationList" />
+    <addUsers
+      :visible.sync="showEdit1"
+      @done="reload"
+      :data="null"
+      ref="userEdit"
+      :organizationList="organizationList"
+    />
     <importDialog
       :defModule="moudleName"
       ref="importDialogRef"
@@ -168,7 +182,7 @@ import {
   removePersonnel,
   unbindLoginName
 } from '@/api/system/organization';
-import { pageUsers } from '@/api/system/user';
+import { pageUsers, exportUsers } from '@/api/system/user';
 export default {
   components: {
     importDialog,
@@ -367,7 +381,6 @@ export default {
       this.userShow = false;
       this.showEdit1 = true;
       this.$refs.userEdit.getByData(this.userRow, this.currentRow);
-
     },
 
     /* 表格数据源 */
@@ -391,11 +404,17 @@ export default {
     reload1(where) {
       this.$refs.table1.reload({ pageNum: 1, where: where });
     },
+    exportUsers() {
+      let where = this.$refs.searchRef.geValue();
+      this.reload(where)
+       
+      exportUsers({ ...where, pageNum: 1, size: 10000, groupId: this.organizationId });
+    },
     /* 显示编辑 */
-    openEdit(row,disabled) {
+    openEdit(row, disabled) {
       this.current = row;
       this.showEdit = true;
-      this.$refs.userEditRef.setDisabled(disabled)
+      this.$refs.userEditRef.setDisabled(disabled);
     },
 
     // 解除绑定

+ 34 - 33
src/views/system/organization/components/org-user-search.vue

@@ -8,7 +8,7 @@
   >
     <el-row :gutter="24">
       <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
-      <el-form-item>
+        <el-form-item>
           <el-input
             clearable
             size="small"
@@ -16,11 +16,9 @@
             placeholder="请输入工号"
           />
         </el-form-item>
-        </el-col>
+      </el-col>
 
       <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
-
-
         <el-form-item>
           <el-input
             clearable
@@ -40,7 +38,7 @@
           />
         </el-form-item>
       </el-col>
-      <el-col v-bind="styleResponsive ?  { md: 6 } : { span: 6 }">
+      <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
         <el-form-item>
           <el-button
             size="small"
@@ -59,36 +57,39 @@
 </template>
 
 <script>
-  export default {
-    data() {
-      // 默认表单数据
-      const defaultWhere = {
-        jobNumber: '',
-        loginName: '',
-        name: ''
-      };
-      return {
-        // 表单数据
-        where: { ...defaultWhere }
-      };
+export default {
+  data() {
+    // 默认表单数据
+    const defaultWhere = {
+      jobNumber: '',
+      loginName: '',
+      name: ''
+    };
+    return {
+      // 表单数据
+      where: { ...defaultWhere }
+    };
+  },
+  computed: {
+    // 是否开启响应式布局
+    styleResponsive() {
+      return this.$store.state.theme.styleResponsive;
+    }
+  },
+  methods: {
+    /* 搜索 */
+    search() {
+      this.$emit('search', this.where);
     },
-    computed: {
-      // 是否开启响应式布局
-      styleResponsive() {
-        return this.$store.state.theme.styleResponsive;
-      }
+    /*  重置 */
+    reset() {
+      this.where = { ...this.defaultWhere };
+      this.search();
     },
-    methods: {
-      /* 搜索 */
-      search() {
-        this.$emit('search', this.where);
-      },
-      /*  重置 */
-      reset() {
-        this.where = { ...this.defaultWhere };
-        this.search();
-      }
+    geValue() {
+      return this.where;
     }
-  };
+  }
+};
 </script>