king
2020-04-29 9b6ce1a5778c6e1a813237e87588c0052aae1bbb
src/templates/zshare/verifycard/customscript/index.jsx
@@ -1,6 +1,6 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Form, Row, Col, Input, Button, notification, Modal, Select, Tooltip, Icon, Radio } from 'antd'
import { Form, Row, Col, Input, Button, notification, Modal, Menu, Tooltip, Icon, Radio, Dropdown } from 'antd'
import moment from 'moment'
import Utils from '@/utils/utils.js'
@@ -12,6 +12,7 @@
class CustomForm extends Component {
  static propTpyes = {
    dict: PropTypes.object,         // 字典项
    btn: PropTypes.object,          // 按钮信息
    usefulfields: PropTypes.string, // 可用字段
    initsql: PropTypes.string,      // sql前缀
    systemScripts: PropTypes.array, // 系统脚本
@@ -130,7 +131,11 @@
    })
  }
  selectScript = (val, option) => {
  selectScript = (e) => {
    const { systemScripts } = this.props
    let option = systemScripts[+e.key]
    let _sql = this.props.form.getFieldValue('sql')
    if (_sql) {
      _sql = _sql + ` 
@@ -139,10 +144,10 @@
    }
    _sql = _sql.replace(/\s{6}$/, '')
    _sql = _sql + `/*${option.props.title}*/
    _sql = _sql + `/*${option.name}*/
    `
    _sql = _sql.replace(/\s{4}$/, '')
    _sql = _sql + val
    _sql = _sql + option.value
    this.props.form.setFieldsValue({
      sql: _sql
@@ -150,7 +155,7 @@
  }
  render() {
    const { usefulfields, systemScripts } = this.props
    const { usefulfields, systemScripts, btn } = this.props
    const { getFieldDecorator } = this.props.form
    const formItemLayout = {
      labelCol: {
@@ -171,7 +176,7 @@
              {usefulfields}
            </Form.Item>
          </Col> : null}
          <Col span={8}>
          <Col span={8} style={{whiteSpace: 'nowrap'}}>
            <Form.Item style={{marginBottom: 0}} label={
              <Tooltip placement="bottomLeft" title={'自定义脚本与默认sql位置关系。'}>
                <Icon type="question-circle" style={{color: '#c49f47', marginRight: '5px'}} />
@@ -189,27 +194,29 @@
              )}
            </Form.Item>
          </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}>
          <Col span={4} style={{lineHeight: '40px', textAlign: 'center'}}>
            <Dropdown trigger={['click']} overlayClassName="mk-normal-dropdown" overlay={
              <Menu onClick={this.selectScript}>
                {systemScripts.map((option, i) =>
                  <Select.Option title={option.name} key={i} value={option.value}>
                    {option.name}
                  </Select.Option>
                  <Menu.Item key={i}>{option.name}</Menu.Item>
                )}
              </Select>
            </Form.Item>
              </Menu>
            }>
              <span style={{color: '#1890ff', display: 'inline-block', cursor: 'pointer'}}>
                快捷添加 <Icon type="down" style={{marginRight: '5px'}} />
              </span>
            </Dropdown>
          </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.sql ? <span style={{maxWidth: '100%', display: 'inline-block', position: 'relative', top: '20px', whiteSpace: 'nowrap', textOverflow: 'ellipsis', overflow: 'hidden'}}>
              表名:  {btn.sql}
            </span> : null}
          </Col>
          <Col span={24} className="sql">
            <Form.Item label={'sql'}>
              {getFieldDecorator('sql', {