king
2020-11-10 a9ac16fecc0cf9bc66dfaefe4e9b35fa3c722812
src/menu/components/card/cardcellcomponent/elementform/index.jsx
@@ -9,13 +9,17 @@
import './index.scss'
const cardTypeOptions = {
  text: ['eleType', 'datatype', 'format', 'fontSize', 'fontWeight', 'width', 'height', 'align', 'padding', 'prefix', 'postfix'],
  number: ['eleType', 'datatype', 'format', 'fontSize', 'fontWeight', 'width', 'height', 'align', 'padding', 'prefix', 'postfix'],
  picture: ['eleType', 'datatype', 'width', 'lenWidRadio', 'radius', 'padding', 'url'],
  icon: ['eleType', 'icon', 'datatype', 'fontSize', 'width', 'align', 'padding'],
  link: ['eleType', 'datatype', 'labelfield', 'fontSize', 'width', 'height', 'align', 'padding', 'prefix'],
  slider: ['eleType', 'field', 'width', 'color', 'padding', 'maxValue'],
  splitline: ['eleType', 'color', 'width', 'padding'],
  sequence: ['eleType', 'width'],
  text: ['eleType', 'datatype', 'format', 'width', 'height', 'prefix', 'postfix'],
  number: ['eleType', 'datatype', 'format', 'width', 'height', 'prefix', 'postfix'],
  picture: ['eleType', 'datatype', 'width', 'lenWidRadio', 'url'],
  icon: ['eleType', 'icon', 'datatype', 'width'],
  link: ['eleType', 'datatype', 'label', 'width', 'height', 'joint'],
  slider: ['eleType', 'datatype', 'width', 'color', 'maxValue'],
  splitline: ['eleType', 'color', 'width', 'borderWidth'],
  barcode: ['eleType', 'datatype', 'width', 'barHeight', 'displayValue', 'interval'],
  qrcode: ['eleType', 'datatype', 'width', 'qrWidth', 'color', 'url'],
  currentDate: ['eleType', 'width', 'dateFormat', 'prefix', 'postfix'],
}
class MainSearch extends Component {
@@ -37,7 +41,7 @@
  UNSAFE_componentWillMount () {
    const { card, config } = this.props
    let _options = this.getOptions(card.eleType, card.datatype)
    this.setState({
      eleType: card.eleType,
      datatype: card.datatype,
@@ -59,16 +63,9 @@
              })
            }
          })
        } else if (item.key === 'labelfield') {
          item.options = []
          config.columns.forEach(col => {
            if (/^Nvarchar/ig.test(col.datatype)) {
              item.options.push({
                value: col.field,
                text: col.label
              })
            }
          })
        } else if (item.key === 'value' && card.eleType === 'slider') {
          item.type = 'number'
          item.label = '值'
        }
        return item
@@ -79,7 +76,7 @@
  getOptions = (eleType, datatype) => {
    let _options = fromJS(cardTypeOptions[eleType]).toJS() // 选项列表
    
    if (['text', 'number', 'picture', 'link'].includes(eleType)) {
    if (['text', 'number', 'picture', 'link', 'slider', 'barcode', 'qrcode'].includes(eleType)) {
      if (datatype === 'dynamic') {
        _options.push('field')
      } else if (eleType !== 'picture') {
@@ -127,6 +124,14 @@
              })
            }
          })
        } else if (item.key === 'value') {
          if (value === 'slider') {
            item.type = 'number'
            item.label = '值'
          } else {
            item.type = 'text'
            item.label = '内容'
          }
        }
        return item
@@ -185,13 +190,6 @@
      if (item.type === 'text') { // 文本搜索
        let rules = []
        if (item.key === 'padding') {
          rules = [{
            pattern: /^\d+px$|^\d+px\s\d+px$|^\d+px\s\d+px\s\d+px$|^\d+px\s\d+px\s\d+px\s\d+px$/ig,
            message: '请正确输入内边距!'
          }]
        }
        fields.push(
          <Col span={12} key={index}>
            <Form.Item label={item.tooltip ?
@@ -234,7 +232,7 @@
                    message: this.props.dict['form.required.input'] + item.label + '!'
                  }
                ]
              })(<InputNumber min={item.min || 0} max={item.max || 10000} precision={item.precision || 0} />)}
              })(<InputNumber min={item.min || 0} max={item.max || 10000} precision={item.precision || 0} onPressEnter={this.handleSubmit} />)}
            </Form.Item>
          </Col>
        )