Commit 308ed5345e321bf00e73c140e064dd1aeec78e60
1 parent
48455300
零售任务手动调整
Showing
4 changed files
with
99 additions
and
27 deletions
src/pages/order3/RetailManualAdjust/component/Modal.tsx
src/pages/order3/RetailTask/api.ts
... | ... | @@ -12,16 +12,19 @@ export interface ListItem { |
12 | 12 | } |
13 | 13 | |
14 | 14 | export interface ShopTaskList { |
15 | - shopId?: number,//门店id | |
16 | - shopName?: string,//门店名称 | |
17 | - taskCount?: number,//任务数量 | |
15 | + shopId?: number//门店id | |
16 | + shopName?: string//门店名称 | |
17 | + taskCount?: number//任务数量 | |
18 | + clueDealTaskCount?: number // 线索到店零售台数 | |
19 | + clueDealTaskRate?: number // 线索到店零售占比 | |
18 | 20 | staffTaskList?: StaffTaskList[]//员工任务列表 |
19 | 21 | } |
20 | 22 | |
21 | 23 | interface StaffTaskList { |
22 | - staffId?: number,//员工id | |
23 | - staffName?: string,//员工名称 | |
24 | - taskCount?: number,//任务数量 | |
24 | + staffId?: number//员工id | |
25 | + staffName?: string//员工名称 | |
26 | + taskCount?: number//任务数量 | |
27 | + clueDealTaskCount?: number // 线索到店零售台数 | |
25 | 28 | regularMonth?: number//转正几个月 |
26 | 29 | } |
27 | 30 | export interface saveParams { |
... | ... | @@ -44,5 +47,4 @@ export function saveHandelTack(params: saveParams) { |
44 | 47 | /*提交 */ |
45 | 48 | export function save(id?: number) { |
46 | 49 | return request.post(`${ORDER3}/erp/sales/task/submit`, { id }, { contentType: 'form-urlencoded' }); |
47 | -} | |
48 | - | |
50 | +} | |
49 | 51 | \ No newline at end of file | ... | ... |
src/pages/order3/RetailTask/component/Modal.tsx
1 | -import React, { useState } from 'react' | |
2 | -import { Row, Modal, Table, Button, InputNumber } from 'antd' | |
3 | -import Column from 'antd/lib/table/Column' | |
1 | +import React, { useState } from 'react'; | |
2 | +import { Row, Modal, Table, Button, InputNumber, message } from 'antd'; | |
3 | +import Column from 'antd/lib/table/Column'; | |
4 | 4 | import { ShopTaskList, ListItem } from '../api'; |
5 | +import { isNil } from 'lodash'; | |
5 | 6 | |
6 | 7 | interface Props { |
7 | 8 | setVisible: any, |
... | ... | @@ -19,14 +20,42 @@ export default function EModal({ setVisible, visible, current = {}, index, setLi |
19 | 20 | |
20 | 21 | function _onChange(e: number, innerIndex: number) { |
21 | 22 | //改变整体外层数据 |
22 | - const data = list; | |
23 | - index && e && (data.shopTaskList![index].staffTaskList![innerIndex].taskCount = e); | |
24 | - index && setList({ ...data }); | |
23 | + const data = JSON.parse(JSON.stringify(list)); | |
24 | + const currentData = JSON.parse(JSON.stringify(current)); | |
25 | + if (!isNil(index) && e) { | |
26 | + data.shopTaskList![index].staffTaskList![innerIndex].taskCount = e; | |
27 | + data.shopTaskList![index].staffTaskList![innerIndex].clueDealTaskCount = Math.ceil((data.shopTaskList![index].clueDealTaskRate || 0)/100 *(e || 0)); | |
28 | + currentData.staffTaskList![innerIndex].taskCount = e; | |
29 | + currentData.staffTaskList![innerIndex].clueDealTaskCount = Math.ceil((data.shopTaskList![index].clueDealTaskRate || 0)/100 *(e || 0)); | |
30 | + } | |
31 | + setList({ ...data }); | |
25 | 32 | //回显改变数据 |
26 | - const currentData = current; | |
27 | - currentData.staffTaskList![innerIndex].taskCount = e || 0; | |
28 | 33 | setCurrent({ ...currentData }); |
29 | 34 | } |
35 | + | |
36 | + /** | |
37 | + * 修改零售任务 | |
38 | + * @param e | |
39 | + * @param innerIndex | |
40 | + */ | |
41 | + function hanldeChangeClue(e: number, innerIndex: number) { | |
42 | + //改变整体外层数据 | |
43 | + const data = JSON.parse(JSON.stringify(list)); | |
44 | + const currentData = JSON.parse(JSON.stringify(current)); | |
45 | + if (!isNil(index) && data.shopTaskList![index].staffTaskList[innerIndex].taskCount < e) { | |
46 | + message.error("线索到店零售台数不能大于零售任务!"); | |
47 | + return; | |
48 | + } | |
49 | + if (!isNil(index) && e) { | |
50 | + console.log("====="); | |
51 | + data.shopTaskList![index].staffTaskList![innerIndex].clueDealTaskCount = e; | |
52 | + currentData.staffTaskList![innerIndex].clueDealTaskCount = e; | |
53 | + } | |
54 | + setList({ ...data }); | |
55 | + //回显改变数据 | |
56 | + setCurrent({ ...currentData }); | |
57 | + } | |
58 | + | |
30 | 59 | function handleClick() { |
31 | 60 | setVisible(false); |
32 | 61 | setEditable(false); |
... | ... | @@ -51,9 +80,9 @@ export default function EModal({ setVisible, visible, current = {}, index, setLi |
51 | 80 | align="center" |
52 | 81 | render={(value: any) => { |
53 | 82 | if (value.regularMonth) { |
54 | - return <span>{value.staffName}(转正第{value.regularMonth}个月)</span> | |
83 | + return <span>{value.staffName}(转正第{value.regularMonth}个月)</span>; | |
55 | 84 | } else { |
56 | - return <span>{value.staffName}</span> | |
85 | + return <span>{value.staffName}</span>; | |
57 | 86 | } |
58 | 87 | }} |
59 | 88 | /> |
... | ... | @@ -63,9 +92,21 @@ export default function EModal({ setVisible, visible, current = {}, index, setLi |
63 | 92 | align="center" |
64 | 93 | render={(value, record, index) => { |
65 | 94 | if (editable) { |
66 | - return <InputNumber min={0} value={value} onChange={(e: any) => _onChange(e, index)} /> | |
95 | + return <InputNumber min={0} value={value} onChange={(e: any) => _onChange(e, index)} />; | |
96 | + } else { | |
97 | + return <span>{value}</span>; | |
98 | + } | |
99 | + }} | |
100 | + /> | |
101 | + <Column | |
102 | + title="线索到店零售台数" | |
103 | + dataIndex="clueDealTaskCount" | |
104 | + align="center" | |
105 | + render={(value, record, index) => { | |
106 | + if (editable) { | |
107 | + return <InputNumber min={0} value={value} onChange={(e: any) => hanldeChangeClue(e, index)} />; | |
67 | 108 | } else { |
68 | - return <span>{value}</span> | |
109 | + return <span>{value}</span>; | |
69 | 110 | } |
70 | 111 | }} |
71 | 112 | /> |
... | ... | @@ -79,5 +120,5 @@ export default function EModal({ setVisible, visible, current = {}, index, setLi |
79 | 120 | ) : null} |
80 | 121 | </Row> |
81 | 122 | </Modal> |
82 | - ) | |
123 | + ); | |
83 | 124 | } |
84 | 125 | \ No newline at end of file | ... | ... |
src/pages/order3/RetailTask/index.tsx
1 | -import React, { useState, useEffect } from 'react'; | |
1 | +import React, { useState, useEffect, useRef } from 'react'; | |
2 | 2 | import { PageHeaderWrapper } from '@ant-design/pro-layout'; |
3 | 3 | import { Card, Table, Button, Row, DatePicker, Col, InputNumber, message } from 'antd'; |
4 | 4 | import { getRetailList, ListItem, saveHandelTack, ShopTaskList, save, saveParams } from './api'; |
... | ... | @@ -24,7 +24,7 @@ export default function TacklingCarModels() { |
24 | 24 | const [date, setDate] = useState<number>(newDay); |
25 | 25 | const [list, setList] = useState<ListItem>({}); |
26 | 26 | const [orginDara, setOrginDara] = useState<ListItem>({}); |
27 | - let index; | |
27 | + const index = useRef(0); | |
28 | 28 | |
29 | 29 | useEffect(() => { |
30 | 30 | getList(newDay); |
... | ... | @@ -57,9 +57,26 @@ export default function TacklingCarModels() { |
57 | 57 | setDate(date.valueOf()); |
58 | 58 | getList(date); |
59 | 59 | } |
60 | + | |
60 | 61 | function _onChange(e: number, index: number) { |
61 | - const data = list; | |
62 | + const data = JSON.parse(JSON.stringify(list)); | |
62 | 63 | data.shopTaskList![index].taskCount = e || 0; |
64 | + data.shopTaskList![index].clueDealTaskCount = Math.ceil((e || 0)*((data.shopTaskList![index].clueDealTaskRate || 0)/100)); | |
65 | + setList({ ...data }); | |
66 | + } | |
67 | + | |
68 | + /** | |
69 | + * 修改线索到店零售台数 | |
70 | + * @param e | |
71 | + * @param index | |
72 | + */ | |
73 | + function handleChangeClue(e: number, index: number) { | |
74 | + const data = JSON.parse(JSON.stringify(list)); | |
75 | + if (data.shopTaskList[index].taskCount < e) { | |
76 | + message.error("线索到店零售台数不能大于零售任务!"); | |
77 | + return; | |
78 | + } | |
79 | + data.shopTaskList![index].clueDealTaskCount = e; | |
63 | 80 | setList({ ...data }); |
64 | 81 | } |
65 | 82 | //保存 |
... | ... | @@ -148,16 +165,28 @@ export default function TacklingCarModels() { |
148 | 165 | }} |
149 | 166 | /> |
150 | 167 | <Column |
168 | + title="线索到店零售台数" | |
169 | + dataIndex="clueDealTaskCount" | |
170 | + align="center" | |
171 | + render={(value, record, index) => { | |
172 | + if (edit) { | |
173 | + return <InputNumber min={0} value={value} onChange={(e: any) => handleChangeClue(e, index)} />; | |
174 | + } else { | |
175 | + return <span>{value}</span>; | |
176 | + } | |
177 | + }} | |
178 | + /> | |
179 | + <Column | |
151 | 180 | title="操作" |
152 | 181 | align="center" |
153 | 182 | render={(value, record, _index) => ( |
154 | 183 | <> |
155 | - <Button type="link" onClick={() => { setVisible(true); setCurrent(value); index = _index; }}>销售顾问任务</Button> | |
184 | + <Button type="link" onClick={() => { setVisible(true); setCurrent(value); index.current = _index; }}>销售顾问任务</Button> | |
156 | 185 | </> |
157 | 186 | )} |
158 | 187 | /> |
159 | 188 | </Table> |
160 | - <EModal setVisible={setVisible} visible={visible} current={current} index={index} setList={setList} list={list} setCurrent={setCurrent} isHandledit={edit} /> | |
189 | + <EModal setVisible={setVisible} visible={visible} current={current} index={index.current} setList={setList} list={list} setCurrent={setCurrent} isHandledit={edit} /> | |
161 | 190 | <Row justify="center" style={{ marginTop: 15 }}> |
162 | 191 | {list.canModified ? ( |
163 | 192 | <> | ... | ... |