Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
公瑾
/
lucky-draw
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
59660f44
authored
2020-01-06 09:31:51 +0800
by
zhangyongfeng
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
删除默认配置
1 parent
cd7de73b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
101 deletions
src/components/LotteryConfig.vue
src/helper/algorithm.js
src/helper/index.js
src/store/index.js
src/components/LotteryConfig.vue
View file @
59660f4
...
...
@@ -2,7 +2,7 @@
<el-dialog
:visible=
"visible"
:append-to-body=
"true"
width=
"
40
0px"
width=
"
39
0px"
@
close=
"$emit('update:visible', false)"
class=
"c-LotteryConfig"
>
...
...
@@ -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>
...
...
@@ -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"
...
...
@@ -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"
...
...
src/helper/algorithm.js
View file @
59660f4
...
...
@@ -15,6 +15,10 @@
}
*/
export
function
generateArray
(
start
,
end
)
{
return
Array
.
from
(
new
Array
(
end
+
1
).
keys
()).
slice
(
start
);
}
/**
* 取范围内随机整数
* @param {number} minNum
...
...
@@ -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
));
...
...
src/helper/index.js
View file @
59660f4
...
...
@@ -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
;
}
...
...
src/store/index.js
View file @
59660f4
...
...
@@ -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
:
[],
...
...
@@ -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
=
[];
},
...
...
@@ -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
=
[];
...
...
Please
register
or
sign in
to post a comment