king
2021-11-11 fd4a4f4513419baa9af45c8176a511450f096fc4
src/menu/components/card/cardcellcomponent/elementform/index.jsx
@@ -14,17 +14,17 @@
const cardTypeOptions = {
  sequence: ['eleType', 'width'],
  text: ['eleType', 'datatype', 'format', 'width', 'height', 'prefix', 'postfix', 'link'],
  text: ['eleType', 'datatype', 'format', 'width', 'height', 'prefix', 'postfix', 'link', 'noValue'],
  number: ['eleType', 'datatype', 'format', 'width', 'height', 'prefix', 'postfix'],
  picture: ['eleType', 'datatype', 'width', 'lenWidRadio', 'maxWidth', 'link'],
  video: ['eleType', 'datatype', 'width', 'aspectRatio', 'autoPlay', 'loop'],
  picture: ['eleType', 'datatype', 'width', 'lenWidRadio', 'maxWidth', 'link', 'noValue'],
  video: ['eleType', 'datatype', 'width', 'aspectRatio', 'autoPlay', 'loop', 'noValue'],
  icon: ['eleType', 'icon', 'datatype', 'width'],
  slider: ['eleType', 'datatype', 'width', 'color', 'maxValue'],
  slider: ['eleType', 'datatype', 'width', 'color', 'maxValue', 'showInfo', 'showType', 'strokeWidth'],
  splitline: ['eleType', 'color', 'width', 'borderWidth'],
  barcode: ['eleType', 'datatype', 'width', 'barHeight', 'displayValue', 'interval'],
  qrcode: ['eleType', 'datatype', 'width', 'qrWidth', 'color', 'url'],
  barcode: ['eleType', 'datatype', 'width', 'barHeight', 'displayValue', 'interval', 'noValue'],
  qrcode: ['eleType', 'datatype', 'width', 'qrWidth', 'color', 'url', 'noValue'],
  currentDate: ['eleType', 'width', 'dateFormat', 'prefix', 'postfix'],
  formula: ['eleType', 'width', 'height', 'prefix', 'postfix', 'formula'],
  formula: ['eleType', 'width', 'height', 'prefix', 'postfix', 'eval', 'formula'],
}
class MainSearch extends Component {
@@ -40,17 +40,19 @@
    formlist: null,  // 表单信息
    eleType: '',
    datatype: '',
    showType: '',
    link: ''
  }
  UNSAFE_componentWillMount () {
    const { card, config } = this.props
    let _options = this.getOptions(card.eleType, card.datatype, card.link)
    let _options = this.getOptions(card.eleType, card.datatype, card.link, (card.showType || 'line'))
    
    this.setState({
      link: card.link,
      eleType: card.eleType,
      datatype: card.datatype,
      showType: card.showType || 'line',
      formlist: this.props.formlist.map(item => {
        item.hidden = !_options.includes(item.key)
@@ -90,7 +92,7 @@
    })
  }
  getOptions = (eleType, datatype, link) => {
  getOptions = (eleType, datatype, link, showType) => {
    let _options = fromJS(cardTypeOptions[eleType]).toJS() // 选项列表
    
    if (['text', 'number', 'picture', 'link', 'slider', 'barcode', 'qrcode', 'video'].includes(eleType)) {
@@ -112,6 +114,8 @@
        }
      } else if (eleType === 'picture' && !link) {
        _options.push('scale')
      } else if (eleType === 'slider' && showType !== 'line') {
        _options.push('outlineWidth', 'textAlign')
      }
    } else if (eleType === 'icon') {
      if (datatype === 'dynamic') {
@@ -131,11 +135,11 @@
   * 3、切换标签类型,重置可选标签
   */
  selectChange = (key, value, option) => {
    const { config } = this.props
    const { datatype, eleType } = this.state
    const { card, config } = this.props
    const { datatype, eleType, showType } = this.state
    if (key === 'eleType') {
      let _options = this.getOptions(value, datatype, '')
      let _options = this.getOptions(value, datatype, '', showType)
      
      let _formlist = this.state.formlist.map(item => {
        item.hidden = !_options.includes(item.key)
@@ -179,6 +183,7 @@
      this.setState({
        link: '',
        eleType: value,
        showType: card.showType || 'line',
        formlist: _formlist
      }, () => {
        if (value === 'slider') {
@@ -197,7 +202,7 @@
        this.props.form.setFieldsValue({value: option.props.title})
      }
    } else if (key === 'link') {
      let _options = this.getOptions(eleType, this.state.datatype, value)
      let _options = this.getOptions(eleType, this.state.datatype, value, showType)
      this.setState({
        link: value,
        formlist: this.state.formlist.map(item => {
@@ -212,11 +217,11 @@
  }
  onChange = (e, key) => {
    const { eleType } = this.state
    const { eleType, datatype, link, showType } = this.state
    let value = e.target.value
    if (key === 'datatype') {
      let _options = this.getOptions(eleType, value, this.state.link)
      let _options = this.getOptions(eleType, value, link, showType)
      this.setState({
        datatype: value,
@@ -227,7 +232,7 @@
        })
      })
    } else if (key === 'link') {
      let _options = this.getOptions(eleType, this.state.datatype, value)
      let _options = this.getOptions(eleType, datatype, value, showType)
      this.setState({
        link: value,
        formlist: this.state.formlist.map(item => {
@@ -238,6 +243,18 @@
          return item
        })
      })
    } else if (key === 'showType') {
      this.setState({
        showType: value
      }, () => {
        let _options = this.getOptions(eleType, datatype, link, value)
        this.setState({
          formlist: this.state.formlist.map(item => {
            item.hidden = !_options.includes(item.key)
            return item
          })
        })
      })
    }
  }