Commit 75523d5f authored by qinhaitao's avatar qinhaitao

feat: 规范库存字段

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