king
2020-09-03 af02b8f3c3ec9e5684be1084904d673429421d2b
src/menu/datasourcecomponent/verifycard/settingform/index.jsx
@@ -14,13 +14,14 @@
    dict: PropTypes.object,       // 字典项
    menuId: PropTypes.string,     // 菜单Id
    permFuncField: PropTypes.any, // 菜单Id
    config: PropTypes.object,     // 组件配置
    setting: PropTypes.object,    // 数据源配置
    columns: PropTypes.array,     // 列设置
    scripts: PropTypes.array,     // 自定义脚本
  }
  state = {
    interType: this.props.setting.interType || 'inner',
    interType: this.props.setting.interType || 'system',
  }
  handleConfirm = () => {
@@ -30,7 +31,7 @@
      this.props.form.validateFieldsAndScroll((err, values) => {
        if (!err) {
          // 数据源前端验证
          if (values.interType === 'inner' && !values.innerFunc && values.execute !== 'false' && !values.dataresource) {
          if (values.interType === 'system' && values.execute !== 'false' && !values.dataresource) {
            notification.warning({
              top: 92,
              message: '请填写内部函数或数据源!',
@@ -38,7 +39,7 @@
            })
            reject()
            return
          } else if (values.interType === 'inner' && !values.innerFunc && values.execute !== 'false' && values.dataresource) {
          } else if (values.interType === 'system' && values.execute !== 'false' && values.dataresource) {
            let _quot = values.dataresource.match(/'{1}/g)
            let _lparen = values.dataresource.match(/\({1}/g)
            let _rparen = values.dataresource.match(/\){1}/g)
@@ -88,7 +89,7 @@
          // 数据源保存
          if (
            values.interType === 'inner' && !values.innerFunc && values.execute !== 'false' &&
            values.interType === 'system' && values.execute !== 'false' &&
            /[^\s]+\s+[^\s]+/ig.test(values.dataresource) && setting.dataresource !== values.dataresource
          ) {
            let param = {
@@ -123,7 +124,7 @@
  }
  render() {
    const { setting, permFuncField, columns } = this.props
    const { setting, permFuncField, columns, config } = this.props
    const { getFieldDecorator } = this.props.form
    const { interType } = this.state
@@ -224,6 +225,7 @@
                  ]
                })(
                <Radio.Group onChange={(e) => {this.onRadioChange(e, 'interType')}}>
                  <Radio value="system">系统</Radio>
                  <Radio value="inner">内部</Radio>
                  <Radio value="outer">外部</Radio>
                </Radio.Group>)}
@@ -238,7 +240,13 @@
              }>
                {getFieldDecorator('innerFunc', {
                  initialValue: setting.innerFunc || '',
                  rules: rules
                  rules: [
                    {
                      required: true,
                      message: this.props.dict['form.required.input'] + '内部函数!'
                    },
                    ...rules
                  ]
                })(<Input placeholder={''} autoComplete="off" />)}
              </Form.Item>
            </Col> : null}
@@ -250,7 +258,7 @@
                    {
                      required: true,
                      message: this.props.dict['form.required.input'] + '接口地址!'
                    },
                    }
                  ]
                })(<Input placeholder={''} autoComplete="off" />)}
              </Form.Item>
@@ -265,7 +273,7 @@
                })(<Input placeholder={''} autoComplete="off" />)}
              </Form.Item>
            </Col> : null}
            {interType === 'inner' ? <Col span={24} className="data-source" style={{paddingLeft: '7px'}}>
            {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={'使用系统函数时,需填写数据源。注:数据权限替换符 $@ -> /* 或 \'\'、 @$ -> */ 或 \'\''}>
                  <Icon type="question-circle" />
@@ -289,7 +297,7 @@
                })(<InputNumber min={150} max={1500} precision={0} />)}
              </Form.Item>
            </Col>
            {interType === 'inner' ? <Col span={8}>
            {interType === 'system' ? <Col span={8}>
              <Form.Item label={
                <Tooltip placement="topLeft" title={'查询时,搜索条件以where条件拼接进入sql,统计时,将数据源中以“@+搜索字段+@”的内容,以搜索条件中的值进行替换后,提交查询,注:查询类型仅在使用系统函数时有效。'}>
                  <Icon type="question-circle" />
@@ -320,7 +328,21 @@
                )}
              </Form.Item>
            </Col>
            {interType === 'inner' ? <Col span={8}>
            {/* 数组数据,需设置排序规则 */}
            {config.format === 'array' ? <Col span={8}>
              <Form.Item label="默认排序">
                {getFieldDecorator('order', {
                  initialValue: setting.order || '',
                  rules: [
                    {
                      required: true,
                      message: this.props.dict['form.required.input'] + '默认排序!'
                    }
                  ]
                })(<Input placeholder={'ID asc, UID desc'} autoComplete="off" />)}
              </Form.Item>
            </Col> : null}
            {interType === 'system' ? <Col span={8}>
              <Form.Item label="默认sql">
                {getFieldDecorator('execute', {
                  initialValue: setting.execute || 'true'
@@ -332,14 +354,49 @@
              </Form.Item>
            </Col> : null}
            <Col span={8}>
              <Form.Item label="初始化数据">
              <Form.Item label="初始化">
                {getFieldDecorator('onload', {
                  initialValue: setting.onload || 'true'
                })(
                <Radio.Group>
                  <Radio value="true">加载</Radio>
                  <Radio value="false">不加载</Radio>
                </Radio.Group>)}
                  <Radio.Group>
                    <Radio value="true">加载数据</Radio>
                    <Radio value="false">不加载数据</Radio>
                  </Radio.Group>
                )}
              </Form.Item>
            </Col>
            {!config.laypage ? <Col span={8}>
              <Form.Item label={
                <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}
            <Col span={8}>
              <Form.Item label={
                <Tooltip placement="topLeft" title={'使用主搜索条件(存在时),主搜索条件与组件的搜索条件会一同用作数据过滤(组件的搜索条件优先)。'}>
                  <Icon type="question-circle" />
                  主搜索
                </Tooltip>
              }>
                {getFieldDecorator('useMSearch', {
                  initialValue: setting.useMSearch || 'false'
                })(
                  <Radio.Group>
                    <Radio value="true">使用</Radio>
                    <Radio value="false">不使用</Radio>
                  </Radio.Group>
                )}
              </Form.Item>
            </Col>
          </Row>