Commit 1219129b authored by XieZhiXiong's avatar XieZhiXiong

chore: 删除 extra 属性

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