Filter.tsx
1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import React, { useCallback } from "react";
import { Button, Row, Select } from "antd";
import { useStore } from "../index";
const { Option } = Select;
export default function Filter() {
const { setVisible, dealerList, setDealerId, dealerId, brandList, brandLoading, brandId, setBrandId } = useStore();
const searchDealer = useCallback((dealerId) => {
setDealerId(dealerId);
}, []);
const searchBrand = useCallback((brandId) => {
setBrandId(brandId);
}, []);
return (
<Row justify="space-between" style={{ marginBottom: 10 }}>
<Row justify="start">
<Select
placeholder="请选择商家"
showSearch
optionFilterProp="children"
onChange={searchDealer}
style={{ width: 200 }}
>
{dealerList.map((dealer) => (
<Option value={dealer.id} key={dealer.id}>
{dealer.name}
</Option>
))}
</Select>
<Select
placeholder="请选择品牌"
loading={brandLoading}
allowClear
optionFilterProp="children"
onChange={searchBrand}
value={brandId && brandId > 0 ? brandId : undefined}
style={{ width: 200,marginLeft:100 }}
>
{brandList.map((brand) => (
<Option value={brand.id} key={brand.id}>
{brand.name}
</Option>
))}
</Select>
</Row>
<Button type="primary" hidden={!dealerId} onClick={() => setVisible(true)}>
新增
</Button>
</Row>
);
}