WaitConfirmList.tsx
8.22 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
import React, { useEffect, useState } from "react";
import {
message,
Modal,
DatePicker,
Input,
Row,
Select,
Button,
Table,
} from "antd";
import { useStore } from "../index";
import _ from "lodash";
import {
AwardTypeEnum,
SupportTypeEnum,
SubjectTypeEnum,
} from "@/pages/stock/AllowanceConfirm/entity";
import usePagination from "@/hooks/usePagination";
import Dimission from "@/pages/cas/Dimission";
import {
getSupportCheckListApi,
getSupportWaitCheckListApi,
} from "@/pages/stock/AllowanceConfirm/EditComfirm/Manufacturer/api";
import moment from "moment";
interface Props {
visible: boolean;
awardType: number;
onCancel: () => void;
onFinish: () => void;
}
const { RangePicker } = DatePicker;
interface Search {
supportType?: number; //1启票 2实销
awardType?: number; //1正激励 2负激励
supportName?: string; //促销政策名称
rebateTimeBegin?: string; //折让兑现时间起
rebateTimeEnd?: string; //折让对象时间止
subjectType?: number;
}
export default function WaitConfirmList(props: Props) {
const { visible, onCancel, onFinish, awardType } = props;
const {
subsidyTypeList,
rebateId,
setVisible,
data,
setLoading: setDetailLoading,
currentItem,
setOrderId,
commonOrderList,
orderId,
detailVisible,
setDetailVisible,
commonComfirmApi,
setSubmitSelectedRowkeys,
commonWaitCheckList,
commonCheckList,
commonRemoveCheckList,
commonEnterCheckList,
} = useStore();
const { dimension } = currentItem;
const [comfrimloading, setComfirmLoading] = useState(false);
const [delay, setDelay] = useState(true);
const [checkDelay, setCheckDelay] = useState(true);
/**
* 存储待确认促销活动列表
*/
const [orderList, setOrderList] = useState<
FvmAllowance.SuportWaitCheckItems[]
>([]);
const [confirmOrderList, setConfirmOrderList] = useState([]);
/**
* 查询待确认促销活动列表 ==》搜索参数
*/
const [searchParams, setSearchParams] = useState<Search>({});
/** 选中行 */
const [selectedRowKeys, setSelectedRowkeys] = useState<React.Key[]>([]);
/**
* 查询待确认促销活动列表
*/
const {
list,
loading,
setParams,
paginationConfig,
setLoading,
innerParams,
} = usePagination<FvmAllowance.SuportWaitCheckItems>(
getSupportWaitCheckListApi,
{ rebateId },
{ delay }
);
useEffect(() => {
if (visible) {
fetchTableList();
}
}, [rebateId, visible]);
useEffect(() => {
if (list instanceof Array) {
setOrderList([...list]);
}
}, [list]);
const fetchTableList = (paramas: Search) => {
//查询待确认促销活动列表
if (rebateId) {
setParams(
{
rebateId,
...paramas,
},
true
);
setDelay(false);
}
};
const columns = [
{
title: "促销活动名称",
dataIndex: "supportName",
key: "supportName",
},
{
title: "附件",
dataIndex: "promotionFid",
key: "promotionFid",
render: (text: string) => (text ? (
<a
title="点击下载文档"
target="_blank"
rel="noreferrer"
href={`/api/file/show?fid=${text}`}
>
查看
</a>
) : (
"--"
)),
},
{
title: "支持类型",
dataIndex: "supportType",
key: "supportType",
render: (text: number) => text && SupportTypeEnum[text],
},
{
title: "激励类型",
dataIndex: "awardType",
key: "awardType",
render: (text: number) => text && AwardTypeEnum[text],
},
{
title: "考核类型",
dataIndex: "subjectType",
key: "subjectType",
render: (text: number) => text && SubjectTypeEnum[text],
},
{
title: "考核对象",
dataIndex: "subjectConfigName",
key: "subjectConfigName",
},
{
title: "折让时间",
dataIndex: " rebateTime",
key: " rebateTime",
render: (text: number) => moment(text).format("YYYY-MM-DD"),
},
{
title: "应折让金额(元)",
dataIndex: "rebateAmount",
key: "rebateAmount",
},
];
const onSelectChange = (
selectedRowKeys: React.Key[],
selectedRows: FvmAllowance.WaitCheckListItems[]
) => {
setSelectedRowkeys([...selectedRowKeys]);
};
const rowSelection = {
selectedRowKeys,
onChange: onSelectChange,
};
// 选中促销政策加入折让清单
const onAdd = async () => {
const { success, result } = await getSupportCheckListApi({
rebateId: Number(rebateId),
awardType,
// @ts-ignore;
promotionIds: selectedRowKeys,
});
if (!success) {
message.error(result, 5);
return;
}
onCancel && onCancel();
// 刷新厂家促销列表
onFinish && onFinish();
};
return (
<Modal
title="待确认促销活动列表"
visible={visible}
width="70%"
maskClosable={false}
confirmLoading={comfrimloading}
onCancel={() => onCancel && onCancel()}
onOk={() => onAdd()}
okText="加入"
>
<Row
justify="space-between"
align="middle"
style={{ marginBottom: 16, flexWrap: "wrap" }}
>
<div>
<span>促销政策名称:</span>
<Input
style={{ width: 200 }}
allowClear
placeholder="搜索促销政策名称"
onChange={(e) => setSearchParams({
...searchParams,
supportName: e.target.value || undefined,
})}
/>
</div>
<div>
{/* 支持类型 1启票支持 2实销支持 */}
<span style={{ marginLeft: 15 }}>支持类型:</span>
<Select
allowClear
style={{ width: 200, marginRight: 15 }}
placeholder="请选择支持类型"
onChange={(v) => setSearchParams({
...searchParams,
supportType: v ? Number(v) : undefined,
})}
>
{[1, 2].map((i) => (
<Select.Option value={i} key={i}>
{SupportTypeEnum[i]}
</Select.Option>
))}
</Select>
</div>
<div>
{/* 激励类型 1正激励 2负激励 */}
<span style={{ marginLeft: 15 }}>激励类型:</span>
<Select
allowClear
style={{ width: 200, marginRight: 15 }}
placeholder="请选择支持类型"
onChange={(v) => setSearchParams({
...searchParams,
awardType: v ? Number(v) : undefined,
})}
>
{[1, 2].map((i) => (
<Select.Option value={i} key={i}>
{AwardTypeEnum[i]}
</Select.Option>
))}
</Select>
</div>
<div>
{/* 考核类型 1同一投资主体 2单一商家*/}
<span style={{ marginLeft: 15 }}>支持类型:</span>
<Select
allowClear
style={{ width: 200, marginRight: 15 }}
placeholder="请选择支持类型"
onChange={(v) => setSearchParams({
...searchParams,
subjectType: v ? Number(v) : undefined,
})}
>
{[1, 2].map((i) => (
<Select.Option value={i} key={i}>
{SubjectTypeEnum[i]}
</Select.Option>
))}
</Select>
</div>
<div style={{ marginTop: 20 }}>
<span>下零售日期范围:</span>
<RangePicker
allowClear
format="YYYY-MM-DD"
onChange={(v) => setSearchParams({
...searchParams,
rebateTimeBegin: v && v[0] && v[0].valueOf(),
rebateTimeEnd: v && v[1] && v[1].valueOf(),
})}
/>
</div>
<Button
type="primary"
onClick={() => fetchTableList(searchParams)}
>
查询
</Button>
</Row>
<Table
loading={loading}
pagination={paginationConfig}
size="small"
rowKey="id"
scroll={{ y: 500 }}
dataSource={orderList}
columns={columns}
rowSelection={rowSelection}
/>
</Modal>
);
}