f145b910 by zhangyongfeng

新增五项重置数据的选项,可选择单独重置

1 parent fa4a56f6
...@@ -20,7 +20,9 @@ ...@@ -20,7 +20,9 @@
20 20
21 ### 重置 21 ### 重置
22 22
23 - 重置所有数据恢复到初始状态 23 - 重置数据恢复到初始状态
24 - 可选的重置选项:
25 `1.重置全部数据 2.重置抽奖配置 3.重置名单 4.重置照片 5.重置抽奖结果`
24 26
25 ### 导入名单 27 ### 导入名单
26 28
...@@ -34,7 +36,7 @@ ...@@ -34,7 +36,7 @@
34 ## 温馨提示 36 ## 温馨提示
35 37
36 - 本抽奖程序无暗箱操作,无后台,无后门。 38 - 本抽奖程序无暗箱操作,无后台,无后门。
37 - 名单和照片显示只需导入一种即可。 39 - 名单和照片显示只需导入一种即可,无导入数据则使用抽奖号码
38 - 建议使用最新的 Chrome 浏览器打开体验最佳。 40 - 建议使用最新的 Chrome 浏览器打开体验最佳。
39 41
40 ## License 42 ## License
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
4 @close="$emit('update:visible', false)" 4 @close="$emit('update:visible', false)"
5 width="600px" 5 width="600px"
6 class="c-Result" 6 class="c-Result"
7 :append-to-body="true"
7 > 8 >
8 <div class="dialog-title" slot="title"> 9 <div class="dialog-title" slot="title">
9 <span :style="{ fontSize: '18px' }"> 10 <span :style="{ fontSize: '18px' }">
...@@ -132,7 +133,7 @@ export default { ...@@ -132,7 +133,7 @@ export default {
132 border: 1px solid #ccc; 133 border: 1px solid #ccc;
133 background-color: #f2f2f2; 134 background-color: #f2f2f2;
134 margin-left: 5px; 135 margin-left: 5px;
135 margin-top: 5px; 136 margin-bottom: 5px;
136 position: relative; 137 position: relative;
137 cursor: pointer; 138 cursor: pointer;
138 &:hover { 139 &:hover {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
3 <el-button @click="startHandler" type="primary" size="mini">{{ 3 <el-button @click="startHandler" type="primary" size="mini">{{
4 running ? '停止' : '开始' 4 running ? '停止' : '开始'
5 }}</el-button> 5 }}</el-button>
6 <el-button size="mini" @click="resetConfig"> 6 <el-button size="mini" @click="showRemoveoptions = true">
7 重置 7 重置
8 </el-button> 8 </el-button>
9 <el-button size="mini" @click="showImport = true"> 9 <el-button size="mini" @click="showImport = true">
...@@ -104,11 +104,41 @@ ...@@ -104,11 +104,41 @@
104 :visible.sync="showImportphoto" 104 :visible.sync="showImportphoto"
105 @getPhoto="$emit('getPhoto')" 105 @getPhoto="$emit('getPhoto')"
106 ></Importphoto> 106 ></Importphoto>
107
108 <el-dialog
109 :visible.sync="showRemoveoptions"
110 width="300px"
111 class="c-removeoptions"
112 :append-to-body="true"
113 >
114 <el-form ref="form" :model="removeInfo" label-width="80px" size="mini">
115 <el-form-item label="重置选项">
116 <el-radio-group v-model="removeInfo.type">
117 <el-radio border :label="0">重置全部数据</el-radio>
118 <el-radio border :label="1">重置抽奖配置</el-radio>
119 <el-radio border :label="2">重置名单</el-radio>
120 <el-radio border :label="3">重置照片</el-radio>
121 <el-radio border :label="4">重置抽奖结果</el-radio>
122 </el-radio-group>
123 </el-form-item>
124 <el-form-item>
125 <el-button type="primary" @click="resetConfig">确定重置</el-button>
126 <el-button @click="showRemoveoptions = false">取消</el-button>
127 </el-form-item>
128 </el-form>
129 </el-dialog>
107 </div> 130 </div>
108 </template> 131 </template>
109 132
110 <script> 133 <script>
111 import { clearData, conversionCategoryName } from '@/helper/index'; 134 import {
135 clearData,
136 removeData,
137 configField,
138 listField,
139 resultField,
140 conversionCategoryName
141 } from '@/helper/index';
112 import Importphoto from './Importphoto'; 142 import Importphoto from './Importphoto';
113 import { database, DB_STORE_NAME } from '@/helper/db'; 143 import { database, DB_STORE_NAME } from '@/helper/db';
114 144
...@@ -158,6 +188,8 @@ export default { ...@@ -158,6 +188,8 @@ export default {
158 showSetwat: false, 188 showSetwat: false,
159 showImport: false, 189 showImport: false,
160 showImportphoto: false, 190 showImportphoto: false,
191 showRemoveoptions: false,
192 removeInfo: { type: 0 },
161 form: { 193 form: {
162 category: '', 194 category: '',
163 mode: 1, 195 mode: 1,
...@@ -167,18 +199,51 @@ export default { ...@@ -167,18 +199,51 @@ export default {
167 listStr: '' 199 listStr: ''
168 }; 200 };
169 }, 201 },
202 watch: {
203 showRemoveoptions(v) {
204 if (!v) {
205 this.removeInfo.type = 0;
206 }
207 }
208 },
170 methods: { 209 methods: {
171 resetConfig() { 210 resetConfig() {
172 this.$confirm('此操作将重置所有数据,是否继续?', '提示', { 211 const type = this.removeInfo.type;
212 this.$confirm('此操作将重置所选数据,是否继续?', '提示', {
173 confirmButtonText: '确定', 213 confirmButtonText: '确定',
174 cancelButtonText: '取消', 214 cancelButtonText: '取消',
175 type: 'warning' 215 type: 'warning'
176 }) 216 })
177 .then(() => { 217 .then(() => {
178 clearData(); 218 switch (type) {
179 this.$store.commit('setClearStore'); 219 case 0:
180 database.clear(DB_STORE_NAME); 220 clearData();
221 this.$store.commit('setClearStore');
222 database.clear(DB_STORE_NAME);
223 break;
224 case 1:
225 removeData(configField);
226 this.$store.commit('setClearConfig');
227 break;
228 case 2:
229 removeData(listField);
230 this.$store.commit('setClearList');
231 break;
232 case 3:
233 database.clear(DB_STORE_NAME);
234 this.$store.commit('setClearPhotos');
235 break;
236 case 4:
237 removeData(resultField);
238 this.$store.commit('setClearResult');
239 break;
240 default:
241 break;
242 }
243
181 this.closeRes && this.closeRes(); 244 this.closeRes && this.closeRes();
245
246 this.showRemoveoptions = false;
182 this.$message({ 247 this.$message({
183 type: 'success', 248 type: 'success',
184 message: '重置成功!' 249 message: '重置成功!'
...@@ -293,4 +358,15 @@ export default { ...@@ -293,4 +358,15 @@ export default {
293 text-align: center; 358 text-align: center;
294 } 359 }
295 } 360 }
361 .c-removeoptions {
362 .el-dialog {
363 height: 290px;
364 }
365 .el-radio.is-bordered + .el-radio.is-bordered {
366 margin-left: 0px;
367 }
368 .el-radio.is-bordered {
369 margin-bottom: 10px;
370 }
371 }
296 </style> 372 </style>
......
...@@ -34,6 +34,35 @@ export default new Vuex.Store({ ...@@ -34,6 +34,35 @@ export default new Vuex.Store({
34 photos: [] 34 photos: []
35 }, 35 },
36 mutations: { 36 mutations: {
37 setClearConfig(state) {
38 state.config = {
39 name: '年会抽奖',
40 number: 70,
41 specialAward: 0,
42 firstPrize: 1,
43 secondPrize: 5,
44 thirdPrize: 8,
45 fourthPrize: 10,
46 fifthPrize: 20
47 };
48 state.newLottery = [];
49 },
50 setClearList(state) {
51 state.list = [];
52 },
53 setClearPhotos(state) {
54 state.photos = [];
55 },
56 setClearResult(state) {
57 state.result = {
58 specialAward: [],
59 firstPrize: [],
60 secondPrize: [],
61 thirdPrize: [],
62 fourthPrize: [],
63 fifthPrize: []
64 };
65 },
37 setClearStore(state) { 66 setClearStore(state) {
38 state.config = { 67 state.config = {
39 name: '年会抽奖', 68 name: '年会抽奖',
......