Merge branch 'master' into positec
| | |
| | | MKEmitter.emit('transferSyncData', tabId) |
| | | |
| | | if (!result.message) return |
| | | |
| | | if (/将截断字符串或二进制数据/ig.test(result.message)) { |
| | | result.message = result.message + '请检查字段集' |
| | | } |
| | | if (result.ErrCode === 'N') { |
| | | Modal.error({ |
| | | title: result.message, |
| | |
| | | MKEmitter.emit('transferSyncData', MenuID) |
| | | |
| | | if (!result.message) return |
| | | |
| | | if (/将截断字符串或二进制数据/ig.test(result.message)) { |
| | | result.message = result.message + '请检查字段集' |
| | | } |
| | | if (result.ErrCode === 'N') { |
| | | Modal.error({ |
| | | title: result.message, |
| | |
| | | MKEmitter.emit('transferSyncData', Tab.uuid) |
| | | |
| | | if (!result.message) return |
| | | |
| | | if (/将截断字符串或二进制数据/ig.test(result.message)) { |
| | | result.message = result.message + '请检查字段集' |
| | | } |
| | | if (result.ErrCode === 'N') { |
| | | Modal.error({ |
| | | title: result.message, |
| | |
| | | import React, { Component } from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { notification } from 'antd' |
| | | import * as XLSX from 'sheetjs-style' |
| | | import Utils from '@/utils/utils.js' |
| | | import './index.scss' |
| | |
| | | onImportExcel = file => { |
| | | const { btn } = this.props |
| | | |
| | | let btnColumns = btn.verify.columns.filter(option => option.import !== 'init') |
| | | let columns = btnColumns.map(option => option.Column) |
| | | let range = btn.verify.range || 0 |
| | | |
| | | // excel数据处理 |
| | | const { files } = file.target |
| | | const fileReader = new FileReader() |
| | |
| | | // 以二进制流方式读取得到整份excel表格对象 |
| | | const workbook = XLSX.read(result, { type: 'binary' }) |
| | | |
| | | let errors = null |
| | | let sheetName = btn.verify.sheet |
| | | let errDetail = '' |
| | | |
| | | if (sheetName === 'Sheet1' && Object.keys(workbook.Sheets).length === 1) { |
| | | sheetName = Object.keys(workbook.Sheets)[0] |
| | | } |
| | | |
| | | if (!workbook.Sheets.hasOwnProperty(sheetName)) { |
| | | errors = 'notexit' |
| | | } else if (range === 1) { |
| | | let header = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName], {header: columns})[0] |
| | | |
| | | if (!header) { |
| | | errors = 'empty' |
| | | } else { |
| | | let iserror = false |
| | | btnColumns.forEach(op => { |
| | | if (iserror) return |
| | | |
| | | 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 = true |
| | | errors = 'headerError' |
| | | errDetail = `Excel中不存在(${_text})列!` |
| | | } else if (_name !== _text) { |
| | | iserror = true |
| | | errors = 'headerError' |
| | | errDetail = `Excel中(${_name})与按钮列信息(${_text})不一致!` |
| | | } |
| | | }) |
| | | if (btn.verify.excelHandle === 'true') { |
| | | // eslint-disable-next-line |
| | | let func = new Function('XLSX', 'workbook', 'btn', 'callback', btn.verify.excel_func) |
| | | func(XLSX, workbook, btn.verify, (data, error) => { |
| | | if (!error && (!data || data.length === 0)) { |
| | | error = '未获取到Excel数据!' |
| | | } |
| | | this.props.returndata(data, error) |
| | | }) |
| | | } else { |
| | | let btnColumns = btn.verify.columns.filter(option => option.import !== 'init') |
| | | let columns = btnColumns.map(option => option.Column) |
| | | let range = btn.verify.range || 0 |
| | | |
| | | let error = null |
| | | let sheetName = btn.verify.sheet |
| | | |
| | | if (sheetName === 'Sheet1' && Object.keys(workbook.Sheets).length === 1) { |
| | | sheetName = Object.keys(workbook.Sheets)[0] |
| | | } |
| | | |
| | | if (!workbook.Sheets.hasOwnProperty(sheetName)) { |
| | | error = '工作表《' + sheetName + '》不存在!' |
| | | } else if (range === 1) { |
| | | let header = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName], {header: columns})[0] |
| | | |
| | | if (!header) { |
| | | error = '工作表《' + sheetName + '》为空!' |
| | | } else { |
| | | btnColumns.forEach(op => { |
| | | if (error) return |
| | | |
| | | 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) { |
| | | error = `工作表《${sheetName}》表头错误,Excel中不存在(${_text})列!` |
| | | } else if (_name !== _text) { |
| | | error = `工作表《${sheetName}》表头错误,Excel中(${_name})与按钮列信息(${_text})不一致!` |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | |
| | | let data = [] |
| | | |
| | | if (!error) { |
| | | data = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName], {header: columns, range: (range)}) |
| | | |
| | | if (!data || data.length === 0) { |
| | | error = '未获取到工作表《' + sheetName + '》数据!' |
| | | } |
| | | } |
| | | |
| | | // 最终获取到并且格式化后的 json 数据 |
| | | this.props.returndata(data, error) |
| | | } |
| | | |
| | | let data = [] |
| | | |
| | | if (!errors) { |
| | | data = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName], {header: columns, range: (range)}) |
| | | } |
| | | |
| | | // 最终获取到并且格式化后的 json 数据 |
| | | this.props.returndata(data, errors, sheetName, errDetail) |
| | | this.setState({ |
| | | excelId: '', |
| | | }, () => { |
| | |
| | | excelId: Utils.getuuid() |
| | | }) |
| | | }) |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '文件解析错误!', |
| | | duration: 5 |
| | | }) |
| | | // 错误传递 |
| | | this.props.returndata([], 'other') |
| | | this.props.returndata([], '文件解析错误!') |
| | | } |
| | | } |
| | | |
| | |
| | | /** |
| | | * @description Excel 导入 |
| | | */ |
| | | getexceldata = (data, errors, sheetName, errDetail) => { |
| | | getexceldata = (data, error) => { |
| | | const { btn, BID } = this.props |
| | | |
| | | if (errors) { |
| | | if (errors === 'notexit') { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '工作表《' + sheetName + '》不存在!', |
| | | duration: 5 |
| | | }) |
| | | } else if (errors === 'empty') { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '工作表《' + sheetName + '》为空!', |
| | | duration: 5 |
| | | }) |
| | | } else if (errors === 'headerError') { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: `工作表《${sheetName}》表头错误,${errDetail}`, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | if (error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: error, |
| | | duration: 5 |
| | | }) |
| | | |
| | | this.setState({ loading: false }) |
| | | return |
| | | } |
| | | |
| | | if (!data || data.length === 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '未获取到工作表《' + sheetName + '》数据!', |
| | | duration: 5 |
| | | }) |
| | | this.setState({ loading: false }) |
| | | return |
| | | } else if (data.length * btn.verify.columns.length > 30000) { |
| | | |
| | | if (data.length * btn.verify.columns.length > 30000) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '当前导入数据量过大,如遇错误提示,请分批导入!', |
| | |
| | | |
| | | Api.genericInterface(param).then(result => { |
| | | if (result.status) { |
| | | this.exportExcel(result.data, result.ErrCode, result.message) |
| | | this.exportExcel(result.data, result.ErrCode, result.message, viewParam.search) |
| | | } else { |
| | | this.execError(result) |
| | | } |
| | |
| | | |
| | | Api.genericInterface(param).then(result => { |
| | | if (result.status) { |
| | | this.exportExcel(result.data, result.ErrCode, result.message) |
| | | this.exportExcel(result.data, result.ErrCode, result.message, viewParam.search) |
| | | } else { |
| | | this.execError(result) |
| | | } |
| | |
| | | |
| | | Api.genericInterface(param).then(result => { |
| | | if (result.status) { |
| | | this.exportExcel(result.data, result.ErrCode, result.message) |
| | | this.exportExcel(result.data, result.ErrCode, result.message, viewParam.search) |
| | | } else { |
| | | this.execError(result) |
| | | } |
| | |
| | | |
| | | Api.genericInterface(res).then(result => { |
| | | if (result.status) { |
| | | this.exportExcel(result.data, result.ErrCode, result.message) |
| | | this.exportExcel(result.data, result.ErrCode, result.message, viewParam.search) |
| | | } else { |
| | | this.execError(result) |
| | | } |
| | |
| | | this.getExcelOutDoubleData(viewParam, pageIndex, pageSize, data) |
| | | } else { |
| | | data = data.concat(result.data) |
| | | this.exportExcel(data, result.ErrCode, result.message) |
| | | this.exportExcel(data, result.ErrCode, result.message, viewParam.search) |
| | | } |
| | | } else { |
| | | this.execError(result) |
| | |
| | | this.getExcelOutData(viewParam, pageIndex, pageSize, data) |
| | | } else { |
| | | data = data.concat(result.data) |
| | | this.exportExcel(data, result.ErrCode, result.message) |
| | | this.exportExcel(data, result.ErrCode, result.message, viewParam.search) |
| | | } |
| | | } else { |
| | | this.execError(result) |
| | |
| | | /** |
| | | * @description Excel 生成 |
| | | */ |
| | | exportExcel = (data, ErrCode, msg) => { |
| | | exportExcel = (data, ErrCode, msg, search) => { |
| | | const { btn } = this.props |
| | | |
| | | let imgCol = false |
| | |
| | | try { |
| | | if (btn.verify.excelHandle === 'true') { |
| | | // eslint-disable-next-line |
| | | let func = new Function('XLSX', 'data', 'columns', 'callback', btn.verify.excel_func) |
| | | func(XLSX, data, columns, (res) => { |
| | | let func = new Function('XLSX', 'data', 'columns', 'searches', 'callback', btn.verify.excel_func) |
| | | func(XLSX, data, columns, search, (res) => { |
| | | res = res || {ErrCode: ErrCode || 'S', message: msg || '导出成功!'} |
| | | this.execSuccess(res) |
| | | }) |
| | |
| | | const { confirm } = Modal |
| | | const { Search } = Input |
| | | const { Paragraph } = Typography |
| | | |
| | | const EditTable = asyncComponent(() => import('@/templates/zshare/editTable')) |
| | | const CodeMirror = asyncComponent(() => import('@/templates/zshare/codemirror')) |
| | | const FullScripts = asyncComponent(() => import('@/templates/zshare/verifycard/fullScripts')) |
| | | |
| | | class VerifyCard extends Component { |
| | |
| | | _verify.range = 1 |
| | | } |
| | | |
| | | _verify.excelHandle = _verify.excelHandle || 'false' |
| | | _verify.default = _verify.default || 'true' |
| | | _verify.sheet = _verify.sheet || 'Sheet1' |
| | | _verify.range = _verify.range || 0 |
| | | _verify.columns = _columns |
| | | _verify.scripts = _verify.scripts || [] |
| | | _verify.uniques = _verify.uniques || [] |
| | | |
| | | this.setState({ |
| | | searchKey: '', |
| | | verify: { |
| | | ..._verify, |
| | | default: _verify.default || 'true', |
| | | sheet: _verify.sheet || 'Sheet1', |
| | | range: _verify.range || 0, |
| | | columns: _columns, |
| | | scripts: _verify.scripts || [], |
| | | uniques: _verify.uniques || [] |
| | | } |
| | | verify: _verify |
| | | }, () => { |
| | | this.resetUniqueColumns() |
| | | }) |
| | |
| | | if (!err) { |
| | | let _verify = {...verify, ...values} |
| | | |
| | | if (_verify.excelHandle !== 'true') { |
| | | delete _verify.excel_func |
| | | } |
| | | |
| | | let cols = _verify.columns.map(col => col.Column.toLowerCase()) |
| | | cols = Array.from(new Set(cols)) |
| | | |
| | |
| | | resolve(_verify) |
| | | } |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请设置Excel表名!', |
| | | duration: 5 |
| | | }) |
| | | this.setState({activeKey: 'basemsg'}) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | onOptionChange = (e, key) => { |
| | | onOptionChange = (e) => { |
| | | const { verify } = this.state |
| | | let value = e.target.value |
| | | |
| | | this.setState({ |
| | | verify: {...verify, default: value} |
| | | }) |
| | | } |
| | | |
| | | onHandleChange = (e) => { |
| | | const { verify } = this.state |
| | | let value = e.target.value |
| | | |
| | | this.setState({ |
| | | verify: {...verify, excelHandle: value} |
| | | }) |
| | | } |
| | | |
| | |
| | | <TabPane tab="基础验证" key="basemsg"> |
| | | <Form {...formItemLayout}> |
| | | <Row gutter={24}> |
| | | {card.intertype === 'system' ? <Col span={8}> |
| | | <Form.Item label={'默认sql'}> |
| | | <Radio.Group value={verify.default} onChange={this.onOptionChange}> |
| | | <Radio value="true">执行</Radio> |
| | | <Radio value="false">不执行</Radio> |
| | | </Radio.Group> |
| | | </Form.Item> |
| | | </Col> : null} |
| | | <Col span={8}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topRight" title="自定义验证Excel格式,可用参数为 XLSX、workbook、btn、callback。"> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 导入格式 |
| | | </Tooltip> |
| | | }> |
| | | {getFieldDecorator('excelHandle', { |
| | | initialValue: verify.excelHandle |
| | | })( |
| | | <Radio.Group onChange={this.onHandleChange}> |
| | | <Radio value="false">默认</Radio> |
| | | <Radio value="true">自定义</Radio> |
| | | </Radio.Group>)} |
| | | </Form.Item> |
| | | </Col> |
| | | {verify.excelHandle === 'true' ? <Col span={24} style={{paddingLeft: '30px'}}> |
| | | <Form.Item wrapperCol={ {xs: { span: 24 }, sm: { span: 24 }} } label=""> |
| | | {getFieldDecorator('excel_func', { |
| | | initialValue: verify.excel_func || '', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请填写自定义逻辑!' |
| | | } |
| | | ] |
| | | })(<CodeMirror mode="text/javascript" theme="cobalt" />)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {verify.excelHandle !== 'true' ? <Col span={8}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="bottomLeft" title="导入时工作表名与excel中必须一致,注:工作表名为Sheet1且excel中仅有一个工作表时不进行表名验证。"> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | |
| | | ] |
| | | })(<Input placeholder="" autoComplete="off" />)} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={8}> |
| | | </Col> : null} |
| | | {verify.excelHandle !== 'true' ? <Col span={8}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="bottomLeft" title="忽略首行时,会校验excel中表头名称与excel列设置是否一致。"> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | |
| | | {getFieldDecorator('range', { |
| | | initialValue: verify.range || 0 |
| | | })(<InputNumber min={0} max={100} precision={0} />)} |
| | | </Form.Item> |
| | | </Col> |
| | | {card.intertype === 'system' ? <Col span={8}> |
| | | <Form.Item label={'默认sql'}> |
| | | <Radio.Group value={verify.default} onChange={this.onOptionChange}> |
| | | <Radio value="true">执行</Radio> |
| | | <Radio value="false">不执行</Radio> |
| | | </Radio.Group> |
| | | </Form.Item> |
| | | </Col> : null} |
| | | </Row> |
| | |
| | | </Col> : null} |
| | | {btnType !== 'print' ? <Col span={8}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topRight" title="自定义生成Excel,可用参数为 XLSX、data、columns、callback。"> |
| | | <Tooltip placement="topRight" title="自定义生成Excel,可用参数为 XLSX、data、columns、searches、callback。"> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 导出格式 |
| | | </Tooltip> |
| | |
| | | return new Promise(resolve => { |
| | | Api.genericInterface(item).then(res => { |
| | | if (!res.status) { |
| | | if (item.func === 'sPC_Get_structured_data' && /将截断字符串或二进制数据/ig.test(res.message)) { |
| | | res.message = res.message + '请检查字段集' |
| | | } |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | |
| | | table { |
| | | border-radius: 0!important; |
| | | .ant-table-column-sorter { |
| | | display: none!important; |
| | | opacity: 0!important; |
| | | } |
| | | } |
| | | .ant-table-thead > tr > th { |
| | |
| | | // import './index.scss' |
| | | |
| | | const Tabview = asyncComponent(() => import('@/components/tabview')) |
| | | const ImgScale = asyncComponent(() => import('@/components/imgScale')) |
| | | |
| | | class MkHS extends Component { |
| | | UNSAFE_componentWillMount() { |
| | |
| | | <Tabview key="tabview"/> |
| | | <Header key="header"/> |
| | | </ConfigProvider> |
| | | <ImgScale /> |
| | | </div> |
| | | ) |
| | | } |