| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { fromJS } from 'immutable' |
| | | import { Form, Row, Col, Icon, Button, notification, Select, Popconfirm, Typography, Modal } from 'antd' |
| | | import { Form, Row, Col, Icon, Button, notification, Select, Popconfirm, Typography, Modal, Radio } from 'antd' |
| | | import moment from 'moment' |
| | | |
| | | import Utils from '@/utils/utils.js' |
| | |
| | | { |
| | | title: 'SQL', |
| | | dataIndex: 'sql', |
| | | width: '73%', |
| | | width: '60%', |
| | | render: (text) => { |
| | | let title = text.match(/^\s*\/\*.+\*\//) |
| | | title = title && title[0] ? title[0] : '' |
| | |
| | | <Paragraph copyable ellipsis={{ rows: 4, expandable: true }}>{text}</Paragraph> |
| | | </div> |
| | | ) |
| | | } |
| | | }, |
| | | { |
| | | title: '执行位置', |
| | | dataIndex: 'position', |
| | | width: '13%', |
| | | render: (text, record) => { |
| | | if (record.position === 'front') { |
| | | return 'sql前' |
| | | } else { |
| | | return 'sql后' |
| | | } |
| | | } |
| | | }, |
| | | { |
| | |
| | | const { searches, scripts } = this.props |
| | | |
| | | let _usefulFields = [] |
| | | let scriptsColumns = fromJS(this.state.scriptsColumns).toJS() |
| | | |
| | | if (searches) { |
| | | searches.forEach(item => { |
| | |
| | | } |
| | | }) |
| | | _usefulFields = _usefulFields.join(', ') |
| | | scriptsColumns = scriptsColumns.filter(item => { |
| | | if (item.dataIndex === 'sql') { |
| | | item.width = '70%' |
| | | } |
| | | return item.dataIndex !== 'position' |
| | | }) |
| | | } else { |
| | | _usefulFields = null |
| | | } |
| | | |
| | | this.setState({ |
| | | usefulFields: _usefulFields, |
| | | scripts: fromJS(scripts).toJS() |
| | | scripts: fromJS(scripts).toJS(), |
| | | scriptsColumns |
| | | }) |
| | | } |
| | | |
| | |
| | | |
| | | let values = { |
| | | uuid: editItem && editItem.uuid ? editItem.uuid : Utils.getuuid(), |
| | | sql: _sql |
| | | sql: _sql, |
| | | } |
| | | |
| | | if (this.props.form.getFieldValue('position')) { |
| | | values.position = this.props.form.getFieldValue('position') |
| | | } |
| | | |
| | | let _quot = values.sql.match(/'{1}/g) |
| | |
| | | } |
| | | |
| | | handleEdit = (record) => { |
| | | const { usefulFields } = this.state |
| | | this.setState({ |
| | | editItem: record |
| | | }) |
| | | |
| | | this.props.form.setFieldsValue({ |
| | | sql: record.sql |
| | | }) |
| | | if (usefulFields) { |
| | | this.props.form.setFieldsValue({ |
| | | sql: record.sql |
| | | }) |
| | | } else { |
| | | this.props.form.setFieldsValue({ |
| | | sql: record.sql, |
| | | position: record.position || 'back' |
| | | }) |
| | | } |
| | | |
| | | this.scrolltop() |
| | | } |
| | |
| | | id, bid, loginuid, sessionuid, userid, username, fullname, appkey, time_id{usefulFields ? ', ' + usefulFields : ''} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {!usefulFields ? <Col span={8} style={{whiteSpace: 'nowrap'}}> |
| | | <Form.Item style={{marginBottom: 0}} label="执行位置"> |
| | | {getFieldDecorator('position', { |
| | | initialValue: 'front' |
| | | })( |
| | | <Radio.Group> |
| | | <Radio value="front">sql前</Radio> |
| | | <Radio value="back">sql后</Radio> |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | <Col span={10} className="quick-add"> |
| | | <Form.Item label={'快捷添加'} style={{marginBottom: 0}}> |
| | | <Select |
| | |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | onChange={this.selectScript} |
| | | > |
| | | {!usefulFields ? <Select.Option key="default" value={`declare @${setting.cbTable} table (mk_api_key nvarchar(100))`}>默认sql</Select.Option> : null} |
| | | {!usefulFields ? <Select.Option key="default" value={`declare @${setting.cbTable} table (mk_api_key nvarchar(100))\n/*@${setting.cbTable}_data table (mk_level nvarchar(10),mk_id nvarchar(50),mk_bid nvarchar(50))*/`}>默认sql</Select.Option> : null} |
| | | {systemScripts.map((option, i) => |
| | | <Select.Option style={{whiteSpace: 'normal'}} key={i} value={option.value}>{option.name}</Select.Option> |
| | | )} |