🎈 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 FilterButton from '../filterButton'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
import { SaleOrderDataFormdataFormStatus } from '@/api/index'
|
import { SaleOrderDataFormdataFormStatus } from '@/api/index'
|
||||||
import { ShoppingProvider } from '@/pages/shopping/components/shoppingCart'
|
|
||||||
|
|
||||||
type ChangedValue = string | number
|
type ChangedValue = string | number
|
||||||
|
|
||||||
@ -14,6 +13,7 @@ interface SelectSaleTypeProps {
|
|||||||
onChange?: (value: ChangedValue) => void
|
onChange?: (value: ChangedValue) => void
|
||||||
dropDownStyle?: React.CSSProperties
|
dropDownStyle?: React.CSSProperties
|
||||||
dropDownClassName?: string
|
dropDownClassName?: string
|
||||||
|
defaultValue?: ChangedValue
|
||||||
}
|
}
|
||||||
|
|
||||||
interface EnumList {
|
interface EnumList {
|
||||||
@ -25,21 +25,21 @@ interface EnumList {
|
|||||||
const SelectSaleRankingIndicators: FC<SelectSaleTypeProps> = (props) => {
|
const SelectSaleRankingIndicators: FC<SelectSaleTypeProps> = (props) => {
|
||||||
const selectName = '排行指标'
|
const selectName = '排行指标'
|
||||||
|
|
||||||
const { onChange, dropDownStyle, dropDownClassName } = props
|
const { onChange, dropDownStyle, dropDownClassName, defaultValue = 1 } = props
|
||||||
console.log(props)
|
console.log(props)
|
||||||
const { fetchData } = SaleOrderDataFormdataFormStatus()
|
const { fetchData } = SaleOrderDataFormdataFormStatus()
|
||||||
|
|
||||||
const [enumList, setEnumList] = useState<EnumList[]>([])
|
const [enumList, setEnumList] = useState<EnumList[]>([])
|
||||||
const getData = async() => {
|
const getData = async() => {
|
||||||
const res = await fetchData()
|
const res = await fetchData()
|
||||||
setEnumList([{ id: -1, code: '', name: '全部' }, ...res.data.list])
|
setEnumList(res.data.list)
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getData()
|
getData()
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const [currentValue, setCurrentValue] = useState<ChangedValue>(-1)
|
const [currentValue, setCurrentValue] = useState<ChangedValue>(defaultValue)
|
||||||
|
|
||||||
const handleClick = (value: ChangedValue) => {
|
const handleClick = (value: ChangedValue) => {
|
||||||
setCurrentValue(value)
|
setCurrentValue(value)
|
||||||
@ -47,7 +47,7 @@ const SelectSaleRankingIndicators: FC<SelectSaleTypeProps> = (props) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const displayTitle = useMemo(() => {
|
const displayTitle = useMemo(() => {
|
||||||
if (currentValue === -1) {
|
if (currentValue === defaultValue) {
|
||||||
return selectName
|
return selectName
|
||||||
}
|
}
|
||||||
return enumList.length ? enumList.filter(option => option.id === currentValue)?.[0]?.name : selectName
|
return enumList.length ? enumList.filter(option => option.id === currentValue)?.[0]?.name : selectName
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user