Commit 38788314b678186c5ab70c9b15bc48f3b34e04ef
Merge branch 'order_buy_fee' into 'master'
Order buy fee See merge request !697
Showing
5 changed files
with
109 additions
and
56 deletions
src/pages/order3/BuyCarGift/api.ts
... | ... | @@ -56,6 +56,7 @@ export interface ListResult { |
56 | 56 | status?: number; // 状态 |
57 | 57 | giveFlower?: boolean; // 是否赠送鲜花 |
58 | 58 | approveNumber?: string; // 审批编号 |
59 | + giveFlowerScope?: number; // 鲜花赠送范围 | |
59 | 60 | } |
60 | 61 | |
61 | 62 | interface ShopVo { |
... | ... | @@ -87,6 +88,7 @@ export interface CouponResult { |
87 | 88 | validType?: number; // 优惠券有效类型 |
88 | 89 | disabled?: boolean; |
89 | 90 | relySchemeList?: number[]; // 限制类型 |
91 | + giveScope?: number; // 赠送范围 | |
90 | 92 | } |
91 | 93 | |
92 | 94 | export enum ShopLimit { | ... | ... |
src/pages/order3/BuyCarGift/components/AddModal.tsx
... | ... | @@ -6,6 +6,7 @@ import { saveBuyCarGiftApi, CouponResult, Cars, ShopLimit } from '../api'; |
6 | 6 | import moment from 'moment'; |
7 | 7 | import { PlusOutlined } from '@ant-design/icons'; |
8 | 8 | import { deleteConfigList } from '@/pages/coupon/CouponConfig/api'; |
9 | +import { GiveScop } from '../entity'; | |
9 | 10 | |
10 | 11 | interface Status { |
11 | 12 | loading: boolean; |
... | ... | @@ -34,7 +35,8 @@ export default function ApplyModal() { |
34 | 35 | applyCarType: currentData.applyCarType, |
35 | 36 | brand: { label: currentData.brandName, value: currentData.brandId }, |
36 | 37 | applyShops: currentData.applyShops?.map((v) => ({ label: v.shopName, value: v.shopId })), |
37 | - applySeriesList: currentData.applyCarType === 2 ? currentData.cars?.map(v => ({label: v.seriesName, value: v.seriesId})) : undefined | |
38 | + applySeriesList: currentData.applyCarType === 2 ? currentData.cars?.map((v) => ({ label: v.seriesName, value: v.seriesId })) : undefined, | |
39 | + giveFlowerScope: currentData.giveFlowerScope, | |
38 | 40 | }); |
39 | 41 | carSelectRef.current && carSelectRef.current?.setBrandId(currentData.brandId); |
40 | 42 | carSelectRef.current && carSelectRef.current?.getSpecList(currentData.brandId); |
... | ... | @@ -130,10 +132,8 @@ export default function ApplyModal() { |
130 | 132 | if (v.couponCode === record.couponCode) { |
131 | 133 | v.validType = value; |
132 | 134 | if (value === 1) { |
133 | - v.disabled = true; | |
135 | + // v.disabled = true; | |
134 | 136 | v.couponValidDays = 0; |
135 | - } else { | |
136 | - v.disabled = false; | |
137 | 137 | } |
138 | 138 | } |
139 | 139 | return { ...v }; |
... | ... | @@ -141,6 +141,17 @@ export default function ApplyModal() { |
141 | 141 | setCouponList(_newCouponList); |
142 | 142 | } |
143 | 143 | |
144 | + function onChangeGiveScop(value: number, record: any) { | |
145 | + const _couponList = JSON.parse(JSON.stringify(couponList)); | |
146 | + const _newCouponList = _couponList.map((v: CouponResult) => { | |
147 | + if (v.couponCode === record.couponCode) { | |
148 | + v.giveScope = value; | |
149 | + } | |
150 | + return { ...v }; | |
151 | + }); | |
152 | + setCouponList(_newCouponList); | |
153 | + } | |
154 | + | |
144 | 155 | const onFinsh = async () => { |
145 | 156 | const param = await form.validateFields(); |
146 | 157 | const _param: any = { |
... | ... | @@ -156,6 +167,7 @@ export default function ApplyModal() { |
156 | 167 | }), // 门店列表 |
157 | 168 | id: currentData.status === 15 ? null : currentData.id, |
158 | 169 | status: currentData.id && currentData.status !== 15 ? currentData.status : null, |
170 | + giveFlowerScope: param.giveFlower ? param.giveFlowerScope : null, | |
159 | 171 | }; |
160 | 172 | if (param.applyCarType === 2 && param.applySeriesList.length === 0) { |
161 | 173 | message.error('请选择适用车辆!'); |
... | ... | @@ -191,6 +203,7 @@ export default function ApplyModal() { |
191 | 203 | const nonType: CouponResult[] = []; |
192 | 204 | const nonCount: CouponResult[] = []; |
193 | 205 | const nonDays: CouponResult[] = []; |
206 | + const nonGiveScope: CouponResult[] = []; | |
194 | 207 | couponList.map((v: CouponResult) => { |
195 | 208 | if (!v.validType) { |
196 | 209 | nonType.push(v); |
... | ... | @@ -201,6 +214,9 @@ export default function ApplyModal() { |
201 | 214 | if (!v.couponValidDays && v.validType !== 1) { |
202 | 215 | nonDays.push(v); |
203 | 216 | } |
217 | + if (!v.giveScope) { | |
218 | + nonGiveScope.push(v); | |
219 | + } | |
204 | 220 | return v; |
205 | 221 | }); |
206 | 222 | if (nonType.length) { |
... | ... | @@ -212,6 +228,9 @@ export default function ApplyModal() { |
212 | 228 | } else if (nonDays.length) { |
213 | 229 | message.error(`${nonDays[0].aliasName}的有效类型不为[当天有效],需要设置有效期`); |
214 | 230 | return; |
231 | + } else if (nonGiveScope.length) { | |
232 | + message.error(`请设置${nonGiveScope[0].aliasName}的赠送范围`); | |
233 | + return; | |
215 | 234 | } else { |
216 | 235 | const giftItems = couponList.map((v: CouponResult) => { |
217 | 236 | return { |
... | ... | @@ -222,7 +241,8 @@ export default function ApplyModal() { |
222 | 241 | couponValidDays: v.couponValidDays || 0, |
223 | 242 | count: v.count, |
224 | 243 | validType: v.validType, |
225 | - relySchemeType: v.relySchemeList?.length ? v.relySchemeList[0] : 0 | |
244 | + relySchemeType: v.relySchemeList?.length ? v.relySchemeList[0] : 0, | |
245 | + giveScope: v.giveScope, | |
226 | 246 | }; |
227 | 247 | }); |
228 | 248 | _param.giftItems = giftItems; |
... | ... | @@ -291,15 +311,37 @@ export default function ApplyModal() { |
291 | 311 | </Select> |
292 | 312 | </Form.Item> |
293 | 313 | <Form.Item name="giveFlower" label="交车是否赠送鲜花" rules={[{ required: true, message: '请选择交车是否赠送鲜花!' }]}> |
294 | - <Radio.Group> | |
314 | + <Radio.Group onChange={() => form.setFieldValue('giveFlowerScope', undefined)}> | |
295 | 315 | <Radio value>赠送</Radio> |
296 | 316 | <Radio value={false}>不赠送</Radio> |
297 | 317 | </Radio.Group> |
298 | 318 | </Form.Item> |
319 | + <Form.Item | |
320 | + noStyle | |
321 | + shouldUpdate={(prevValues, currValues) => { | |
322 | + return prevValues.giveFlower !== currValues.giveFlower; | |
323 | + }} | |
324 | + > | |
325 | + {({ getFieldValue }) => { | |
326 | + const value = getFieldValue('giveFlower'); | |
327 | + if (!value) { | |
328 | + return; | |
329 | + } | |
330 | + return ( | |
331 | + <Form.Item name="giveFlowerScope" label="鲜花赠送范围" rules={[{ required: true, message: '请选择鲜花赠送范围!' }]}> | |
332 | + <Select placeholder="请选择" options={GiveScop} allowClear /> | |
333 | + </Form.Item> | |
334 | + ); | |
335 | + }} | |
336 | + </Form.Item> | |
299 | 337 | <Form.Item label="优惠券"> |
300 | 338 | <Card |
301 | 339 | style={{ display: 'block' }} |
302 | - title={<span style={{ fontSize: 14, color: '#666' }}>如有优惠券请在添加后填写优惠券有效期和数量和有效类型</span>} | |
340 | + title={ | |
341 | + <span style={{ fontSize: 14, color: '#666' }}> | |
342 | + 如有优惠券请在添加后填写<span style={{ color: '#ff0000' }}>优惠券赠送范围、有效期、数量和有效类型</span> | |
343 | + </span> | |
344 | + } | |
303 | 345 | extra={ |
304 | 346 | !status.readOnly && ( |
305 | 347 | <div |
... | ... | @@ -318,22 +360,32 @@ export default function ApplyModal() { |
318 | 360 | ) |
319 | 361 | } |
320 | 362 | > |
321 | - <Table bordered dataSource={couponList} style={{ width: '100%' }} rowKey={(record) => record.couponCode!}> | |
322 | - <Column title="优惠券类型" dataIndex="giftName" key="giftName" width="10%" /> | |
323 | - <Column title="优惠券别名" dataIndex="aliasName" key="aliasName" width="10%" render={(text: string) => <span>{text || '--'}</span>} /> | |
324 | - <Column title="金额" dataIndex="amount" key="amount" width="10%" /> | |
363 | + <Table scroll={{ x: 1200 }} bordered dataSource={couponList} style={{ width: '100%' }} rowKey={(record) => record.couponCode!}> | |
364 | + <Column title="优惠券类型" dataIndex="giftName" key="giftName" /> | |
365 | + <Column title="优惠券别名" dataIndex="aliasName" key="aliasName" render={(text: string) => <span>{text || '--'}</span>} /> | |
366 | + <Column title="金额" dataIndex="amount" key="amount" /> | |
325 | 367 | <Column |
326 | 368 | title="使用条件" |
327 | 369 | dataIndex="orgType" |
328 | 370 | key="orgType" |
329 | - width="10%" | |
371 | + // width="10%" | |
330 | 372 | render={(text: number) => <span>{text ? ShopLimit[text] : '--'}</span>} |
331 | 373 | /> |
332 | 374 | <Column |
375 | + title="赠送范围" | |
376 | + dataIndex="giveScope" | |
377 | + key="giveScope" | |
378 | + width={150} | |
379 | + // width="10%" | |
380 | + render={(text, record: any) => ( | |
381 | + <Select placeholder="请选择" options={GiveScop} value={record.giveScope} onChange={(value) => onChangeGiveScop(value, record)} /> | |
382 | + )} | |
383 | + /> | |
384 | + <Column | |
333 | 385 | title="有效类型" |
334 | 386 | dataIndex="validType" |
335 | 387 | key="validType" |
336 | - width="10%" | |
388 | + // width="10%" | |
337 | 389 | render={(text, record: any) => ( |
338 | 390 | <Select placeholder="请选择" value={record.validType} onChange={(value) => onChangeSelect(value, record)}> |
339 | 391 | <Option key="1_1" value={1}> |
... | ... | @@ -352,11 +404,11 @@ export default function ApplyModal() { |
352 | 404 | title="有效期" |
353 | 405 | dataIndex="couponValidDays" |
354 | 406 | key="couponValidDays" |
355 | - width="10%" | |
407 | + // width="10%" | |
356 | 408 | render={(text, record: any) => ( |
357 | 409 | <Input |
358 | 410 | value={record.couponValidDays} |
359 | - disabled={status.readOnly || record.disabled} | |
411 | + disabled={status.readOnly || (record.validType && record.validType === 1)} | |
360 | 412 | onChange={(value) => handleCoupon(record, value.target.value, 'couponValidDays')} |
361 | 413 | placeholder="请输入整数" |
362 | 414 | /> |
... | ... | @@ -366,7 +418,7 @@ export default function ApplyModal() { |
366 | 418 | title="数量" |
367 | 419 | dataIndex="count" |
368 | 420 | key="count" |
369 | - width="10%" | |
421 | + // width="10%" | |
370 | 422 | render={(text, record: any) => ( |
371 | 423 | <Input |
372 | 424 | value={record.count} |
... | ... | @@ -378,14 +430,14 @@ export default function ApplyModal() { |
378 | 430 | /> |
379 | 431 | <Column |
380 | 432 | title="操作" |
381 | - width="10%" | |
433 | + fixed="right" | |
382 | 434 | render={(text, record: ExternalPromotion.giftItems) => |
383 | 435 | status.readOnly ? ( |
384 | 436 | <Button type="link" onClick={() => setCoupon({ ...coupon, visible: true, confNo: record.couponCode! })}> |
385 | 437 | 查看 |
386 | 438 | </Button> |
387 | 439 | ) : ( |
388 | - <Space> | |
440 | + <Space size={0}> | |
389 | 441 | <Button |
390 | 442 | type="link" |
391 | 443 | disabled={status.readOnly} | ... | ... |
src/pages/order3/BuyCarGift/components/CouponModal.tsx
1 | 1 | import React from 'react'; |
2 | -import { Modal, Table, Button, Space } from 'antd'; | |
2 | +import { Modal, Table, Button } from 'antd'; | |
3 | 3 | import _ from "lodash"; |
4 | 4 | import {useStore} from '../index'; |
5 | -import {ValidTypeEnum } from '../entity'; | |
5 | +import {ValidTypeEnum, GiveScopEnum } from '../entity'; | |
6 | 6 | |
7 | 7 | const Column = Table.Column; |
8 | 8 | const ShowModal = () => { |
... | ... | @@ -14,58 +14,39 @@ const ShowModal = () => { |
14 | 14 | <Modal |
15 | 15 | destroyOnClose |
16 | 16 | forceRender |
17 | - visible={couponModal.visible} | |
17 | + open={couponModal.visible} | |
18 | 18 | title="优惠券" |
19 | 19 | maskClosable={false} |
20 | 20 | onCancel={handleCancel} |
21 | 21 | onOk={handleCancel} |
22 | - width="40%" | |
22 | + width="60%" | |
23 | 23 | > |
24 | - <Table | |
25 | - pagination={false} | |
26 | - bordered | |
27 | - dataSource={couponModal.data || []} | |
28 | - style={{width: '100%'}} | |
29 | - rowKey={(record) => record.couponCode!} | |
30 | - > | |
24 | + <Table pagination={false} bordered dataSource={couponModal.data || []} style={{ width: '100%' }} rowKey={(record) => record.couponCode!}> | |
25 | + <Column title="优惠券类型" dataIndex="giftName" key="giftType" /> | |
26 | + <Column title="优惠券别名" dataIndex="aliasName" key="orgType" render={(text: string) => <span>{text || '--'}</span>} /> | |
31 | 27 | <Column |
32 | - title="优惠券类型" | |
33 | - dataIndex="giftName" | |
34 | - key="giftType" | |
35 | - width="6%" | |
36 | - /> | |
37 | - <Column | |
38 | - title="优惠券别名" | |
39 | - dataIndex="aliasName" | |
40 | - key="orgType" | |
41 | - width="10%" | |
42 | - render={(text: string) => <span>{text || "--"}</span>} | |
28 | + title="赠送范围" | |
29 | + dataIndex="giveScope" | |
30 | + key="giveScope" | |
31 | + render={(text, record: any) => record.giveScope && GiveScopEnum[record.giveScope]} | |
43 | 32 | /> |
44 | 33 | <Column |
45 | 34 | title="有效类型" |
46 | 35 | dataIndex="validType" |
47 | 36 | key="validType" |
48 | - width="10%" | |
49 | 37 | render={(text, record: any) => record.validType && ValidTypeEnum[record.validType]} |
50 | 38 | /> |
51 | - <Column | |
52 | - title="有效期" | |
53 | - dataIndex="couponValidDays" | |
54 | - key="couponValidDays" | |
55 | - width="10%" | |
56 | - /> | |
57 | - <Column | |
58 | - title="数量" | |
59 | - dataIndex="count" | |
60 | - key="count" | |
61 | - width="10%" | |
62 | - /> | |
39 | + <Column title="有效期" dataIndex="couponValidDays" key="couponValidDays" /> | |
40 | + <Column title="数量" dataIndex="count" key="count" /> | |
63 | 41 | <Column |
64 | 42 | title="操作" |
65 | 43 | dataIndex="opeating" |
66 | 44 | key="opeating" |
67 | - width="10%" | |
68 | - render={(_text, record: any) => <Button type="link" onClick={() => setCoupon({...coupon, disabled: true, visible: true, confNo: record.couponCode})}>查看</Button>} | |
45 | + render={(_text, record: any) => ( | |
46 | + <Button type="link" onClick={() => setCoupon({ ...coupon, disabled: true, visible: true, confNo: record.couponCode })}> | |
47 | + 查看 | |
48 | + </Button> | |
49 | + )} | |
69 | 50 | /> |
70 | 51 | </Table> |
71 | 52 | </Modal> | ... | ... |
src/pages/order3/BuyCarGift/components/List.tsx
... | ... | @@ -2,7 +2,7 @@ import React, { useState } from "react"; |
2 | 2 | import { message, Popconfirm, Table, Tooltip, Space, Tag } from "antd"; |
3 | 3 | import moment from "moment"; |
4 | 4 | import {useStore} from '../index'; |
5 | -import { ApplyCarTypeEnum, BuyType } from '../entity'; | |
5 | +import { ApplyCarTypeEnum, BuyType, GiveScopEnum } from '../entity'; | |
6 | 6 | import { applyDisabledApi, fetchCancleApproveApi, fetchDeleteApi, ListResult } from '../api'; |
7 | 7 | import ApproveModal from '@/pages/stock/AdvanceProgress/components/ApproveModal'; |
8 | 8 | import * as entity from '@/pages/order3/Common/entity'; |
... | ... | @@ -205,6 +205,12 @@ export default function List() { |
205 | 205 | /> |
206 | 206 | <Column title="赠送鲜花" align="left" dataIndex="giveFlower" render={(_text, record: any) => (record.giveFlower === true ? '是' : '否')} /> |
207 | 207 | <Column |
208 | + title="赠送范围" | |
209 | + align="left" | |
210 | + dataIndex="giveFlowerScope" | |
211 | + render={(_text, record: any) => (_text && GiveScopEnum[_text] || '--')} | |
212 | + /> | |
213 | + <Column | |
208 | 214 | title="状态" |
209 | 215 | align="left" |
210 | 216 | dataIndex="status" | ... | ... |
src/pages/order3/BuyCarGift/entity.ts
... | ... | @@ -19,4 +19,16 @@ export enum ValidTypeEnum { |
19 | 19 | "当天有效" = 1, |
20 | 20 | "小时", |
21 | 21 | "天" |
22 | +} | |
23 | + | |
24 | +export const GiveScop = [ | |
25 | + { label: '商家自营车辆', value: 1 }, | |
26 | + { label: '厂家直营车', value: 2 }, | |
27 | + { label: '不限制', value: 3 }, | |
28 | +]; | |
29 | + | |
30 | +export enum GiveScopEnum { | |
31 | + "商家自营车辆" = 1, | |
32 | + "厂家直营车", | |
33 | + "不限制" | |
22 | 34 | } |
23 | 35 | \ No newline at end of file | ... | ... |