Commit 75f10597dabfc743bc50f1c54dd29baec65efa22

Authored by Shinner
1 parent d8aedefd

回刷页面

src/pages/order3/SaleTask/api.ts
@@ -84,8 +84,8 @@ export function getSaleTaskApi( @@ -84,8 +84,8 @@ export function getSaleTaskApi(
84 } 84 }
85 85
86 export interface GetShopSaleTaskReq { 86 export interface GetShopSaleTaskReq {
87 - shopId: number;  
88 - taskDate: number; 87 + shopId?: number;
  88 + taskDate?: number;
89 } 89 }
90 90
91 /** 门店零售任务详情 */ 91 /** 门店零售任务详情 */
src/pages/order3/SaleTask/components/EntryTaskPreview.tsx
@@ -40,6 +40,7 @@ const EntryTaskPreview = ({ @@ -40,6 +40,7 @@ const EntryTaskPreview = ({
40 showSeriesModal, 40 showSeriesModal,
41 }: EntryTaskPreviewProps) => { 41 }: EntryTaskPreviewProps) => {
42 const [type, setType] = useState(OrderTaskApprovalType.门店维度); 42 const [type, setType] = useState(OrderTaskApprovalType.门店维度);
  43 + const [keywords, setKeywords] = useState("");
43 44
44 const { data, loading, setParams } = useInitial< 45 const { data, loading, setParams } = useInitial<
45 API.PreviewTaskRes, 46 API.PreviewTaskRes,
@@ -57,7 +58,7 @@ const EntryTaskPreview = ({ @@ -57,7 +58,7 @@ const EntryTaskPreview = ({
57 return; 58 return;
58 } 59 }
59 setType(value); 60 setType(value);
60 - setParams({ orderTaskApprovalType: value }, true); 61 + setParams({ orderTaskApprovalType: value, keywords }, true);
61 }; 62 };
62 63
63 // 查看顾问任务 64 // 查看顾问任务
@@ -186,14 +187,11 @@ const EntryTaskPreview = ({ @@ -186,14 +187,11 @@ const EntryTaskPreview = ({
186 allowClear 187 allowClear
187 placeholder="搜索门店或顾问" 188 placeholder="搜索门店或顾问"
188 style={{ width: 263, marginLeft: 20 }} 189 style={{ width: 263, marginLeft: 20 }}
  190 + value={keywords}
  191 + onChange={(e) => setKeywords(e.target.value)}
189 onSearch={(v) => { 192 onSearch={(v) => {
190 setParams({ keywords: v }, true); 193 setParams({ keywords: v }, true);
191 }} 194 }}
192 - onBlur={(e) => {  
193 - if (e.target.value.trim() === "") {  
194 - setParams({ keywords: "" }, true);  
195 - }  
196 - }}  
197 /> 195 />
198 </Row> 196 </Row>
199 <Card 197 <Card
src/pages/order3/SaleTask/index.tsx
@@ -407,10 +407,10 @@ function SaleTaskList() { @@ -407,10 +407,10 @@ function SaleTaskList() {
407 <Table.Summary.Cell index={4}> 407 <Table.Summary.Cell index={4}>
408 {data.fuelVehicleTaskCount} 408 {data.fuelVehicleTaskCount}
409 </Table.Summary.Cell> 409 </Table.Summary.Cell>
410 - <Table.Summary.Cell index={5}>-</Table.Summary.Cell>  
411 - <Table.Summary.Cell index={6}> 410 + <Table.Summary.Cell index={5}>
412 {data.totalGrossProfitTask} 411 {data.totalGrossProfitTask}
413 </Table.Summary.Cell> 412 </Table.Summary.Cell>
  413 + <Table.Summary.Cell index={6}>-</Table.Summary.Cell>
414 <Table.Summary.Cell index={7}> 414 <Table.Summary.Cell index={7}>
415 {data.clueDealTaskCount} 415 {data.clueDealTaskCount}
416 </Table.Summary.Cell> 416 </Table.Summary.Cell>
src/pages/order3/SaleTask/subpages/TaskEdit/components/AdviserTask.tsx
@@ -13,9 +13,10 @@ interface AdviserTaskEditForm { @@ -13,9 +13,10 @@ interface AdviserTaskEditForm {
13 13
14 interface AdviserTaskProps { 14 interface AdviserTaskProps {
15 form: any; 15 form: any;
  16 + onRefresh: () => void;
16 } 17 }
17 18
18 -export default function AdviserTask({ form }: AdviserTaskProps) { 19 +export default function AdviserTask({ form, onRefresh }: AdviserTaskProps) {
19 const adviserTaskEditRef = useRef<AdviserTaskEditForm>(null); 20 const adviserTaskEditRef = useRef<AdviserTaskEditForm>(null);
20 const { 21 const {
21 shopTaskItem, 22 shopTaskItem,
@@ -47,6 +48,10 @@ export default function AdviserTask({ form }: AdviserTaskProps) { @@ -47,6 +48,10 @@ export default function AdviserTask({ form }: AdviserTaskProps) {
47 48
48 // 前端更新编辑后的顾问分配任务 49 // 前端更新编辑后的顾问分配任务
49 const onOk = () => { 50 const onOk = () => {
  51 + if (isReadOnly) {
  52 + setVisible(false);
  53 + return;
  54 + }
50 adviserTaskEditRef.current?.submit((newTask) => { 55 adviserTaskEditRef.current?.submit((newTask) => {
51 setShopTaskItem(newTask); 56 setShopTaskItem(newTask);
52 setAdvisersFiltered(newTask?.staffTaskList); // 刷新列表 57 setAdvisersFiltered(newTask?.staffTaskList); // 刷新列表
@@ -65,6 +70,7 @@ export default function AdviserTask({ form }: AdviserTaskProps) { @@ -65,6 +70,7 @@ export default function AdviserTask({ form }: AdviserTaskProps) {
65 .run({ ...other, id: taskId, ...shopFormValue }) 70 .run({ ...other, id: taskId, ...shopFormValue })
66 .then(() => { 71 .then(() => {
67 message.success("保存草稿成功"); 72 message.success("保存草稿成功");
  73 + onRefresh();
68 }) 74 })
69 .catch((error: any) => { 75 .catch((error: any) => {
70 message.error(error.message ?? "请求失败"); 76 message.error(error.message ?? "请求失败");
@@ -137,9 +143,6 @@ export default function AdviserTask({ form }: AdviserTaskProps) { @@ -137,9 +143,6 @@ export default function AdviserTask({ form }: AdviserTaskProps) {
137 width: 100, 143 width: 100,
138 dataIndex: "seriesTaskCount", 144 dataIndex: "seriesTaskCount",
139 }, 145 },
140 - ];  
141 -  
142 - const extraColumns: ColumnsType<API.StaffTaskItem> = [  
143 { 146 {
144 title: "操作", 147 title: "操作",
145 render: (text: string, record: API.StaffTaskItem) => { 148 render: (text: string, record: API.StaffTaskItem) => {
@@ -150,7 +153,7 @@ export default function AdviserTask({ form }: AdviserTaskProps) { @@ -150,7 +153,7 @@ export default function AdviserTask({ form }: AdviserTaskProps) {
150 setVisible(true); 153 setVisible(true);
151 }} 154 }}
152 > 155 >
153 - 编辑 156 + {isReadOnly ? "查看" : "编辑"}
154 </a> 157 </a>
155 ); 158 );
156 }, 159 },
@@ -173,7 +176,7 @@ export default function AdviserTask({ form }: AdviserTaskProps) { @@ -173,7 +176,7 @@ export default function AdviserTask({ form }: AdviserTaskProps) {
173 </Row> 176 </Row>
174 <Table 177 <Table
175 bordered 178 bordered
176 - columns={isReadOnly ? columns : columns.concat(extraColumns)} 179 + columns={columns}
177 dataSource={[...advisersFiltered]} 180 dataSource={[...advisersFiltered]}
178 pagination={false} 181 pagination={false}
179 rowKey="id" 182 rowKey="id"
src/pages/order3/SaleTask/subpages/TaskEdit/components/AdviserTaskEdit.tsx
@@ -124,6 +124,7 @@ function AdviserTaskEdit(props: AdviserTaskEditProps, ref: any) { @@ -124,6 +124,7 @@ function AdviserTaskEdit(props: AdviserTaskEditProps, ref: any) {
124 form={form} 124 form={form}
125 initialValues={editAdviser} 125 initialValues={editAdviser}
126 onFinish={onFinish} 126 onFinish={onFinish}
  127 + disabled={isReadOnly}
127 > 128 >
128 <Form.Item name="taskCount" label="零售任务:" required> 129 <Form.Item name="taskCount" label="零售任务:" required>
129 <InputNumber 130 <InputNumber
@@ -132,7 +133,6 @@ function AdviserTaskEdit(props: AdviserTaskEditProps, ref: any) { @@ -132,7 +133,6 @@ function AdviserTaskEdit(props: AdviserTaskEditProps, ref: any) {
132 min={0} 133 min={0}
133 max={MAX_NUM} 134 max={MAX_NUM}
134 style={{ width: "100%" }} 135 style={{ width: "100%" }}
135 - disabled={isReadOnly}  
136 precision={0} 136 precision={0}
137 /> 137 />
138 </Form.Item> 138 </Form.Item>
@@ -164,7 +164,6 @@ function AdviserTaskEdit(props: AdviserTaskEditProps, ref: any) { @@ -164,7 +164,6 @@ function AdviserTaskEdit(props: AdviserTaskEditProps, ref: any) {
164 min={0} 164 min={0}
165 max={MAX_NUM} 165 max={MAX_NUM}
166 style={{ width: "100%" }} 166 style={{ width: "100%" }}
167 - disabled={isReadOnly}  
168 precision={2} 167 precision={2}
169 /> 168 />
170 </Form.Item> 169 </Form.Item>
@@ -204,7 +203,6 @@ function AdviserTaskEdit(props: AdviserTaskEditProps, ref: any) { @@ -204,7 +203,6 @@ function AdviserTaskEdit(props: AdviserTaskEditProps, ref: any) {
204 min={0} 203 min={0}
205 max={MAX_NUM} 204 max={MAX_NUM}
206 style={{ width: "100%" }} 205 style={{ width: "100%" }}
207 - disabled={isReadOnly}  
208 precision={0} 206 precision={0}
209 /> 207 />
210 </Form.Item> 208 </Form.Item>
@@ -237,7 +235,6 @@ function AdviserTaskEdit(props: AdviserTaskEditProps, ref: any) { @@ -237,7 +235,6 @@ function AdviserTaskEdit(props: AdviserTaskEditProps, ref: any) {
237 min={0} 235 min={0}
238 max={MAX_NUM} 236 max={MAX_NUM}
239 style={{ width: "100%" }} 237 style={{ width: "100%" }}
240 - disabled={isReadOnly}  
241 precision={0} 238 precision={0}
242 /> 239 />
243 </Form.Item> 240 </Form.Item>
@@ -252,7 +249,6 @@ function AdviserTaskEdit(props: AdviserTaskEditProps, ref: any) { @@ -252,7 +249,6 @@ function AdviserTaskEdit(props: AdviserTaskEditProps, ref: any) {
252 min={0} 249 min={0}
253 max={MAX_NUM} 250 max={MAX_NUM}
254 style={{ width: "100%" }} 251 style={{ width: "100%" }}
255 - disabled={isReadOnly}  
256 precision={2} 252 precision={2}
257 /> 253 />
258 </Form.Item> 254 </Form.Item>
@@ -267,7 +263,6 @@ function AdviserTaskEdit(props: AdviserTaskEditProps, ref: any) { @@ -267,7 +263,6 @@ function AdviserTaskEdit(props: AdviserTaskEditProps, ref: any) {
267 min={0} 263 min={0}
268 max={MAX_NUM} 264 max={MAX_NUM}
269 style={{ width: "100%" }} 265 style={{ width: "100%" }}
270 - disabled={isReadOnly}  
271 precision={0} 266 precision={0}
272 /> 267 />
273 </Form.Item> 268 </Form.Item>
@@ -278,7 +273,6 @@ function AdviserTaskEdit(props: AdviserTaskEditProps, ref: any) { @@ -278,7 +273,6 @@ function AdviserTaskEdit(props: AdviserTaskEditProps, ref: any) {
278 min={0} 273 min={0}
279 max={MAX_NUM} 274 max={MAX_NUM}
280 style={{ width: "100%" }} 275 style={{ width: "100%" }}
281 - disabled={isReadOnly}  
282 precision={0} 276 precision={0}
283 /> 277 />
284 </Form.Item> 278 </Form.Item>
src/pages/order3/SaleTask/subpages/TaskEdit/components/ShopTask.tsx
@@ -19,14 +19,16 @@ import EditableCell from &quot;./EditableCell&quot;; @@ -19,14 +19,16 @@ import EditableCell from &quot;./EditableCell&quot;;
19 import SeriesModal from "./SeriesModal"; 19 import SeriesModal from "./SeriesModal";
20 import { history, useRequest } from "umi"; 20 import { history, useRequest } from "umi";
21 import { MAX_NUM } from "../../../entity"; 21 import { MAX_NUM } from "../../../entity";
  22 +import "../../../components/index.less";
22 23
23 const { Column } = Table; 24 const { Column } = Table;
24 25
25 interface ShopTaskProps { 26 interface ShopTaskProps {
26 form: any; 27 form: any;
  28 + onRefresh: () => void;
27 } 29 }
28 30
29 -export default function ShopTask({ form }: ShopTaskProps) { 31 +export default function ShopTask({ form, onRefresh }: ShopTaskProps) {
30 const { 32 const {
31 shopTaskItem, 33 shopTaskItem,
32 isReadOnly, 34 isReadOnly,
@@ -97,6 +99,7 @@ export default function ShopTask({ form }: ShopTaskProps) { @@ -97,6 +99,7 @@ export default function ShopTask({ form }: ShopTaskProps) {
97 .run({ ...other, ...values, id: taskId }) 99 .run({ ...other, ...values, id: taskId })
98 .then(() => { 100 .then(() => {
99 message.success("保存草稿成功"); 101 message.success("保存草稿成功");
  102 + onRefresh();
100 }) 103 })
101 .catch((error: any) => { 104 .catch((error: any) => {
102 message.error(error.message ?? "请求失败"); 105 message.error(error.message ?? "请求失败");
@@ -111,7 +114,7 @@ export default function ShopTask({ form }: ShopTaskProps) { @@ -111,7 +114,7 @@ export default function ShopTask({ form }: ShopTaskProps) {
111 title: ( 114 title: (
112 <span> 115 <span>
113 确认分配到 116 确认分配到
114 - <span className="tip">全部门店和顾问</span> 117 + <span className="tip">门店和顾问</span>
115 吗? 118 吗?
116 </span> 119 </span>
117 ), 120 ),
@@ -127,6 +130,7 @@ export default function ShopTask({ form }: ShopTaskProps) { @@ -127,6 +130,7 @@ export default function ShopTask({ form }: ShopTaskProps) {
127 }) 130 })
128 .then((res) => { 131 .then((res) => {
129 message.success("分配成功"); 132 message.success("分配成功");
  133 + onRefresh();
130 }) 134 })
131 .catch((error: any) => { 135 .catch((error: any) => {
132 message.error(error.message ?? "请求失败"); 136 message.error(error.message ?? "请求失败");
@@ -157,6 +161,7 @@ export default function ShopTask({ form }: ShopTaskProps) { @@ -157,6 +161,7 @@ export default function ShopTask({ form }: ShopTaskProps) {
157 labelAlign="left" 161 labelAlign="left"
158 form={form} 162 form={form}
159 initialValues={shopTaskItem!} 163 initialValues={shopTaskItem!}
  164 + disabled={isReadOnly}
160 > 165 >
161 <Form.Item name="taskCount" label="零售任务:" required> 166 <Form.Item name="taskCount" label="零售任务:" required>
162 <InputNumber 167 <InputNumber
@@ -165,7 +170,6 @@ export default function ShopTask({ form }: ShopTaskProps) { @@ -165,7 +170,6 @@ export default function ShopTask({ form }: ShopTaskProps) {
165 min={0} 170 min={0}
166 max={MAX_NUM} 171 max={MAX_NUM}
167 style={{ width: "100%" }} 172 style={{ width: "100%" }}
168 - disabled={isReadOnly}  
169 precision={0} 173 precision={0}
170 /> 174 />
171 </Form.Item> 175 </Form.Item>
@@ -197,7 +201,6 @@ export default function ShopTask({ form }: ShopTaskProps) { @@ -197,7 +201,6 @@ export default function ShopTask({ form }: ShopTaskProps) {
197 min={0} 201 min={0}
198 max={MAX_NUM} 202 max={MAX_NUM}
199 style={{ width: "100%" }} 203 style={{ width: "100%" }}
200 - disabled={isReadOnly}  
201 precision={2} 204 precision={2}
202 /> 205 />
203 </Form.Item> 206 </Form.Item>
@@ -237,7 +240,6 @@ export default function ShopTask({ form }: ShopTaskProps) { @@ -237,7 +240,6 @@ export default function ShopTask({ form }: ShopTaskProps) {
237 min={0} 240 min={0}
238 max={MAX_NUM} 241 max={MAX_NUM}
239 style={{ width: "100%" }} 242 style={{ width: "100%" }}
240 - disabled={isReadOnly}  
241 precision={0} 243 precision={0}
242 /> 244 />
243 </Form.Item> 245 </Form.Item>
@@ -271,7 +273,6 @@ export default function ShopTask({ form }: ShopTaskProps) { @@ -271,7 +273,6 @@ export default function ShopTask({ form }: ShopTaskProps) {
271 min={0} 273 min={0}
272 max={MAX_NUM} 274 max={MAX_NUM}
273 style={{ width: "100%" }} 275 style={{ width: "100%" }}
274 - disabled={isReadOnly}  
275 precision={0} 276 precision={0}
276 /> 277 />
277 </Form.Item> 278 </Form.Item>
@@ -286,7 +287,6 @@ export default function ShopTask({ form }: ShopTaskProps) { @@ -286,7 +287,6 @@ export default function ShopTask({ form }: ShopTaskProps) {
286 min={0} 287 min={0}
287 max={MAX_NUM} 288 max={MAX_NUM}
288 style={{ width: "100%" }} 289 style={{ width: "100%" }}
289 - disabled={isReadOnly}  
290 precision={2} 290 precision={2}
291 /> 291 />
292 </Form.Item> 292 </Form.Item>
@@ -301,7 +301,6 @@ export default function ShopTask({ form }: ShopTaskProps) { @@ -301,7 +301,6 @@ export default function ShopTask({ form }: ShopTaskProps) {
301 min={0} 301 min={0}
302 max={MAX_NUM} 302 max={MAX_NUM}
303 style={{ width: "100%" }} 303 style={{ width: "100%" }}
304 - disabled={isReadOnly}  
305 precision={0} 304 precision={0}
306 /> 305 />
307 </Form.Item> 306 </Form.Item>
@@ -312,7 +311,6 @@ export default function ShopTask({ form }: ShopTaskProps) { @@ -312,7 +311,6 @@ export default function ShopTask({ form }: ShopTaskProps) {
312 min={0} 311 min={0}
313 max={MAX_NUM} 312 max={MAX_NUM}
314 style={{ width: "100%" }} 313 style={{ width: "100%" }}
315 - disabled={isReadOnly}  
316 precision={0} 314 precision={0}
317 /> 315 />
318 </Form.Item> 316 </Form.Item>
src/pages/order3/SaleTask/subpages/TaskEdit/index.tsx
@@ -26,14 +26,13 @@ function TaskEdit() { @@ -26,14 +26,13 @@ function TaskEdit() {
26 const [shopTaskForm] = Form.useForm(); 26 const [shopTaskForm] = Form.useForm();
27 27
28 // 获取门店零售任务详情 28 // 获取门店零售任务详情
29 - const { data } = useInitial<API.ShopTaskItem, API.GetShopSaleTaskReq>(  
30 - API.getShopSaleTask,  
31 - {} as API.ShopTaskItem,  
32 - {  
33 - shopId,  
34 - taskDate,  
35 - }  
36 - ); 29 + const { data, setParams } = useInitial<
  30 + API.ShopTaskItem,
  31 + API.GetShopSaleTaskReq
  32 + >(API.getShopSaleTask, {} as API.ShopTaskItem, {
  33 + shopId,
  34 + taskDate,
  35 + });
37 36
38 useEffect(() => { 37 useEffect(() => {
39 setShopTaskItem(data); 38 setShopTaskItem(data);
@@ -54,14 +53,20 @@ function TaskEdit() { @@ -54,14 +53,20 @@ function TaskEdit() {
54 label: `门店任务分配${readOnly ? "详情" : ""}`, 53 label: `门店任务分配${readOnly ? "详情" : ""}`,
55 key: "1", 54 key: "1",
56 children: !isEmpty(shopTaskItem) && ( 55 children: !isEmpty(shopTaskItem) && (
57 - <ShopTask form={shopTaskForm} /> 56 + <ShopTask
  57 + form={shopTaskForm}
  58 + onRefresh={() => setParams({}, true)}
  59 + />
58 ), 60 ),
59 }, 61 },
60 { 62 {
61 label: `销售顾问任务分配${readOnly ? "详情" : ""}`, 63 label: `销售顾问任务分配${readOnly ? "详情" : ""}`,
62 key: "2", 64 key: "2",
63 children: !isEmpty(shopTaskItem) && ( 65 children: !isEmpty(shopTaskItem) && (
64 - <AdviserTask form={shopTaskForm} /> 66 + <AdviserTask
  67 + form={shopTaskForm}
  68 + onRefresh={() => setParams({}, true)}
  69 + />
65 ), 70 ),
66 }, 71 },
67 ]} 72 ]}