From e083c8aa4f1b73d1bb64859ef270a9085493b1a1 Mon Sep 17 00:00:00 2001 From: xuan Date: Tue, 6 Dec 2022 13:58:45 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=88=20perf(ID1000784):=20=E3=80=90?= =?UTF-8?q?=E9=87=8D=E6=9E=84=E7=89=88=E3=80=91=E9=94=80=E5=94=AE=E6=8E=92?= =?UTF-8?q?=E8=A1=8C=E7=9A=84=E7=AD=9B=E9=80=89=E6=8C=87=E6=A0=87=EF=BC=8C?= =?UTF-8?q?=E5=8E=BB=E6=8E=89=E2=80=9C=E5=85=A8=E9=83=A8=E2=80=9D=EF=BC=8C?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E2=80=9C=E5=B7=B2=E9=85=8D=E5=B8=83=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【【重构版】销售排行的筛选指标,去掉“全部”,默认“已配布”】 https://www.tapd.cn/53459131/prong/stories/view/1153459131001000784 --- src/components/SelectSaleRankingIndicators/index.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/SelectSaleRankingIndicators/index.tsx b/src/components/SelectSaleRankingIndicators/index.tsx index 559ba51..45ae960 100644 --- a/src/components/SelectSaleRankingIndicators/index.tsx +++ b/src/components/SelectSaleRankingIndicators/index.tsx @@ -6,7 +6,6 @@ import DropDownItem from '../dropDown-item' import FilterButton from '../filterButton' import styles from './index.module.scss' import { SaleOrderDataFormdataFormStatus } from '@/api/index' -import { ShoppingProvider } from '@/pages/shopping/components/shoppingCart' type ChangedValue = string | number @@ -14,6 +13,7 @@ interface SelectSaleTypeProps { onChange?: (value: ChangedValue) => void dropDownStyle?: React.CSSProperties dropDownClassName?: string + defaultValue?: ChangedValue } interface EnumList { @@ -25,21 +25,21 @@ interface EnumList { const SelectSaleRankingIndicators: FC = (props) => { const selectName = '排行指标' - const { onChange, dropDownStyle, dropDownClassName } = props + const { onChange, dropDownStyle, dropDownClassName, defaultValue = 1 } = props console.log(props) const { fetchData } = SaleOrderDataFormdataFormStatus() const [enumList, setEnumList] = useState([]) const getData = async() => { const res = await fetchData() - setEnumList([{ id: -1, code: '', name: '全部' }, ...res.data.list]) + setEnumList(res.data.list) } useEffect(() => { getData() }, []) - const [currentValue, setCurrentValue] = useState(-1) + const [currentValue, setCurrentValue] = useState(defaultValue) const handleClick = (value: ChangedValue) => { setCurrentValue(value) @@ -47,7 +47,7 @@ const SelectSaleRankingIndicators: FC = (props) => { } const displayTitle = useMemo(() => { - if (currentValue === -1) { + if (currentValue === defaultValue) { return selectName } return enumList.length ? enumList.filter(option => option.id === currentValue)?.[0]?.name : selectName