| | |
| | | import React, {Component} from 'react' |
| | | import React, { Component } from 'react' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Select } from 'antd' |
| | | |
| | |
| | | const { value, config, options } = this.state |
| | | |
| | | if (config.type !== 'multiselect') { |
| | | if (config.extendName) { |
| | | return ( |
| | | <Select |
| | | showSearch |
| | | allowClear |
| | | value={value} |
| | | dropdownMatchSelectWidth={config.dropdown !== 'false'} |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0 || |
| | | option.props.extend.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | onSelect={this.selectChange} |
| | | onChange={(val) => val === undefined && this.selectChange('')} |
| | | > |
| | | {options.map((option, i) => |
| | | <Select.Option key={i} disabled={option.disabled} title={option.label || option.text} extend={option[config.extendName] || ''} value={option.value || option.field || ''}>{option.label || option.text}</Select.Option> |
| | | )} |
| | | </Select> |
| | | ) |
| | | } else { |
| | | if (config.joint) { |
| | | return ( |
| | | <Select |
| | | showSearch |
| | |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | onSelect={this.selectChange} |
| | | onChange={(val) => val === undefined && this.selectChange('')} |
| | | getPopupContainer={() => document.getElementById('normal-form-field')} |
| | | > |
| | | {options.map((option, i) => |
| | | <Select.Option key={i} disabled={option.disabled} value={option.value || option.field || ''}>{option.label || option.text}</Select.Option> |
| | | <Select.Option key={i} disabled={option.disabled} value={option.field || ''}>{`${option.label}(${option.field})`}</Select.Option> |
| | | )} |
| | | </Select> |
| | | ) |
| | | } |
| | | return ( |
| | | <Select |
| | | showSearch |
| | | allowClear |
| | | value={value} |
| | | dropdownMatchSelectWidth={config.dropdown !== 'false'} |
| | | filterOption={(input, option) => (option.props.children + option.props.extend).toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | onSelect={this.selectChange} |
| | | onChange={(val) => val === undefined && this.selectChange('')} |
| | | getPopupContainer={() => document.getElementById('normal-form-field')} |
| | | > |
| | | {options.map((option, i) => |
| | | <Select.Option key={i} disabled={option.disabled} title={option.label || option.text} extend={config.extendName ? (option[config.extendName] || '') : ''} value={option.value || option.field || ''}>{option.label || option.text}</Select.Option> |
| | | )} |
| | | </Select> |
| | | ) |
| | | } else { |
| | | return (<Select |
| | | showSearch |
| | |
| | | defaultValue={value} |
| | | filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} |
| | | onChange={this.mutilselectChange} |
| | | getPopupContainer={() => document.getElementById('normal-form-field')} |
| | | > |
| | | {options.map((option, i) => |
| | | <Select.Option key={i} disabled={option.disabled} value={option.value || option.field}>{option.label || option.text}</Select.Option> |