80a5e282
zhaolin
往来单位增加类型筛选
|
1
|
import React from "react";
|
da267386
zhaofeng
批量删除
|
2
|
import { Button, Col, Popconfirm, Row, Select, Input, message } from "antd";
|
80a5e282
zhaolin
往来单位增加类型筛选
|
3
4
5
|
import { useStore } from "../index";
import { CompanyCategoryTypeEnum } from "@/pages/finance/entitys";
import { debounce } from "lodash";
|
862b2d73
zhaofeng
往来单位关系设置
|
6
7
|
import { deleteCompanyRelationApi } from "@/pages/finance/CompanyRelationAuth/api";
import { history } from "umi";
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
8
9
10
11
12
|
const Search = Input.Search;
const { Option } = Select;
export default function Filter() {
|
80a5e282
zhaolin
往来单位增加类型筛选
|
13
14
15
16
|
const {
setVisible,
dealerList,
setCompanyParams,
|
80a5e282
zhaolin
往来单位增加类型筛选
|
17
18
19
|
dealerLoading,
disabled,
setDisabled,
|
80a5e282
zhaolin
往来单位增加类型筛选
|
20
21
22
|
setSelected,
companyList,
comBussinessList,
|
da267386
zhaofeng
批量删除
|
23
24
25
26
27
|
selectedRelation,
submitLoading,
setSubmitLoading,
companyParams,
setLoading,
|
80a5e282
zhaolin
往来单位增加类型筛选
|
28
|
} = useStore();
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
29
30
31
32
33
34
35
36
|
const searchDealer = (dealerId: number) => {
setCompanyParams({ ...companyParams, dealerId }, true);
};
function searchType(compCategory: number) {
setCompanyParams({ ...companyParams, compCategory }, true);
}
|
80a5e282
zhaolin
往来单位增加类型筛选
|
37
38
39
40
41
|
function searchCompanyType(companyType: number) {
setCompanyParams({ ...companyParams, companyType }, true);
}
const fetchListByName = debounce((value) => {
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
42
43
44
45
46
47
48
49
50
51
52
53
|
setCompanyParams({ ...companyParams, keywords: value }, true);
}, 500);
function onCancel() {
setDisabled(true);
setSelected([...companyList]);
}
function onEdit() {
setDisabled(false);
}
|
fd16749f
zhaofeng
往来单位关系设置
|
54
|
// 新增
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
55
|
function onAdd() {
|
862b2d73
zhaofeng
往来单位关系设置
|
56
|
history.push({ pathname: "/finance2/companyRelationAuth/create", state: companyParams });
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
57
|
}
|
da267386
zhaofeng
批量删除
|
58
59
60
61
62
63
|
/**
* @param compId
*/
async function onDelete() {
const compIdList = selectedRelation.map((item) => item.compId);
try {
|
862b2d73
zhaofeng
往来单位关系设置
|
64
|
const pa = { ...companyParams, compIdList };
|
da267386
zhaofeng
批量删除
|
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
setSubmitLoading(true);
const { success, result } = await deleteCompanyRelationApi(pa);
setSubmitLoading(false);
if (!success) {
return message.error(result);
} else {
message.success(result);
setLoading(true);
}
} catch (e) {
setSubmitLoading(false);
message.error(e.message);
}
}
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
80
81
|
return (
|
80a5e282
zhaolin
往来单位增加类型筛选
|
82
83
84
85
86
87
88
89
90
91
92
|
<div
style={{
display: "flex",
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
marginBottom: 20,
}}
>
<Row style={{ display: "flex", flex: 1 }}>
<Col span={9}>
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
93
94
95
96
97
98
99
100
|
<Select
placeholder="请选择商家"
showSearch
loading={dealerLoading}
disabled={!disabled}
optionFilterProp="children"
onChange={searchDealer}
value={companyParams.dealerId}
|
80a5e282
zhaolin
往来单位增加类型筛选
|
101
|
style={{ width: "80%" }}
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
102
|
>
|
80a5e282
zhaolin
往来单位增加类型筛选
|
103
104
105
106
|
{dealerList.map((dealer) => (
<Option value={dealer.id} key={dealer.id}>
{dealer.name}
</Option>
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
107
108
109
|
))}
</Select>
</Col>
|
80a5e282
zhaolin
往来单位增加类型筛选
|
110
|
<Col span={5}>
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
111
112
113
114
115
|
<Search
allowClear
disabled={!disabled}
placeholder="搜索单位名称"
onChange={(e) => fetchListByName(e.target.value || undefined)}
|
80a5e282
zhaolin
往来单位增加类型筛选
|
116
|
style={{ width: 200 }}
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
117
118
|
/>
</Col>
|
80a5e282
zhaolin
往来单位增加类型筛选
|
119
|
<Col span={3}>
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
120
121
122
123
124
125
126
|
<Select
placeholder="搜索单位类别"
disabled={!disabled}
onChange={searchType}
value={companyParams.compCategory}
style={{ width: 100 }}
>
|
80a5e282
zhaolin
往来单位增加类型筛选
|
127
128
129
130
131
132
133
134
135
136
137
138
139
|
{[1, 2].map((i) => (
<Option value={i} key={i}>
{CompanyCategoryTypeEnum[i]}
</Option>
))}
</Select>
</Col>
<Col>
<Select placeholder="搜索类型" disabled={!disabled} onChange={searchCompanyType} style={{ width: 150 }}>
{comBussinessList.map((item) => (
<Option key={item.id} value={item.id}>
{item.name}
</Option>
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
140
141
142
|
))}
</Select>
</Col>
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
143
|
</Row>
|
80a5e282
zhaolin
往来单位增加类型筛选
|
144
|
<div style={{ display: "flex", flexDirection: "row-reverse" }}>
|
38c0cdfa
zhaofeng
往来单位关系设置修改新增、删除
|
145
|
<Button type="primary" onClick={onAdd}>
|
80a5e282
zhaolin
往来单位增加类型筛选
|
146
147
|
新增
</Button>
|
da267386
zhaofeng
批量删除
|
148
149
|
<Popconfirm title="确定删除?" onConfirm={onDelete}>
|
862b2d73
zhaofeng
往来单位关系设置
|
150
|
<Button style={{ marginRight: 10 }} hidden={!selectedRelation.length} danger loading={submitLoading}>
|
da267386
zhaofeng
批量删除
|
151
152
153
|
删除
</Button>
</Popconfirm>
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
154
155
|
</div>
</div>
|
80a5e282
zhaolin
往来单位增加类型筛选
|
156
|
);
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
157
|
}
|