| | |
| | | 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', 'noValue'], |
| | | qrcode: ['eleType', 'datatype', 'width', 'qrWidth', 'color', 'url', 'noValue'], |
| | |
| | | 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) |
| | | |
| | |
| | | }) |
| | | } |
| | | |
| | | 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)) { |
| | |
| | | } |
| | | } 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') { |
| | |
| | | * 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) |
| | |
| | | this.setState({ |
| | | link: '', |
| | | eleType: value, |
| | | showType: card.showType || 'line', |
| | | formlist: _formlist |
| | | }, () => { |
| | | if (value === 'slider') { |
| | |
| | | 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 => { |
| | |
| | | } |
| | | |
| | | 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, |
| | |
| | | }) |
| | | }) |
| | | } 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 => { |
| | |
| | | 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 |
| | | }) |
| | | }) |
| | | }) |
| | | } |
| | | } |
| | | |