Commit f88b313f by Kyle_Li

更改上传文件方式

parent 33bbdec3
......@@ -194,6 +194,6 @@ export const postForm = (url, params) => {
// return data
// }
// ],
headers: {} //'content-type': 'application/x-www-form-urlencoded'multipart/form-data{"token": token}
headers: {'Content-Type': 'multipart/form-data'} //'content-type': 'application/x-www-form-urlencoded'multipart/form-data{"token": token}
});
};
......@@ -98,7 +98,7 @@
</template>
</div>
<div class="import-tip">
<span class="import-tip-text">只能上传一个excle文件(2003版本以上),且数据不超过5000条</span>
<span class="import-tip-text">只能上传一个excel文件(2003版本以上),且数据不超过50000条</span>
<el-button type="text" @click="downloadExcelTemp">
<span class="font-12">下载Excel模板</span>
</el-button>
......@@ -128,7 +128,8 @@ import navCrumb from '@/components/nav/nav.vue';
import { export_json_to_excel } from '@/vendor/Export2Excel';
import showMsg from '@/common/js/showmsg';
import errMsg from '@/common/js/error';
import { getRequest, postRequest } from '@/api/api';
/* eslint-disable */
import { getRequest, postRequest, postForm } from '@/api/api';
/**
* 通过excel导入会员的业务逻辑 2019-5-27
* 轮询接口的实现方式
......@@ -175,6 +176,7 @@ export default {
// 当前上传 excel 表头的数据
excelHeader: []
},
filesData: undefined,
// 标签值列表的数据
tagValTableData: [],
......@@ -383,6 +385,8 @@ export default {
e.target.value = '';
return;
}
this.filesData = files;
console.log(this.filesData)
this.importPop.excelName = files.name;
const reader = new FileReader();
reader.onload = e => {
......@@ -400,10 +404,10 @@ export default {
}
this.importPop.excelHeader = this.get_header_row(worksheet);
this.importPop.excelData = XLSX.utils.sheet_to_json(worksheet);
if (this.importPop.excelData.length > 5000) {
if (this.importPop.excelData.length > 50000) {
this.$message.error({
duration: 1000,
message: '单次上传数据不能超过 5000 条,请重新上传文件'
message: '单次上传数据不能超过 50000 条,请重新上传文件'
});
}
};
......@@ -462,13 +466,30 @@ export default {
tagItemIndex: this.importPop.tagItemIndex,
tagItemId: this.importPop.tagItemId
});
const para = {
tagItemId: this.importPop.tagItemId,
data: JSON.stringify(this.importPop.excelData)
};
postRequest('/memberTag/uploadHandTagItemImport', para).then((res) => {
let {tagItemId, optType } = this.importPop;
// postRequest('/memberTag/uploadHandTagItemImport', para).then((res) => {
// const { errorCode } = res.data;
// errorCode === 1 ? this.handTagItemImport() : errMsg.errorMsg(res.data);
// }).catch(error => {
// this.$message.error({
// duration: 1000,
// message: error.message
// });
// });
const param = new FormData();
param.append("file", this.filesData);
param.append("optType", optType ? 1 : 0);
param.append("tagItemId", tagItemId);
postForm('/memberTag/uploadTagItemExcel', param).then((res) => {
const { errorCode } = res.data;
errorCode === 1 ? this.handTagItemImport() : errMsg.errorMsg(res.data);
if (errorCode === 1) {
// 关闭上传的弹窗
this.closeImportPop();
// 查询上传进度
this.handleRefreshTag();
} else {
errMsg.errorMsg(res.data);
}
}).catch(error => {
this.$message.error({
duration: 1000,
......
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