cd477b8c
曾柯
考评0213
|
1
2
3
4
5
|
import React, { useEffect, useState } from "react";
import { Modal, Form, Select, InputNumber, message, Input, Button, Radio } from "antd";
import { useStore } from "../index";
import _ from "lodash";
import Rule1 from "@/pages/performance/CompensateGroupConfig/components/Rule1";
|
0b59354a
曾柯
考评组设置1656
|
6
|
import { EvaGroupSetteing } from "@/pages/performance/EvaGroupSetting/interface";
|
cd477b8c
曾柯
考评0213
|
7
|
import SingleAmount from "@/pages/performance/CompensateGroupConfig/EditComfirm/components/SingleAmount";
|
5ac136b7
曾柯
考评组设置1620
|
8
|
import TotalAmountSal from "./TotalAmountSal";
|
cd477b8c
曾柯
考评0213
|
9
|
import FixedCommission from "@/pages/performance/CompensateGroupConfig/EditComfirm/components/FixedCommission";
|
5ac136b7
曾柯
考评组设置1620
|
10
11
|
import CommissionParamsSal from "./CommissionParamsSal";
import LadderParamsSal from "./LadderParamsSal";
|
4927eb1a
曾柯
考评组设置加列表及草稿
|
12
|
import RankModal from "./RankModal";
|
cd477b8c
曾柯
考评0213
|
13
|
import { Any } from "currency.js";
|
5ac136b7
曾柯
考评组设置1620
|
14
|
import CondsSal from "./CondsSal";
|
cd477b8c
曾柯
考评0213
|
15
16
17
18
19
20
|
const Option = Select.Option;
interface Props {
visible: boolean;
onCancel: Function;
onOk: (vales: any) => void;
|
0b59354a
曾柯
考评组设置1656
|
21
|
currentItem: EvaGroupSetteing.Rewards;
|
cd477b8c
曾柯
考评0213
|
22
23
24
|
indicatorsList?: any[];
postId?: number;
shopIds?: string;
|
5ac136b7
曾柯
考评组设置1620
|
25
|
scopeType: number;
|
cd477b8c
曾柯
考评0213
|
26
27
28
29
30
31
32
33
34
|
}
export default function CreateModal(props: Props) {
const [form] = Form.useForm();
const {
ladderParamAlias,
setLadderParamAlias,
commissionParamAlias,
setCommissionParamAlias,
|
5ac136b7
曾柯
考评组设置1620
|
35
|
preconditionAliasSal,
|
0b59354a
曾柯
考评组设置1656
|
36
|
setPreconditionAliasSal,
|
4927eb1a
曾柯
考评组设置加列表及草稿
|
37
38
|
calType,
setCalType,
|
cd477b8c
曾柯
考评0213
|
39
|
} = useStore();
|
5ac136b7
曾柯
考评组设置1620
|
40
|
const { visible, onCancel, onOk, currentItem, indicatorsList = [], postId, shopIds, scopeType } = props;
|
cd477b8c
曾柯
考评0213
|
41
42
43
|
// 是否为百分比
const [isPercent, setIsPercent] = useState<number>(0);
|
4927eb1a
曾柯
考评组设置加列表及草稿
|
44
|
|
cd477b8c
曾柯
考评0213
|
45
46
47
48
49
50
51
|
// 判断占比相加是否为100
const [isHundred, setIsHundred] = useState(false);
const [isHundredLadder, setIsHundredLadder] = useState(false);
// 显示前置条件
const [condsVisible, setCondsVisible] = useState(false);
const [id, setItemId] = useState<number>();
|
f2dd0995
曾柯
考评编辑bugfix
|
52
|
|
cd477b8c
曾柯
考评0213
|
53
54
55
56
|
useEffect(() => {
if (visible && currentItem.name) {
setLadderParamAlias(currentItem.ladderParamAlias);
setCommissionParamAlias(currentItem.commissionParamAlias);
|
0b59354a
曾柯
考评组设置1656
|
57
|
setPreconditionAliasSal(currentItem.preconditionAlias);
|
cd477b8c
曾柯
考评0213
|
58
59
|
//编辑时存储当前薪酬项目的计算方式
setCalType(currentItem.calMethod);
|
0b59354a
曾柯
考评组设置1656
|
60
61
62
|
// if (currentItem.settings[0].stairKeyDesc !== undefined && currentItem.calMethod === 4) {
// setFixData(currentItem.settings);
// }
|
cd477b8c
曾柯
考评0213
|
63
64
65
66
67
68
|
if (currentItem.conds && currentItem.conds.length > 0) {
setCondsVisible(true);
} else {
setCondsVisible(false);
}
form.setFieldsValue({
|
0b59354a
曾柯
考评组设置1656
|
69
|
...currentItem,
|
cd477b8c
曾柯
考评0213
|
70
71
72
73
74
75
76
|
});
}
if (!currentItem.name) {
setCondsVisible(false);
}
}, [visible]);
|
cd477b8c
曾柯
考评0213
|
77
78
|
// 保存Modal
function handSubmit(fieldsValue: any) {
|
4927eb1a
曾柯
考评组设置加列表及草稿
|
79
|
const pa: any = fieldsValue;
|
cd477b8c
曾柯
考评0213
|
80
81
82
83
84
85
86
87
88
89
90
91
92
|
// 校验标准分不能大于绩效分值
// if (id) {
// pa.id = id;
// } else {
// pa.id = pa.name;
// }
if (pa?.ladderParams && pa?.ladderParams.length > 0) {
pa.ladderParamAlias = ladderParamAlias;
}
if (pa?.commissionParams && pa?.commissionParams.length > 0) {
pa.commissionParamAlias = commissionParamAlias;
}
if (pa?.conds && pa?.conds.length > 0) {
|
5ac136b7
曾柯
考评组设置1620
|
93
|
pa.preconditionAlias = preconditionAliasSal;
|
cd477b8c
曾柯
考评0213
|
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
|
}
let hundred = 0;
let ladderHundred = 0;
//设置sort
if (pa?.commissionParams && pa?.commissionParams.length > 0) {
pa?.commissionParams.forEach((item: any, index: number) => {
Object.assign(item, { sort: index + 1 });
});
hundred = pa?.commissionParams.reduce((data: number, item: any) => {
return data + item.proportion;
}, 0);
}
if (pa?.ladderParams && pa?.ladderParams.length > 0) {
pa?.ladderParams.forEach((item: any, index: number) => {
Object.assign(item, { sort: index + 1 });
});
ladderHundred = pa?.ladderParams.reduce((data: number, item: any) => {
return data + item.proportion;
}, 0);
if (isPercent == 0) {
pa.laddersType = currentItem.laddersType;
} else {
pa.laddersType = isPercent;
}
}
if (!pa?.ladderParams || pa?.ladderParams.length === 0) {
pa.laddersType = 2;
}
if (pa?.conds) {
pa?.conds.forEach((item: any, index: number) => {
Object.assign(item, { sort: index + 1 });
});
}
if (pa?.ladderParams && pa?.ladderParams.length > 0 && pa?.commissionParams && pa?.commissionParams.length > 0) {
if (hundred === 100 && ladderHundred === 100) {
setIsHundred(false);
setIsHundredLadder(false);
onOk(pa);
console.log("100pa", pa);
onCancel && onCancel();
} else if (hundred === 100 && ladderHundred !== 100) {
setIsHundred(false);
setIsHundredLadder(true);
} else if (hundred !== 100 && ladderHundred === 100) {
setIsHundred(true);
setIsHundredLadder(false);
} else {
setIsHundred(true);
setIsHundredLadder(true);
}
} else if (!pa?.ladderParams && pa?.commissionParams && pa?.commissionParams.length > 0) {
if (hundred === 100) {
setIsHundred(false);
onOk(pa);
console.log("100pa", pa);
onCancel && onCancel();
} else {
setIsHundred(true);
}
} else if (pa?.ladderParams && pa?.commissionParams && pa?.commissionParams.length === 0) {
if (ladderHundred === 100) {
setIsHundredLadder(false);
onOk(pa);
console.log("100pa", pa);
onCancel && onCancel();
} else {
setIsHundredLadder(true);
}
} else if (pa?.ladderParams && pa?.commissionParams == undefined) {
if (ladderHundred === 100) {
setIsHundredLadder(false);
onOk(pa);
console.log("100pa", pa);
onCancel && onCancel();
} else {
setIsHundredLadder(true);
}
} else if (pa?.commissionParams == undefined) {
setIsHundred(false);
onOk(pa);
console.log("100pa", pa);
onCancel && onCancel();
} else if (pa?.commissionParams && pa?.commissionParams.length == 0) {
setIsHundred(false);
onOk(pa);
console.log("100pa", pa);
onCancel && onCancel();
}
}
|
cd477b8c
曾柯
考评0213
|
184
185
|
return (
<Modal
|
0b59354a
曾柯
考评组设置1656
|
186
|
title={`${currentItem.name ? "编辑" : "新增"}考评奖惩`}
|
cd477b8c
曾柯
考评0213
|
187
188
189
190
191
192
193
194
195
196
|
visible={visible}
maskClosable={false}
afterClose={() => {
form.resetFields();
onCancel();
}}
onCancel={() => onCancel()}
onOk={form.submit}
width={1200}
>
|
5ac136b7
曾柯
考评组设置1620
|
197
198
199
200
201
|
<Form
form={form}
labelCol={{ span: 4 }}
wrapperCol={{ span: 20 }}
onFinish={handSubmit}
|
a34f5d4b
曾柯
考评bugfix
|
202
203
204
|
initialValues={{
ladders: [{ lower: 0, money: 0, key: 0 }],
}}
|
5ac136b7
曾柯
考评组设置1620
|
205
|
>
|
0b59354a
曾柯
考评组设置1656
|
206
|
<Form.Item name="name" label="考评奖惩指标名称" rules={[{ required: true, message: "请输入指标名称" }]}>
|
cd477b8c
曾柯
考评0213
|
207
208
209
210
211
|
<Input placeholder="请输入指标名称" />
</Form.Item>
<Form.Item
noStyle
|
4927eb1a
曾柯
考评组设置加列表及草稿
|
212
|
shouldUpdate={(prevValues, currentValues) => prevValues.calMethod !== currentValues.calMethod}
|
cd477b8c
曾柯
考评0213
|
213
214
215
216
217
218
219
220
221
|
>
{({ getFieldValue }) => {
return (
<Form.Item name="calMethod" label="计算方式" rules={[{ required: true, message: "请选择计算方式" }]}>
<Select
placeholder="选择计算方式"
onChange={(value) => {
const _type = value;
setCalType(_type);
|
cd477b8c
曾柯
考评0213
|
222
223
224
|
}}
>
<Option value={1} key={1}>
|
0b59354a
曾柯
考评组设置1656
|
225
|
排名正负激励
|
cd477b8c
曾柯
考评0213
|
226
227
|
</Option>
<Option value={2} key={2}>
|
0b59354a
曾柯
考评组设置1656
|
228
|
固定值
|
cd477b8c
曾柯
考评0213
|
229
230
231
232
233
|
</Option>
<Option value={3} key={3}>
阶梯
</Option>
<Option value={4} key={4}>
|
0b59354a
曾柯
考评组设置1656
|
234
235
236
237
|
总金额占比
</Option>
<Option value={5} key={5}>
阶梯翻倍
|
cd477b8c
曾柯
考评0213
|
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
|
</Option>
</Select>
</Form.Item>
);
}}
</Form.Item>
<div style={{ marginLeft: 95, marginBottom: 20 }}>
<span>是否添加前置条件设置:</span>
<Radio.Group
onChange={(e) => {
setCondsVisible(e.target.value);
}}
value={condsVisible}
>
<Radio value>是</Radio>
<Radio value={false}>否</Radio>
</Radio.Group>
</div>
|
5ac136b7
曾柯
考评组设置1620
|
257
|
{condsVisible && (
|
cd477b8c
曾柯
考评0213
|
258
|
<Form.Item name="conds" label="前置条件">
|
5ac136b7
曾柯
考评组设置1620
|
259
|
<CondsSal postId={postId} shopIds={shopIds} setItemId={setItemId} scopeType={scopeType} />
|
cd477b8c
曾柯
考评0213
|
260
|
</Form.Item>
|
5ac136b7
曾柯
考评组设置1620
|
261
262
|
)}
<Form.Item
|
cd477b8c
曾柯
考评0213
|
263
264
265
266
267
|
noStyle
shouldUpdate={(prevValues, currentValues) => prevValues.calMethod !== currentValues.calMethod}
>
{({ getFieldValue }) => {
const caculateType = getFieldValue("calMethod");
|
a34f5d4b
曾柯
考评bugfix
|
268
|
if (caculateType !== 1) {
|
cd477b8c
曾柯
考评0213
|
269
270
271
272
273
274
275
|
return (
<>
<Form.Item
name="commissionParams"
label="提成指标"
rules={[{ required: caculateType == 2 || caculateType == 4, message: "请增加提成指标" }]}
>
|
5ac136b7
曾柯
考评组设置1620
|
276
|
<CommissionParamsSal
|
cd477b8c
曾柯
考评0213
|
277
278
279
280
|
postId={postId}
shopIds={shopIds}
setItemId={setItemId}
isHundred={isHundred}
|
5ac136b7
曾柯
考评组设置1620
|
281
|
scopeType={scopeType}
|
cd477b8c
曾柯
考评0213
|
282
283
284
285
286
287
288
289
|
/>
</Form.Item>
</>
);
} else {
return null;
}
}}
|
5ac136b7
曾柯
考评组设置1620
|
290
291
|
</Form.Item>
<Form.Item
|
cd477b8c
曾柯
考评0213
|
292
293
294
295
296
|
noStyle
shouldUpdate={(prevValues, currentValues) => prevValues.calMethod !== currentValues.calMethod}
>
{({ getFieldValue }) => {
const caculateType = getFieldValue("calMethod");
|
5ac136b7
曾柯
考评组设置1620
|
297
|
if (caculateType == 1) {
|
cd477b8c
曾柯
考评0213
|
298
|
return (
|
5ac136b7
曾柯
考评组设置1620
|
299
|
<>
|
a34f5d4b
曾柯
考评bugfix
|
300
301
302
303
304
305
306
307
308
309
310
311
312
|
<Form.Item
name="ladderParams"
label="台阶条件指标"
rules={[{ required: true, message: "请增加台阶条件指标" }]}
>
<LadderParamsSal
postId={postId}
shopIds={shopIds}
setItemId={setItemId}
isHundredLadder={isHundredLadder}
scopeType={scopeType}
/>
</Form.Item>
|
5ac136b7
曾柯
考评组设置1620
|
313
314
315
316
317
318
|
<Form.Item name="rankType" label="排名方式" rules={[{ required: true, message: "请选择排名方式" }]}>
<Radio.Group>
<Radio value={1}>按固定值 </Radio>
<Radio value={2}>按比例</Radio>
</Radio.Group>
</Form.Item>
|
27123514
曾柯
考评组排名倒数
|
319
320
321
322
323
324
|
{/* <Form.Item name="rankOrderType" label="排名顺序" rules={[{ required: true, message: "请选择排名顺序" }]}>
<Radio.Group>
<Radio value={1}>正数</Radio>
<Radio value={2}>倒数</Radio>
</Radio.Group>
</Form.Item> */}
|
5ac136b7
曾柯
考评组设置1620
|
325
|
<Form.Item
|
4927eb1a
曾柯
考评组设置加列表及草稿
|
326
327
|
noStyle
shouldUpdate={(prevValues, currentValues) => prevValues.rankType !== currentValues.rankType}
|
5ac136b7
曾柯
考评组设置1620
|
328
|
>
|
4927eb1a
曾柯
考评组设置加列表及草稿
|
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
|
{({ getFieldValue }) => {
const rankType = getFieldValue("rankType");
if (rankType == 1) {
setIsPercent(1);
} else {
setIsPercent(2);
}
return null;
}}
</Form.Item>
<Form.Item
noStyle
shouldUpdate={(prevValues, currentValues) => prevValues.rankType !== currentValues.rankType}
>
{({ getFieldValue }) => {
const rankType = getFieldValue("rankType");
|
5f3c3ca8
曾柯
pc考评bugfix
|
345
|
if (rankType == 1 && (!currentItem.ladders || currentItem.ladders.length == 0)) {
|
27123514
曾柯
考评组排名倒数
|
346
|
form.setFieldValue("ladders", [{ lower: 1, money: 0, key: 0, rankOrderType: 1 }]);
|
5f3c3ca8
曾柯
pc考评bugfix
|
347
348
349
|
} else if (rankType == 2 && (!currentItem.ladders || currentItem.ladders.length == 0)) {
form.setFieldValue("ladders", [{ lower: 0, money: 0, key: 0, rankOrderType: 1 }]);
} else if (!rankType && (!currentItem.ladders || currentItem.ladders.length == 0)) {
|
27123514
曾柯
考评组排名倒数
|
350
|
form.setFieldValue("ladders", [{ lower: 0, money: 0, key: 0, rankOrderType: 1 }]);
|
4927eb1a
曾柯
考评组设置加列表及草稿
|
351
|
}
|
5f3c3ca8
曾柯
pc考评bugfix
|
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
|
return (
<Form.Item
name="ladders"
label="排名设置"
rules={[{ required: true, message: "请配置排名" }]}
style={{ width: "100%" }}
>
<RankModal
visible
isPercent={isPercent}
laddersType={currentItem?.laddersType}
calType={calType}
rankType={rankType}
/>
</Form.Item>
);
|
4927eb1a
曾柯
考评组设置加列表及草稿
|
368
|
}}
|
5ac136b7
曾柯
考评组设置1620
|
369
|
</Form.Item>
|
5ac136b7
曾柯
考评组设置1620
|
370
|
</>
|
cd477b8c
曾柯
考评0213
|
371
|
);
|
5ac136b7
曾柯
考评组设置1620
|
372
|
} else if (caculateType == 2 || caculateType == 4) {
|
cd477b8c
曾柯
考评0213
|
373
|
return (
|
5ac136b7
曾柯
考评组设置1620
|
374
375
376
377
378
379
380
381
382
383
|
<>
<Form.Item
label="金额"
name="money"
rules={[{ required: true, message: "请输入金额" }]}
style={{ marginLeft: 0 }}
>
<InputNumber style={{ width: 960 }} addonAfter="元" />
</Form.Item>
</>
|
cd477b8c
曾柯
考评0213
|
384
|
);
|
5ac136b7
曾柯
考评组设置1620
|
385
|
} else if (caculateType == 3 || caculateType == 5) {
|
cd477b8c
曾柯
考评0213
|
386
387
388
389
390
391
392
|
return (
<>
<Form.Item
name="ladderParams"
label="台阶条件指标"
rules={[{ required: true, message: "请增加台阶条件指标" }]}
>
|
5ac136b7
曾柯
考评组设置1620
|
393
|
<LadderParamsSal
|
cd477b8c
曾柯
考评0213
|
394
395
396
397
|
postId={postId}
shopIds={shopIds}
setItemId={setItemId}
isHundredLadder={isHundredLadder}
|
5ac136b7
曾柯
考评组设置1620
|
398
|
scopeType={scopeType}
|
cd477b8c
曾柯
考评0213
|
399
400
401
402
403
|
/>
</Form.Item>
</>
);
}
|
cd477b8c
曾柯
考评0213
|
404
405
|
return null;
}}
|
5ac136b7
曾柯
考评组设置1620
|
406
407
408
|
</Form.Item>
<Form.Item
|
cd477b8c
曾柯
考评0213
|
409
410
411
412
413
|
noStyle
shouldUpdate={(prevValues, currentValues) => prevValues.ladderParams !== currentValues.ladderParams}
>
{({ getFieldValue }) => {
const ladderParams = getFieldValue("ladderParams");
|
4927eb1a
曾柯
考评组设置加列表及草稿
|
414
415
|
const calMethod = getFieldValue("calMethod");
if (ladderParams && ladderParams.length > 0 && (calMethod == 3 || calMethod == 5)) {
|
cd477b8c
曾柯
考评0213
|
416
417
418
419
420
421
422
423
424
425
426
427
428
429
|
console.log("ladderParams", ladderParams);
if (ladderParams.length > 1) {
setIsPercent(2);
} else if (ladderParams[0].targetValue) {
setIsPercent(2);
} else if (ladderParams[0].dataType === 2) {
setIsPercent(2);
} else if (ladderParams[0].dataType === 1 || ladderParams[0].dataType === 3) {
console.log("hasvdhjasvhdj");
setIsPercent(1);
}
}
return null;
}}
|
5ac136b7
曾柯
考评组设置1620
|
430
431
|
</Form.Item>
<Form.Item
|
cd477b8c
曾柯
考评0213
|
432
|
noStyle
|
4927eb1a
曾柯
考评组设置加列表及草稿
|
433
|
shouldUpdate={(prevValues, currentValues) => prevValues.calMethod !== currentValues.calMethod}
|
cd477b8c
曾柯
考评0213
|
434
435
436
|
>
{({ getFieldValue }) => {
const caculateType = getFieldValue("calMethod");
|
5f3c3ca8
曾柯
pc考评bugfix
|
437
|
// console.log(caculateType, currentItem);
|
cd477b8c
曾柯
考评0213
|
438
|
//阶梯(总)
|
4927eb1a
曾柯
考评组设置加列表及草稿
|
439
|
if (caculateType == 3 || caculateType == 5) {
|
5f3c3ca8
曾柯
pc考评bugfix
|
440
|
if (caculateType == 3 && (!currentItem.ladders || currentItem.ladders.length == 0)) {
|
4927eb1a
曾柯
考评组设置加列表及草稿
|
441
|
form.setFieldValue("ladders", [{ lower: 0, money: 0, key: 0 }]);
|
5f3c3ca8
曾柯
pc考评bugfix
|
442
|
} else if (caculateType == 5 && (!currentItem.ladders || currentItem.ladders.length == 0)) {
|
4927eb1a
曾柯
考评组设置加列表及草稿
|
443
444
|
form.setFieldValue("ladders", [{ lower: 0, money: 0, capMoney: 0, key: 0 }]);
}
|
a34f5d4b
曾柯
考评bugfix
|
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
|
return (
<>
<Form.Item
name="ladders"
label="阶梯条件"
rules={[{ required: true, message: "请配置阶梯" }]}
style={{ width: "100%" }}
>
<TotalAmountSal
visible
isPercent={isPercent}
laddersType={currentItem.laddersType}
calType={calType}
/>
</Form.Item>
</>
);
}
|
cd477b8c
曾柯
考评0213
|
463
464
|
return null;
}}
|
5ac136b7
曾柯
考评组设置1620
|
465
|
</Form.Item>
|
cd477b8c
曾柯
考评0213
|
466
467
468
469
|
</Form>
</Modal>
);
}
|