| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { Form, Tabs, Row, Col, Input, Button, Table, Popconfirm, Icon, notification, Modal, message, InputNumber, Radio, Typography } from 'antd' |
| | | import { Form, Tabs, Row, Col, Input, Button, Table, Popconfirm, Icon, Tooltip, notification, Modal, message, InputNumber, Radio, Typography } from 'antd' |
| | | import moment from 'moment' |
| | | |
| | | import Api from '@/api' |
| | |
| | | state = { |
| | | verify: {}, |
| | | systemScripts: [], |
| | | activeKey: 'basemsg', |
| | | excelColumns: [ |
| | | { |
| | | title: this.props.dict['model.form.field'], |
| | |
| | | if (col.field && !_cols.includes(col.field)) { |
| | | let _type = 'Nvarchar(50)' |
| | | let _limit = '50' |
| | | if (col.type === 'number' && col.decimal === 0) { |
| | | if (col.type === 'number' && !col.decimal) { |
| | | _type = 'Int' |
| | | _limit = '' |
| | | } else if (col.type === 'number') { |
| | |
| | | ...verify, |
| | | columns: _columns |
| | | } |
| | | }) |
| | | } |
| | | |
| | | clearField = () => { |
| | | const { verify } = this.state |
| | | const _this = this |
| | | |
| | | confirm({ |
| | | content: `确定清空Excel列吗?`, |
| | | okText: this.props.dict['model.confirm'], |
| | | cancelText: this.props.dict['model.cancel'], |
| | | onOk() { |
| | | _this.setState({ |
| | | verify: { |
| | | ...verify, |
| | | columns: [] |
| | | } |
| | | }) |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | | } |
| | | |
| | |
| | | let _loading = false |
| | | if (this.columnForm && this.columnForm.state.editItem) { |
| | | _loading = true |
| | | this.setState({activeKey: 'excelcolumn'}) |
| | | } else if (this.scriptsForm && this.scriptsForm.state.editItem) { |
| | | _loading = true |
| | | this.setState({activeKey: 'scripts'}) |
| | | } else if (this.uniqueForm && this.uniqueForm.state.editItem) { |
| | | _loading = true |
| | | this.setState({activeKey: 'unique'}) |
| | | } |
| | | |
| | | if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) { |
| | | _loading = true |
| | | this.setState({activeKey: 'scripts'}) |
| | | } |
| | | |
| | | if (_loading) { |
| | |
| | | }) |
| | | } |
| | | |
| | | tabchange = (val) => { |
| | | const { activeKey } = this.state |
| | | |
| | | if (activeKey === 'basemsg') { |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | this.setState({activeKey: val}) |
| | | } |
| | | }) |
| | | } else { |
| | | this.setState({activeKey: val}) |
| | | } |
| | | } |
| | | |
| | | render() { |
| | | const { card } = this.props |
| | | const { getFieldDecorator } = this.props.form |
| | | const { verify, excelColumns, scriptsColumns, uniqueColumns } = this.state |
| | | const { verify, excelColumns, scriptsColumns, uniqueColumns, activeKey } = this.state |
| | | const formItemLayout = { |
| | | labelCol: { |
| | | xs: { span: 24 }, |
| | |
| | | |
| | | return ( |
| | | <div id="verify-excel-box-tab"> |
| | | <Tabs defaultActiveKey="1" className="verify-card-box" onChange={this.tabchange}> |
| | | <TabPane tab="基础验证" key="1"> |
| | | <Tabs activeKey={activeKey} className="verify-card-box" onChange={this.tabchange}> |
| | | <TabPane tab="基础验证" key="basemsg"> |
| | | <Form {...formItemLayout}> |
| | | <Row gutter={24}> |
| | | <Col span={8}> |
| | |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={8}> |
| | | <Form.Item label={'忽略行'}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="bottomLeft" title="忽略首行时,会校验excel中表头名称与excel列设置是否一致。"> |
| | | <Icon type="question-circle" style={{color: '#c49f47', marginRight: '5px'}}/> |
| | | 忽略行 |
| | | </Tooltip> |
| | | }> |
| | | {getFieldDecorator('range', { |
| | | initialValue: verify.range || 0 |
| | | })(<InputNumber min={0} max={100} precision={0} />)} |
| | |
| | | </Row> |
| | | </Form> |
| | | </TabPane> |
| | | <TabPane tab="Excel列设置" key="2x"> |
| | | <TabPane tab="Excel列设置" key="excelcolumn"> |
| | | <ColumnForm |
| | | dict={this.props.dict} |
| | | columns={verify.columns} |
| | |
| | | /> |
| | | <Button className="excel-col-add mk-green" title="添加显示列字段" onClick={this.columnFieldInput}> |
| | | 同步显示列 |
| | | </Button> |
| | | <Button className="excel-col-add mk-red" title="清空Excel列" onClick={this.clearField}> |
| | | 清空Excel列 |
| | | </Button> |
| | | <Table |
| | | bordered |
| | |
| | | pagination={false} |
| | | /> |
| | | </TabPane> |
| | | {card.intertype === 'inner' && !card.innerFunc ? <TabPane tab="唯一性验证" key="3"> |
| | | {card.intertype === 'inner' && !card.innerFunc ? <TabPane tab="唯一性验证" key="unique"> |
| | | <UniqueForm |
| | | fields={verify.columns} |
| | | dict={this.props.dict} |
| | |
| | | pagination={false} |
| | | /> |
| | | </TabPane> : null} |
| | | {card.intertype === 'inner' && !card.innerFunc ? <TabPane tab="自定义脚本" key="6"> |
| | | {card.intertype === 'inner' && !card.innerFunc ? <TabPane tab="自定义脚本" key="scripts"> |
| | | <CustomScript |
| | | dict={this.props.dict} |
| | | btn={this.props.card} |
| | |
| | | pagination={false} |
| | | /> |
| | | </TabPane> : null} |
| | | <TabPane tab="信息提示" key="7"> |
| | | <TabPane tab="信息提示" key="tip"> |
| | | <Form {...formItemLayout}> |
| | | <Row gutter={24}> |
| | | <Col offset={6} span={6}> |