From 814b3084debe2c074be77b23bc48040f94e564c2 Mon Sep 17 00:00:00 2001 From: xiongchengqiang Date: Thu, 21 May 2020 18:17:22 +0800 Subject: [PATCH] =?UTF-8?q?export=20=E5=91=98=E5=B7=A5=E6=A1=A3=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/api_staff.js | 5 +++++ src/utils/http.js | 6 +++--- src/views/modules/staff/manage/index.vue | 20 ++++++++++++++++++-- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/api/api_staff.js b/src/api/api_staff.js index b423f0d..99bb408 100644 --- a/src/api/api_staff.js +++ b/src/api/api_staff.js @@ -27,3 +27,8 @@ export const apiEmployeessItuation = data => { export const apiUploadFile = params => { return http({ url: '/lz_management/staff/info/batchImport', method: 'post', data: params }) } + +// 导出文件 +export const apiExportFile = params => { + return http({ url: '/lz_management/staff/info/downloadTemplate', method: 'post', responseType: 'blob', data: params }) +} diff --git a/src/utils/http.js b/src/utils/http.js index 686b916..5d949e4 100644 --- a/src/utils/http.js +++ b/src/utils/http.js @@ -20,9 +20,9 @@ http.interceptors.request.use(config => { // config.data = Object.assign({}, config.data, { t: new Date().getTime() }) return config }, -error => { - return Promise.reject(error) -}) + error => { + return Promise.reject(error) + }) /** * 响应拦截 diff --git a/src/views/modules/staff/manage/index.vue b/src/views/modules/staff/manage/index.vue index 2a2f84f..032d652 100644 --- a/src/views/modules/staff/manage/index.vue +++ b/src/views/modules/staff/manage/index.vue @@ -53,6 +53,9 @@ 批量导入员工档案 + + 导出员工档案 +
@@ -132,7 +135,7 @@ import menuTree from '@/components/menu-tree' import basis from './componments/basis.vue' import professional from './componments/professional' import education from './componments/education' -import { apiOrganizationList, apiEmployeesList, apiUploadFile } from '@/api/api_staff' +import { apiOrganizationList, apiEmployeesList, apiUploadFile, apiExportFile } from '@/api/api_staff' export default { components: { @@ -185,6 +188,19 @@ export default { this.handleGetTableList(this.current) }, methods: { + // 到处员工档案 + async handleExport () { + let result = await apiExportFile() + console.log('result: ', result) + const blob = new Blob([result], { type: 'application/json' }) + // const blob = new Blob([data], {type: 'audio/wav'}) + const a = document.createElement('a') + a.href = URL.createObjectURL(blob) + a.download = '员工档案.xls' // 这里填保存成的文件名 + a.click() + URL.revokeObjectURL(a.href) + a.remove() + }, // 上传文件 async handleUpLoad (file) { let data = new FormData() @@ -206,7 +222,7 @@ export default { title: '提示', message: h('p', null, [ h('div', { style: 'color: #a96161' }, '文件名:' + file.name), - h('span', null, '此操作不可逆,是否上传') + h('span', null, '此操作不可逆,是否上传?') ]), showCancelButton: true, confirmButtonText: '确定',