Commit b4869c88 authored by 王波's avatar 王波

1.修改活动时间校验

2.奖品类型选择从下拉变成单选框
3.库存校验排除空格
4.初始化奖品resetPrizeInit方法中没有获取typeChecked
5.奖品保存类型为积分时没有校验是否上传图片
6.servers端validateParams错误校验返回取反了
parent 3a0cb26a
......@@ -22,12 +22,14 @@
</form-item>
<form-item style="width:100%" size="large" class="probability-prize-content-formItem" label="奖品类型" required>
<view class="probability-prize-content-formitem-choosePrize-wrap">
<select onChange="onPrizeTypeChange" defaultValue="{{isEdit ? prizeDialogData.record.type : prizeInitData.type}}">
<option a:if="{{typeChecked.includes(1)}}" value="{{1}}">优惠券</option>
<option a:if="{{typeChecked.includes(2)}}" value="{{2}}">积分</option>
<option a:if="{{typeChecked.includes(3)}}" value="{{3}}">实物</option>
<!-- <option a:if="{{typeChecked.includes(5)}}" value="{{5}}">降级奖品</option> -->
</select>
<radio-group value="{{isEdit ? prizeDialogData.record.type : prizeInitData.type}}" onChange="onPrizeTypeChange">
<radio a:if="{{typeChecked.includes(1)}}" value="{{1}}">优惠券</radio>
<radio a:if="{{typeChecked.includes(2)}}" value="{{2}}">积分</radio>
<radio a:if="{{typeChecked.includes(3)}}" value="{{3}}">实物</radio>
<!-- <radio a:if="{{typeChecked.includes(5)}}" value="{{5}}">降级奖品</radio> -->
</radio-group>
</view>
</form-item>
<form-item a:if="{{[EQUITY_TYPE].includes(prizeInitData.type)}}" validateState="{{choosePrizeTips.status}}" style="width:100%" size="large" help="{{choosePrizeTips.content}}" class="probability-prize-content-formItem probability-prize-content-formItem-choosePrize" label="选择奖品" required>
......
......@@ -253,7 +253,7 @@ Component({
});
},
resetPrizeInit() {
const { isEdit, prizeDialogData } = this.props;
const { isEdit, prizeDialogData, typeChecked } = this.props;
console.log(isEdit, prizeDialogData);
if (isEdit) {
console.log(prizeDialogData);
......@@ -435,7 +435,7 @@ Component({
// this.showItemTips('goodsIdTips', 'success', '');
// }
// }
if (type == EQUITY_TYPE || type == OBJECT_TYPE) {
if (type == EQUITY_TYPE || type == OBJECT_TYPE || type == CREDITS_TYPE) {
// if (!desc) {
// this.showItemTips("prizeDescTips", "error", "请填写奖品描述");
// } else {
......@@ -450,9 +450,10 @@ Component({
this.showItemTips("imageTips", "error", "请配置奖品图片");
}
}
let intPattern = new RegExp('^[0-9]+?$')
// 库存奖品的库存值判断
let usePass = switchStock == 1 ? +stock >= (useStock || 0) : true;
let stockPass = switchStock == 1 ? validateRangeNumber(stock, [0, 99999]) : true;
let stockPass = switchStock == 1 ? intPattern.test(stock) && validateRangeNumber(stock, [0, 99999]) : true;
if (!stockPass || !usePass) {
this.showItemTips(
"prizeNumberTips",
......
......@@ -84,8 +84,8 @@ Component({
const {
formState
} = _this.data;
_this.setFormTips(formState, errors, target)
if (errors) {
let newValidator = _this.setFormTips(formState, errors, target);
if (errors || newValidator) {
resolve(false);
} else {
resolve(true);
......@@ -101,12 +101,16 @@ Component({
Object.keys(formState).forEach(key => {
let error = errors.filter(v => target ? v.field === target && v.field === key : v.field === key).length && errors.filter(v => v.field === key)[0];
// 时间实时校验
// if (key === 'timeRange' && formState[key].status === 'error') {
// return
// }
if (key === 'timeRange' && formState[key].status === 'error') {
newValidator[key] = {
status: formState[key].status,
message: formState[key].message
};
} else {
newValidator[key] = {
status: error ? 'error' : 'success',
message: error ? error.message : ''
};
}
})
......@@ -115,6 +119,7 @@ Component({
this.setData({
formState: newValidator
})
return Object.values(newValidator).some(i => i.status === 'error')
},
// 提交信息
async onSubmit() {
......
......@@ -28,9 +28,9 @@ const validateParams = (validators: Rules, data: object) => {
console.log('errors', errors)
console.log('fields', fields)
if (errors) {
resolve({})
} else {
resolve({ errors, fields })
} else {
resolve({})
}
})
})
......
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