Commit 2e9656b1 authored by 前端-李俊鑫's avatar 前端-李俊鑫
parents 8d3f53db 4bd96544
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-06-22 17:12:38
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-08-13 15:44:43
* @LastEditTime: 2021-09-24 14:03:18
* @Description: 适用商品
*/
import React from 'react';
......@@ -97,7 +97,7 @@ const ApplicableGoods: React.FC<IProps> = (props) => {
render: (text) => {
const unitPrice = normalizeUnitPrice(text);
const start = unitPrice[0]?.price;
const end = unitPrice[unitPrice.length - 1].price;
const end = unitPrice[unitPrice.length - 1]?.price;
return start !== end ? ${start}~${end}` : ${start}`;
},
},
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-08-02 16:56:32
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-08-03 09:48:34
* @LastEditTime: 2021-09-23 16:40:12
* @Description: 适用用户
*/
import React, { useMemo } from 'react';
......@@ -17,6 +17,16 @@ import { OptionItemType as MemberOptionItemType } from '../MemberCheckboxGroup';
import ApplicableList from '../FormilyFieldItem/ApplicableList';
export type ApplicationMemberLevelType = Omit<MemberOptionItemType, 'value'> & { id: string }
export type SuitableMemberType = {
/**
* 值
*/
value: number,
/**
* 名称
*/
name: string,
}
interface IProps extends MellowCardProps {
/**
......@@ -26,7 +36,7 @@ interface IProps extends MellowCardProps {
/**
* 适用用户
*/
suitableMemberTypes: {}[],
suitableMemberTypes: SuitableMemberType[],
/**
* 适用用户列表
*/
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-06-25 17:23:30
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-09-17 14:33:06
* @LastEditTime: 2021-09-23 16:41:28
* @Description: 商家优惠券页面详情组件
*/
import React, { useMemo } from 'react';
......@@ -34,9 +34,11 @@ import ApplicableGoods, { ListItemDataType } from '../ApplicableGoods';
import ApplicableShopList from '../ApplicableShopList';
import ApplicableCategories from '../ApplicableCategories';
import ApplicableBrands from '../ApplicableBrands';
import ApplicableMember, { ApplicationMemberLevelType } from '../ApplicableMember';
import ApplicableMember, { ApplicationMemberLevelType, SuitableMemberType } from '../ApplicableMember';
import InnerFlowRecords from '../InnerFlowRecords';
export type SuitableMemberLevelType = Omit<ApplicationMemberLevelType, 'roleName' | 'levelTypeName'> & { roleTypeName: string, memberLevelTypeName: string }
export type DetailType = BacisInfoPropsType['dataSource'] & CouponRulesPropsType['dataSource'] & {
/**
* 优惠券名称
......@@ -127,7 +129,11 @@ export type DetailType = BacisInfoPropsType['dataSource'] & CouponRulesPropsType
/**
* 适用会员
*/
suitableMemberLevelTypes?: ApplicationMemberLevelType[],
suitableMemberLevelTypes?: SuitableMemberLevelType[],
/**
* 适用用户
*/
suitableMemberTypes: SuitableMemberType[],
};
interface IProps {
......@@ -263,6 +269,8 @@ const MerchantCouponDetail: React.FC<IProps> = (props) => {
invalidDay: dataSource?.invalidDay,
useConditionMoney: dataSource?.useConditionMoney,
useConditionDesc: dataSource?.useConditionDesc,
conditionGetDay: dataSource?.conditionGetDay as number,
conditionGetTotal: dataSource?.conditionGetTotal as number,
}}
id="couponRules"
/>
......@@ -284,7 +292,7 @@ const MerchantCouponDetail: React.FC<IProps> = (props) => {
? (
<Col span={24}>
<ApplicableGoods
dataSource={dataSource?.suitableCommoditySkuList}
dataSource={dataSource?.suitableCommoditySkuList!}
id="applicableGoods"
/>
</Col>
......@@ -329,8 +337,8 @@ const MerchantCouponDetail: React.FC<IProps> = (props) => {
<Col span={24}>
<ApplicableMember
applicableMember={{
suitableMemberTypes: [],
applicationMemberLevel: dataSource?.suitableMemberLevelTypes,
suitableMemberTypes: dataSource?.suitableMemberTypes,
applicationMemberLevel: dataSource?.suitableMemberLevelTypes!.map(({ roleTypeName, memberLevelTypeName, ...rest }) => ({ roleName: roleTypeName, levelTypeName: memberLevelTypeName, ...rest })),
}}
id="applicableMember"
/>
......
......@@ -48,6 +48,14 @@ export type PropsType = Omit<CustomizeColumnProps, 'data' | 'column'> & {
* 使用条件说明
*/
useConditionDesc: string,
/**
* 每日可领取
*/
conditionGetDay: number,
/**
* 每会员ID总共可领取
*/
conditionGetTotal: number,
},
}
......@@ -80,7 +88,7 @@ const CouponRules: React.FC<PropsType> = (props: PropsType) => {
},
{
title: '领取条件',
value: '每会员ID总共可领取 3 张,每日 1 张',
value: `每会员ID总共可领取 ${dataSource.conditionGetTotal} 张,每日 ${dataSource.conditionGetDay} 张`,
},
{
title: '有效期结束时间',
......
@import '~antd/es/style/themes/default.less';
.tofuCheckbox-list {
margin-bottom: -@margin-md;
&-item {
display: inline-flex;
align-items: center;
padding: @padding-sm - 2 @padding-md;
margin-right: @margin-md;
margin-bottom: @margin-md;
position: relative;
background-color: @background-color-base;
border: 1px solid @border-color-base;
......
......@@ -142,6 +142,8 @@ const PlatformCouponAnalysisDeliver: React.FC<{}> = () => {
invalidDay: couponInfo?.invalidDay as number,
useConditionMoney: couponInfo?.useConditionMoney as number,
useConditionDesc: couponInfo?.useConditionDesc as string,
conditionGetDay: couponInfo?.conditionGetDay as number,
conditionGetTotal: couponInfo?.conditionGetTotal as number,
}}
id="couponRules"
/>
......
......@@ -115,6 +115,8 @@ const PlatformCouponAnalysisDetail: React.FC<{}> = () => {
invalidDay: couponInfo?.invalidDay as number,
useConditionMoney: couponInfo?.useConditionMoney as number,
useConditionDesc: couponInfo?.useConditionDesc as string,
conditionGetDay: couponInfo?.conditionGetDay as number,
conditionGetTotal: couponInfo?.conditionGetTotal as number,
}}
id="couponRules"
/>
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-06-22 09:49:42
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-08-03 18:21:20
* @LastEditTime: 2021-09-22 14:09:45
* @Description: 商家优惠劵查询
*/
import React, { useRef, useState } from 'react';
......@@ -254,6 +254,27 @@ const PlatformCouponQuery: React.FC = () => {
break;
}
};
// 初始化高级筛选选项
const fetchSearchItems = async () => {
const res = await PublicApi.getMarketingCouponPlatformPageCondition();
if (res.code === 1000) {
const { data } = res;
const {
typeList = [],
getWayList = [],
statusList = [],
} = data;
return {
type: typeList.map(item => ({ label: item.name, value: item.value })).filter(item => item.value),
getWay: getWayList.map(item => ({ label: item.name, value: item.value })).filter(item => item.value),
status: statusList.map(item => ({ label: item.name, value: item.value })).filter(item => item.value),
};
}
return {};
};
return (
<Card>
......@@ -278,6 +299,10 @@ const PlatformCouponQuery: React.FC = () => {
'name',
FORM_FILTER_PATH,
);
useAsyncInitSelect(
['type', 'getWay', 'status'],
fetchSearchItems,
);
}}
schema={querySchema}
/>
......
......@@ -70,7 +70,7 @@ const ApplicableGoodsFormItem = (props) => {
render: (text) => {
const unitPrice = normalizeUnitPrice(text);
const start = unitPrice[0]?.price;
const end = unitPrice[unitPrice.length - 1].price;
const end = unitPrice[unitPrice.length - 1]?.price;
return start !== end ? ${start}~${end}` : ${start}`;
},
},
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-06-24 14:03:34
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-08-03 15:52:33
* @LastEditTime: 2021-09-23 16:17:02
* @Description:
*/
import { FormPath, FormEffectHooks } from '@formily/antd';
......@@ -88,8 +88,24 @@ const fetchSuitableUser = async () => {
};
};
// 初始化 适用会员类型
const fetchMemberTypes = async () => {
const res = await PublicApi.getMarketingCouponPlatformMemberTypeList();
if (res.code === 1000) {
const { data = [] } = res;
return {
memberTypes: data.map(item => ({ label: item.name, value: item.value })),
};
}
return {
data: [],
totalCount: 0,
};
};
// 获取 实用会员选项
const fetchMemberOptions: (params: { current: string, pageSize: string, levelConfigIds: string, roleIds: string }) => Promise<ResponseType> = async (params) => {
const fetchMemberOptions: (params: { current: string, pageSize: string, levelConfigIds: string, roleIds: string, memberTypes: string }) => Promise<ResponseType> = async (params) => {
const res = await PublicApi.getMemberManageMarketingSuitableLevelConfigPage(params);
if (res.code === 1000) {
const options = res.data.data.map(item => ({
......@@ -124,6 +140,8 @@ export const createEffects = (context, actions) => {
useAsyncInitSelect(['suitableMemberTypes'], fetchSuitableUser);
useAsyncInitSelect(['memberTypes'], fetchMemberTypes);
// 初始化 适用商城数据
onFieldMount$('suitableMallTypes').subscribe(() => {
PublicApi.getManageShopAllByShopType({
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-06-24 14:04:16
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-07-30 17:48:32
* @LastEditTime: 2021-09-24 10:59:06
* @Description:
*/
import { FormEffectHooks, FormPath, IFormActions } from '@formily/antd';
......@@ -19,8 +19,6 @@ import {
MERCHANT_COUPON_RECEIVE_OPERATE,
SUITABLE_TYPE_NEW_USER,
SUITABLE_TYPE_OLD_USER,
SUITABLE_TYPE_NEW_MEMBER,
SUITABLE_TYPE_OLD_MEMBER,
} from '@/constants/const/marketing';
const {
......@@ -178,37 +176,6 @@ export const useBusinessEffects = (context, actions: IFormActions) => {
}
});
});
// 领券方式
onFieldValueChange$('getWay').subscribe(state => {
const { value } = state;
const suitableMemberTypesEnum = [...getFieldState('suitableMemberTypes', state => state.props.enum)];
const newData = suitableMemberTypesEnum.map((item) => {
const newItem = {...item};
newItem.disabled = false;
if (
(
value === MERCHANT_COUPON_RECEIVE_DESIGNATED
|| value === MERCHANT_COUPON_RECEIVE_OPERATE
) && (
newItem.value === SUITABLE_TYPE_NEW_USER
|| newItem.value === SUITABLE_TYPE_OLD_USER
)
) {
newItem.disabled = true;
}
return newItem;
});
const showReceiveCondition = value === MERCHANT_COUPON_RECEIVE_FRONT;
setFieldState('suitableMemberTypes', state => {
FormPath.setIn(state, 'props.enum', newData);
});
setFieldState('receiveCondition', state => {
FormPath.setIn(state, 'visible', showReceiveCondition);
});
});
// 适用用户角色
onFieldInputChange$('applicationUserRole').subscribe(state => {
......@@ -232,18 +199,6 @@ export const useBusinessEffects = (context, actions: IFormActions) => {
});
});
// 适用用户
onFieldValueChange$('suitableMemberTypes').subscribe(state => {
const { value } = state;
// 包含新会员(仅会员用户) 或者 老会员(仅会员用户),展示 适用用户角色 与 会员等级列表
if (value && (value.includes(SUITABLE_TYPE_NEW_MEMBER) || value.includes(SUITABLE_TYPE_OLD_MEMBER))) {
linkage.show('*(applicationUserRole,applicationMemberLevel)');
} else {
linkage.hide('*(applicationUserRole,applicationMemberLevel)');
}
});
// 券有效期类型,展示对应的 FieldItem
onFieldValueChange$('effectiveType').subscribe(state => {
const { value } = state;
......@@ -255,4 +210,30 @@ export const useBusinessEffects = (context, actions: IFormActions) => {
linkage.show('invalidDay');
}
});
// 每日可领取量
onFieldInputChange$('receiveCondition.conditionGetDay').subscribe(state => {
const { value } = state;
const conditionGetTotalValue = getFieldValue('receiveCondition.conditionGetTotal'); // 每会员ID总共可领取;
if (+value > +conditionGetTotalValue) {
setFieldState('receiveCondition.conditionGetDay', fieldState => {
FormPath.setIn(fieldState, 'errors', '每日可领取必须小于或等于总可领取量');
});
} else {
actions.clearErrors('receiveCondition.conditionGetDay');
}
});
// 每会员ID总共可领取
onFieldInputChange$('receiveCondition.conditionGetTotal').subscribe(state => {
const { value } = state;
const conditionGetDayValue = getFieldValue('receiveCondition.conditionGetDay'); // 每会员ID总共可领取;
if (+value < +conditionGetDayValue) {
setFieldState('receiveCondition.conditionGetTotal', fieldState => {
FormPath.setIn(fieldState, 'errors', '每会员ID总共可领取必须大于每日可领取');
});
} else {
actions.clearErrors('receiveCondition.conditionGetTotal');
}
});
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-06-24 13:47:47
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-08-13 15:14:24
* @LastEditTime: 2021-09-23 16:55:22
* @Description: 新增/修改 优惠券表单
*/
import React, { useState, useMemo, useEffect } from 'react';
......@@ -122,6 +122,10 @@ export type SubmitValueType = {
* 适用商城
*/
suitableMallTypes: number[],
/**
* 实用会员类型
*/
memberTypes: number[],
}
export type CouponInfoType = SubmitValueType & {}
......@@ -188,7 +192,7 @@ const CouponForm: React.FC<IProps> = (props) => {
goodsList: suitableCommoditySkuList as any,
applicationUserRole,
applicationMemberLevel: suitableMemberLevelTypes?.map((item) => item.id),
suitableMemberTypes: suitableMemberTypes?.map((item) => item.value),
suitableMemberTypes: suitableMemberTypes,
suitableMallTypes: suitableMallTypes?.map((item) => item.id),
denomination: `${denomination}`,
quantity: `${quantity}`,
......@@ -355,7 +359,7 @@ const CouponForm: React.FC<IProps> = (props) => {
return (
<Spin spinning={infoLoading}>
<AnchorPage
title="新增平台优惠券"
title={`${!id ? '新增' : '编辑'}平台优惠券`}
anchors={anchorsArr}
extra={[
<Button
......
......@@ -2,13 +2,22 @@
* @Author: XieZhiXiong
* @Date: 2021-06-24 14:05:57
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-08-02 17:38:26
* @LastEditTime: 2021-09-24 13:50:18
* @Description:
*/
import { ISchema } from '@formily/antd';
import moment from 'moment';
import themeConfig from '@/../config/theme.config';
import { PATTERN_MAPS } from '@/constants/regExp';
function range(start, end) {
const result = [];
for (let i = start; i < end; i++) {
result.push(i);
}
return result;
}
const schema: ISchema = {
type: 'object',
properties: {
......@@ -51,6 +60,12 @@ const schema: ISchema = {
'x-component-props': {
allowClear: false,
},
'x-rules': [
{
limitByte: true, // 自定义校验规则
maxByte: 60,
}
],
},
denomination: {
title: '券面额',
......@@ -89,6 +104,17 @@ const schema: ISchema = {
'x-component-props': {
placeholder: ['领(发)劵起始时间', '领(发)劵截止时间'],
showTime: true,
disabledDate: (current) => current && current < moment().startOf('day'),
disabledTime: (_, type) => {
if (type === 'start') {
return {
disabledHours: () => range(0, 24).splice(0, moment().get('hour')),
disabledMinutes: () => range(0, 60).splice(0, moment().get('minute')),
disabledSeconds: () => range(0, 60).splice(0, moment().get('second')),
};
}
return {};
},
},
},
},
......@@ -140,7 +166,7 @@ const schema: ISchema = {
'x-component-props': {
grid: true,
full: true,
columns: 2,
columns: 1,
autoRow: true,
},
properties: {
......@@ -276,6 +302,17 @@ const schema: ISchema = {
'x-component-props': {
placeholder: ['劵有效期起始时间', '劵有效期截止时间'],
showTime: true,
disabledDate: (current) => current && current < moment().startOf('day'),
disabledTime: (_, type) => {
if (type === 'start') {
return {
disabledHours: () => range(0, 24).splice(0, moment().get('hour')),
disabledMinutes: () => range(0, 60).splice(0, moment().get('minute')),
disabledSeconds: () => range(0, 60).splice(0, moment().get('second')),
};
}
return {};
},
},
},
invalidDay: {
......@@ -388,6 +425,16 @@ const schema: ISchema = {
'x-component-props': {
},
},
memberTypes: {
title: '适用会员类型',
type: 'string',
enum: [],
default: [],
required: true,
'x-component': 'TofuCheckGroup',
'x-component-props': {
},
},
applicationUserRole: {
title: '适用用户角色',
type: 'string',
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-06-24 16:11:55
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-08-13 15:39:44
* @LastEditTime: 2021-09-24 14:12:08
* @Description: 商品选择抽屉
*/
import React, { useEffect } from 'react';
......@@ -112,6 +112,7 @@ const GoodsDrawer: React.FC<IProps> = (props) => {
const fetchData = async (params: ExtraFetchType) => {
const res = await PublicApi.postProductCommodityCommonGetCommodityListByPlatform({
priceTypeList: [1],
...params,
}, {
ctlType: 'none',
......@@ -167,7 +168,7 @@ const GoodsDrawer: React.FC<IProps> = (props) => {
render: (text) => {
const unitPrice = normalizeUnitPrice(text);
const start = unitPrice[0]?.price;
const end = unitPrice[unitPrice.length - 1].price;
const end = unitPrice[unitPrice.length - 1]?.price;
return start !== end ? ${start}~${end}` : ${start}`;
},
},
......
......@@ -609,7 +609,7 @@ const getInformationByIds = (idList: number[]) => {
"componentName": "PlatformPurchase.Banner",
"componentType": PROPS_SETTING_TYPES.platformPurchaseAdvert,
"props": {
advertList: []
advertList: flowItem.content || []
},
}
});
......
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