Commit 93c97ea3 authored by XieZhiXiong's avatar XieZhiXiong

fix: 修复发券数量可以小于每个Id总可以领取数量的问题

parent 68eede12
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-06-24 14:04:16
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-09-30 16:09:51
* @LastEditTime: 2021-09-30 16:38:36
* @Description:
*/
import { FormEffectHooks, FormPath, IFormActions } from '@formily/antd';
......@@ -294,12 +294,26 @@ 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总共可领取必须大于每日可领取');
});
} else {
actions.clearErrors('receiveCondition.conditionGetTotal');
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');
}
}
});
......@@ -342,4 +356,18 @@ export const useBusinessEffects = (context, actions: IFormActions) => {
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('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