king
2022-02-09 d59f518f466274b2caeb2e01c10c92deafe7c93b
src/menu/datasource/verifycard/settingform/index.jsx
@@ -1,6 +1,7 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Form, Row, Col, Input, Radio, Tooltip, Icon, notification, Select, InputNumber, Cascader } from 'antd'
import { Form, Row, Col, Input, Radio, Tooltip, notification, Select, InputNumber, Cascader } from 'antd'
import { QuestionCircleOutlined } from '@ant-design/icons'
import { formRule } from '@/utils/option.js'
import Utils from '@/utils/utils.js'
@@ -13,7 +14,6 @@
class SettingForm extends Component {
  static propTpyes = {
    dict: PropTypes.object,       // 字典项
    menu: PropTypes.any,          // 菜单配置信息
    config: PropTypes.object,     // 组件配置
    setting: PropTypes.object,    // 数据源配置
    modules: PropTypes.array,     // 可绑定的上级组件
@@ -27,16 +27,14 @@
    modules: [],
    usefulFields: [],
    useMSearch: this.props.setting.useMSearch || 'false',
    supModule: this.props.setting.supModule || []
    supModule: this.props.setting.supModule || [],
    appType: sessionStorage.getItem('appType')
  }
  UNSAFE_componentWillMount () {
    const { menu, config } = this.props
    const { config } = this.props
    let modules = MenuUtils.getSupModules(menu.components, config.uuid)
    if (!modules) {
      modules = []
    }
    let modules = MenuUtils.getSupModules(window.GLOB.customMenu.components, config.uuid) || []
    modules.unshift({
      value: 'empty',
@@ -47,7 +45,7 @@
    if (usefulFields) {
      try {
        usefulFields = JSON.parse(usefulFields)
      } catch {
      } catch (e) {
        usefulFields = []
      }
    } else {
@@ -58,10 +56,17 @@
  }
  handleConfirm = () => {
    const { appType } = this.state
    // 表单提交时检查输入值是否正确
    return new Promise((resolve, reject) => {
      this.props.form.validateFieldsAndScroll((err, values) => {
        if (!err) {
          values.sync = values.sync || 'false'
          if (appType === 'mob' && values.useMSearch === 'true') {
            values.syncRefresh = 'true'
          }
          // 数据源前端验证
          if (values.interType === 'system' && values.execute !== 'false' && !values.dataresource) {
            notification.warning({
@@ -137,6 +142,14 @@
    }
  }
  onSysInter = (e) => {
    let value = e.target.value
    if (value === 'true') {
      this.props.form.setFieldsValue({interface: window.GLOB.mainSystemApi})
    }
  }
  changeSupModule = (val) => {
    this.setState({supModule: val})
  }
@@ -144,7 +157,7 @@
  render() {
    const { setting, columns, config } = this.props
    const { getFieldDecorator } = this.props.form
    const { interType, modules, useMSearch, laypage, supModule, usefulFields } = this.state
    const { interType, modules, useMSearch, laypage, supModule, usefulFields, appType } = this.state
    const formItemLayout = {
      labelCol: {
@@ -210,32 +223,21 @@
                </Radio.Group>)}
              </Form.Item>
            </Col>
            {interType === 'system' ? <Col span={8}>
              <Form.Item label={
                <Tooltip placement="topLeft" title={'自定义脚本中的变量(除报错及可用字段外),需以此标识开头。'}>
                  <Icon type="question-circle" />
                  变量标识
                </Tooltip>
              }>
                {getFieldDecorator('varMark', {
                  initialValue: setting.varMark || '',
                  rules: [
                    {
                      pattern: /^[a-zA-Z_]*$/ig,
                      message: '请使用字母或_'
                    },
                    {
                      max: 3,
                      message: '最多三个字符。'
                    }
                  ]
                })(<Input placeholder={''} autoComplete="off" />)}
            {interType === 'outer' ? <Col span={8}>
              <Form.Item label="系统接口">
                {getFieldDecorator('sysInterface', {
                  initialValue: setting.sysInterface || 'false'
                })(
                <Radio.Group onChange={this.onSysInter}>
                  <Radio value="true">是</Radio>
                  <Radio value="false">否</Radio>
                </Radio.Group>)}
              </Form.Item>
            </Col> : null}
            {interType === 'inner' ? <Col span={8}>
              <Form.Item label={tooltip ?
                <Tooltip placement="topLeft" title={tooltip}>
                  <Icon type="question-circle" />
                  <QuestionCircleOutlined className="mk-form-tip" />
                  内部函数
                </Tooltip> : '内部函数'
              }>
@@ -266,7 +268,7 @@
            </Col> : null}
            {interType === 'outer' ? <Col className="outer-interface" span={24}>
              <Form.Item label={<Tooltip placement="topLeft" title="正式系统接口地址,为空时使用接口地址">
                  <Icon type="question-circle" />
                  <QuestionCircleOutlined className="mk-form-tip" />
                  正式地址
                </Tooltip>
              }>
@@ -288,7 +290,7 @@
            {interType === 'system' ? <Col span={24} className="data-source" style={{paddingLeft: '7px'}}>
              <Form.Item labelCol={{xs: { span: 24 }, sm: { span: 2 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 22 }} } label={
                <Tooltip placement="topLeft" title={`使用系统函数时,需填写数据源。注:数据权限替换符 $@ -> /* 或 ''、 @$ -> */ 或 '';查询替换符 $select@ -> /* 或 ''、 @select$ -> */ 或 '';统计替换符 $sum@ -> /* 或 ''、 @sum$ -> */ 或 ''。`}>
                  <Icon type="question-circle" />
                  <QuestionCircleOutlined className="mk-form-tip" />
                  数据源
                </Tooltip>
              }>
@@ -300,7 +302,7 @@
            {interType === 'system' ? <Col span={8}>
              <Form.Item label={
                <Tooltip placement="topLeft" title={'查询时,搜索条件以where条件拼接进入sql,统计时,将数据源中以“@+搜索字段+@”的内容,以搜索条件中的值进行替换后,提交查询,注:查询类型仅在使用系统函数时有效。'}>
                  <Icon type="question-circle" />
                  <QuestionCircleOutlined className="mk-form-tip" />
                  查询类型
                </Tooltip>
              }>
@@ -353,10 +355,10 @@
                </Radio.Group>)}
              </Form.Item>
            </Col> : null}
            {config.type !== 'navbar' && config.type !== 'balcony' ? <Col span={8}>
            {!['navbar', 'balcony', 'menubar'].includes(config.type) && (!config.wrap || config.wrap.supType !== 'multi') ? <Col span={8}>
              <Form.Item label={
                <Tooltip placement="topLeft" title={'该组件如果受其他组件控制,请选项相应的组件,没有时选“无”。'}>
                  <Icon type="question-circle" />
                  <QuestionCircleOutlined className="mk-form-tip" />
                  上级组件
                </Tooltip>
              }>
@@ -388,7 +390,7 @@
            {config.pageable && laypage !== 'false' ? <Col span={8}>
              <Form.Item label={
                <Tooltip placement="topLeft" title="选择分页时有效。">
                  <Icon type="question-circle" />
                  <QuestionCircleOutlined className="mk-form-tip" />
                  每页数量
                </Tooltip>
              }>
@@ -404,10 +406,10 @@
              </Form.Item>
            </Col> : null}
            {/* 1、不分页且不存在上级模块 */}
            {config.type !== 'navbar' && (!config.pageable || (config.pageable && laypage === 'false')) && (!supModule || supModule.length === 0 || supModule[0] === 'empty') ? <Col span={8}>
            {!['navbar'].includes(config.type) && (!config.pageable || (config.pageable && laypage === 'false')) && (!supModule || supModule.length === 0 || supModule[0] === 'empty') ? <Col span={8}>
              <Form.Item label={
                <Tooltip placement="topLeft" title={'初始化加载时,是否与其他组件一同加载数据,注:仅在使用系统函数,且初始化加载数据时有效,分页请求时无效。'}>
                  <Icon type="question-circle" />
                  <QuestionCircleOutlined className="mk-form-tip" />
                  同步查询
                </Tooltip>
              }>
@@ -421,10 +423,10 @@
                )}
              </Form.Item>
            </Col> : null}
            {config.type !== 'navbar' && config.type !== 'balcony' ? <Col span={8}>
            {!['navbar', 'balcony', 'menubar'].includes(config.type) ? <Col span={8}>
              <Form.Item label={
                <Tooltip placement="topLeft" title={'优先使用同级的搜索条件组件,同级搜索不存在时,依次向上选取,与当前组件的搜索条件一同用作数据过滤(当前组件的搜索条件优先)。'}>
                  <Icon type="question-circle" />
                  <QuestionCircleOutlined className="mk-form-tip" />
                  外部搜索
                </Tooltip>
              }>
@@ -438,10 +440,10 @@
                )}
              </Form.Item>
            </Col> : null}
            {config.type !== 'navbar' && config.type !== 'balcony' && useMSearch === 'true' ? <Col span={8}>
            {!['navbar', 'balcony', 'menubar'].includes(config.type) && useMSearch === 'true' && appType !== 'mob' ? <Col span={8}>
              <Form.Item label={
                <Tooltip placement="topLeft" title={'外层搜索条件改变时,是否刷新当前组件数据。'}>
                  <Icon type="question-circle" />
                  <QuestionCircleOutlined className="mk-form-tip" />
                  同步刷新
                </Tooltip>
              }>
@@ -455,7 +457,18 @@
                )}
              </Form.Item>
            </Col> : null}
            {config.type !== 'navbar' && config.type !== 'balcony' ? <Col span={8}>
            <Col span={8}>
              <Form.Item label="事务">
                {getFieldDecorator('transaction', {
                  initialValue: setting.transaction || 'false'
                })(
                <Radio.Group>
                  <Radio value="true">使用</Radio>
                  <Radio value="false">不使用</Radio>
                </Radio.Group>)}
              </Form.Item>
            </Col>
            {!['navbar', 'balcony', 'menubar'].includes(config.type) ? <Col span={8}>
              <Form.Item label="初始化数据">
                {getFieldDecorator('onload', {
                  initialValue: setting.onload || 'true'