export 员工档案

This commit is contained in:
xiongchengqiang 2020-05-21 18:17:22 +08:00
parent 055e5f9b0d
commit 814b3084de
3 changed files with 26 additions and 5 deletions

View File

@ -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 })
}

View File

@ -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)
})
/**
* 响应拦截

View File

@ -53,6 +53,9 @@
<el-button type="primary" :loading="isUploading" icon="el-icon-plus">批量导入员工档案</el-button>
</el-upload>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleExport">导出员工档案</el-button>
</el-form-item>
</el-form>
</div>
<div class="table">
@ -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: '确定',