king
2021-05-12 cf804e19634ff953bb132af1b2f46905d80c1e3a
src/templates/sharecomponent/settingcomponent/settingform/datasource/index.jsx
@@ -1,6 +1,6 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Form, Row, Col, Input, Radio, Tooltip, Icon, notification, Select } from 'antd'
import { Form, Row, Col, Input, Radio, Tooltip, Icon, notification, Select, InputNumber } from 'antd'
import moment from 'moment'
import Api from '@/api'
@@ -19,11 +19,12 @@
    setting: PropTypes.object,    // 数据源配置
    columns: PropTypes.array,     // 列设置
    scripts: PropTypes.array,     // 自定义脚本
    updateStatus: PropTypes.func, // 状态更新
  }
  state = {
    interType: 'system',
    procMode: 'system',
    procMode: 'script',
    requestMode: 'system',
    funcTooltip: '',
    funcRules: []
@@ -59,7 +60,7 @@
    this.setState({
      interType: setting.interType || 'system',
      procMode: setting.procMode || 'system',
      procMode: setting.procMode || 'script',
      requestMode: setting.requestMode || 'system',
      funcTooltip: tooltip,
      funcRules: rules
@@ -175,6 +176,7 @@
        interface: window.GLOB.mainSystemApi || ''
      })
    }
    this.props.updateStatus({[key]: value})
  }
  primaryKeyChange = (val) => {
@@ -214,6 +216,10 @@
                      required: true,
                      message: dict['form.required.input'] + '表名!'
                    },
                    {
                      max: 50,
                      message: '表名最长为50个字符!'
                    }
                  ]
                })(<Input placeholder={''} autoComplete="off" />)}
              </Form.Item>
@@ -279,7 +285,7 @@
                  ]
                })(
                <Radio.Group style={{whiteSpace: 'nowrap'}} onChange={(e) => {this.onRadioChange(e, 'procMode')}}>
                  <Radio value="system">前置脚本</Radio>
                  <Radio value="script">前置脚本</Radio>
                  <Radio value="inner">前置函数</Radio>
                </Radio.Group>)}
              </Form.Item>
@@ -291,8 +297,8 @@
                  前置函数
                </Tooltip>
              }>
                {getFieldDecorator('innerFunc', {
                  initialValue: setting.innerFunc || '',
                {getFieldDecorator('prevFunc', {
                  initialValue: setting.prevFunc || '',
                  rules: [
                    {
                      required: true,
@@ -308,19 +314,19 @@
              </Form.Item>
            </Col> : null}
            {interType === 'outer' || interType === 'custom' ? <Col className="data-source" span={24}>
              <Form.Item label="接口地址">
              <Form.Item label="测试地址">
                {getFieldDecorator('interface', {
                  initialValue: setting.interface || '',
                  rules: [
                    {
                      required: true,
                      message: dict['form.required.input'] + '接口地址!'
                      message: dict['form.required.input'] + '测试地址!'
                    },
                  ]
                })(<TextArea rows={2} />)}
              </Form.Item>
            </Col> : null}
            {interType === 'custom' ? <Col className="data-source" span={24}>
            {interType === 'outer' || interType === 'custom' ? <Col className="data-source" span={24}>
              <Form.Item label={
                <Tooltip placement="topLeft" title="正式系统所使用的的接口地址。">
                  <Icon type="question-circle" />
@@ -330,6 +336,23 @@
                {getFieldDecorator('proInterface', {
                  initialValue: setting.proInterface || ''
                })(<TextArea rows={2} />)}
              </Form.Item>
            </Col> : null}
            {interType === 'custom' ? <Col span={12}>
              <Form.Item label="请求方式">
                {getFieldDecorator('method', {
                  initialValue: setting.method || 'post',
                  rules: [
                    {
                      required: true,
                      message: dict['form.required.select'] + '请求方式!'
                    },
                  ]
                })(
                <Radio.Group>
                  <Radio value="get">GET</Radio>
                  <Radio value="post">POST</Radio>
                </Radio.Group>)}
              </Form.Item>
            </Col> : null}
            {interType === 'custom' ? <Col span={12}>
@@ -446,7 +469,7 @@
            <Col span={12}>
              <Form.Item label="默认排序">
                {getFieldDecorator('order', {
                  initialValue: setting.order || '',
                  initialValue: setting.order || 'ID desc',
                  rules: [
                    {
                      required: true,
@@ -463,12 +486,29 @@
            {interType === 'custom' ? <Col span={12}>
              <Form.Item label="回调方式">
                {getFieldDecorator('callbackType', {
                  initialValue: setting.callbackType || 'default'
                  initialValue: setting.callbackType || 'script'
                })(
                <Radio.Group>
                <Radio.Group onChange={(e) => {this.onRadioChange(e, 'callbackType')}}>
                  <Radio value="default">默认脚本</Radio>
                  <Radio value="script">自定义脚本</Radio>
                </Radio.Group>)}
              </Form.Item>
            </Col> : null}
            {interType === 'custom' ? <Col span={12}>
              <Form.Item label="回调表名">
                {getFieldDecorator('cbTable', {
                  initialValue: setting.cbTable || '',
                  rules: [
                    {
                      required: true,
                      message: dict['form.required.input'] + '回调表名!'
                    },
                    {
                      max: formRule.input.max,
                      message: formRule.input.message
                    }
                  ]
                })(<Input placeholder={''} autoComplete="off" />)}
              </Form.Item>
            </Col> : null}
            {interType === 'custom' ? <Col span={12}>
@@ -484,6 +524,22 @@
                <Radio.Group>
                  <Radio value="sync">同步</Radio>
                  <Radio value="async">异步</Radio>
                </Radio.Group>)}
              </Form.Item>
            </Col> : null}
            {interType === 'custom' ? <Col span={12}>
              <Form.Item label={
                <Tooltip placement="topLeft" title={'如果自定义接口不支持跨域请求,会通过当前系统转发。'}>
                  <Icon type="question-circle" />
                  跨域请求
                </Tooltip>
              }>
                {getFieldDecorator('cross', {
                  initialValue: setting.cross || 'true'
                })(
                <Radio.Group>
                  <Radio value="true">支持</Radio>
                  <Radio value="false">不支持</Radio>
                </Radio.Group>)}
              </Form.Item>
            </Col> : null}
@@ -560,6 +616,18 @@
            </Col>
            <Col span={12}>
              <Form.Item label={
                <Tooltip placement="topLeft" title="高级搜索弹窗的宽度,注:当宽度值小于100时表示占窗口的百分比,大于100时表示宽度的绝对值。">
                  <Icon type="question-circle" />
                  高级搜索
                </Tooltip>
              }>
                {getFieldDecorator('advanceWidth', {
                  initialValue: setting.advanceWidth || 1000
                })(<InputNumber min={10} max={3000} precision={0}/>)}
              </Form.Item>
            </Col>
            <Col span={12}>
              <Form.Item label={
                <Tooltip placement="topLeft" title="双击表格中行,触发的按钮。">
                  <Icon type="question-circle" />
                  双击事件