king
2020-09-04 b987be8dd8b6bc1fa01810daa1e1a60e58a3c921
src/menu/datasource/verifycard/settingform/index.jsx
File was renamed from src/menu/datasourcecomponent/verifycard/settingform/index.jsx
@@ -1,9 +1,7 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Form, Row, Col, Input, Radio, Tooltip, Icon, notification, InputNumber, Select } from 'antd'
import moment from 'moment'
import Api from '@/api'
import { formRule } from '@/utils/option.js'
import Utils from '@/utils/utils.js'
import CodeMirror from '@/templates/zshare/codemirror'
@@ -12,8 +10,7 @@
class SettingForm extends Component {
  static propTpyes = {
    dict: PropTypes.object,       // 字典项
    menuId: PropTypes.string,     // 菜单Id
    permFuncField: PropTypes.any, // 菜单Id
    menu: PropTypes.any,          // 菜单配置信息
    config: PropTypes.object,     // 组件配置
    setting: PropTypes.object,    // 数据源配置
    columns: PropTypes.array,     // 列设置
@@ -22,10 +19,34 @@
  state = {
    interType: this.props.setting.interType || 'system',
    supModule: '',
    modules: []
  }
  UNSAFE_componentWillMount () {
    const { menu, setting } = this.props
    let supModule = setting.supModule || ''
    let modules = []
    menu.components.forEach(item => {
      if (!item.switchable || !item.setting || !item.setting.name) return
      modules.push({
        value: item.uuid,
        text: item.setting.name
      })
    })
    if (supModule && supModule !== 'empty') {
      if (modules.filter(item => item.value === supModule).length === 0) {
        supModule = ''
      }
    }
    this.setState({supModule, modules})
  }
  handleConfirm = () => {
    const { setting } = this.props
    // 表单提交时检查输入值是否正确
    return new Promise((resolve, reject) => {
      this.props.form.validateFieldsAndScroll((err, values) => {
@@ -87,24 +108,6 @@
            }
          }
          // 数据源保存
          if (
            values.interType === 'system' && values.execute !== 'false' &&
            /[^\s]+\s+[^\s]+/ig.test(values.dataresource) && setting.dataresource !== values.dataresource
          ) {
            let param = {
              func: 's_DataSrc_Save',
              LText: values.dataresource,
              MenuID: this.props.menuId
            }
            param.LText = Utils.formatOptions(param.LText)
            param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
            param.secretkey = Utils.encrypt(param.LText, param.timestamp)
            Api.getLocalConfig(param)
          }
          resolve(values)
        } else {
          reject(err)
@@ -124,9 +127,9 @@
  }
  render() {
    const { setting, permFuncField, columns, config } = this.props
    const { setting, menu, columns, config } = this.props
    const { getFieldDecorator } = this.props.form
    const { interType } = this.state
    const { interType, supModule, modules } = this.state
    const formItemLayout = {
      labelCol: {
@@ -142,9 +145,9 @@
    let tooltip = null
    let rules = []
    if (permFuncField && permFuncField.length > 0) {
      tooltip = '开头可用字符:' + permFuncField.join(', ')
      let str = '^(' + permFuncField.join('|') + ')'
    if (menu.permFuncField && menu.permFuncField.length > 0) {
      tooltip = '开头可用字符:' + menu.permFuncField.join(', ')
      let str = '^(' + menu.permFuncField.join('|') + ')'
      let _patten = new RegExp(str + formRule.func.innerPattern + '$', 'g')
      rules.push({
@@ -354,26 +357,53 @@
              </Form.Item>
            </Col> : null}
            <Col span={8}>
              <Form.Item label="初始化">
                {getFieldDecorator('onload', {
                  initialValue: setting.onload || 'true'
              <Form.Item label={
                <Tooltip placement="topLeft" title={'该组件如果受其他组件控制,请选项相应的组件,没有时选“无”。'}>
                  <Icon type="question-circle" />
                  上级模块
                </Tooltip>
              }>
                {getFieldDecorator('supModule', {
                  initialValue: supModule,
                  rules: [
                    {
                      required: true,
                      message: this.props.dict['form.required.select'] + '上级模块!'
                    }
                  ]
                })(
                  <Radio.Group>
                    <Radio value="true">加载数据</Radio>
                    <Radio value="false">不加载数据</Radio>
                  </Radio.Group>
                  <Select>
                    <Select.Option key="empty" value="empty"> 无 </Select.Option>
                    {modules.map((option, i) =>
                      <Select.Option key={i} value={option.value}>
                        {option.text}
                      </Select.Option>
                    )}
                  </Select>
                )}
              </Form.Item>
            </Col>
            {!config.laypage ? <Col span={8}>
            {!config.pageable ? <Col span={8}>
              <Form.Item label={
                <Tooltip placement="topLeft" title={'初始化加载时,是否与其他组件一同加载数据,注:仅在使用系统函数,且初始化加载数据时有效。'}>
                <Tooltip placement="topLeft" title={'初始化加载时,是否与其他组件一同加载数据,注:仅在使用系统函数,且初始化加载数据时有效,分页请求时无效。'}>
                  <Icon type="question-circle" />
                  同步查询
                </Tooltip>
              }>
                {getFieldDecorator('sync', {
                  initialValue: setting.sync || 'true'
                })(
                  <Radio.Group>
                    <Radio value="true">是</Radio>
                    <Radio value="false">否</Radio>
                  </Radio.Group>
                )}
              </Form.Item>
            </Col> : null}
            {config.pageable ? <Col span={8}>
              <Form.Item label="分页">
                {getFieldDecorator('laypage', {
                  initialValue: setting.laypage || 'false'
                })(
                  <Radio.Group>
                    <Radio value="true">是</Radio>
@@ -399,6 +429,18 @@
                )}
              </Form.Item>
            </Col>
            <Col span={8}>
              <Form.Item label="初始化数据">
                {getFieldDecorator('onload', {
                  initialValue: setting.onload || 'true'
                })(
                  <Radio.Group>
                    <Radio value="true">加载</Radio>
                    <Radio value="false">不加载</Radio>
                  </Radio.Group>
                )}
              </Form.Item>
            </Col>
          </Row>
        </Form>
      </div>