48455300
舒述军
零售任务自动调整
|
1
|
import React, { useState, useEffect, useRef } from 'react';
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
2
3
4
5
6
|
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { Card, Table, Button, Row, DatePicker, Col, InputNumber, message } from 'antd';
import { getRetailManualList, ListItem, autoAlloctionApi, ShopTaskList, save, saveParams } from './api';
import EModal from './component/Modal';
import moment from 'moment';
|
ac4dfc43
舒述军
零售任务精度调整
|
7
|
import currency from 'currency.js';
|
2ee855e8
舒述军
零售任务和攻坚车任务调整
|
8
|
import ApproveModal from '@/pages/order3/Common/ApproveModal';
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
const { Column } = Table;
const day = new Date();
const month = day.getMonth() + 1;
const year = day.getFullYear();
const strtime = year + '-' + month;
let newDate = new Date(strtime);
const newDay = newDate.getTime();
export default function TacklingCarModels() {
const [visible, setVisible] = useState<boolean>(false);
const [loading, setLoading] = useState<boolean>(false);
const [current, setCurrent] = useState<ShopTaskList>({});
const [confirmLoading, setConfirmLoading] = useState<boolean>(false);
const [saveLoading, setSaveLoading] = useState<boolean>(false);
const [date, setDate] = useState<number>(newDay);
const [edit, setEdit] = useState<boolean>(false);
const [list, setList] = useState<ListItem>({});
const [orginDara, setOrginDara] = useState<ListItem>({});
|
48455300
舒述军
零售任务自动调整
|
29
|
const index = useRef();
|
2ee855e8
舒述军
零售任务和攻坚车任务调整
|
30
|
const [approveOpen, setApproveOpen] = useState<boolean>(false);
|
48455300
舒述军
零售任务自动调整
|
31
|
// let index;
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
useEffect(() => {
getList(newDay);
}, []);
function setReset() {
setList({ ...orginDara });
setEdit(false);
}
//查询列表
function getList(date: number) {
const params = {
taskDate: date.valueOf(),
autoAssign: true,
};
getRetailManualList(params).then(res => {
setLoading(false);
const data = res.data;
setOrginDara(data || {});
setList(data || {});
|
89670995
舒述军
提示修改
|
53
|
// message.success(res.result);
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
54
55
56
57
58
59
|
}).catch(e => {
setLoading(false);
message.warning(e.message);
});
}
|
48455300
舒述军
零售任务自动调整
|
60
|
/**
|
c531dd20
曾柯
关于薪酬阶梯单位回显
|
61
|
* 修改零售任务数量
|
48455300
舒述军
零售任务自动调整
|
62
63
64
|
* @param e
* @param index
*/
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
65
|
function _onChange(e: number, index: number) {
|
48455300
舒述军
零售任务自动调整
|
66
|
const data = JSON.parse(JSON.stringify(list));
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
67
|
data.shopTaskList![index].taskCount = e;
|
ac4dfc43
舒述军
零售任务精度调整
|
68
69
|
data.shopTaskList![index].clueDealTaskCount = currency(e || 0).multiply(data.shopTaskList[index].clueDealTaskRate || 0).divide(100).value;
// data.shopTaskList![index].clueDealTaskCount = Math.ceil((e || 0)*((data.shopTaskList![index].clueDealTaskRate || 0)/100));
|
48455300
舒述军
零售任务自动调整
|
70
71
72
73
|
setList({ ...data });
}
/**
|
c531dd20
曾柯
关于薪酬阶梯单位回显
|
74
|
* 修改线索到店零售数量
|
48455300
舒述军
零售任务自动调整
|
75
76
77
78
79
80
|
* @param e
* @param index
*/
function handleChangeClue(e: number, index: number) {
const data = JSON.parse(JSON.stringify(list));
if (data.shopTaskList[index].taskCount < e) {
|
c531dd20
曾柯
关于薪酬阶梯单位回显
|
81
|
message.error("线索到店零售数量不能大于零售任务!");
|
48455300
舒述军
零售任务自动调整
|
82
83
84
|
return;
}
data.shopTaskList![index].clueDealTaskCount = e;
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
setList({ ...data });
}
function _ChangeMoth(date: any) {
setLoading(true);
setDate(date.valueOf());
getList(date);
}
//保存
function handleClick() {
setLoading(true);
const params = {
id: list.id,
shopTaskList: list.shopTaskList
};
autoAllocationSave(params);
}
|
48455300
舒述军
零售任务自动调整
|
102
|
|
2ee855e8
舒述军
零售任务和攻坚车任务调整
|
103
104
105
106
|
function handleOpenApprove() {
setApproveOpen(true);
}
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
107
|
//提交审批
|
2ee855e8
舒述军
零售任务和攻坚车任务调整
|
108
|
function saveClick(params?: any) {
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
109
110
|
setLoading(true);
setSaveLoading(true);
|
2ee855e8
舒述军
零售任务和攻坚车任务调整
|
111
|
save({...params, id: list.id}).then((res) => {
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
112
113
114
|
setSaveLoading(false);
setLoading(false);
setList({ ...list, canModified: false });
|
89670995
舒述军
提示修改
|
115
|
message.success(res.result);
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
116
117
118
119
120
121
|
}).catch(e => {
setLoading(false);
message.warning(e.message);
setSaveLoading(false);
});
}
|
48455300
舒述军
零售任务自动调整
|
122
|
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
123
124
125
126
|
//自动提交
function autoAllocationSave(params: saveParams) {
setConfirmLoading(true);
setEdit(true);
|
89670995
舒述军
提示修改
|
127
|
autoAlloctionApi(params).then((res) => {
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
128
129
130
|
setConfirmLoading(false);
getList(date);
setEdit(false);
|
89670995
舒述军
提示修改
|
131
|
message.success(res.result);
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
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
|
}).catch(e => {
message.warning(`${e.message}`);
setConfirmLoading(false);
setLoading(false);
});
}
return (
<PageHeaderWrapper title="零售任务">
<Card>
<Row style={{ marginTop: 20, marginBottom: 20 }}>
<Col span={4}><DatePicker defaultValue={moment(newDay)} picker="month" onChange={_ChangeMoth} /></Col>
</Row>
<Table
dataSource={list.shopTaskList}
loading={loading}
rowKey="shopId"
pagination={false}
summary={pageData => {
let total = 0;
pageData.forEach(({ taskCount }) => {
total += taskCount || 0;
});
return (
<>
{total == 0 ? null :
(
<Table.Summary.Row>
<Table.Summary.Cell index={1}><span style={{ display: 'block', textAlign: 'center' }}>合计</span></Table.Summary.Cell>
<Table.Summary.Cell index={2}>
<span style={{ display: 'block', textAlign: 'center' }}>{total}</span>
</Table.Summary.Cell>
<Table.Summary.Cell index={3} />
</Table.Summary.Row>
)}
</>
);
}}
>
|
48455300
舒述军
零售任务自动调整
|
171
172
173
174
175
|
<Column title="门店" dataIndex="shopName" align="center" />
<Column
title="零售任务(台)"
dataIndex="taskCount"
align="center"
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
176
177
178
179
180
181
182
183
|
render={(value, record, index) => {
if (edit) {
return <InputNumber min={0} value={value} onChange={(e: any) => _onChange(e, index)} />;
} else {
return <span>{value}</span>;
}
}}
/>
|
48455300
舒述军
零售任务自动调整
|
184
|
<Column
|
c531dd20
曾柯
关于薪酬阶梯单位回显
|
185
|
title="线索到店零售数量"
|
48455300
舒述军
零售任务自动调整
|
186
187
188
189
190
191
192
193
|
dataIndex="clueDealTaskCount"
align="center"
render={(value, record, index) => <span>{value}</span>}
/>
<Column
title="操作"
align="center"
render={(value, record, _index) => (
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
194
|
<>
|
48455300
舒述军
零售任务自动调整
|
195
|
<Button type="link" onClick={() => { setVisible(true); setCurrent(value); index.current = _index; }}>销售顾问任务</Button>
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
196
197
198
199
|
</>
)}
/>
</Table>
|
48455300
舒述军
零售任务自动调整
|
200
|
<EModal setVisible={setVisible} visible={visible} current={current} index={index.current} setList={setList} list={list} setCurrent={setCurrent} isHandledit={edit} />
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
201
202
203
204
205
206
|
<Row justify="center" style={{ marginTop: 15 }}>
{list.canModified ?
(
<>
{edit ?
<Button style={{ width: 110 }} type="primary" onClick={handleClick} loading={confirmLoading}>确定</Button> :
|
2ee855e8
舒述军
零售任务和攻坚车任务调整
|
207
|
<Button style={{ width: 110 }} type="primary" onClick={handleOpenApprove} loading={saveLoading}>提交审批</Button>}
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
208
|
{edit ? null :
|
48455300
舒述军
零售任务自动调整
|
209
|
<Button style={{ width: 110, marginLeft: 15, backgroundColor: '#FFF' }} onClick={() => setEdit(true)} type="default">自动调整</Button>}
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
210
211
|
{edit ?
<Button style={{ width: 110, marginLeft: 15 }} type="default" onClick={setReset} loading={confirmLoading}>取消</Button> :
|
48455300
舒述军
零售任务自动调整
|
212
|
null}
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
213
214
215
216
217
|
</>
)
: null}
</Row>
</Card>
|
2ee855e8
舒述军
零售任务和攻坚车任务调整
|
218
|
<ApproveModal callback={saveClick} open={approveOpen} setOpen={setApproveOpen} />
|
cc26d1fc
张志伟
🎉 重新构建项目,解决项目过大的问题
|
219
220
221
|
</PageHeaderWrapper>
);
}
|