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