Commit 01093727 authored by XieZhiXiong's avatar XieZhiXiong

feat: 对接优惠券发券相关

parent 1c8c5039
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-06-29 09:36:35
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-06-29 10:18:11
* @LastEditTime: 2021-07-28 17:49:07
* @Description:
*/
import { ISchema } from '@formily/antd';
......@@ -31,7 +31,7 @@ export const querySchema: ISchema = {
'x-component': 'Search',
'x-component-props': {
placeholder: '搜索',
tip: '输入 优惠劵名称 进行搜索',
tip: '输入 会员名称 进行搜索',
},
},
},
......@@ -45,33 +45,48 @@ export const querySchema: ISchema = {
},
},
properties: {
id: {
memberId: {
type: 'string',
'x-component-props': {
placeholder: '优惠劵ID',
placeholder: '会员ID',
allowClear: true,
style: {
width: 160,
},
},
},
'[startTime2, endTime2]': {
type: 'object',
'x-component': 'RangePicker',
memberType: {
type: 'string',
default: undefined,
enum: [],
'x-component-props': {
placeholder: ['劵有效期起始时间', '劵有效期截止时间'],
showTime: true,
placeholder: '会员类型(所有)',
allowClear: true,
},
},
type: {
level: {
type: 'string',
default: undefined,
enum: [],
'x-component-props': {
placeholder: '优惠劵类型(所有)',
placeholder: '会员等级(所有)',
allowClear: true,
},
},
suitableMemberType: {
type: 'string',
default: undefined,
enum: [],
'x-component-props': {
placeholder: '适用用户(所有)',
allowClear: true,
},
},
'[startTime2, endTime2]': {
type: 'string',
'x-component': 'RangePicker',
'x-component-props': {
placeholder: ['成为会员起始时间', '成为会员截止时间'],
showTime: true,
},
},
submit: {
'x-component': 'Submit',
'x-mega-props': {
......@@ -105,17 +120,19 @@ export const drawerSchema: ISchema = {
'x-component': 'Mega-Layout',
'x-component-props': {
grid: true,
full: true,
autoRow: true,
columns: 4,
},
properties: {
id: {
memberId: {
type: 'string',
'x-component': 'NumberPicker',
'x-component-props': {
placeholder: '会员ID',
allowClear: true,
},
},
memberType: {
memberTypeEnum: {
type: 'string',
default: undefined,
enum: [],
......@@ -124,7 +141,7 @@ export const drawerSchema: ISchema = {
allowClear: true,
},
},
memberLevel: {
level: {
type: 'string',
default: undefined,
enum: [],
......@@ -133,7 +150,7 @@ export const drawerSchema: ISchema = {
allowClear: true,
},
},
applicable: {
suitableMemberType: {
type: 'string',
default: undefined,
enum: [],
......@@ -142,7 +159,7 @@ export const drawerSchema: ISchema = {
allowClear: true,
},
},
'[startTime2, endTime2]': {
'[becomeTimeStart, becomeTimeEnd]': {
type: 'string',
'x-component': 'RangePicker',
'x-component-props': {
......
......@@ -2,15 +2,21 @@
* @Author: XieZhiXiong
* @Date: 2021-06-28 17:51:33
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-07-06 14:07:32
* @Description:
* @LastEditTime: 2021-07-28 17:33:55
* @Description: 商家优惠劵发劵
*/
import React, { useState, useEffect } from 'react';
import React, { useState, useEffect, useRef } from 'react';
import {
Row,
Col,
Spin,
Button,
message,
} from 'antd';
import {
SendOutlined,
} from '@ant-design/icons';
import { history } from 'umi';
import { usePageStatus } from '@/hooks/usePageStatus';
import { PublicApi } from '@/services/api';
import { GetMarketingCouponWaiteExecuteGetResponse } from '@/services/MarketingApi';
......@@ -19,18 +25,21 @@ import AnchorPage from '@/layouts/AnchorPage';
import AuditProcess from '@/components/AuditProcess';
import BacisInfo from '../../components/BacisInfo';
import CouponRules from '../../components/CouponRules';
import DeliverCoupon from '../../components/DeliverCoupon';
import DeliverCoupon, { SuitableMemberType } from '../../components/DeliverCoupon';
const MerchantCouponAnalysisDeliver: React.FC<{}> = () => {
const { id } = usePageStatus();
const [couponInfo, setCouponInfo] = useState<GetMarketingCouponWaiteExecuteGetResponse>(null);
const [infoLoading, setInfoLoaading] = useState(false);
const [infoLoading, setInfoLoading] = useState(false);
const [submitLoading, setSubmitLoading] = useState(false);
const deliverRef = useRef<SuitableMemberType[]>([]);
const getBasicInfo = () => {
if (!id) {
return;
}
setInfoLoaading(true);
setInfoLoading(true);
PublicApi.getMarketingCouponWaiteExecuteGet({
id,
}).then(res => {
......@@ -38,7 +47,7 @@ const MerchantCouponAnalysisDeliver: React.FC<{}> = () => {
setCouponInfo(res.data);
}
}).finally(() => {
setInfoLoaading(false);
setInfoLoading(false);
});
};
......@@ -46,6 +55,34 @@ const MerchantCouponAnalysisDeliver: React.FC<{}> = () => {
getBasicInfo();
}, []);
const handleDeliverChange = (value: SuitableMemberType[]) => {
deliverRef.current = value;
};
const handleSubmit = () => {
if (!id) {
return;
}
if (!deliverRef.current.length) {
message.warning('未选择任何会员');
return;
}
setSubmitLoading(true);
PublicApi.postMarketingCouponWaiteExecuteGrant({
id: +id,
grantMembers: deliverRef.current.map((item) => ({ subMemberId: item.memberId, subRoleId: item.roleId })),
}).then(res => {
if (res.code !== 1000) {
return;
}
setTimeout(() => {
history.goBack();
}, 800);
}).finally(() => {
setSubmitLoading(false);
});
};
const anchorsArr = [
{
key: 'verifySteps',
......@@ -70,6 +107,16 @@ const MerchantCouponAnalysisDeliver: React.FC<{}> = () => {
<AnchorPage
title={couponInfo?.name}
anchors={anchorsArr}
extra={(
<Button
type="primary"
icon={<SendOutlined style={{ transform: `rotate(-45deg)`, position: 'relative', top: -2 }} />}
onClick={handleSubmit}
loading={submitLoading}
>
提交
</Button>
)}
>
<Row gutter={[16, 16]}>
{/* 流转记录 */}
......@@ -121,6 +168,7 @@ const MerchantCouponAnalysisDeliver: React.FC<{}> = () => {
{/* 优惠券规则 */}
<Col span={24}>
<DeliverCoupon
onChange={handleDeliverChange}
id="deliverCoupon"
/>
</Col>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment