Commit 68eede12 authored by XieZhiXiong's avatar XieZhiXiong

fix: 修复券有效期可以大于券领取起始时间的问题

parent 5dfe0bdc
......@@ -2,10 +2,11 @@
* @Author: XieZhiXiong
* @Date: 2021-06-24 14:04:16
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-09-22 13:45:32
* @LastEditTime: 2021-09-30 16:09:51
* @Description:
*/
import { FormEffectHooks, FormPath, IFormActions } from '@formily/antd';
import moment from 'moment';
import { useLinkageUtils } from '@/utils/formEffectUtils';
import {
MERCHANT_COUPON_TYPE_UNIVERSAL,
......@@ -301,4 +302,44 @@ export const useBusinessEffects = (context, actions: IFormActions) => {
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]');
}
});
}
\ 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