From 8040a18c4b2a848d252bf01838f06c7aec1be9f3 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 07 六月 2024 15:16:11 +0800 Subject: [PATCH] 2024-06-07 --- src/components/normalform/modalform/mkSelect/index.jsx | 55 +++++++++++++++++++++++++++---------------------------- 1 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/components/normalform/modalform/mkSelect/index.jsx b/src/components/normalform/modalform/mkSelect/index.jsx index 840dd4a..4b8ee1a 100644 --- a/src/components/normalform/modalform/mkSelect/index.jsx +++ b/src/components/normalform/modalform/mkSelect/index.jsx @@ -1,4 +1,4 @@ -import React, {Component} from 'react' +import React, { Component } from 'react' import { is, fromJS } from 'immutable' import { Select } from 'antd' @@ -31,13 +31,11 @@ MKEmitter.addListener('mkFC', this.mkFormControl) } - UNSAFE_componentWillReceiveProps (nextProps) { - const { config } = this.state - - if (!is(fromJS(config.oriOptions), fromJS(nextProps.config.oriOptions))) { + UNSAFE_componentWillReceiveProps(nextProps) { + if (nextProps.config.timestamp && nextProps.config.timestamp !== this.state.config.timestamp) { this.setState({ config: fromJS(nextProps.config).toJS(), - options: fromJS(nextProps.config.options).toJS() + options: fromJS(nextProps.config.options).toJS(), }) } } @@ -68,7 +66,7 @@ const { config } = this.state - let options = config.oriOptions ? config.oriOptions.filter(option => option.ParentID === parentId) : [] + let options = config.oriOptions ? config.oriOptions.filter(option => option.ParentID === parentId || option.ParentID === '') : [] let val = options[0] ? options[0].value : '' this.setState({ @@ -117,24 +115,7 @@ 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 @@ -144,13 +125,30 @@ 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 @@ -158,9 +156,10 @@ 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 => - <Select.Option key={option.value} disabled={option.disabled} value={option.value}>{option.label || option.text}</Select.Option> + {options.map((option, i) => + <Select.Option key={i} disabled={option.disabled} value={option.value || option.field}>{option.label || option.text}</Select.Option> )} </Select>) } -- Gitblit v1.8.0