Commit 4e2f64ec authored by GuanHua's avatar GuanHua

fix:店铺商品品类筛选问题

parent e6bb8559
This diff is collapsed.
......@@ -6,6 +6,7 @@ import { LAYOUT_TYPE, FILTER_TYPE } from '@/constants'
import { PublicApi } from '@/services/api'
import isEmpty from 'lodash/isEmpty'
import styles from './index.less'
import { Layout } from '@formily/antd'
const CheckboxGroup = Checkbox.Group
......@@ -29,6 +30,7 @@ const Category: React.FC<CategoryPropsType> = (props) => {
const [initSelectAttributeList, setInitSelectAttributeList] = useState<any>([])
useEffect(() => {
console.log(JSON.stringify(filterList))
if (isEmpty(filterList)) {
setSelectedKeys([])
setLastCategoryId(null)
......@@ -39,6 +41,8 @@ const Category: React.FC<CategoryPropsType> = (props) => {
for (const item of filterList) {
if (item.type === FILTER_TYPE.category) {
initKeys.push(String(item.key))
} else if(item.type === FILTER_TYPE.customerCategory) {
initKeys.push(String(item.key))
}
if (item.type === FILTER_TYPE.attribute) {
setInitSelectAttributeList(item.key)
......@@ -186,7 +190,6 @@ const Category: React.FC<CategoryPropsType> = (props) => {
}
const handleSelect = (selectedKeys, info) => {
console.log(info)
const { title, children, name } = info.node
setSelectedKeys(selectedKeys)
if (children.length === 0) {
......@@ -196,17 +199,31 @@ const Category: React.FC<CategoryPropsType> = (props) => {
} else {
setLastCategoryId(null)
setAttributeList([])
onFilter({
type: FILTER_TYPE.attribute,
key: null,
title: ``
})
if(filterList.some(item => item.type === FILTER_TYPE.attribute)) {
onFilter({
type: FILTER_TYPE.attribute,
key: null,
title: ``
})
}
}
onFilter({
type: FILTER_TYPE.category,
key: selectedKeys,
title: typeof title === 'string' ? title : name
})
switch(layoutType) {
case LAYOUT_TYPE.mall:
onFilter({
type: FILTER_TYPE.category,
key: selectedKeys,
title: typeof title === 'string' ? title : name
})
break
default:
onFilter({
type: FILTER_TYPE.customerCategory,
key: selectedKeys,
title: typeof title === 'string' ? title : name
})
break
}
}
const handleExpand = (expandedKeys) => {
......
......@@ -138,6 +138,9 @@ class FilterStore {
case FILTER_TYPE.category:
tempFilterParam.categoryId = Number(filterItem.key[0])
break
case FILTER_TYPE.customerCategory:
tempFilterParam.customerCategoryId = Number(filterItem.key[0])
break
case FILTER_TYPE.commodityType:
tempFilterParam.priceTypeList = [filterItem.key]
break
......@@ -202,6 +205,10 @@ class FilterStore {
tempFilterParam.customerCategoryId = filterItem.key[0]
tempFilterParam.customerCategoryName = filterItem.title
break
case FILTER_TYPE.customerCategory:
tempFilterParam.customerCategoryId = filterItem.key[0]
tempFilterParam.customerCategoryName = filterItem.title
break
case FILTER_TYPE.brand:
tempFilterParam.brandId = filterItem.key
tempFilterParam.brandName = filterItem.title
......
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