Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shenshaokai
jinfa-platform
Commits
6f321ec5
Commit
6f321ec5
authored
Dec 07, 2020
by
GuanHua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 商品属性分类筛选问题
parent
b932ee57
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
13 deletions
+28
-13
index.tsx
...es/lxMall/components/Filter/components/Category/index.tsx
+25
-12
index.ts
src/store/filter/index.ts
+3
-1
No files found.
src/pages/lxMall/components/Filter/components/Category/index.tsx
View file @
6f321ec5
...
...
@@ -30,14 +30,14 @@ const Category: React.FC<CategoryPropsType> = (props) => {
const
[
initSelectAttributeList
,
setInitSelectAttributeList
]
=
useState
<
any
>
([])
useEffect
(()
=>
{
console
.
log
(
JSON
.
stringify
(
filterList
))
if
(
isEmpty
(
filterList
))
{
setSelectedKeys
([])
setLastCategoryId
(
null
)
setSelectAttrbuteList
([])
}
else
{
const
initKeys
=
[]
// let initAttr
Keys = []
let
attrInit
Keys
=
[]
for
(
const
item
of
filterList
)
{
if
(
item
.
type
===
FILTER_TYPE
.
category
)
{
initKeys
.
push
(
String
(
item
.
key
))
...
...
@@ -45,9 +45,15 @@ const Category: React.FC<CategoryPropsType> = (props) => {
initKeys
.
push
(
String
(
item
.
key
))
}
if
(
item
.
type
===
FILTER_TYPE
.
attribute
)
{
setInitSelectAttributeList
(
item
.
key
)
attrInitKeys
=
item
.
key
}
}
setInitSelectAttributeList
(
attrInitKeys
)
if
(
isEmpty
(
attrInitKeys
))
{
setSelectAttrbuteList
([])
}
setSelectedKeys
(
initKeys
)
}
},
[
filterList
])
...
...
@@ -197,15 +203,10 @@ const Category: React.FC<CategoryPropsType> = (props) => {
setLastCategoryId
(
selectedKeys
[
0
])
}
}
else
{
setLastCategoryId
(
null
)
setAttributeList
([])
if
(
filterList
.
some
(
item
=>
item
.
type
===
FILTER_TYPE
.
attribute
))
{
onFilter
({
type
:
FILTER_TYPE
.
attribute
,
key
:
null
,
title
:
``
})
}
initAttribute
()
}
if
(
selectedKeys
.
length
===
0
)
{
initAttribute
()
}
switch
(
layoutType
)
{
case
LAYOUT_TYPE
.
mall
:
...
...
@@ -226,6 +227,18 @@ const Category: React.FC<CategoryPropsType> = (props) => {
}
const
initAttribute
=
()
=>
{
setLastCategoryId
(
null
)
setAttributeList
([])
if
(
filterList
.
some
(
item
=>
item
.
type
===
FILTER_TYPE
.
attribute
))
{
onFilter
({
type
:
FILTER_TYPE
.
attribute
,
key
:
null
,
title
:
``
})
}
}
const
handleExpand
=
(
expandedKeys
)
=>
{
setExpandedKeys
(
expandedKeys
)
}
...
...
src/store/filter/index.ts
View file @
6f321ec5
...
...
@@ -136,7 +136,9 @@ class FilterStore {
for
(
const
filterItem
of
newFilterList
)
{
switch
(
filterItem
.
type
)
{
case
FILTER_TYPE
.
category
:
tempFilterParam
.
categoryId
=
Number
(
filterItem
.
key
[
0
])
if
(
Number
(
filterItem
.
key
[
0
]))
{
tempFilterParam
.
categoryId
=
Number
(
filterItem
.
key
[
0
])
}
break
case
FILTER_TYPE
.
customerCategory
:
tempFilterParam
.
customerCategoryId
=
Number
(
filterItem
.
key
[
0
])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment