共计 843 个字符,预计需要花费 3 分钟才能阅读完成。
upload_excel(e) {let fileReader = new FileReader();
fileReader.onload = async (event) => {var workbook = XLSX.read(event.target.result, { type: 'binary'});
console.log(workbook);
let json = XLSX.utils.sheet_to_json(workbook.Sheets.Sheet1, { range: 1, dateNF: 'FMT 22'});
console.log(this);
let data = json.map((temp) => {switch (temp['号牌品种']) {
case '大型汽车':
var type = '01';
break;
case '挂车':
var type = '15';
break;
case '小型汽车':
var type = '02';
break;
}
switch (temp['是否解决']) {
case '未解决':
var handle = '1';
break;
case '已解决':
var handle = '3';
break;
}
return {
type: type,
chepai: temp['号牌号码'],
wf_time: this.formatDate(temp['守法工夫']),
wf_address: temp['守法地点'],
content: temp['违法行为'],
handle: handle,
pay_type: temp['缴款状态'] == '未交款' ? 0 : 1,
};
});
let result = await create({data: data});
if (result.err == 0) {this.tableRef.current.reload();
message.success(result.msg);
} else {message.success(result.msg);
}
};
fileReader.readAsBinaryString(e.file); // 二进制
}
正文完
发表至: javascript
2021-10-13