| | |
| | | let config = fromJS(this.props.config).toJS() |
| | | |
| | | let selectKeys = config.initval |
| | | let initlength = 0 |
| | | if (config.multiple === 'true') { |
| | | selectKeys = config.initval ? config.initval.split(',') : [] |
| | | initlength = selectKeys.length |
| | | selectKeys = this.filterVals(config.options, selectKeys) |
| | | } |
| | | |
| | | if (!config.selectStyle && config.backgroundColor) { |
| | |
| | | config: config, |
| | | options: fromJS(config.options).toJS(), |
| | | selectKeys: selectKeys |
| | | }, () => { |
| | | if (config.multiple === 'true' && selectKeys.length < initlength) { |
| | | this.props.onChange(selectKeys.join(',')) |
| | | } |
| | | }) |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { config } = this.state |
| | | const { config, selectKeys } = this.state |
| | | |
| | | if (!is(fromJS(config.oriOptions), fromJS(nextProps.config.oriOptions))) { |
| | | if (config.multiple === 'true') { |
| | | let keys = this.filterVals(nextProps.config.options, fromJS(selectKeys).toJS()) |
| | | if (keys.length < selectKeys.length) { |
| | | this.setState({ |
| | | selectKeys: keys |
| | | }, () => { |
| | | this.props.onChange(keys.join(',')) |
| | | }) |
| | | } |
| | | } |
| | | |
| | | this.setState({ |
| | | config: {...config, oriOptions: nextProps.config.oriOptions}, |
| | | options: fromJS(nextProps.config.options).toJS() |
| | |
| | | MKEmitter.removeListener('mkFP', this.mkFormHandle) |
| | | } |
| | | |
| | | filterVals = (options, vals) => { |
| | | if (options.length === 0 || vals.length === 0) return vals |
| | | |
| | | let ops = options.map(item => item.$value) |
| | | |
| | | vals = vals.filter(val => ops.includes(val)) |
| | | |
| | | return vals |
| | | } |
| | | |
| | | mkFormHandle = (uuid, parentId, level) => { |
| | | if (uuid !== this.state.config.uuid) return |
| | | |