From 395c645926f91640400b43d120b50a2b53b237ce Mon Sep 17 00:00:00 2001 From: zhangwenshuai Date: Wed, 17 Jun 2020 16:18:47 +0800 Subject: [PATCH] update edit select,search,assoSearch ui --- .../component/base/edit/search/index.less | 5 +++++ .../component/base/edit/select/styles.less | 3 +++ .../base/extra/associationSearch/index.tsx | 21 ++++++++++++------- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/components/apolloTable/component/base/edit/search/index.less b/components/apolloTable/component/base/edit/search/index.less index c439d10..af0f82d 100644 --- a/components/apolloTable/component/base/edit/search/index.less +++ b/components/apolloTable/component/base/edit/search/index.less @@ -5,5 +5,10 @@ width: 100%; min-height: 100%; border-radius: 0; + display: flex; + align-items: center; + } + :global(.ant-select-selection__rendered){ + width: 100%; } } diff --git a/components/apolloTable/component/base/edit/select/styles.less b/components/apolloTable/component/base/edit/select/styles.less index b9ebf50..20aca23 100644 --- a/components/apolloTable/component/base/edit/select/styles.less +++ b/components/apolloTable/component/base/edit/select/styles.less @@ -12,4 +12,7 @@ display: flex; align-items: center; } + :global(.ant-select-selection__rendered){ + width: 100%; + } } diff --git a/components/apolloTable/component/base/extra/associationSearch/index.tsx b/components/apolloTable/component/base/extra/associationSearch/index.tsx index cb97147..4603451 100644 --- a/components/apolloTable/component/base/extra/associationSearch/index.tsx +++ b/components/apolloTable/component/base/extra/associationSearch/index.tsx @@ -2,7 +2,6 @@ import React from 'react'; import { Spin, Select } from 'antd'; import lodash from 'lodash'; import { Consumer } from '../../../context'; -import s from './index.less'; interface Props { initDataType?: undefined | 'onfocus'; // 初始化请求方式 @@ -20,6 +19,12 @@ interface Props { }; } +enum Loaded { + Init='init', + Has='has', + Empty='empty', +} + interface State { value: any; data: any[]; @@ -28,6 +33,7 @@ interface State { initData: any[]; searchStr: string; canFocus: boolean; + loaded: Loaded; } class AssociationSearch extends React.Component { @@ -42,6 +48,7 @@ class AssociationSearch extends React.Component { initData: [], searchStr: '', canFocus: true, + loaded: Loaded.Init, }; } @@ -89,7 +96,7 @@ class AssociationSearch extends React.Component { } else { data = Array.isArray(dataSource) ? dataSource : []; } - this.setState({ data, fetching: false }); + this.setState({ data, loaded: data.length > 0 ? Loaded.Has : Loaded.Empty, fetching: false }); }; onSearch = (val: string) => { @@ -207,23 +214,23 @@ class AssociationSearch extends React.Component { } }; - notFoundContent = (locale) => { - const { data, fetching, value } = this.state; + notFoundContent = (locale:any) => { + const { fetching, loaded } = this.state; if (fetching) { return ; } - if (!data || data.length === 0) { + if (loaded === Loaded.Empty) { return {locale.notFoundContent}; } return null; }; render() { - const { data, fetching, value } = this.state; + const { data, value } = this.state; const { selfCom, autoFocus, onChange, ...rest } = this.props; return ( - {({ locale }) => { + {({ locale }:any) => { return (