Commit 39a6422d by Kyle_Li

去掉读取excel

parent f88b313f
......@@ -170,8 +170,8 @@ export const constantRouterMap = [
];
export default new Router({
mode: 'history',
base: '/member-tag/',
// mode: 'history',
// base: '/member-tag/',
routes: constantRouterMap,
scrollBehavior: () => ({ y: 0 })
});
\ No newline at end of file
......@@ -81,7 +81,7 @@
<!-- excel导入 -->
<el-dialog :title="importPop.title" :visible.sync="importPop.isShow" custom-class="manual-dialog">
<div class="import">
<div :class="['excel-icon', importPop.excelData.length > 0 ? 'excel-icon--active' : 'excel-icon--add']" @click="handleUpload">
<div :class="['excel-icon', filesData ? 'excel-icon--active' : 'excel-icon--add']" @click="handleUpload">
<span v-show="importPop.excelData.length === 0" class="import-btn">点击上传会员</span>
</div>
<div class="import-cont">
......@@ -387,31 +387,31 @@ export default {
}
this.filesData = files;
console.log(this.filesData)
this.importPop.excelName = files.name;
const reader = new FileReader();
reader.onload = e => {
const data = e.target.result;
const fixedData = this.fixData(data);
const workbook = XLSX.read(btoa(fixedData), { type: 'base64' });
const firstSheetName = workbook.SheetNames[0];
const worksheet = workbook.Sheets[firstSheetName];
if (Object.keys(worksheet).indexOf('!ref') === -1) {
this.$message.error({
duration: 1000,
message: '文档内容为空'
});
return false;
}
this.importPop.excelHeader = this.get_header_row(worksheet);
this.importPop.excelData = XLSX.utils.sheet_to_json(worksheet);
if (this.importPop.excelData.length > 50000) {
this.$message.error({
duration: 1000,
message: '单次上传数据不能超过 50000 条,请重新上传文件'
});
}
};
reader.readAsArrayBuffer(files);
// this.importPop.excelName = files.name;
// const reader = new FileReader();
// reader.onload = e => {
// const data = e.target.result;
// const fixedData = this.fixData(data);
// const workbook = XLSX.read(btoa(fixedData), { type: 'base64' });
// const firstSheetName = workbook.SheetNames[0];
// const worksheet = workbook.Sheets[firstSheetName];
// if (Object.keys(worksheet).indexOf('!ref') === -1) {
// this.$message.error({
// duration: 1000,
// message: '文档内容为空'
// });
// return false;
// }
// this.importPop.excelHeader = this.get_header_row(worksheet);
// this.importPop.excelData = XLSX.utils.sheet_to_json(worksheet);
// if (this.importPop.excelData.length > 50000) {
// this.$message.error({
// duration: 1000,
// message: '单次上传数据不能超过 50000 条,请重新上传文件'
// });
// }
// };
// reader.readAsArrayBuffer(files);
},
fixData(data) {
......@@ -454,13 +454,14 @@ export default {
// 导入数据到服务端
tagItemImport() {
if (this.importPop.excelData.length === 0) {
this.$message.error({
duration: 1000,
message: '导入数据有为空或者数据异常'
});
return;
}
// if (this.importPop.excelData.length === 0) {
// this.$message.error({
// duration: 1000,
// message: '导入数据有为空或者数据异常'
// });
// return;
// }
if(!this.filesData) return this.$message.warning('请上传文件');
this.$refs.upload.value = '';
this.refreshTag.push({
tagItemIndex: this.importPop.tagItemIndex,
......
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