Commit b4869c88 authored by 王波's avatar 王波

1.修改活动时间校验

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