| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Form, Row, Col, Button, notification, Tooltip, Select } from 'antd' |
| | | import { Form, Row, Col, Button, notification, Tooltip, Select, Switch } from 'antd' |
| | | import moment from 'moment' |
| | | |
| | | import Api from '@/api' |
| | |
| | | systemScripts: [], |
| | | usefulfields: null, |
| | | loading: false, |
| | | skip: false |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | } |
| | | |
| | | handleConfirm = () => { |
| | | const { skip } = this.state |
| | | // 表单提交时检查输入值是否正确 |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | |
| | | this.props.scriptsChange(values, (status) => { |
| | | if (status) { |
| | | this.setState({ |
| | | skip: false, |
| | | loading: false, |
| | | editItem: null |
| | | }) |
| | |
| | | loading: false |
| | | }) |
| | | } |
| | | }) |
| | | }, skip) |
| | | } |
| | | }) |
| | | } |
| | |
| | | } |
| | | |
| | | selectScript = (value, option) => { |
| | | const { usefulfields, sheet } = this.props |
| | | |
| | | let _value = '' |
| | | if (value === 'default') { |
| | | let fields = usefulfields.filter(item => item.import !== 'false') |
| | | fields = fields.map(col => col.Column).join(',') |
| | | |
| | | let _sheet = sheet.replace(/(.*)\.(.*)\.|@db@/ig, '') |
| | | |
| | | _value = `Select ${fields} From ${_sheet}` |
| | | } else { |
| | | _value = value |
| | | } |
| | | |
| | | let _value = value |
| | | let _sql = this.props.form.getFieldValue('sql') |
| | | if (/^\s+$/.test(_sql)) { |
| | | _sql = '' |
| | |
| | | |
| | | render() { |
| | | const { sheet, linefields } = this.props |
| | | const { usefulfields, systemScripts } = this.state |
| | | const { usefulfields, systemScripts, skip } = this.state |
| | | const { getFieldDecorator } = this.props.form |
| | | const formItemLayout = { |
| | | labelCol: { |
| | |
| | | onSelect={this.selectScript} |
| | | getPopupContainer={() => document.getElementById('verify-excelin-custom-scripts')} |
| | | > |
| | | <Select.Option key="default" value={'default'}> |
| | | 默认sql |
| | | </Select.Option> |
| | | <Select.Option key="debugger" value={`z_debug: select @ErrorCode='E',@retmsg='测试断点' goto aaa`}> |
| | | 测试断点 |
| | | </Select.Option> |
| | |
| | | </Select> |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={6} className="add"> |
| | | <Col span={5} className="add" style={{whiteSpace: 'nowrap'}}> |
| | | <Button onClick={this.handleConfirm} loading={this.state.loading} className="mk-green" style={{marginBottom: 15, marginLeft: 40}}> |
| | | 保存 |
| | | </Button> |
| | |
| | | 取消 |
| | | </Button> |
| | | </Col> |
| | | <Col span={3} style={{paddingTop: '15px', fontSize: '12px', whiteSpace: 'nowrap'}}> |
| | | 强制保存: |
| | | <Switch checked={skip} size="small" onChange={() => this.setState({skip: !skip})}/> |
| | | </Col> |
| | | <Col span={24} className="sql"> |
| | | <Form.Item label="sql"> |
| | | {getFieldDecorator('sql', { |