Commit d8aedefd2be8d36625f8f2e7a4515f8b4b7c58af

Authored by Shinner
1 parent 604e7e51

单个门店支持分配到门店和顾问

src/pages/order3/SaleTask/api.ts
... ... @@ -25,6 +25,7 @@ export interface GetSaleTaskApiRes {
25 25 testDriveTaskCount: number;
26 26 seriesTaskCount: number;
27 27 vehicleGrossProfitTask: number;
  28 + totalGrossProfitTask: number;
28 29 }
29 30  
30 31 export interface SeriesTaskItem {
... ... @@ -71,6 +72,8 @@ export interface ShopTaskItem {
71 72 seriesTaskCount: number;
72 73 vehicleGrossProfitTask: number;
73 74 taskId?: number;
  75 + orderTaskApplyId?: number;
  76 + orderShopTaskId?: number;
74 77 }
75 78  
76 79 /** 月度零售任务列表 */
... ... @@ -150,6 +153,13 @@ export function batchSetSaleTask(
150 153 return request.post(`${ORDER3_HOST}/erp/sales/task/batch/shop/set`, params);
151 154 }
152 155  
  156 +/** 自动分配单个门店的零售任务 */
  157 +export function autoAssignOneShop(
  158 + params: ShopTaskItem
  159 +): PromiseResp<boolean> {
  160 + return request.post(`${ORDER3_HOST}/erp/sales/task/auto/assign/shop`, params);
  161 +}
  162 +
153 163 export interface BrandItem {
154 164 id: number;
155 165 initial: string;
... ...
src/pages/order3/SaleTask/components/EntryTaskPreview.tsx
... ... @@ -189,6 +189,11 @@ const EntryTaskPreview = ({
189 189 onSearch={(v) => {
190 190 setParams({ keywords: v }, true);
191 191 }}
  192 + onBlur={(e) => {
  193 + if (e.target.value.trim() === "") {
  194 + setParams({ keywords: "" }, true);
  195 + }
  196 + }}
192 197 />
193 198 </Row>
194 199 <Card
... ...
src/pages/order3/SaleTask/components/SaleTaskBatchSet.tsx
... ... @@ -14,6 +14,7 @@ import React, { useState } from &quot;react&quot;;
14 14 import { MAX_NUM } from "../entity";
15 15 import * as API from "../api";
16 16 import ShopSelectNew from "@/components/ShopSelectNew";
  17 +import { isArray } from "lodash";
17 18  
18 19 interface SaleTaskBatchSetProps {
19 20 id: number;
... ... @@ -33,7 +34,11 @@ export default function SaleTaskBatchSet(props: SaleTaskBatchSetProps) {
33 34 const batchSetSaleTask = async (isAssignToAdviser: boolean) => {
34 35 await form.validateFields();
35 36 const values = form.getFieldsValue();
36   - if (Object.values(values).every((item) => !item)) {
  37 + if (
  38 + Object.values(values).every(
  39 + (item) => !item || (isArray(item) && item.length === 0)
  40 + )
  41 + ) {
37 42 message.warn("请设置任务后再进行分配");
38 43 return;
39 44 }
... ...
src/pages/order3/SaleTask/index.tsx
... ... @@ -354,6 +354,11 @@ function SaleTaskList() {
354 354 onSearch={(v) => {
355 355 setParams({ shopName: v }, true);
356 356 }}
  357 + onBlur={(e) => {
  358 + if (e.target.value.trim() === "") {
  359 + setParams({ shopName: "" }, true);
  360 + }
  361 + }}
357 362 />
358 363 </Row>
359 364 {!isReadOnly && (
... ... @@ -403,7 +408,9 @@ function SaleTaskList() {
403 408 {data.fuelVehicleTaskCount}
404 409 </Table.Summary.Cell>
405 410 <Table.Summary.Cell index={5}>-</Table.Summary.Cell>
406   - <Table.Summary.Cell index={6}>-</Table.Summary.Cell>
  411 + <Table.Summary.Cell index={6}>
  412 + {data.totalGrossProfitTask}
  413 + </Table.Summary.Cell>
407 414 <Table.Summary.Cell index={7}>
408 415 {data.clueDealTaskCount}
409 416 </Table.Summary.Cell>
... ...
src/pages/order3/SaleTask/subpages/TaskEdit/components/ShopTask.tsx
... ... @@ -8,6 +8,7 @@ import {
8 8 Button,
9 9 Row,
10 10 Tag,
  11 + Modal,
11 12 } from "antd";
12 13 import { PlusOutlined } from "@ant-design/icons";
13 14 import * as API from "../../../api";
... ... @@ -102,6 +103,41 @@ export default function ShopTask({ form }: ShopTaskProps) {
102 103 });
103 104 };
104 105  
  106 + // 分配到门店和顾问
  107 + const autoAssignOneShop = async () => {
  108 + await form.validateFields();
  109 + const values = form.getFieldsValue();
  110 + Modal.confirm({
  111 + title: (
  112 + <span>
  113 + 确认分配到
  114 + <span className="tip">全部门店和顾问</span>
  115 + 吗?
  116 + </span>
  117 + ),
  118 + zIndex: 1002,
  119 + onOk: async () => {
  120 + const hide = message.loading("分配中,请稍候", 0);
  121 + const { taskId, id, ...other } = shopTaskItem!;
  122 + API.autoAssignOneShop({
  123 + ...other,
  124 + ...values,
  125 + orderTaskApplyId: taskId,
  126 + orderShopTaskId: id,
  127 + })
  128 + .then((res) => {
  129 + message.success("分配成功");
  130 + })
  131 + .catch((error: any) => {
  132 + message.error(error.message ?? "请求失败");
  133 + })
  134 + .finally(() => {
  135 + hide();
  136 + });
  137 + },
  138 + });
  139 + };
  140 +
105 141 const layout = {
106 142 labelCol: { span: 5 },
107 143 wrapperCol: { span: 19 },
... ... @@ -405,6 +441,15 @@ export default function ShopTask({ form }: ShopTaskProps) {
405 441 保存草稿
406 442 </Button>
407 443 )}
  444 + {!isReadOnly && (
  445 + <Button
  446 + type="primary"
  447 + style={{ marginLeft: 10 }}
  448 + onClick={autoAssignOneShop}
  449 + >
  450 + 分配到门店和顾问
  451 + </Button>
  452 + )}
408 453 </Row>
409 454 <SeriesModal
410 455 visible={seriesVisible}
... ...