Commit 01093727 authored by XieZhiXiong's avatar XieZhiXiong

feat: 对接优惠券发券相关

parent 1c8c5039
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: XieZhiXiong * @Author: XieZhiXiong
* @Date: 2021-06-29 09:36:35 * @Date: 2021-06-29 09:36:35
* @LastEditors: XieZhiXiong * @LastEditors: XieZhiXiong
* @LastEditTime: 2021-06-29 10:18:11 * @LastEditTime: 2021-07-28 17:49:07
* @Description: * @Description:
*/ */
import { ISchema } from '@formily/antd'; import { ISchema } from '@formily/antd';
...@@ -31,7 +31,7 @@ export const querySchema: ISchema = { ...@@ -31,7 +31,7 @@ export const querySchema: ISchema = {
'x-component': 'Search', 'x-component': 'Search',
'x-component-props': { 'x-component-props': {
placeholder: '搜索', placeholder: '搜索',
tip: '输入 优惠劵名称 进行搜索', tip: '输入 会员名称 进行搜索',
}, },
}, },
}, },
...@@ -45,33 +45,48 @@ export const querySchema: ISchema = { ...@@ -45,33 +45,48 @@ export const querySchema: ISchema = {
}, },
}, },
properties: { properties: {
id: { memberId: {
type: 'string', type: 'string',
'x-component-props': { 'x-component-props': {
placeholder: '优惠劵ID', placeholder: '会员ID',
allowClear: true, allowClear: true,
style: {
width: 160,
},
}, },
}, },
'[startTime2, endTime2]': { memberType: {
type: 'object', type: 'string',
'x-component': 'RangePicker', default: undefined,
enum: [],
'x-component-props': { 'x-component-props': {
placeholder: ['劵有效期起始时间', '劵有效期截止时间'], placeholder: '会员类型(所有)',
showTime: true, allowClear: true,
}, },
}, },
type: { level: {
type: 'string', type: 'string',
default: undefined, default: undefined,
enum: [], enum: [],
'x-component-props': { 'x-component-props': {
placeholder: '优惠劵类型(所有)', placeholder: '会员等级(所有)',
allowClear: true, 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: { submit: {
'x-component': 'Submit', 'x-component': 'Submit',
'x-mega-props': { 'x-mega-props': {
...@@ -105,17 +120,19 @@ export const drawerSchema: ISchema = { ...@@ -105,17 +120,19 @@ export const drawerSchema: ISchema = {
'x-component': 'Mega-Layout', 'x-component': 'Mega-Layout',
'x-component-props': { 'x-component-props': {
grid: true, grid: true,
full: true,
autoRow: true,
columns: 4, columns: 4,
}, },
properties: { properties: {
id: { memberId: {
type: 'string', type: 'string',
'x-component': 'NumberPicker',
'x-component-props': { 'x-component-props': {
placeholder: '会员ID', placeholder: '会员ID',
allowClear: true,
}, },
}, },
memberType: { memberTypeEnum: {
type: 'string', type: 'string',
default: undefined, default: undefined,
enum: [], enum: [],
...@@ -124,7 +141,7 @@ export const drawerSchema: ISchema = { ...@@ -124,7 +141,7 @@ export const drawerSchema: ISchema = {
allowClear: true, allowClear: true,
}, },
}, },
memberLevel: { level: {
type: 'string', type: 'string',
default: undefined, default: undefined,
enum: [], enum: [],
...@@ -133,7 +150,7 @@ export const drawerSchema: ISchema = { ...@@ -133,7 +150,7 @@ export const drawerSchema: ISchema = {
allowClear: true, allowClear: true,
}, },
}, },
applicable: { suitableMemberType: {
type: 'string', type: 'string',
default: undefined, default: undefined,
enum: [], enum: [],
...@@ -142,7 +159,7 @@ export const drawerSchema: ISchema = { ...@@ -142,7 +159,7 @@ export const drawerSchema: ISchema = {
allowClear: true, allowClear: true,
}, },
}, },
'[startTime2, endTime2]': { '[becomeTimeStart, becomeTimeEnd]': {
type: 'string', type: 'string',
'x-component': 'RangePicker', 'x-component': 'RangePicker',
'x-component-props': { 'x-component-props': {
......
...@@ -2,15 +2,21 @@ ...@@ -2,15 +2,21 @@
* @Author: XieZhiXiong * @Author: XieZhiXiong
* @Date: 2021-06-28 17:51:33 * @Date: 2021-06-28 17:51:33
* @LastEditors: XieZhiXiong * @LastEditors: XieZhiXiong
* @LastEditTime: 2021-07-06 14:07:32 * @LastEditTime: 2021-07-28 17:33:55
* @Description: * @Description: 商家优惠劵发劵
*/ */
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect, useRef } from 'react';
import { import {
Row, Row,
Col, Col,
Spin, Spin,
Button,
message,
} from 'antd'; } from 'antd';
import {
SendOutlined,
} from '@ant-design/icons';
import { history } from 'umi';
import { usePageStatus } from '@/hooks/usePageStatus'; import { usePageStatus } from '@/hooks/usePageStatus';
import { PublicApi } from '@/services/api'; import { PublicApi } from '@/services/api';
import { GetMarketingCouponWaiteExecuteGetResponse } from '@/services/MarketingApi'; import { GetMarketingCouponWaiteExecuteGetResponse } from '@/services/MarketingApi';
...@@ -19,18 +25,21 @@ import AnchorPage from '@/layouts/AnchorPage'; ...@@ -19,18 +25,21 @@ import AnchorPage from '@/layouts/AnchorPage';
import AuditProcess from '@/components/AuditProcess'; import AuditProcess from '@/components/AuditProcess';
import BacisInfo from '../../components/BacisInfo'; import BacisInfo from '../../components/BacisInfo';
import CouponRules from '../../components/CouponRules'; import CouponRules from '../../components/CouponRules';
import DeliverCoupon from '../../components/DeliverCoupon'; import DeliverCoupon, { SuitableMemberType } from '../../components/DeliverCoupon';
const MerchantCouponAnalysisDeliver: React.FC<{}> = () => { const MerchantCouponAnalysisDeliver: React.FC<{}> = () => {
const { id } = usePageStatus(); const { id } = usePageStatus();
const [couponInfo, setCouponInfo] = useState<GetMarketingCouponWaiteExecuteGetResponse>(null); 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 = () => { const getBasicInfo = () => {
if (!id) { if (!id) {
return; return;
} }
setInfoLoaading(true); setInfoLoading(true);
PublicApi.getMarketingCouponWaiteExecuteGet({ PublicApi.getMarketingCouponWaiteExecuteGet({
id, id,
}).then(res => { }).then(res => {
...@@ -38,7 +47,7 @@ const MerchantCouponAnalysisDeliver: React.FC<{}> = () => { ...@@ -38,7 +47,7 @@ const MerchantCouponAnalysisDeliver: React.FC<{}> = () => {
setCouponInfo(res.data); setCouponInfo(res.data);
} }
}).finally(() => { }).finally(() => {
setInfoLoaading(false); setInfoLoading(false);
}); });
}; };
...@@ -46,6 +55,34 @@ const MerchantCouponAnalysisDeliver: React.FC<{}> = () => { ...@@ -46,6 +55,34 @@ const MerchantCouponAnalysisDeliver: React.FC<{}> = () => {
getBasicInfo(); 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 = [ const anchorsArr = [
{ {
key: 'verifySteps', key: 'verifySteps',
...@@ -70,6 +107,16 @@ const MerchantCouponAnalysisDeliver: React.FC<{}> = () => { ...@@ -70,6 +107,16 @@ const MerchantCouponAnalysisDeliver: React.FC<{}> = () => {
<AnchorPage <AnchorPage
title={couponInfo?.name} title={couponInfo?.name}
anchors={anchorsArr} 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]}> <Row gutter={[16, 16]}>
{/* 流转记录 */} {/* 流转记录 */}
...@@ -121,6 +168,7 @@ const MerchantCouponAnalysisDeliver: React.FC<{}> = () => { ...@@ -121,6 +168,7 @@ const MerchantCouponAnalysisDeliver: React.FC<{}> = () => {
{/* 优惠券规则 */} {/* 优惠券规则 */}
<Col span={24}> <Col span={24}>
<DeliverCoupon <DeliverCoupon
onChange={handleDeliverChange}
id="deliverCoupon" id="deliverCoupon"
/> />
</Col> </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