king
2021-03-23 a8e94242166881639cecf3809e45ca527233ebd7
src/menu/datasource/verifycard/settingform/index.jsx
@@ -4,6 +4,7 @@
import { formRule } from '@/utils/option.js'
import Utils from '@/utils/utils.js'
import MenuUtils from '@/utils/utils-custom.js'
import CodeMirror from '@/templates/zshare/codemirror'
import './index.scss'
@@ -13,7 +14,7 @@
    menu: PropTypes.any,          // 菜单配置信息
    config: PropTypes.object,     // 组件配置
    setting: PropTypes.object,    // 数据源配置
    modules: PropTypes.array,     // 列设置
    modules: PropTypes.array,     // 可绑定的上级组件
    columns: PropTypes.array,     // 列设置
    scripts: PropTypes.array,     // 自定义脚本
  }
@@ -22,13 +23,15 @@
    interType: this.props.setting.interType || 'system',
    laypage: this.props.setting.laypage || 'true',
    modules: [],
    useMSearch: this.props.setting.useMSearch || 'false'
    usefulFields: [],
    useMSearch: this.props.setting.useMSearch || 'false',
    supModule: this.props.setting.supModule || []
  }
  UNSAFE_componentWillMount () {
    const { menu, config } = this.props
    let modules = this.getModules(menu.components, config.uuid)
    let modules = MenuUtils.getSupModules(menu.components, config.uuid)
    if (!modules) {
      modules = []
    }
@@ -38,58 +41,18 @@
      label: '无'
    })
    this.setState({modules})
  }
  getModules = (components, selfId) => {
    let modules = components.map(item => {
      if (item.uuid === selfId) {
        return {
          children: null
        }
      } else if (item.switchable) {
        return {
          value: item.uuid,
          label: item.name
        }
      } else if (item.type === 'tabs') {
        let _item = {
          value: item.uuid,
          label: item.name,
          children: item.subtabs.map(f_tab => {
            let subItem = {
              value: f_tab.uuid,
              label: f_tab.label,
              children: this.getModules(f_tab.components, selfId)
            }
            if (!subItem.children || subItem.children.length === 0) {
              return {children: null}
            }
            return subItem
          })
        }
        _item.children = _item.children.filter(t => t.children !== null)
        if (_item.children.length === 0) {
          return {children: null}
        }
        return _item
      } else {
        return {
          children: null
        }
    let usefulFields = sessionStorage.getItem('permFuncField')
    if (usefulFields) {
      try {
        usefulFields = JSON.parse(usefulFields)
      } catch {
        usefulFields = []
      }
    })
    modules = modules.filter(mod => mod.children !== null)
    if (modules.length === 0) {
      return null
    } else {
      usefulFields = []
    }
    return modules
    this.setState({modules, usefulFields})
  }
  handleConfirm = () => {
@@ -172,10 +135,14 @@
    }
  }
  changeSupModule = (val) => {
    this.setState({supModule: val})
  }
  render() {
    const { setting, menu, columns, config } = this.props
    const { setting, columns, config } = this.props
    const { getFieldDecorator } = this.props.form
    const { interType, modules, useMSearch, laypage } = this.state
    const { interType, modules, useMSearch, laypage, supModule, usefulFields } = this.state
    const formItemLayout = {
      labelCol: {
@@ -191,9 +158,9 @@
    let tooltip = null
    let rules = []
    if (menu.permFuncField && menu.permFuncField.length > 0) {
      tooltip = '开头可用字符:' + menu.permFuncField.join(', ')
      let str = '^(' + menu.permFuncField.join('|') + ')'
    if (usefulFields.length > 0) {
      tooltip = '开头可用字符:' + usefulFields.join(', ')
      let str = '^(' + usefulFields.join('|') + ')'
      let _patten = new RegExp(str + formRule.func.innerPattern + '$', 'g')
      rules.push({
@@ -348,7 +315,7 @@
            {config.format === 'array' ? <Col span={8}>
              <Form.Item label="默认排序">
                {getFieldDecorator('order', {
                  initialValue: setting.order || '',
                  initialValue: setting.order || 'ID asc',
                  rules: [
                    {
                      required: true,
@@ -369,27 +336,27 @@
                </Radio.Group>)}
              </Form.Item>
            </Col> : null}
            {menu.MenuType !== 'billPrint' ? <Col span={8}>
            <Col span={8}>
              <Form.Item label={
                <Tooltip placement="topLeft" title={'该组件如果受其他组件控制,请选项相应的组件,没有时选“无”。'}>
                  <Icon type="question-circle" />
                  上级模块
                  上级组件
                </Tooltip>
              }>
                {getFieldDecorator('supModule', {
                  initialValue: setting.supModule || [],
                  initialValue: supModule,
                  rules: [
                    {
                      required: true,
                      message: this.props.dict['form.required.select'] + '上级模块!'
                      message: this.props.dict['form.required.select'] + '上级组件!'
                    }
                  ]
                })(
                  <Cascader options={modules} expandTrigger="hover" placeholder="" />
                  <Cascader options={modules} onChange={this.changeSupModule} expandTrigger="hover" placeholder="" />
                )}
              </Form.Item>
            </Col> : null}
            {menu.MenuType !== 'billPrint' && config.pageable ? <Col span={8}>
            </Col>
            {config.pageable ? <Col span={8}>
              <Form.Item label="分页">
                {getFieldDecorator('laypage', {
                  initialValue: setting.laypage || 'true'
@@ -401,7 +368,7 @@
                )}
              </Form.Item>
            </Col> : null}
            {menu.MenuType !== 'billPrint' && config.pageable && laypage !== 'false' ? <Col span={8}>
            {config.pageable && laypage !== 'false' ? <Col span={8}>
              <Form.Item label={
                <Tooltip placement="topLeft" title="选择分页时有效。">
                  <Icon type="question-circle" />
@@ -419,7 +386,8 @@
                })(<InputNumber min={1} max={500} precision={0} />)}
              </Form.Item>
            </Col> : null}
            {!config.pageable || (config.pageable && laypage === 'false') ? <Col span={8}>
            {/* 1、不分页且不存在上级模块 */}
            {(!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" />
@@ -436,15 +404,15 @@
                )}
              </Form.Item>
            </Col> : null}
            {menu.MenuType !== 'billPrint' ? <Col span={8}>
            <Col span={8}>
              <Form.Item label={
                <Tooltip placement="topLeft" title={'优先使用同级的搜索条件组件,同级搜索不存在时,依次向上选取,与当前组件的搜索条件一同用作数据过滤(当前组件的搜索条件优先)。'}>
                  <Icon type="question-circle" />
                  外层搜索
                  外部搜索
                </Tooltip>
              }>
                {getFieldDecorator('useMSearch', {
                  initialValue: setting.useMSearch || 'false'
                  initialValue: setting.useMSearch || 'true'
                })(
                  <Radio.Group onChange={(e) => this.setState({useMSearch: e.target.value})}>
                    <Radio value="true">使用</Radio>
@@ -452,8 +420,8 @@
                  </Radio.Group>
                )}
              </Form.Item>
            </Col> : null}
            {menu.MenuType !== 'billPrint' && useMSearch === 'true' ? <Col span={8}>
            </Col>
            {useMSearch === 'true' ? <Col span={8}>
              <Form.Item label={
                <Tooltip placement="topLeft" title={'外层搜索条件改变时,是否刷新当前组件数据。'}>
                  <Icon type="question-circle" />
@@ -470,7 +438,7 @@
                )}
              </Form.Item>
            </Col> : null}
            {menu.MenuType !== 'billPrint' ? <Col span={8}>
            <Col span={8}>
              <Form.Item label="初始化数据">
                {getFieldDecorator('onload', {
                  initialValue: setting.onload || 'true'
@@ -481,7 +449,7 @@
                  </Radio.Group>
                )}
              </Form.Item>
            </Col> : null}
            </Col>
          </Row>
        </Form>
      </div>