Commit 1219129b authored by XieZhiXiong's avatar XieZhiXiong

chore: 删除 extra 属性

parent 4f14490b
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: XieZhiXiong * @Author: XieZhiXiong
* @Date: 2021-08-05 10:28:06 * @Date: 2021-08-05 10:28:06
* @LastEditors: XieZhiXiong * @LastEditors: XieZhiXiong
* @LastEditTime: 2021-12-02 10:53:32 * @LastEditTime: 2021-12-02 15:35:07
* @Description: 地址选择 FormItem * @Description: 地址选择 FormItem
*/ */
import React, { useState, useEffect, useMemo, useRef } from 'react'; import React, { useState, useEffect, useMemo, useRef } from 'react';
...@@ -119,10 +119,6 @@ interface IProps { ...@@ -119,10 +119,6 @@ interface IProps {
* 是否显示下拉框 * 是否显示下拉框
*/ */
echo?: boolean, echo?: boolean,
/**
* 只显示文字
*/
extra?: React.ReactNode,
} }
export type SubmitValuesType = { export type SubmitValuesType = {
...@@ -185,7 +181,6 @@ const AddressSelect: React.FC<IProps> = (props) => { ...@@ -185,7 +181,6 @@ const AddressSelect: React.FC<IProps> = (props) => {
disabled = false, disabled = false,
editable = true, editable = true,
echo = false, echo = false,
extra,
} = props; } = props;
const [list, setList] = useState<AddressValueType[]>([]); const [list, setList] = useState<AddressValueType[]>([]);
const [internalValue, setInternalValue] = useState<AddressValueType>(); const [internalValue, setInternalValue] = useState<AddressValueType>();
...@@ -602,8 +597,8 @@ const AddressSelect: React.FC<IProps> = (props) => { ...@@ -602,8 +597,8 @@ const AddressSelect: React.FC<IProps> = (props) => {
label: `${item.name} ${item.fullAddress} ${item.phone}`, label: `${item.name} ${item.fullAddress} ${item.phone}`,
})); }));
}, [list]); }, [list]);
if (!editable) { const renderAddressStr = () => {
const current = list.find((item) => item.id === value?.id); const current = list.find((item) => item.id === value?.id);
const full = current ? `${current.name} ${current.fullAddress} ${current.phone}` : null; const full = current ? `${current.name} ${current.fullAddress} ${current.phone}` : null;
const isStr = typeof value === 'string'; const isStr = typeof value === 'string';
...@@ -611,6 +606,10 @@ const AddressSelect: React.FC<IProps> = (props) => { ...@@ -611,6 +606,10 @@ const AddressSelect: React.FC<IProps> = (props) => {
return ( return (
<div>{full || (!isStr ? `${value?.name || ''} ${value?.fullAddress || ''} ${value?.phone || ''}` : value)}</div> <div>{full || (!isStr ? `${value?.name || ''} ${value?.fullAddress || ''} ${value?.phone || ''}` : value)}</div>
); );
};
if (!editable) {
return renderAddressStr();
} }
return ( return (
...@@ -636,7 +635,7 @@ const AddressSelect: React.FC<IProps> = (props) => { ...@@ -636,7 +635,7 @@ const AddressSelect: React.FC<IProps> = (props) => {
)} )}
{echo && ( {echo && (
<div className={styles['address-select-input']}> <div className={styles['address-select-input']}>
{extra} {renderAddressStr()}
</div> </div>
)} )}
<Button <Button
...@@ -644,7 +643,7 @@ const AddressSelect: React.FC<IProps> = (props) => { ...@@ -644,7 +643,7 @@ const AddressSelect: React.FC<IProps> = (props) => {
className={styles['address-select-action']} className={styles['address-select-action']}
disabled={disabled} disabled={disabled}
> >
管理 更改
</Button> </Button>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment