Commit 75523d5f authored by qinhaitao's avatar qinhaitao

feat: 规范库存字段

parent decf940d
......@@ -53,14 +53,14 @@
class="probablity-prize-content-formItem"
label="库存类型"
required>
<radio-group value="{{+prizeInitData.limitStock}}" onChange="onLimitStockChange">
<radio value="{{0}}">不限库存</radio>
<radio-group value="{{+prizeInitData.switchStock}}" onChange="onswitchStockChange">
<radio value="{{2}}">不限库存</radio>
<radio value="{{1}}">限制库存</radio>
</radio-group>
</form-item>
<form-item
style="width:100%"
a:if="{{(prizeInitData.type == OBJECT_TYPE || prizeInitData.type == EQUITY_TYPE) && prizeInitData.limitStock && type === 'probablity'}}"
a:if="{{(prizeInitData.type == OBJECT_TYPE || prizeInitData.type == EQUITY_TYPE) && prizeInitData.switchStock && type === 'probablity'}}"
size="large"
class="probablity-prize-content-formItem"
label="奖品库存"
......
......@@ -11,6 +11,9 @@ const CREDITS_TYPE = 2;
const OBJECT_TYPE = 3;
const THANKS_TYPE = 4;
const STOCK_LIMIT = 1;
const STOCK_NO_LIMIT = 2;
const INIT_DATA = {
ename: "",
stock: "",
......@@ -19,7 +22,7 @@ const INIT_DATA = {
credits: "",
probablity: "",
name: "",
limitStock: 0,
switchStock: STOCK_NO_LIMIT,
useStock: 0,
rank: ""
};
......@@ -71,7 +74,7 @@ Component({
credits: "",
probablity: "",
name: "",
limitStock: 0,
switchStock: STOCK_NO_LIMIT,
useStock: 0,
rank: ""
},
......@@ -172,7 +175,7 @@ Component({
credits: "",
probablity: "",
name: "",
limitStock: 0
switchStock: STOCK_NO_LIMIT
};
if(type !== value) {
this.resetPrizeData(+value, rank);
......@@ -208,12 +211,12 @@ Component({
});
}
},
onLimitStockChange(e) {
onswitchStockChange(e) {
const value = e.detail.value;
this.setData({
prizeInitData: {
...this.data.prizeInitData,
limitStock: value,
switchStock: value,
stock: value === 0 ? '' : this.data.prizeInitData.stock
},
});
......@@ -292,7 +295,7 @@ Component({
probablity,
stock,
credits,
limitStock,
switchStock,
endTime,
rank,
...rest
......@@ -337,7 +340,7 @@ Component({
this.showItemTips("prizeNameTips", "success", "");
}
if ((type == OBJECT_TYPE || type == EQUITY_TYPE) && limitStock && !validateRangeNumber(stock, [0, 9999])) {
if ((type == OBJECT_TYPE || type == EQUITY_TYPE) && switchStock === STOCK_LIMIT && !validateRangeNumber(stock, [0, 9999])) {
this.showItemTips(
"prizeNumberTips",
"error",
......@@ -382,7 +385,7 @@ Component({
const isImagePass = image && imageTips.status !== "error";
let stockPass = true;
if(limitStock && !stock) {
if(switchStock === STOCK_LIMIT && !stock) {
stockPass = false;
}
const isEquietyPass =
......@@ -417,7 +420,7 @@ Component({
stock,
credits,
rank,
limitStock,
switchStock,
...rest,
};
......
......@@ -10,7 +10,9 @@ import {
addFloat
} from '/utils/helper'
const THANKS_TYPE = 5
const THANKS_TYPE = 5;
const STOCK_LIMIT = 1;
const STOCK_NO_LIMIT = 2;
var validator = new schema(descriptor);
......@@ -33,7 +35,7 @@ Component({
image: "",
credits: "",
name: "",
limitStock: 0,
switchStock: STOCK_NO_LIMIT,
useStock: 0,
rank: "1"
},
......@@ -45,7 +47,7 @@ Component({
image: "",
credits: "",
name: "",
limitStock: 0,
switchStock:STOCK_NO_LIMIT,
useStock: 0,
rank: "2"
},
......@@ -57,7 +59,7 @@ Component({
image: "",
credits: "",
name: "",
limitStock: 0,
switchStock: STOCK_NO_LIMIT,
useStock: 0,
rank: "3"
}
......
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