Commit 53816a4d authored by Bill's avatar Bill

Merge branch 'v2' of 10.0.0.22:lingxi/lingxi-business-system into v2

parents 6d9252e1 5c0c40ab
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-06-22 15:34:47
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-06-22 16:44:56
* @LastEditTime: 2021-09-30 17:11:02
* @Description: 基本信息
*/
import React from 'react';
......@@ -91,7 +91,7 @@ const CouponBacisInfo: React.FC<PropsType> = (props: PropsType) => {
},
{
title: '活动名称',
value: '全品类通用优惠券',
value: dataSource.name,
},
{
title: '券面额',
......
......@@ -8,10 +8,10 @@
import React, { useRef } from 'react';
import { Modal } from 'antd';
import ReasonForm, { ReasonValueType, ReasonFormRefHandle } from '../ReasonForm';
import EditForm, { EditSubmitValueType, EditFormRefHandle } from '../EditForm';
import EditForm, { EditSubmitValueType, EditFormRefHandle, EditValueType } from '../EditForm';
export type ActionModalType = 'stop' | 'cancel' | 'startUp' | 'edit';
export type ActionModalValueType = { id: number };
export type ActionModalValueType = { id: number } & Partial<EditValueType>;
interface IProps {
/**
......@@ -96,6 +96,7 @@ const ActionModal: React.FC<IProps> = (props) => {
render: () => (
<EditForm
onSubmit={handleEditSubmit}
value={value as EditValueType}
ref={formRef}
/>
),
......
......@@ -40,6 +40,10 @@ interface IProps {
* 提交触发事件
*/
onSubmit: (values: EditSubmitValueType) => void,
/**
* 值
*/
value: EditValueType,
}
export interface EditFormRefHandle {
......@@ -70,6 +74,7 @@ const EditForm: React.ForwardRefRenderFunction<EditFormRefHandle, IProps> = ((pr
components={{
DatePicker,
}}
value={value}
effects={($, { setFieldState }) => {
}}
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-06-22 09:49:42
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-09-22 14:09:45
* @LastEditTime: 2021-09-30 17:07:20
* @Description: 商家优惠劵查询
*/
import React, { useRef, useState } from 'react';
......@@ -179,7 +179,7 @@ const PlatformCouponQuery: React.FC = () => {
{record.update && (
<Button
type="link"
onClick={() => handleShowActionModal('edit', { id: record.id })}
onClick={() => handleShowActionModal('edit', { id: record.id, releaseTimeStart: moment(record.releaseTimeStart).format('YYYY-MM-DD HH:mm:ss'), releaseTimeEnd: moment(record.releaseTimeEnd).format('YYYY-MM-DD HH:mm:ss'), quantity: `${record.quantity}` })}
>
修改
</Button>
......
......@@ -2,10 +2,11 @@
* @Author: XieZhiXiong
* @Date: 2021-06-24 14:04:16
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-09-27 10:08:44
* @LastEditTime: 2021-09-30 16:39:11
* @Description:
*/
import { FormEffectHooks, FormPath, IFormActions } from '@formily/antd';
import moment from 'moment';
import { useLinkageUtils } from '@/utils/formEffectUtils';
import {
MERCHANT_COUPON_TYPE_UNIVERSAL,
......@@ -230,12 +231,80 @@ export const useBusinessEffects = (context, actions: IFormActions) => {
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总共可领取必须大于每日可领取');
const quantityValue = getFieldValue('quantity'); // 每会员ID总共可领取
if (value && quantityValue) {
if (+value > +quantityValue) {
setFieldState('receiveCondition.conditionGetTotal', fieldState => {
FormPath.setIn(fieldState, 'errors', '每会员ID总共可领取数量应该小于等于发券数量');
});
} else {
actions.clearErrors('receiveCondition.conditionGetTotal');
}
}
if (value && conditionGetDayValue) {
if (+value < +conditionGetDayValue) {
setFieldState('receiveCondition.conditionGetTotal', fieldState => {
FormPath.setIn(fieldState, 'errors', '每会员ID总共可领取必须大于每日可领取');
});
} else {
actions.clearErrors('receiveCondition.conditionGetTotal');
}
}
});
// 领(发)券起始时间
onFieldValueChange$('[releaseTimeStart, releaseTimeEnd]').subscribe(state => {
const { value } = state;
const releaseTimeStartValue = value?.[0];
const effectiveTime = getFieldValue('[effectiveTimeStart, effectiveTimeEnd]'); // 券有效期
const effectiveTimeStartValue = effectiveTime?.[0];
if (
releaseTimeStartValue
&& effectiveTimeStartValue
&& moment(releaseTimeStartValue) > moment(effectiveTimeStartValue)
) {
setFieldState('[releaseTimeStart, releaseTimeEnd]', fieldState => {
FormPath.setIn(fieldState, 'errors', '领(发)券起始时间应该小于券有效期起始时间');
});
} else {
actions.clearErrors('[releaseTimeStart, releaseTimeEnd]');
}
});
// 券有效期始时间
onFieldValueChange$('[effectiveTimeStart, effectiveTimeEnd]').subscribe(state => {
const { value } = state;
const effectiveTimeStartValue = value?.[0];
const releaseTime = getFieldValue('[releaseTimeStart, releaseTimeEnd]'); // 券有效期
const releaseTimeStartValue = releaseTime?.[0];
if (
effectiveTimeStartValue
&& releaseTimeStartValue
&& moment(effectiveTimeStartValue) < moment(releaseTimeStartValue)
) {
setFieldState('[effectiveTimeStart, effectiveTimeEnd]', fieldState => {
FormPath.setIn(fieldState, 'errors', '券有效期起始时间应该大于等于领(发)券起始时间');
});
} else {
actions.clearErrors('[effectiveTimeStart, effectiveTimeEnd]');
}
});
// 发券数量
onFieldValueChange$('quantity').subscribe(state => {
const { value } = state;
const conditionGetTotalValue = getFieldValue('receiveCondition.conditionGetTotal'); // 每会员ID总共可领取
if (value && conditionGetTotalValue && +value <= +conditionGetTotalValue) {
setFieldState('quantity', fieldState => {
FormPath.setIn(fieldState, 'errors', '发券数量应该大于等于每会员ID总共可领取数量');
});
} else {
actions.clearErrors('receiveCondition.conditionGetTotal');
actions.clearErrors('quantity');
}
});
}
\ No newline at end of file
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