From f3d4db769ba9b51b799d981511a710fd443d0e08 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 21 四月 2025 12:18:03 +0800 Subject: [PATCH] Merge branch 'master' into positec --- src/components/normalform/modalform/mkSelect/index.jsx | 45 +++++++++++++++++++++++++++++++++++++-------- 1 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/components/normalform/modalform/mkSelect/index.jsx b/src/components/normalform/modalform/mkSelect/index.jsx index c5c6ad4..7c7d8ed 100644 --- a/src/components/normalform/modalform/mkSelect/index.jsx +++ b/src/components/normalform/modalform/mkSelect/index.jsx @@ -1,9 +1,8 @@ -import React, {Component} from 'react' +import React, { Component } from 'react' import { is, fromJS } from 'immutable' import { Select } from 'antd' import MKEmitter from '@/utils/events.js' -import './index.scss' class MKSelect extends Component { constructor(props) { @@ -32,6 +31,15 @@ MKEmitter.addListener('mkFC', this.mkFormControl) } + 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(), + }) + } + } + shouldComponentUpdate (nextProps, nextState) { return !is(fromJS(this.state), fromJS(nextState)) } @@ -58,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({ @@ -107,17 +115,37 @@ const { value, config, options } = this.state if (config.type !== 'multiselect') { + if (config.joint) { + return ( + <Select + showSearch + allowClear + value={value} + dropdownMatchSelectWidth={config.dropdown !== 'false'} + filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} + onSelect={this.selectChange} + onChange={(val) => val === undefined && this.selectChange('')} + getPopupContainer={() => config.$formId ? document.getElementById(config.$formId) : document.body} + > + {options.map((option, i) => + <Select.Option key={i} disabled={option.disabled} value={option.field || ''}>{`${option.label}锛�${option.field}锛塦}</Select.Option> + )} + </Select> + ) + } return ( <Select showSearch allowClear value={value} - filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} + 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={() => config.$formId ? document.getElementById(config.$formId) : document.body} > - {options.map(option => - <Select.Option key={option.value || option.field} disabled={option.disabled} value={option.value || option.field}>{option.label || option.text}</Select.Option> + {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> ) @@ -128,9 +156,10 @@ defaultValue={value} filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} onChange={this.mutilselectChange} + getPopupContainer={() => config.$formId ? document.getElementById(config.$formId) : document.body} > - {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