Filter.tsx
3.28 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import React from 'react';
import { Input } from 'antd';
import { useStore } from '../index';
import debounce from 'lodash/debounce';
import {getPartTypeApi} from '@/pages/pms/part/Repertory/api';
import useInitail from '@/hooks/useInitail';
import PmsSelect from '@/pages/pms/comonents/PmsSelect';
const { Search } = Input;
export default function Filter() {
const { shops, setParams, storages, innerParams } = useStore();
const { data: partTypeData } = useInitail(getPartTypeApi, [], {});
const handleChangeKeywords = debounce((value: string) => {
setParams({ current: 1, keyword: value }, true);
}, 500);
const isStock = (v:any) => {
if (v == undefined) {
setParams({current: 1, pageSize: 10, haveStock: undefined }, true);
return;
}
const param = Boolean(v);
setParams({current: 1, pageSize: 10, haveStock: param }, true);
};
const isSorter = (v:any) => {
setParams({current: 1, pageSize: 10, orderBy: v }, true);
};
return (
<div>
<Search
style={{ width: 180, marginRight: 10, marginBottom: 10 }}
allowClear
enterButton
placeholder="配件编码|名称"
onSearch={v => handleChangeKeywords(v)}
/>
<PmsSelect
style={{ width: 180, marginRight: 10, marginBottom: 10 }}
allowClear
value={innerParams.shopId}
onChange={value => {
const st: any = storages.find(it => it.shopId == value) || {};
setParams({ current: 1, shopId: value, storageId: st.id }, true);
}}
placeholder="请选择服务站"
options={shops
.filter(it => (innerParams.shopId && it.id == innerParams.shopId) || !innerParams.shopId)
.map((item: PmsStoragePartShop.Option) => ({value: item.id, label: item.name}))}
/>
<PmsSelect
style={{ width: 180, marginRight: 10, marginBottom: 10 }}
allowClear
value={innerParams.storageId}
onChange={value => {
const st: any = storages.find(it => it.id == value) || {};
setParams({ current: 1, storageId: value, shopId: st.shopId }, true);
}}
placeholder="请选择库房"
options={storages
.filter(it => (innerParams.shopId && it.shopId == innerParams.shopId) || !innerParams.shopId)
.map((item: PartStorageSpace.PageVO) => ({value: item.id, label: item.storageName}))}
/>
<PmsSelect
allowClear
style={{ width: 180, marginRight: 10, marginBottom: 10 }}
onChange={(type) => {
setParams({ ...innerParams, current: 1, type }, true);
}}
placeholder="请选择配件类型"
options={partTypeData.map((item: any) => ({value: item.value, label: item.label}))}
/>
<PmsSelect
allowClear
placeholder="有无库存筛选"
onChange={v => isStock(v)}
style={{ width: 180, marginRight: 10, marginBottom: 10 }}
options={[
{value: 1, label: "有库存"},
{value: 0, label: "无库存"},
]}
/>
<PmsSelect
placeholder="排序方式"
defaultValue={18}
onChange={v => isSorter(v)}
style={{ width: 180 }}
options={[
{value: 18, label: "总库存降序"},
{value: 21, label: "锁定库存降序"},
]}
/>
</div>
);
}