|
@ -4,7 +4,7 @@ import { connect } from 'react-redux'; |
|
|
import moment from 'moment'; |
|
|
import moment from 'moment'; |
|
|
import { Modal, Form, Button, Notification } from '@douyinfe/semi-ui'; |
|
|
import { Modal, Form, Button, Notification } from '@douyinfe/semi-ui'; |
|
|
import { IconUpload } from '@douyinfe/semi-icons'; |
|
|
import { IconUpload } from '@douyinfe/semi-icons'; |
|
|
import XLSX from 'xlsx'; |
|
|
import * as XLSX from 'xlsx' |
|
|
import { performanceSummaryKeys } from '../../constants/index'; |
|
|
import { performanceSummaryKeys } from '../../constants/index'; |
|
|
//下载模板和上传文件读取 |
|
|
//下载模板和上传文件读取 |
|
|
const ImportPerformanceSummaryModal = props => { |
|
|
const ImportPerformanceSummaryModal = props => { |
|
@ -68,12 +68,13 @@ const ImportPerformanceSummaryModal = props => { |
|
|
reader.readAsBinaryString(request.response); |
|
|
reader.readAsBinaryString(request.response); |
|
|
reader.onload = event => { |
|
|
reader.onload = event => { |
|
|
try { |
|
|
try { |
|
|
|
|
|
debugger |
|
|
const { result } = event.target; |
|
|
const { result } = event.target; |
|
|
// 以二进制流方式读取得到整份excel表格对象 |
|
|
// 以二进制流方式读取得到整份excel表格对象 |
|
|
const workbook = XLSX.read(result, { |
|
|
const workbook = XLSX.read(result, { |
|
|
type: "binary", |
|
|
type: "binary", |
|
|
cellDates: true,//设为true,将天数的时间戳转为时间格式 |
|
|
cellDates: true,//设为true,将天数的时间戳转为时间格式 |
|
|
codepage: 936//解决了乱码问题 |
|
|
codepage: 936,//解决了乱码问题 |
|
|
}); |
|
|
}); |
|
|
let data = []; // 存储获取到的数据 |
|
|
let data = []; // 存储获取到的数据 |
|
|
// 遍历每张工作表进行读取(这里默认只读取第一张表) |
|
|
// 遍历每张工作表进行读取(这里默认只读取第一张表) |
|
@ -195,7 +196,6 @@ const ImportPerformanceSummaryModal = props => { |
|
|
postData.push(obj); |
|
|
postData.push(obj); |
|
|
} |
|
|
} |
|
|
setPostData(postData) |
|
|
setPostData(postData) |
|
|
console.log(postData,'======================='); |
|
|
|
|
|
let msg = '文件解析完成,点击确定按钮上传保存!' |
|
|
let msg = '文件解析完成,点击确定按钮上传保存!' |
|
|
setMsg(msg) |
|
|
setMsg(msg) |
|
|
onSuccess({ message: msg }) |
|
|
onSuccess({ message: msg }) |
|
|