Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
web-ci-test
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
test-ci
web-ci-test
Commits
d7c6a6ef
提交
d7c6a6ef
authored
5月 18, 2023
作者:
翁进城
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
filter组件改为前端渲染,简化使用方式
上级
5bb6d048
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
78 行增加
和
50 行删除
+78
-50
index.ts
components/filter/api/index.ts
+22
-0
index.tsx
components/filter/compoents/brandItem/index.tsx
+11
-3
index.tsx
components/filter/compoents/categoryItem/index.tsx
+11
-3
index.tsx
components/filter/compoents/modelItem/index.tsx
+11
-3
index.tsx
components/filter/compoents/partItem/index.tsx
+11
-3
index.tsx
components/filter/compoents/qualityItem/index.tsx
+11
-3
index.tsx
components/filter/compoents/regionItem/index.tsx
+1
-0
index.tsx
components/filter/index.tsx
+0
-11
index.page.tsx
pages/mall/index.page.tsx
+0
-24
没有找到文件。
components/filter/api/index.ts
浏览文件 @
d7c6a6ef
...
@@ -4,6 +4,28 @@ export interface FilterOptionResp {
...
@@ -4,6 +4,28 @@ export interface FilterOptionResp {
id
:
number
,
id
:
number
,
name
:
string
name
:
string
}
}
export
default
{
category
:
():
Promise
<
Response
<
Array
<
FilterOptionResp
>>>
=>
{
return
request
(
'/pms/webProductMall/category'
);
},
brand
:
():
Promise
<
Response
<
Array
<
FilterOptionResp
>>>
=>
{
return
request
(
'/pms/webDevice/brand'
);
},
model
:
():
Promise
<
Response
<
Array
<
FilterOptionResp
>>>
=>
{
return
request
(
'/pms/webDevice/model'
);
},
part
:
():
Promise
<
Response
<
Array
<
FilterOptionResp
>>>
=>
{
return
request
(
'/pms/webProductMall/parts'
);
},
quality
:
():
Promise
<
Response
<
Array
<
FilterOptionResp
>>>
=>
{
return
request
(
'/pms/webProductMall/quality'
);
},
region
:
():
Promise
<
Response
<
Array
<
FilterOptionResp
>>>
=>
{
return
request
(
'/pms/webDevice/getSecondDistrictInfo'
);
},
}
//商城接口
//商城接口
export
const
mallApi
=
{
export
const
mallApi
=
{
category
:
():
Promise
<
Response
<
Array
<
FilterOptionResp
>>>
=>
{
category
:
():
Promise
<
Response
<
Array
<
FilterOptionResp
>>>
=>
{
...
...
components/filter/compoents/brandItem/index.tsx
浏览文件 @
d7c6a6ef
import
{
Space
,
Button
,
Select
}
from
'antd'
;
import
{
Space
,
Button
,
Select
}
from
'antd'
;
import
styles
from
'../../index.module.scss'
;
import
styles
from
'../../index.module.scss'
;
import
{
FilterOptionResp
}
from
"../../api"
;
import
api
,
{
FilterOptionResp
}
from
"../../api"
;
import
{
useEffect
,
useState
}
from
"react"
;
type
Props
=
{
type
Props
=
{
data
:
Array
<
FilterOptionResp
>
;
onChange
:
(
id
:
FilterOptionResp
)
=>
void
;
onChange
:
(
id
:
FilterOptionResp
)
=>
void
;
};
};
export
default
function
BrandItem
(
props
:
Props
)
{
export
default
function
BrandItem
(
props
:
Props
)
{
const
[
data
,
setData
]
=
useState
<
FilterOptionResp
[]
>
([])
useEffect
(()
=>
{
api
.
brand
().
then
(
res
=>
{
setData
(
res
?.
result
||
[]);
});
},
[])
const
onClick
=
(
item
:
FilterOptionResp
)
=>
{
const
onClick
=
(
item
:
FilterOptionResp
)
=>
{
props
.
onChange
({
props
.
onChange
({
id
:
item
.
id
,
id
:
item
.
id
,
...
@@ -21,7 +29,7 @@ export default function BrandItem(props: Props) {
...
@@ -21,7 +29,7 @@ export default function BrandItem(props: Props) {
<
div
className=
{
styles
.
filterItemMain
}
>
<
div
className=
{
styles
.
filterItemMain
}
>
<
Space
size=
{
40
}
>
<
Space
size=
{
40
}
>
{
{
props
?.
data
?
.
map
(
item
=>
{
data
.
map
(
item
=>
{
return
<
Button
type=
"link"
key=
{
item
.
id
}
onClick=
{
(
e
)
=>
onClick
(
item
)
}
>
{
item
.
name
}
</
Button
>;
return
<
Button
type=
"link"
key=
{
item
.
id
}
onClick=
{
(
e
)
=>
onClick
(
item
)
}
>
{
item
.
name
}
</
Button
>;
})
})
}
}
...
...
components/filter/compoents/categoryItem/index.tsx
浏览文件 @
d7c6a6ef
import
{
Space
,
Button
,
Select
}
from
'antd'
;
import
{
Space
,
Button
,
Select
}
from
'antd'
;
import
styles
from
'../../index.module.scss'
;
import
styles
from
'../../index.module.scss'
;
import
{
FilterOptionResp
}
from
"../../api"
;
import
api
,
{
FilterOptionResp
}
from
"../../api"
;
import
{
useState
,
useEffect
}
from
'react'
;
type
Props
=
{
type
Props
=
{
data
:
Array
<
FilterOptionResp
>
;
onChange
:
(
id
:
FilterOptionResp
)
=>
void
;
onChange
:
(
id
:
FilterOptionResp
)
=>
void
;
};
};
export
default
function
CategoryItem
(
props
:
Props
)
{
export
default
function
CategoryItem
(
props
:
Props
)
{
const
[
data
,
setData
]
=
useState
<
FilterOptionResp
[]
>
([]);
useEffect
(()
=>
{
api
.
category
().
then
((
res
)
=>
{
setData
(
res
?.
result
||
[]);
});
},
[]);
const
onClick
=
(
item
:
FilterOptionResp
)
=>
{
const
onClick
=
(
item
:
FilterOptionResp
)
=>
{
props
.
onChange
({
props
.
onChange
({
id
:
item
.
id
,
id
:
item
.
id
,
...
@@ -21,7 +29,7 @@ export default function CategoryItem(props: Props) {
...
@@ -21,7 +29,7 @@ export default function CategoryItem(props: Props) {
<
div
className=
{
styles
.
filterItemMain
}
>
<
div
className=
{
styles
.
filterItemMain
}
>
<
Space
size=
{
40
}
>
<
Space
size=
{
40
}
>
{
{
props
?.
data
?
.
map
(
item
=>
{
data
.
map
(
item
=>
{
return
<
Button
type=
"link"
key=
{
item
.
id
}
onClick=
{
(
e
)
=>
onClick
(
item
)
}
>
{
item
.
name
}
</
Button
>;
return
<
Button
type=
"link"
key=
{
item
.
id
}
onClick=
{
(
e
)
=>
onClick
(
item
)
}
>
{
item
.
name
}
</
Button
>;
})
})
}
}
...
...
components/filter/compoents/modelItem/index.tsx
浏览文件 @
d7c6a6ef
import
{
Space
,
Button
,
Select
}
from
'antd'
;
import
{
Space
,
Button
,
Select
}
from
'antd'
;
import
styles
from
'../../index.module.scss'
;
import
styles
from
'../../index.module.scss'
;
import
{
FilterOptionResp
}
from
"../../api"
;
import
api
,
{
FilterOptionResp
}
from
"../../api"
;
import
{
useEffect
,
useState
}
from
'react'
;
type
Props
=
{
type
Props
=
{
data
:
Array
<
FilterOptionResp
>
;
onChange
:
(
id
:
FilterOptionResp
)
=>
void
;
onChange
:
(
id
:
FilterOptionResp
)
=>
void
;
};
};
export
default
function
ModelItem
(
props
:
Props
)
{
export
default
function
ModelItem
(
props
:
Props
)
{
const
[
data
,
setData
]
=
useState
<
FilterOptionResp
[]
>
([]);
useEffect
(()
=>
{
api
.
model
().
then
((
res
)
=>
{
setData
(
res
?.
result
||
[]);
});
},
[]);
const
onClick
=
(
item
:
FilterOptionResp
)
=>
{
const
onClick
=
(
item
:
FilterOptionResp
)
=>
{
props
.
onChange
({
props
.
onChange
({
id
:
item
.
id
,
id
:
item
.
id
,
...
@@ -21,7 +29,7 @@ export default function ModelItem(props: Props) {
...
@@ -21,7 +29,7 @@ export default function ModelItem(props: Props) {
<
div
className=
{
styles
.
filterItemMain
}
>
<
div
className=
{
styles
.
filterItemMain
}
>
<
Space
size=
{
40
}
>
<
Space
size=
{
40
}
>
{
{
props
?.
data
?.
map
(
item
=>
{
data
?.
map
(
item
=>
{
return
<
Button
type=
"link"
key=
{
item
.
id
}
onClick=
{
(
e
)
=>
onClick
(
item
)
}
>
{
item
.
name
}
</
Button
>;
return
<
Button
type=
"link"
key=
{
item
.
id
}
onClick=
{
(
e
)
=>
onClick
(
item
)
}
>
{
item
.
name
}
</
Button
>;
})
})
}
}
...
...
components/filter/compoents/partItem/index.tsx
浏览文件 @
d7c6a6ef
import
{
Space
,
Button
,
Select
}
from
'antd'
;
import
{
Space
,
Button
,
Select
}
from
'antd'
;
import
styles
from
'../../index.module.scss'
;
import
styles
from
'../../index.module.scss'
;
import
{
FilterOptionResp
}
from
"../../api"
;
import
api
,
{
FilterOptionResp
}
from
"../../api"
;
import
{
useState
,
useEffect
}
from
'react'
;
type
Props
=
{
type
Props
=
{
data
:
Array
<
FilterOptionResp
>
;
onChange
:
(
id
:
FilterOptionResp
)
=>
void
;
onChange
:
(
id
:
FilterOptionResp
)
=>
void
;
};
};
export
default
function
PartItem
(
props
:
Props
)
{
export
default
function
PartItem
(
props
:
Props
)
{
const
[
data
,
setData
]
=
useState
<
FilterOptionResp
[]
>
([]);
useEffect
(()
=>
{
api
.
part
().
then
((
res
)
=>
{
setData
(
res
?.
result
||
[]);
});
},
[]);
const
onClick
=
(
item
:
FilterOptionResp
)
=>
{
const
onClick
=
(
item
:
FilterOptionResp
)
=>
{
props
.
onChange
({
props
.
onChange
({
id
:
item
.
id
,
id
:
item
.
id
,
...
@@ -20,7 +28,7 @@ export default function PartItem(props: Props) {
...
@@ -20,7 +28,7 @@ export default function PartItem(props: Props) {
<
div
className=
{
styles
.
filterItemTitle
}
>
部件:
</
div
>
<
div
className=
{
styles
.
filterItemTitle
}
>
部件:
</
div
>
<
div
className=
{
styles
.
filterItemMain
}
>
<
div
className=
{
styles
.
filterItemMain
}
>
<
Space
size=
{
40
}
>
<
Space
size=
{
40
}
>
{
props
?.
data
?.
map
((
item
)
=>
{
{
data
?.
map
((
item
)
=>
{
return
(
return
(
<
Button
type=
"link"
key=
{
item
.
id
}
onClick=
{
(
e
)
=>
onClick
(
item
)
}
>
<
Button
type=
"link"
key=
{
item
.
id
}
onClick=
{
(
e
)
=>
onClick
(
item
)
}
>
{
item
.
name
}
{
item
.
name
}
...
...
components/filter/compoents/qualityItem/index.tsx
浏览文件 @
d7c6a6ef
import
{
Space
,
Button
,
Select
}
from
'antd'
;
import
{
Space
,
Button
,
Select
}
from
'antd'
;
import
styles
from
'../../index.module.scss'
;
import
styles
from
'../../index.module.scss'
;
import
{
FilterOptionResp
}
from
"../../api"
;
import
api
,
{
FilterOptionResp
}
from
"../../api"
;
import
{
useState
,
useEffect
}
from
'react'
;
type
Props
=
{
type
Props
=
{
data
:
Array
<
FilterOptionResp
>
;
onChange
:
(
id
:
FilterOptionResp
)
=>
void
;
onChange
:
(
id
:
FilterOptionResp
)
=>
void
;
};
};
export
default
function
QualityItem
(
props
:
Props
)
{
export
default
function
QualityItem
(
props
:
Props
)
{
const
[
data
,
setData
]
=
useState
<
FilterOptionResp
[]
>
([]);
useEffect
(()
=>
{
api
.
quality
().
then
((
res
)
=>
{
setData
(
res
?.
result
||
[]);
});
},
[]);
const
onClick
=
(
item
:
FilterOptionResp
)
=>
{
const
onClick
=
(
item
:
FilterOptionResp
)
=>
{
props
.
onChange
({
props
.
onChange
({
id
:
item
.
id
,
id
:
item
.
id
,
...
@@ -20,7 +28,7 @@ export default function QualityItem(props: Props) {
...
@@ -20,7 +28,7 @@ export default function QualityItem(props: Props) {
<
div
className=
{
styles
.
filterItemTitle
}
>
成色:
</
div
>
<
div
className=
{
styles
.
filterItemTitle
}
>
成色:
</
div
>
<
div
className=
{
styles
.
filterItemMain
}
>
<
div
className=
{
styles
.
filterItemMain
}
>
<
Space
size=
{
40
}
>
<
Space
size=
{
40
}
>
{
props
?.
data
?.
map
((
item
)
=>
{
{
data
?.
map
((
item
)
=>
{
return
(
return
(
<
Button
type=
"link"
key=
{
item
.
id
}
onClick=
{
(
e
)
=>
onClick
(
item
)
}
>
<
Button
type=
"link"
key=
{
item
.
id
}
onClick=
{
(
e
)
=>
onClick
(
item
)
}
>
{
item
.
name
}
{
item
.
name
}
...
...
components/filter/compoents/regionItem/index.tsx
浏览文件 @
d7c6a6ef
import
{
Space
,
Select
}
from
'antd'
;
import
{
Space
,
Select
}
from
'antd'
;
import
{
useEffect
,
useState
}
from
'react'
;
import
{
useEffect
,
useState
}
from
'react'
;
import
styles
from
'../../index.module.scss'
;
import
styles
from
'../../index.module.scss'
;
import
api
from
'../../api'
;
export
default
function
RegionItem
(){
export
default
function
RegionItem
(){
const
[
productList
,
setProductList
]
=
useState
(
Array
<
{}
>
);
const
[
productList
,
setProductList
]
=
useState
(
Array
<
{}
>
);
...
...
components/filter/index.tsx
浏览文件 @
d7c6a6ef
...
@@ -18,12 +18,6 @@ type itemType = "类目" | "地域" | "品牌" | "部件" | "型号" | "成色";
...
@@ -18,12 +18,6 @@ type itemType = "类目" | "地域" | "品牌" | "部件" | "型号" | "成色";
type
Props
=
{
type
Props
=
{
types
:
[
itemType
,
itemType
,
itemType
,
itemType
,
itemType
,
itemType
];
//需要包含的筛选条件项
types
:
[
itemType
,
itemType
,
itemType
,
itemType
,
itemType
,
itemType
];
//需要包含的筛选条件项
showResultItem
:
Boolean
;
//显示结果栏
showResultItem
:
Boolean
;
//显示结果栏
categoryData
?:
Array
<
FilterOptionResp
>
;
regionData
?:
Array
<
FilterOptionResp
>
;
brandData
?:
Array
<
FilterOptionResp
>
;
modelData
?:
Array
<
FilterOptionResp
>
;
partData
?:
Array
<
FilterOptionResp
>
;
qualityData
?:
Array
<
FilterOptionResp
>
;
onChange
:
(
filterResult
:
FilterResult
)
=>
void
;
//筛选条件更改事件
onChange
:
(
filterResult
:
FilterResult
)
=>
void
;
//筛选条件更改事件
};
};
export
default
function
Filter
(
props
:
Props
)
{
export
default
function
Filter
(
props
:
Props
)
{
...
@@ -59,31 +53,26 @@ export default function Filter(props: Props) {
...
@@ -59,31 +53,26 @@ export default function Filter(props: Props) {
<
div
className=
{
styles
.
filterWrap
}
>
<
div
className=
{
styles
.
filterWrap
}
>
{
props
.
types
.
includes
(
"品牌"
)
&&
(
{
props
.
types
.
includes
(
"品牌"
)
&&
(
<
BrandItem
<
BrandItem
data=
{
props
.
brandData
||
[]
}
onChange=
{
(
item
:
FilterOptionResp
)
=>
onChange
(
item
,
"brand"
)
}
onChange=
{
(
item
:
FilterOptionResp
)
=>
onChange
(
item
,
"brand"
)
}
></
BrandItem
>
></
BrandItem
>
)
}
)
}
{
props
.
types
.
includes
(
"类目"
)
&&
(
{
props
.
types
.
includes
(
"类目"
)
&&
(
<
CategoryItem
<
CategoryItem
data=
{
props
.
categoryData
||
[]
}
onChange=
{
(
item
:
FilterOptionResp
)
=>
onChange
(
item
,
"category"
)
}
onChange=
{
(
item
:
FilterOptionResp
)
=>
onChange
(
item
,
"category"
)
}
></
CategoryItem
>
></
CategoryItem
>
)
}
)
}
{
props
.
types
.
includes
(
"部件"
)
&&
(
{
props
.
types
.
includes
(
"部件"
)
&&
(
<
PartItem
<
PartItem
data=
{
props
.
partData
||
[]
}
onChange=
{
(
item
:
FilterOptionResp
)
=>
onChange
(
item
,
"part"
)
}
onChange=
{
(
item
:
FilterOptionResp
)
=>
onChange
(
item
,
"part"
)
}
></
PartItem
>
></
PartItem
>
)
}
)
}
{
props
.
types
.
includes
(
"型号"
)
&&
(
{
props
.
types
.
includes
(
"型号"
)
&&
(
<
ModelItem
<
ModelItem
data=
{
props
.
modelData
||
[]
}
onChange=
{
(
item
:
FilterOptionResp
)
=>
onChange
(
item
,
"model"
)
}
onChange=
{
(
item
:
FilterOptionResp
)
=>
onChange
(
item
,
"model"
)
}
></
ModelItem
>
></
ModelItem
>
)
}
)
}
{
props
.
types
.
includes
(
"成色"
)
&&
(
{
props
.
types
.
includes
(
"成色"
)
&&
(
<
QualityItem
<
QualityItem
data=
{
props
.
qualityData
||
[]
}
onChange=
{
(
item
:
FilterOptionResp
)
=>
onChange
(
item
,
"quality"
)
}
onChange=
{
(
item
:
FilterOptionResp
)
=>
onChange
(
item
,
"quality"
)
}
></
QualityItem
>
></
QualityItem
>
)
}
)
}
...
...
pages/mall/index.page.tsx
浏览文件 @
d7c6a6ef
...
@@ -9,32 +9,13 @@ import { FilterOptionResp, mallApi } from "~/components/filter/api";
...
@@ -9,32 +9,13 @@ import { FilterOptionResp, mallApi } from "~/components/filter/api";
// 此函数在构建时被调用
// 此函数在构建时被调用
export
async
function
getServerSideProps
()
{
export
async
function
getServerSideProps
()
{
//获取筛选数据,进行静态渲染
const
brand
=
Filter
.
mallApi
.
brand
();
const
category
=
Filter
.
mallApi
.
category
();
const
model
=
Filter
.
mallApi
.
model
();
const
part
=
Filter
.
mallApi
.
part
();
const
quality
=
Filter
.
mallApi
.
quality
();
const
res
=
await
Promise
.
all
([
brand
,
category
,
part
,
model
,
quality
]);
return
{
return
{
props
:
{
props
:
{
brandData
:
res
[
0
].
result
||
[],
categoryData
:
res
[
1
].
result
||
[],
partData
:
res
[
2
].
result
||
[],
modelData
:
res
[
3
].
result
||
[],
qualityData
:
res
[
4
].
result
||
[],
},
},
};
};
}
}
type
Props
=
{
type
Props
=
{
brandData
:
Array
<
FilterOptionResp
>
;
categoryData
:
Array
<
FilterOptionResp
>
;
partData
:
Array
<
FilterOptionResp
>
;
modelData
:
Array
<
FilterOptionResp
>
;
qualityData
:
Array
<
FilterOptionResp
>
;
};
};
export
default
function
Mall
(
props
:
Props
)
{
export
default
function
Mall
(
props
:
Props
)
{
...
@@ -49,11 +30,6 @@ export default function Mall(props: Props) {
...
@@ -49,11 +30,6 @@ export default function Mall(props: Props) {
<
Filter
<
Filter
types=
{
[
"类目"
,
"地域"
,
"品牌"
,
"部件"
,
"型号"
,
"成色"
]
}
types=
{
[
"类目"
,
"地域"
,
"品牌"
,
"部件"
,
"型号"
,
"成色"
]
}
showResultItem
showResultItem
brandData=
{
props
.
brandData
}
categoryData=
{
props
.
categoryData
}
partData=
{
props
.
partData
}
modelData=
{
props
.
modelData
}
qualityData=
{
props
.
qualityData
}
onChange=
{
onFilterChange
}
onChange=
{
onFilterChange
}
></
Filter
>
></
Filter
>
<
div
className=
{
styles
.
productList
}
>
<
div
className=
{
styles
.
productList
}
>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论