Skip to content

Commit

Permalink
cleardata
Browse files Browse the repository at this point in the history
  • Loading branch information
vitozyf committed Dec 27, 2019
1 parent 509663e commit 75e4d4d
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 65 deletions.
6 changes: 6 additions & 0 deletions src/assets/style/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ input {
}
body {
overflow: hidden;
padding: 0 !important;
}
.el-form-item {
margin-bottom: 5px !important;
Expand All @@ -46,3 +47,8 @@ body {
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
}
::-webkit-scrollbar {
width: 5px;
height: 5px;
background-color: #ccc;
}
128 changes: 85 additions & 43 deletions src/components/LotteryConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
:visible="visible"
:append-to-body="true"
width="400px"
:lock-scroll="true"
@close="$emit('update:visible', false)"
class="c-LotteryConfig"
>
Expand All @@ -19,48 +18,87 @@
>取消</el-button
>
</div>
<el-form ref="form" :model="form" label-width="100px" size="mini">
<el-form-item label="抽奖标题">
<el-input v-model="form.name"></el-input>
</el-form-item>
<el-form-item label="抽奖总人数">
<el-input type="number" v-model="form.number"></el-input>
</el-form-item>
<el-form-item label="特等奖人数">
<el-input type="number" v-model="form.specialAward"></el-input>
</el-form-item>
<el-form-item label="一等奖人数">
<el-input type="number" v-model="form.firstPrize"></el-input>
</el-form-item>
<el-form-item label="二等奖人数">
<el-input type="number" v-model="form.secondPrize"></el-input>
</el-form-item>
<el-form-item label="三等奖人数">
<el-input type="number" v-model="form.thirdPrize"></el-input>
</el-form-item>
<el-form-item label="四等奖人数">
<el-input type="number" v-model="form.fourthPrize"></el-input>
</el-form-item>
<el-form-item label="五等奖人数">
<el-input type="number" v-model="form.fifthPrize"></el-input>
</el-form-item>
<div class="container">
<el-form ref="form" :model="form" label-width="90px" size="mini">
<el-form-item label="抽奖标题">
<el-input v-model="form.name"></el-input>
</el-form-item>
<el-form-item label="抽奖总人数">
<el-input
type="number"
v-model="form.number"
:min="1"
: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"
v-model="form.firstPrize"
:min="0"
: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"
:key="newitem.key"
>
<el-input
type="number"
v-model="form[newitem.key]"
@change="
val => {
form[newitem.key] = Number(val);
}
"
></el-input>
</el-form-item>
</el-form>
<el-form-item
:label="newitem.name"
v-for="newitem in storeNewLottery"
:key="newitem.key"
>
<el-input
type="number"
:min="0"
:step="1"
v-model="form[newitem.key]"
@change="
val => {
form[newitem.key] = Number(val);
}
"
></el-input>
</el-form-item>
</el-form>
</div>

<el-dialog
:visible.sync="showAddLottery"
Expand Down Expand Up @@ -146,7 +184,11 @@ export default {
.c-LotteryConfig {
.el-dialog__body {
height: 340px;
overflow-y: auto;
.container {
height: 100%;
overflow-y: auto;
padding: 0 10px;
}
}
}
.dialog-showAddLottery {
Expand Down
14 changes: 7 additions & 7 deletions src/components/Tool.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@

<el-form-item label=" " v-if="form.category">
<span>
共<span class="colorred">{{ config[form.category] }}</span
>名
&nbsp;
<span class="colorred">{{ config[form.category] }}</span>
&nbsp;
</span>
<span :style="{ marginLeft: '20px' }">
剩余<span class="colorred">{{ remain }}</span
>名
剩余&nbsp;
<span class="colorred">{{ remain }}</span>
&nbsp;
</span>
</el-form-item>

Expand Down Expand Up @@ -133,13 +135,11 @@ export default {
})
.then(() => {
clearData();
this.$store.commit('setClearStore');
this.$message({
type: 'success',
message: '重置成功!'
});
setTimeout(() => {
window.location.reload();
}, 3000);
})
.catch(() => {
this.$message({
Expand Down
15 changes: 0 additions & 15 deletions src/helper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,6 @@ export function conversionCategoryName(key) {
case 'fifthPrize':
name = '五等奖';
break;
case 'additionalPrize1':
name = '追加奖(1)';
break;
case 'additionalPrize2':
name = '追加奖(2)';
break;
case 'additionalPrize3':
name = '追加奖(3)';
break;
case 'additionalPrize4':
name = '追加奖(4)';
break;
case 'additionalPrize5':
name = '追加奖(5)';
break;

default:
break;
Expand Down
21 changes: 21 additions & 0 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,27 @@ export default new Vuex.Store({
newLottery: []
},
mutations: {
setClearStore(state) {
state.config = {
name: '年会抽奖',
number: 70,
specialAward: 0,
firstPrize: 1,
secondPrize: 5,
thirdPrize: 8,
fourthPrize: 10,
fifthPrize: 20
};
state.result = {
specialAward: [],
firstPrize: [],
secondPrize: [],
thirdPrize: [],
fourthPrize: [],
fifthPrize: []
};
state.newLottery = [];
},
setConfig(state, config) {
state.config = config;
},
Expand Down

0 comments on commit 75e4d4d

Please sign in to comment.