Skip to content

Commit

Permalink
删除默认配置
Browse files Browse the repository at this point in the history
  • Loading branch information
vitozyf committed Jan 6, 2020
1 parent cd7de73 commit 59660f4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 101 deletions.
45 changes: 2 additions & 43 deletions src/components/LotteryConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<el-dialog
:visible="visible"
:append-to-body="true"
width="400px"
width="390px"
@close="$emit('update:visible', false)"
class="c-LotteryConfig"
>
Expand All @@ -19,7 +19,7 @@
>
</div>
<div class="container">
<el-form ref="form" :model="form" label-width="90px" size="mini">
<el-form ref="form" :model="form" size="mini">
<el-form-item label="抽奖标题">
<el-input v-model="form.name"></el-input>
</el-form-item>
Expand All @@ -31,14 +31,6 @@
:step="1"
></el-input>
</el-form-item>
<el-form-item label="特等奖">
<el-input
type="number"
v-model="form.specialAward"
:min="0"
:step="1"
></el-input>
</el-form-item>
<el-form-item label="一等奖">
<el-input
type="number"
Expand All @@ -47,39 +39,6 @@
:step="1"
></el-input>
</el-form-item>
<el-form-item label="二等奖">
<el-input
type="number"
v-model="form.secondPrize"
:min="0"
:step="1"
></el-input>
</el-form-item>
<el-form-item label="三等奖">
<el-input
type="number"
v-model="form.thirdPrize"
:min="0"
:step="1"
></el-input>
</el-form-item>
<el-form-item label="四等奖">
<el-input
type="number"
v-model="form.fourthPrize"
:min="0"
:step="1"
></el-input>
</el-form-item>
<el-form-item label="五等奖">
<el-input
type="number"
v-model="form.fifthPrize"
:min="0"
:step="1"
></el-input>
</el-form-item>

<el-form-item
:label="newitem.name"
v-for="newitem in storeNewLottery"
Expand Down
11 changes: 5 additions & 6 deletions src/helper/algorithm.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
}
*/

export function generateArray(start, end) {
return Array.from(new Array(end + 1).keys()).slice(start);
}

/**
* 取范围内随机整数
* @param {number} minNum
Expand All @@ -30,13 +34,8 @@ export function randomNum(minNum = 1, maxNum) {
* @param {number} num 本次抽取人数
*/
export function luckydrawHandler(total, won = [], num) {
const peolist = [];
for (let i = 1; i <= total; i++) {
peolist.push(i);
}

const peolist = generateArray(1, Number(total));
const wons = won;

const res = [];
for (let j = 0; j < num; j++) {
const nodraws = peolist.filter(item => !wons.includes(item));
Expand Down
16 changes: 0 additions & 16 deletions src/helper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,9 @@ export const listField = 'list'; // 名单
export function conversionCategoryName(key) {
let name = '';
switch (key) {
case 'specialAward':
name = '特等奖';
break;
case 'firstPrize':
name = '一等奖';
break;
case 'secondPrize':
name = '二等奖';
break;
case 'thirdPrize':
name = '三等奖';
break;
case 'fourthPrize':
name = '四等奖';
break;
case 'fifthPrize':
name = '五等奖';
break;

default:
break;
}
Expand Down
42 changes: 6 additions & 36 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,10 @@ export default new Vuex.Store({
config: {
name: '年会抽奖',
number: 70,
specialAward: 0,
firstPrize: 1,
secondPrize: 5,
thirdPrize: 8,
fourthPrize: 10,
fifthPrize: 20
firstPrize: 1
},
result: {
specialAward: [],
firstPrize: [],
secondPrize: [],
thirdPrize: [],
fourthPrize: [],
fifthPrize: []
firstPrize: []
},
newLottery: [],
list: [],
Expand All @@ -38,12 +28,7 @@ export default new Vuex.Store({
state.config = {
name: '年会抽奖',
number: 70,
specialAward: 0,
firstPrize: 1,
secondPrize: 5,
thirdPrize: 8,
fourthPrize: 10,
fifthPrize: 20
firstPrize: 1
};
state.newLottery = [];
},
Expand All @@ -55,32 +40,17 @@ export default new Vuex.Store({
},
setClearResult(state) {
state.result = {
specialAward: [],
firstPrize: [],
secondPrize: [],
thirdPrize: [],
fourthPrize: [],
fifthPrize: []
firstPrize: []
};
},
setClearStore(state) {
state.config = {
name: '年会抽奖',
number: 70,
specialAward: 0,
firstPrize: 1,
secondPrize: 5,
thirdPrize: 8,
fourthPrize: 10,
fifthPrize: 20
firstPrize: 1
};
state.result = {
specialAward: [],
firstPrize: [],
secondPrize: [],
thirdPrize: [],
fourthPrize: [],
fifthPrize: []
firstPrize: []
};
state.newLottery = [];
state.list = [];
Expand Down

0 comments on commit 59660f4

Please sign in to comment.