Commit 75f10597dabfc743bc50f1c54dd29baec65efa22

Authored by Shinner
1 parent d8aedefd

回刷页面

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