| | |
| | | |
| | | const cardTypeOptions = { |
| | | sequence: ['eleType', 'width'], |
| | | text: ['eleType', 'datatype', 'format', 'width', 'height', 'prefix', 'postfix', 'link', 'noValue', 'bgImage'], |
| | | number: ['eleType', 'datatype', 'format', 'width', 'height', 'prefix', 'postfix', 'noValue'], |
| | | text: ['eleType', 'datatype', 'format', 'width', 'height', 'prefix', 'postfix', 'link', 'noValue', 'bgImage', 'fixStyle'], |
| | | number: ['eleType', 'datatype', 'format', 'width', 'height', 'prefix', 'postfix', 'noValue', 'fixStyle'], |
| | | picture: ['eleType', 'datatype', 'width', 'lenWidRadio', 'maxWidth', 'link', 'noValue'], |
| | | video: ['eleType', 'datatype', 'width', 'aspectRatio', 'autoPlay', 'loop', 'noValue'], |
| | | icon: ['eleType', 'icon', 'datatype', 'width'], |
| | |
| | | splitline: ['eleType', 'color', 'width', 'borderWidth'], |
| | | 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', 'eval', 'formula'], |
| | | currentDate: ['eleType', 'width', 'dateFormat', 'prefix', 'postfix', 'fixStyle'], |
| | | formula: ['eleType', 'width', 'height', 'prefix', 'postfix', 'eval', 'formula', 'noValue', 'fixStyle'], |
| | | } |
| | | |
| | | class MainSearch extends Component { |
| | |
| | | datatype: '', |
| | | showType: '', |
| | | showInfo: 'false', |
| | | fixStyle: '', |
| | | link: '' |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { card, config } = this.props |
| | | let _options = this.getOptions(card.eleType, card.datatype, card.link, (card.showType || 'line'), card.showInfo) |
| | | let _options = this.getOptions(card.eleType, card.datatype, card.link, (card.showType || 'line'), card.showInfo, card.fixStyle || '') |
| | | |
| | | this.setState({ |
| | | link: card.link, |
| | |
| | | datatype: card.datatype, |
| | | showType: card.showType || 'line', |
| | | showInfo: card.showInfo || 'false', |
| | | fixStyle: card.fixStyle || '', |
| | | formlist: this.props.formlist.map(item => { |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | |
| | | }) |
| | | } |
| | | |
| | | getOptions = (eleType, datatype, link, showType, showInfo) => { |
| | | getOptions = (eleType, datatype, link, showType, showInfo, fixStyle) => { |
| | | let _options = fromJS(cardTypeOptions[eleType]).toJS() // 选项列表 |
| | | |
| | | if (['text', 'number', 'picture', 'slider', 'barcode', 'qrcode', 'video'].includes(eleType)) { |
| | |
| | | _options.push('tooltip') |
| | | } |
| | | } |
| | | if (_options.includes('fixStyle') && fixStyle === 'alone') { |
| | | _options.push('fixSize', 'fixColor', 'fixLeft', 'fixRight') |
| | | } |
| | | |
| | | return _options |
| | | } |
| | |
| | | */ |
| | | selectChange = (key, value, option) => { |
| | | const { card, config } = this.props |
| | | const { datatype, eleType, showType, showInfo } = this.state |
| | | const { datatype, eleType, showType, showInfo, fixStyle } = this.state |
| | | |
| | | if (key === 'eleType') { |
| | | let _options = this.getOptions(value, datatype, '', showType, showInfo) |
| | | let _options = this.getOptions(value, datatype, '', showType, showInfo, fixStyle) |
| | | |
| | | let _formlist = this.state.formlist.map(item => { |
| | | item.hidden = !_options.includes(item.key) |
| | |
| | | item.required = value !== 'qrcode' |
| | | } else if (item.key === 'showInfo') { |
| | | item.initVal = showInfo |
| | | } else if (item.key === 'fixStyle') { |
| | | item.initVal = fixStyle |
| | | } |
| | | |
| | | return item |
| | |
| | | this.props.form.setFieldsValue({value: option.props.title}) |
| | | } |
| | | } else if (key === 'link') { |
| | | let _options = this.getOptions(eleType, datatype, value, showType, showInfo) |
| | | let _options = this.getOptions(eleType, datatype, value, showType, showInfo, fixStyle) |
| | | this.setState({ |
| | | link: value, |
| | | formlist: this.state.formlist.map(item => { |
| | |
| | | } |
| | | |
| | | onChange = (e, key) => { |
| | | const { eleType, datatype, link, showType, showInfo } = this.state |
| | | const { eleType, datatype, link, showType, showInfo, fixStyle } = this.state |
| | | let value = e.target.value |
| | | |
| | | if (key === 'datatype') { |
| | | let _options = this.getOptions(eleType, value, link, showType, showInfo) |
| | | let _options = this.getOptions(eleType, value, link, showType, showInfo, fixStyle) |
| | | |
| | | this.setState({ |
| | | datatype: value, |
| | |
| | | }) |
| | | }) |
| | | } else if (key === 'link') { |
| | | let _options = this.getOptions(eleType, datatype, value, showType, showInfo) |
| | | let _options = this.getOptions(eleType, datatype, value, showType, showInfo, fixStyle) |
| | | this.setState({ |
| | | link: value, |
| | | formlist: this.state.formlist.map(item => { |
| | |
| | | }) |
| | | }) |
| | | } else if (key === 'showInfo') { |
| | | let _options = this.getOptions(eleType, datatype, link, showType, value) |
| | | let _options = this.getOptions(eleType, datatype, link, showType, value, fixStyle) |
| | | this.setState({ |
| | | showInfo: value, |
| | | formlist: this.state.formlist.map(item => { |
| | |
| | | this.setState({ |
| | | showType: value |
| | | }, () => { |
| | | let _options = this.getOptions(eleType, datatype, link, value, showInfo) |
| | | let _options = this.getOptions(eleType, datatype, link, value, showInfo, fixStyle) |
| | | this.setState({ |
| | | formlist: this.state.formlist.map(item => { |
| | | item.hidden = !_options.includes(item.key) |
| | | return item |
| | | }) |
| | | }) |
| | | }) |
| | | } else if (key === 'fixStyle') { |
| | | this.setState({ |
| | | fixStyle: value |
| | | }, () => { |
| | | let _options = this.getOptions(eleType, datatype, link, showType, showInfo, value) |
| | | this.setState({ |
| | | formlist: this.state.formlist.map(item => { |
| | | item.hidden = !_options.includes(item.key) |