完成导入账号功能

main
wuyize 2022-07-13 15:44:30 +08:00
parent 4f3d028beb
commit 26e43ae624
3 changed files with 38 additions and 15 deletions

11
package-lock.json generated
View File

@ -15,6 +15,7 @@
"echarts": "^5.3.3",
"element-plus": "^2.2.6",
"moment": "^2.29.1",
"spark-md5": "^3.0.2",
"vue": "^3.0.0",
"vue-router": "^4.0.0-0",
"vuex": "^4.0.2",
@ -12665,6 +12666,11 @@
"resolved": "https://registry.npmmirror.com/sourcemap-codec/download/sourcemap-codec-1.4.8.tgz",
"integrity": "sha1-6oBL2UhXQC5pktBaOO8a41qatMQ="
},
"node_modules/spark-md5": {
"version": "3.0.2",
"resolved": "https://registry.npmmirror.com/spark-md5/-/spark-md5-3.0.2.tgz",
"integrity": "sha512-wcFzz9cDfbuqe0FZzfi2or1sgyIrsDwmPwfZC4hiNidPdPINjeUwNfv5kldczoEAcjl9Y1L3SM7Uz2PUEQzxQw=="
},
"node_modules/spdx-correct": {
"version": "3.1.1",
"resolved": "https://registry.npmmirror.com/spdx-correct/download/spdx-correct-3.1.1.tgz",
@ -25999,6 +26005,11 @@
"resolved": "https://registry.npmmirror.com/sourcemap-codec/download/sourcemap-codec-1.4.8.tgz",
"integrity": "sha1-6oBL2UhXQC5pktBaOO8a41qatMQ="
},
"spark-md5": {
"version": "3.0.2",
"resolved": "https://registry.npmmirror.com/spark-md5/-/spark-md5-3.0.2.tgz",
"integrity": "sha512-wcFzz9cDfbuqe0FZzfi2or1sgyIrsDwmPwfZC4hiNidPdPINjeUwNfv5kldczoEAcjl9Y1L3SM7Uz2PUEQzxQw=="
},
"spdx-correct": {
"version": "3.1.1",
"resolved": "https://registry.npmmirror.com/spdx-correct/download/spdx-correct-3.1.1.tgz",

View File

@ -14,6 +14,7 @@
"echarts": "^5.3.3",
"element-plus": "^2.2.6",
"moment": "^2.29.1",
"spark-md5": "^3.0.2",
"vue": "^3.0.0",
"vue-router": "^4.0.0-0",
"vuex": "^4.0.2",

View File

@ -78,7 +78,7 @@
</div>
<template #tip>
<div class="el-upload__tip">
<el-link href="https://element.eleme.io" type="primary">下载模板</el-link>
<el-link href="https://www.hammer-hfut.tk/api/public/账户导入模板.xlsx" type="primary">下载模板</el-link>
</div>
</template>
</el-upload>
@ -95,7 +95,6 @@ import {UploadFilled} from '@element-plus/icons'
import request from "@/utils/request";
import router from "../router";
import {ElMessage} from "element-plus";
import md5 from 'blueimp-md5'
export default {
name: 'Home',
@ -126,20 +125,32 @@ export default {
},
methods: {
customUpload(options) {
const that = this
let param = new FormData()
param.append('fileDigest', md5(options.file))
param.append('uploadFile', options.file)
request({
url: '/staff/import',
data: param,
method: 'post',
onUploadProgress: progressEvent => {
progressEvent.percent = progressEvent.loaded / progressEvent.total * 100 | 0
options.onProgress(progressEvent)
}
}).then((res) => {
console.log(res.data);
})
const fileReader = new FileReader()
fileReader.readAsBinaryString(options.file);
fileReader.onload = e => {
console.log(e.target.result)
let SparkMD5 = require('spark-md5')
param.append('fileDigest', SparkMD5.hashBinary(e.target.result))
param.append('uploadFile', options.file)
request({
url: '/staff/import',
data: param,
method: 'post',
onUploadProgress: progressEvent => {
progressEvent.percent = progressEvent.loaded / progressEvent.total * 100 | 0
options.onProgress(progressEvent)
}
}).then((res) => {
console.log(res.data);
ElMessage({
message: '导入成功',
type: 'success',
})
that.uploadDialogVisible = false
})
}
},
getStaffFullname() {
if (this.$store && this.$store.state.staff)