| | |
| | | |
| | | const cardTypeOptions = { |
| | | sequence: ['eleType', 'width'], |
| | | text: ['eleType', 'datatype', 'format', 'width', 'height', 'prefix', 'postfix'], |
| | | text: ['eleType', 'datatype', 'format', 'width', 'height', 'prefix', 'postfix', 'link'], |
| | | number: ['eleType', 'datatype', 'format', 'width', 'height', 'prefix', 'postfix'], |
| | | picture: ['eleType', 'datatype', 'width', 'lenWidRadio', 'url'], |
| | | picture: ['eleType', 'datatype', 'width', 'lenWidRadio', 'url', 'link'], |
| | | 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'], |
| | |
| | | state = { |
| | | formlist: null, // 表单信息 |
| | | eleType: '', |
| | | datatype: '' |
| | | datatype: '', |
| | | link: '' |
| | | } |
| | | |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { card, config } = this.props |
| | | let _options = this.getOptions(card.eleType, card.datatype) |
| | | let _options = this.getOptions(card.eleType, card.datatype, card.link) |
| | | |
| | | this.setState({ |
| | | link: card.link, |
| | | eleType: card.eleType, |
| | | datatype: card.datatype, |
| | | formlist: this.props.formlist.map(item => { |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | | if (item.key === 'field') { |
| | | if (item.key === 'field' || item.key === 'linkurl') { |
| | | item.options = [] |
| | | config.columns.forEach(col => { |
| | | if (!/^Nvarchar/ig.test(col.datatype) && (card.eleType === 'number' || card.eleType === 'slider')) { |
| | |
| | | } else if (item.key === 'value' && card.eleType === 'slider') { |
| | | item.type = 'number' |
| | | item.label = '值' |
| | | } else if (item.key === 'format') { |
| | | if (card.eleType === 'text') { |
| | | item.options = item.oriOptions.filter(op => op.value !== 'percent' && op.value !== 'thdSeparator') |
| | | } else if (card.eleType === 'number') { |
| | | item.options = item.oriOptions.filter(op => op.value !== 'YYYY-MM-DD') |
| | | } |
| | | } |
| | | if (item.key === 'linkurl') { |
| | | item.type = card.link === 'dynamic' ? 'select' : 'text' |
| | | } |
| | | |
| | | return item |
| | |
| | | }) |
| | | } |
| | | |
| | | getOptions = (eleType, datatype) => { |
| | | getOptions = (eleType, datatype, link) => { |
| | | let _options = fromJS(cardTypeOptions[eleType]).toJS() // 选项列表 |
| | | |
| | | if (['text', 'number', 'picture', 'link', 'slider', 'barcode', 'qrcode'].includes(eleType)) { |
| | |
| | | _options.push('field') |
| | | } else if (eleType !== 'picture') { |
| | | _options.push('value') |
| | | } |
| | | |
| | | if (['text', 'picture'].includes(eleType) && link) { |
| | | _options.push('linkurl', 'joint') |
| | | } |
| | | } else if (eleType === 'icon') { |
| | | if (datatype === 'dynamic') { |
| | |
| | | const { datatype } = this.state |
| | | |
| | | if (key === 'eleType') { |
| | | let _options = this.getOptions(value, datatype) |
| | | let _options = this.getOptions(value, datatype, '') |
| | | |
| | | let _formlist = this.state.formlist.map(item => { |
| | | item.hidden = !_options.includes(item.key) |
| | |
| | | item.type = 'text' |
| | | item.label = '内容' |
| | | } |
| | | } else if (item.key === 'format') { |
| | | if (value === 'text') { |
| | | item.options = item.oriOptions.filter(op => op.value !== 'percent' && op.value !== 'thdSeparator') |
| | | } else if (value === 'number') { |
| | | item.options = item.oriOptions.filter(op => op.value !== 'YYYY-MM-DD') |
| | | } |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | this.setState({ |
| | | link: '', |
| | | eleType: value, |
| | | formlist: _formlist |
| | | }, () => { |
| | |
| | | this.props.form.setFieldsValue({width: 24, color: '#1890ff'}) |
| | | } else if (value === 'splitline') { |
| | | this.props.form.setFieldsValue({width: 24, color: '#e8e8e8'}) |
| | | } else if (value === 'text' || value === 'number') { |
| | | this.props.form.setFieldsValue({format: ''}) |
| | | } |
| | | if (value === 'text' || value === 'picture') { |
| | | this.props.form.setFieldsValue({link: ''}) |
| | | } |
| | | }) |
| | | } else if (key === 'field') { |
| | |
| | | let value = e.target.value |
| | | |
| | | if (key === 'datatype') { |
| | | let _options = this.getOptions(eleType, value) |
| | | let _options = this.getOptions(eleType, value, this.state.link) |
| | | |
| | | this.setState({ |
| | | datatype: value, |
| | |
| | | return item |
| | | }) |
| | | }) |
| | | } else if (key === 'link') { |
| | | let _options = this.getOptions(eleType, this.state.datatype, value) |
| | | this.setState({ |
| | | link: value, |
| | | formlist: this.state.formlist.map(item => { |
| | | item.hidden = !_options.includes(item.key) |
| | | if (item.key === 'linkurl') { |
| | | item.type = value === 'dynamic' ? 'select' : 'text' |
| | | } |
| | | return item |
| | | }) |
| | | }) |
| | | } |
| | | } |
| | | |