| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { Form, Row, Col, Input, Button, notification, Modal, Menu, Icon, Tooltip, Radio, Dropdown } from 'antd' |
| | | import { Form, Row, Col, Input, Button, notification, Modal, Icon, Tooltip, Radio, Select } from 'antd' |
| | | import moment from 'moment' |
| | | |
| | | import Utils from '@/utils/utils.js' |
| | |
| | | }) |
| | | } |
| | | |
| | | selectScript = (e) => { |
| | | const { systemScripts, usefulfields, btn } = this.props |
| | | selectScript = (value, option) => { |
| | | const { usefulfields, btn } = this.props |
| | | |
| | | let option = '' |
| | | if (e.key === 'default') { |
| | | let _value = '' |
| | | if (value === 'default') { |
| | | let fields = usefulfields.map(col => col.Column).join(',') |
| | | |
| | | if (fields) { |
| | | fields = fields + ',' |
| | | } |
| | | |
| | | option = { |
| | | name: '默认sql', |
| | | value: `Insert into ${btn.sheet} (${fields}createuserid,createuser,createstaff,bid)\nSelect ${fields}@userid,@username,@fullname,@BID From @${btn.sheet}` |
| | | } |
| | | _value = `Insert into ${btn.sheet} (${fields}createuserid,createuser,createstaff,bid)\nSelect ${fields}@userid,@username,@fullname,@BID From @${btn.sheet}` |
| | | } else { |
| | | option = systemScripts[+e.key] |
| | | _value = value |
| | | } |
| | | |
| | | let _sql = this.props.form.getFieldValue('sql') |
| | |
| | | } |
| | | |
| | | _sql = _sql.replace(/\s{6}$/, '') |
| | | _sql = _sql + `/*${option.name}*/ |
| | | _sql = _sql + `/*${option.props.children}*/ |
| | | ` |
| | | _sql = _sql.replace(/\s{4}$/, '') |
| | | _sql = _sql + option.value |
| | | _sql = _sql + _value |
| | | |
| | | this.props.form.setFieldsValue({ |
| | | sql: _sql |
| | |
| | | } |
| | | |
| | | return ( |
| | | <Form {...formItemLayout} className="verify-form" id="verifycard2"> |
| | | <Form {...formItemLayout} className="verify-form" id="verify-excelin-custom-scripts"> |
| | | <Row gutter={24}> |
| | | {btn.sheet ? <Col span={8}> |
| | | <Form.Item label={'表名'} style={{whiteSpace: 'nowrap', margin: 0}}> |
| | | {btn.sheet} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | <Col span={16}> |
| | | <Form.Item label={'报错字段'} style={{margin: 0}}> |
| | | errorCode, errmsg |
| | | </Form.Item> |
| | | </Col> |
| | | {usefulfields ? <Col span={24} className="sqlfield"> |
| | | <Form.Item label={'可用字段'}> |
| | | {usefulfields} |
| | |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={4} style={{lineHeight: '40px', textAlign: 'center'}}> |
| | | <Dropdown trigger={['click']} overlayClassName="mk-normal-dropdown" overlay={ |
| | | <Menu onClick={this.selectScript}> |
| | | <Menu.Item key="default">默认sql</Menu.Item> |
| | | <Col span={10}> |
| | | <Form.Item style={{marginBottom: 0}} label={'快捷添加'}> |
| | | <Select |
| | | showSearch |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | onChange={this.selectScript} |
| | | getPopupContainer={() => document.getElementById('verify-excelin-custom-scripts')} |
| | | > |
| | | <Select.Option key="default" value={'default'}> |
| | | 默认sql |
| | | </Select.Option> |
| | | {systemScripts.map((option, i) => |
| | | <Menu.Item key={i} value={option.value}>{option.name}</Menu.Item> |
| | | )} |
| | | {systemScripts.map((option, i) => |
| | | <Menu.Item key={i + '1'} value={option.value}>{option.name}</Menu.Item> |
| | | )} |
| | | </Menu> |
| | | }> |
| | | <span style={{color: '#1890ff', display: 'inline-block', cursor: 'pointer'}}> |
| | | 快捷添加 <Icon type="down" style={{marginRight: '5px'}} /> |
| | | </span> |
| | | </Dropdown> |
| | | </Col> |
| | | {/* <Col span={8}> |
| | | <Form.Item style={{marginBottom: 0}} label={ |
| | | <Tooltip placement="bottomLeft" title={'从系统函数集中选择需要的函数,可快速添加至sql中。'}> |
| | | <Icon type="question-circle" style={{color: '#c49f47', marginRight: '5px'}} /> |
| | | 快捷添加 |
| | | </Tooltip> |
| | | }> |
| | | <Select value="" onChange={this.selectScript}> |
| | | {systemScripts.map((option, i) => |
| | | <Select.Option title={option.name} key={i} value={option.value}> |
| | | <Select.Option key={i} value={option.value}> |
| | | {option.name} |
| | | </Select.Option> |
| | | )} |
| | | </Select> |
| | | </Form.Item> |
| | | </Col> */} |
| | | </Col> |
| | | <Col span={4} className="add"> |
| | | <Button onClick={this.handleConfirm} loading={this.state.loading} className="mk-green" style={{marginBottom: 15, marginLeft: 40}}> |
| | | 保存 |
| | | </Button> |
| | | </Col> |
| | | <Col span={8} style={{textAlign: 'right'}}> |
| | | {btn.sheet ? <span style={{maxWidth: '100%', display: 'inline-block', position: 'relative', top: '20px', whiteSpace: 'nowrap', textOverflow: 'ellipsis', overflow: 'hidden'}}> |
| | | 表名: {btn.sheet} |
| | | </span> : null} |
| | | </Col> |
| | | <Col span={24} className="sql"> |
| | | <Form.Item label={'sql'}> |