🎈 perf(ID1000784): 【重构版】销售排行的筛选指标,去掉“全部”,默认“已配布”
【【重构版】销售排行的筛选指标,去掉“全部”,默认“已配布”】 https://www.tapd.cn/53459131/prong/stories/view/1153459131001000784
This commit is contained in:
parent
2d57f586d4
commit
e083c8aa4f
@ -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<SelectSaleTypeProps> = (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<EnumList[]>([])
|
||||
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<ChangedValue>(-1)
|
||||
const [currentValue, setCurrentValue] = useState<ChangedValue>(defaultValue)
|
||||
|
||||
const handleClick = (value: ChangedValue) => {
|
||||
setCurrentValue(value)
|
||||
@ -47,7 +47,7 @@ const SelectSaleRankingIndicators: FC<SelectSaleTypeProps> = (props) => {
|
||||
}
|
||||
|
||||
const displayTitle = useMemo(() => {
|
||||
if (currentValue === -1) {
|
||||
if (currentValue === defaultValue) {
|
||||
return selectName
|
||||
}
|
||||
return enumList.length ? enumList.filter(option => option.id === currentValue)?.[0]?.name : selectName
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user