48455300
舒述军
零售任务自动调整
|
1
2
3
|
import React, { useState } from 'react';
import { Row, Modal, Table, Button, InputNumber, message } from 'antd';
import Column from 'antd/lib/table/Column';
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
4
|
import { ShopTaskList, ListItem } from '../api';
|
48455300
舒述军
零售任务自动调整
|
5
|
import { isNil } from 'lodash';
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
interface Props {
setVisible: any,
visible: boolean,
current: ShopTaskList,
index?: number,
setList: (value: any) => any,
list: ListItem,
setCurrent: (value: any) => any
isHandledit: boolean
}
export default function EModal({ setVisible, visible, current = {}, index, setList, list = {}, setCurrent, isHandledit }: Props) {
const [editable, setEditable] = useState<boolean>(false);
|
48455300
舒述军
零售任务自动调整
|
21
22
23
24
25
|
/**
* 修改零售任务
* @param e
* @param innerIndex
*/
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
26
27
|
function _onChange(e: number, innerIndex: number) {
//改变整体外层数据
|
48455300
舒述军
零售任务自动调整
|
28
29
30
31
32
33
34
35
36
|
const data = JSON.parse(JSON.stringify(list));
const currentData = JSON.parse(JSON.stringify(current));
if (!isNil(index) && e) {
data.shopTaskList![index].staffTaskList![innerIndex].taskCount = e;
data.shopTaskList![index].staffTaskList![innerIndex].clueDealTaskCount = Math.ceil((data.shopTaskList![index].clueDealTaskRate || 0)/100 *(e || 0));
currentData.staffTaskList![innerIndex].taskCount = e;
currentData.staffTaskList![innerIndex].clueDealTaskCount = Math.ceil((data.shopTaskList![index].clueDealTaskRate || 0)/100 *(e || 0));
}
setList({ ...data });
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
37
|
//回显改变数据
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
38
39
|
setCurrent({ ...currentData });
}
|
48455300
舒述军
零售任务自动调整
|
40
41
|
/**
|
308ed534
舒述军
零售任务手动调整
|
42
|
* 修改线索到店零售台数
|
48455300
舒述军
零售任务自动调整
|
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
* @param e
* @param innerIndex
*/
function hanldeChangeClue(e: number, innerIndex: number) {
//改变整体外层数据
const data = JSON.parse(JSON.stringify(list));
const currentData = JSON.parse(JSON.stringify(current));
if (!isNil(index) && data.shopTaskList![index].staffTaskList[innerIndex].taskCount < e) {
message.error("线索到店零售台数不能大于零售任务!");
return;
}
if (!isNil(index) && e) {
data.shopTaskList![index].staffTaskList![innerIndex].clueDealTaskCount = e;
currentData.staffTaskList![innerIndex].clueDealTaskCount = e;
}
setList({ ...data });
//回显改变数据
setCurrent({ ...currentData });
}
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
function handleClick() {
setVisible(false);
setEditable(false);
}
return (
<Modal
visible={visible}
onCancel={() => setVisible(false)}
maskClosable={false}
width={600}
footer={null}
>
<Table
style={{ marginTop: 20 }}
dataSource={current.staffTaskList}
rowKey="staffId"
pagination={false}
>
|
48455300
舒述军
零售任务自动调整
|
82
83
84
|
<Column
title="销售顾问"
align="center"
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
85
86
|
render={(value: any) => {
if (value.regularMonth) {
|
48455300
舒述军
零售任务自动调整
|
87
|
return <span>{value.staffName}(转正第{value.regularMonth}个月)</span>;
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
88
|
} else {
|
48455300
舒述军
零售任务自动调整
|
89
|
return <span>{value.staffName}</span>;
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
90
91
92
|
}
}}
/>
|
48455300
舒述军
零售任务自动调整
|
93
94
95
96
|
<Column
title="零售任务(台)"
dataIndex="taskCount"
align="center"
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
97
98
|
render={(value, record, index) => {
if (editable) {
|
48455300
舒述军
零售任务自动调整
|
99
|
return <InputNumber min={0} value={value} onChange={(e: any) => _onChange(e, index)} />;
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
100
|
} else {
|
48455300
舒述军
零售任务自动调整
|
101
|
return <span>{value}</span>;
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
102
103
104
|
}
}}
/>
|
48455300
舒述军
零售任务自动调整
|
105
106
107
108
109
110
|
<Column
title="线索到店零售台数"
dataIndex="clueDealTaskCount"
align="center"
render={(value, record, index) => <span>{value}</span>}
/>
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
111
112
|
</Table>
<Row justify="center" style={{ marginTop: 20 }}>
|
48455300
舒述军
零售任务自动调整
|
113
|
{isHandledit ? (
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
114
|
<>
|
48455300
舒述军
零售任务自动调整
|
115
116
117
118
|
<Button type="primary" style={{ marginRight: 15, width: 110 }} onClick={handleClick}>确定</Button>
<Button type="default" style={{ width: 110 }} onClick={() => setEditable(!editable)}>手动编辑</Button>
</>
) : null}
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
119
120
|
</Row>
</Modal>
|
48455300
舒述军
零售任务自动调整
|
121
|
);
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
122
|
}
|