| | |
| | | import React, { Component } from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { notification } from 'antd' |
| | | import * as XLSX from 'xlsx' |
| | | import * as XLSX from 'sheetjs-style' |
| | | import Utils from '@/utils/utils.js' |
| | | import './index.scss' |
| | | |
| | |
| | | |
| | | let errors = null |
| | | let sheetName = btn.verify.sheet |
| | | let errDetail = '' |
| | | |
| | | if (Object.keys(workbook.Sheets).length === 1) { |
| | | if (sheetName === 'Sheet1' && Object.keys(workbook.Sheets).length === 1) { |
| | | sheetName = Object.keys(workbook.Sheets)[0] |
| | | } |
| | | |
| | |
| | | } else { |
| | | let iserror = false |
| | | btn.verify.columns.forEach(op => { |
| | | if (header[op.Column] !== op.Text) { |
| | | let _name = typeof(header[op.Column]) === 'string' ? header[op.Column].replace(/(^\s*|\s*$)/g, '') : header[op.Column] |
| | | let _text = op.Text ? op.Text.replace(/(^\s*|\s*$)/g, '') : op.Text |
| | | |
| | | if (!_name && !iserror) { |
| | | iserror = true |
| | | errors = 'headerError' |
| | | errDetail = `Excel中不存在(${_text})列!` |
| | | } else if (_name !== _text && !iserror) { |
| | | iserror = true |
| | | errors = 'headerError' |
| | | errDetail = `Excel中(${_name})与按钮列信息(${_text})不一致!` |
| | | } |
| | | }) |
| | | |
| | | if (iserror) { |
| | | errors = 'headerError' |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | // 最终获取到并且格式化后的 json 数据 |
| | | this.props.returndata(data, errors, sheetName) |
| | | this.props.returndata(data, errors, sheetName, errDetail) |
| | | this.setState({ |
| | | excelId: '', |
| | | }, () => { |