Commit 0b10b72b authored by 刘洪铨's avatar 刘洪铨

用户导入

parent 8e91088d
...@@ -157,7 +157,7 @@ export function importExcel(data) { ...@@ -157,7 +157,7 @@ export function importExcel(data) {
// 下载错误文件 // 下载错误文件
export function uploadFalseFile(params) { export function uploadFalseFile(params) {
console.log(params) params = Qs.stringify(params)
return request({ return request({
url: '/system/user/downFalseFile', url: '/system/user/downFalseFile',
method: 'post', method: 'post',
......
...@@ -7,14 +7,14 @@ import SM4 from './gmUtil' ...@@ -7,14 +7,14 @@ import SM4 from './gmUtil'
import errorCode from '@/utils/errorCode' import errorCode from '@/utils/errorCode'
import { refreshToken } from '@/api/login.js' import { refreshToken } from '@/api/login.js'
axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded'
// 创建axios实例 // 创建axios实例
const service = axios.create({ const service = axios.create({
// axios中请求配置有baseURL选项,表示请求URL公共部分 // axios中请求配置有baseURL选项,表示请求URL公共部分
baseURL: process.env.VUE_APP_BASE_API, baseURL: process.env.VUE_APP_BASE_API,
// 超时 // 超时
timeout: 100000, timeout: 100000
headers: { 'clientType': 'fy_authority' } // headers: { 'clientType': 'fy_authority' }
}) })
// let loadingInstance = '' // let loadingInstance = ''
// request拦截器 // request拦截器
......
...@@ -293,8 +293,6 @@ ...@@ -293,8 +293,6 @@
<!-- 用户导入对话框 --> <!-- 用户导入对话框 -->
<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body> <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
<el-upload <el-upload
ref="upload"
:limit="1"
accept=".xlsx, .xls" accept=".xlsx, .xls"
:headers="upload.headers" :headers="upload.headers"
:action="upload.url + '?updateSupport=' + upload.updateSupport" :action="upload.url + '?updateSupport=' + upload.updateSupport"
...@@ -302,6 +300,11 @@ ...@@ -302,6 +300,11 @@
:on-progress="handleFileUploadProgress" :on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess" :on-success="handleFileSuccess"
:auto-upload="false" :auto-upload="false"
:on-change="employeeUpload"
:on-remove="handleRemove"
:before-remove="beforeRemove"
:on-preview="handlePreview"
:file-list="fileList"
drag drag
> >
<i class="el-icon-upload" /> <i class="el-icon-upload" />
...@@ -422,6 +425,8 @@ export default { ...@@ -422,6 +425,8 @@ export default {
pwdType: 'password', pwdType: 'password',
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 导入列表
fileList: [],
// 选中数组 // 选中数组
ids: [], ids: [],
// 非单个禁用 // 非单个禁用
...@@ -874,11 +879,11 @@ export default { ...@@ -874,11 +879,11 @@ export default {
this.fileList = [] this.fileList = []
// 导入成功后关闭弹出框 // 导入成功后关闭弹出框
this.importLoading = false this.importLoading = false
this.upload.open = true this.upload.open = false
// 导入成功后刷新页面 // 导入成功后刷新页面
this.getList() this.getList()
} else { } else {
uploadFalseFile({ filename: res.data.filename }).then(res => { uploadFalseFile({ fileName: res.data.filename }).then(res => {
const blob = new Blob([res]) const blob = new Blob([res])
const downloadElement = document.createElement('a') const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob) // 创建下载的链接 const href = window.URL.createObjectURL(blob) // 创建下载的链接
...@@ -900,6 +905,24 @@ export default { ...@@ -900,6 +905,24 @@ export default {
this.importLoading = false this.importLoading = false
}) })
} }
},
employeeUpload(file, fileList) {
if (fileList.length > 1) {
fileList.splice(0, 1)
}
this.fileList = fileList[0].raw
},
handleRemove(file, fileList) {
this.fileList = []
console.log(file, fileList)
},
beforeRemove(file, fileList) {
this.fileList = []
console.log(file, fileList)
},
/* 上传文件所需求 */
handlePreview(file) {
console.log(file)
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment