king
2023-01-17 cc1a76df575c18f0d0ee96e8658461efdce3a918
src/menu/datasource/verifycard/customscript/index.jsx
@@ -1,15 +1,15 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Form, Row, Col, Button, notification, Select } from 'antd'
import { Form, Row, Col, Button, notification, Select, Tooltip } from 'antd'
import Utils from '@/utils/utils.js'
import CodeMirror from '@/templates/zshare/codemirror'
import MKEmitter from '@/utils/events.js'
import './index.scss'
class CustomForm extends Component {
  static propTpyes = {
    dict: PropTypes.object,         // 字典项
    defaultsql: PropTypes.string,   // 默认sql
    setting: PropTypes.object,      // 设置
    searches: PropTypes.array,      // 搜索条件
@@ -100,6 +100,15 @@
    // 表单提交时检查输入值是否正确
    this.props.form.validateFieldsAndScroll((err, values) => {
      if (!err) {
        if (/^[\s\n]+$/.test(values.sql)) {
          notification.warning({
            top: 92,
            message: '请输入sql!',
            duration: 5
          })
          return
        }
        values.uuid = this.state.editItem ? this.state.editItem.uuid : ''
        let _quot = values.sql.match(/'{1}/g)
@@ -150,6 +159,11 @@
            editItem: null,
            loading: false
          })
          if (values.uuid) {
            MKEmitter.emit('editLineId', values.uuid)
          }
          this.props.form.setFieldsValue({
            sql: ' '
          })
@@ -165,7 +179,9 @@
  selectScript = (value, option) => {
    let _sql = this.props.form.getFieldValue('sql')
    if (_sql) {
    if (_sql === ' ') {
      _sql = ''
    } else if (_sql) {
      _sql = _sql + ` 
      `
@@ -201,6 +217,8 @@
      }
    }
    let urlFields = window.GLOB.urlFields ? window.GLOB.urlFields.join(', ') : ''
    return (
      <Form {...formItemLayout} className="modal-menu-setting-script">
        <Row gutter={24}>
@@ -216,7 +234,10 @@
          </Col>
          <Col span={24} className="sqlfield">
            <Form.Item label={'可用字段'}>
              id, bid, loginuid, sessionuid, userid, username, fullname, RoleID, login_city, appkey, time_id, orderBy, pageSize, pageIndex{usefulFields ? ', ' + usefulFields : ''}{window.GLOB.urlFields && window.GLOB.urlFields.length > 0 ? ', ' + window.GLOB.urlFields.join(', ') : ''}
              <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'公共值,请按照@xxx@格式使用。'}><span style={{color: '#1890ff'}}>BID, ID, LoginUID, SessionUid, UserID, Appkey, time_id</span></Tooltip>,&nbsp;
              <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'系统变量,系统会定义变量并赋值。'}><span style={{color: '#fa8c16'}}>UserName, FullName, RoleID, mk_departmentcode, mk_organization, mk_user_type, mk_nation, mk_province, mk_city, mk_district, mk_address</span></Tooltip>,&nbsp;
              <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'排序、分页以及搜索条件变量,请按照@xxx@格式使用。'}>orderBy, pageSize, pageIndex{usefulFields ? ', ' + usefulFields : ''}</Tooltip>
              <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'url变量,请按照@xxx@格式使用。'}>{urlFields ? ', ' : ''}<span style={{color: '#13c2c2'}}>{urlFields}</span></Tooltip>
            </Form.Item>
          </Col>
          <Col span={10} style={{width: '43%'}}>
@@ -227,6 +248,9 @@
                onSelect={this.selectScript}
              >
                <Select.Option style={{whiteSpace: 'normal'}} key="default" value="defaultsql">默认sql</Select.Option>
                <Select.Option key="debugger" value={`z_debug: select @ErrorCode='E',@retmsg='测试断点' goto aaa`}>
                  测试断点
                </Select.Option>
                {systemScripts.map((option, i) =>
                  <Select.Option style={{whiteSpace: 'normal'}} key={i} value={option.value}>{option.name}</Select.Option>
                )}
@@ -242,16 +266,16 @@
            </Button>
          </Col>
          <Col span={24} className="sql">
            <Form.Item label={'sql'}>
            <Form.Item label="sql">
              {getFieldDecorator('sql', {
                initialValue: '',
                rules: [
                  {
                    required: true,
                    message: this.props.dict['form.required.input'] + 'sql!'
                    message: '请输入sql!'
                  }
                ]
              })(<CodeMirror />)}
              })(<CodeMirror/>)}
            </Form.Item>
          </Col>
        </Row>