-
Notifications
You must be signed in to change notification settings - Fork 0
/
setting.html
executable file
·431 lines (430 loc) · 13.1 KB
/
setting.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>奖项设置</title>
<link rel="stylesheet" href="css/reset.css" />
<link rel="stylesheet" href="js/[email protected]/lib/theme-chalk/index.css" />
<script src="js/polyfill.min.js"></script>
<script src="js/vue.min.js"></script>
<script src="js/[email protected]/lib/index.js"></script>
<style>
.el-input {
width: 120px;
}
.el-table {
margin-bottom: 10px;
}
* {
cursor: initial;
}
.awards,
.members {
width: 80%;
margin: auto;
margin-top: 50px;
}
h1 {
font-size: 30px;
text-align: center;
line-height: 1.5;
margin-bottom: 20px;
}
h1 span {
font-size: 16px;
}
a {
text-decoration: underline;
cursor: pointer;
}
</style>
</head>
<body>
<div id="app">
<div class="awards">
<h1>奖项设置 <span>(请按抽奖顺序添加)</span></h1>
<el-table :data="tableData" style="width: 100%">
<el-table-column
:prop="item.prop"
:label="item.label"
width="180"
v-for="(item, index) in columns"
:key="index"
>
<template slot-scope="scope">
<div>
<div v-if="scope.row.editing[item.prop]">
<el-input
size="mini"
v-model="scope.row[item.prop]"
@blur="onSaveCell(scope.row, item.prop)"
></el-input>
</div>
<div v-else @dblclick="onEditCell(scope.row, item.prop, $event)">
{{ scope.row[item.prop] || '(请填写)' }}
</div>
</div>
</template>
</el-table-column>
<el-table-column prop="address" label="操作">
<template slot-scope="scope">
<el-button
size="small"
@click="onAdd(scope.row, scope.$index)"
type="primary"
>增加</el-button
>
<el-button
size="small"
@click="onRemove(scope.row, scope.$index)"
type="danger"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<el-button
size="small"
type="primary"
@click="onAdd(null, -1)"
v-show="tableData.length===0">增加</el-button>
<span>每个奖项每次抽取人数:</span>
<el-select size="small" v-model="batchNumber" @change="onChange">
<el-option
v-for="index in 40"
:key="index"
:label="index"
:value="index"></el-option>
</el-select>
<el-button size="small" type="danger" @click="onReset">重置中奖结果</el-button>
<a href="./index.html" class="el-button el-button--success el-button--small">去抽奖 <i class="el-icon--"></i></a>
</div>
<div class="members">
<h1>参与人员列表(共{{memberSource.length}}人)</h1>
<el-table :data="memberSource" style="width: 100%" stripe>
<el-table-column
:prop="item.prop"
:label="item.label"
width="180"
v-for="(item, index) in memberColumns"
:key="index">
<template slot-scope="scope">
<div>
<div v-if="scope.row.editing[item.prop]">
<el-input
size="mini"
v-model="scope.row[item.prop]"
@blur="onSaveCell(scope.row, item.prop)"
></el-input>
</div>
<div
v-else
@dblclick="onEditCell(scope.row, item.prop, $event)">
{{ scope.row[item.prop] || '(请填写)' }}
</div>
</div>
</template>
</el-table-column>
<el-table-column prop="address" label="操作">
<template slot-scope="scope">
<el-button
size="small"
@click="onRemoveMember(scope.row, scope.$index)"
type="danger">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-form class="demo-form-inline">
<el-form-item label="参与人数">
<el-input @change="handleChange" :min="1" size="small" v-model="memberSource.length" label="参与人数"></el-input>
<el-button size="small" type="warning" @click="onImport">重置默认</el-button>
<el-button size="small" @click="onAddMember" type="primary">增加一个</el-button>
</el-form-item>
</el-form>
</div>
</div>
<script>
createMember(200);
function createMember(amount)
{
window.members = [];
for (var i = 1; i <= amount; i++) {
var item = new Array();
item['id'] = i;
item['name'] = i;
window.members.push(item);
}
}
new Vue({
el: '#app',
data: {
dialogVisible: false,
batchNumber: 20,
columns: [
{
prop: 'name',
label: '名称',
},
{
prop: 'count',
label: '数量',
},
{
prop: 'award',
label: '奖品',
},
],
memberColumns: [
{
prop: 'name',
label: '编号',
},
{
prop: 'id',
label: 'ID',
},
],
tableData: [
{
name: '特等奖',
count: 1,
editing: {},
},
{
name: '一等奖',
count: 1,
editing: {},
},
],
memberSource: [],
},
computed: {
awards: function() {
return this.tableData
.filter(function(item) {
return item.name && item.count;
})
.map(function(item) {
return {
name: item.name,
count: item.count,
award: item.award,
};
});
},
members: function() {
return this.memberSource
.filter(function(item) {
return item.name && item.id;
})
.map(function(item) {
return {
name: item.name,
id: item.id,
};
});
},
},
methods: {
onReset: function() {
this.$confirm(
'重置会清空所有抽奖结果,无法撤销!',
'确定要重置吗?',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}
).then(function() {
localStorage.removeItem('players');
localStorage.removeItem('result');
});
},
onChange: function(value) {
//console.log(value);
localStorage.setItem('batchNumber', value);
},
onSaveCell: function(row, key) {
this.$set(row.editing, key, false);
this.saveData();
},
onEditCell: function(row, key, e) {
this.$set(row.editing, key, true);
const parent = e.target.parentNode;
this.$nextTick(function() {
// console.log(parent.innerHTML, row)
parent.querySelector('input').focus();
});
},
onAdd: function(row, index) {
console.log(row, index);
this.tableData.splice(index + 1, 0, {
editing: {
name: true,
},
});
},
onRemove: function(row, index) {
this.tableData.splice(index, 1);
this.saveData();
},
onAddMember: function() {
this.memberSource.push({
editing: {
name: true,
},
});
},
handleChange(value) {
createMember(value);
this.onImport();
},
onRemoveMember: function(row, index) {
var vm = this;
this.$confirm('删除不可撤销!可重新添加', '确定删除吗?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(function() {
vm.memberSource.splice(index, 1);
vm.saveData();
});
},
onImport: function() {
var vm = this;
this.$confirm('重新导入会覆盖现有人员列表', '确定执行此操作吗?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(function() {
vm.memberSource = window.members.map(function(item) {
return {
name: item.name,
id: item.id,
editing: {},
};
});
vm.saveData();
});
},
saveData: function() {
localStorage.setItem('awards', JSON.stringify(this.awards));
localStorage.setItem('members', JSON.stringify(this.members));
localStorage.setItem(
'batchNumber',
JSON.stringify(this.batchNumber)
);
},
},
created: function() {
var awards = JSON.parse(localStorage.getItem('awards')) || [
{
name: '济南新金城影视器材',
award: '摄影双肩包',
count: 2,
},
{
name: '济南新金城影视器材',
award: '摄影人专用毛毯',
count: 10,
},
{
name: '德州市摄影家协会',
award: '高级画册',
count: 10,
},
{
name: '德州百茶舫茶业',
award: '古树滇红茶',
count: 6,
},
{
name: '德州市手机、数码相机维修中心',
award: '数码清洁套装',
count: 20,
},
{
name: '吴桥杂技大世界景区',
award: '杂技大世界门票',
count: 15,
},
{
name: '吴桥杂技大世界景区',
award: '杂技大世界门票',
count: 15,
},
{
name: '妈妈咪呀儿童摄影',
award: '儿童摄影卡',
count: 10,
},
{
name: '中国驿·泉城中华饮食文化小镇景',
award: '小镇美食卡',
count: 8,
},
{
name: '德州建志剪纸艺术中心',
award: '水晶剪纸',
count: 10,
},
{
name: '韩华子先生',
award: '收藏级字画',
count: 3,
},
{
name: '山东济南红叶谷生态文化旅游区',
award: '红叶谷门票',
count: 10,
},
{
name: '德州贵派电器有限公司',
award: '小家电',
count: 5,
},
{
name: '云游天下房车俱乐部',
award: '房车体验一日游',
count: 3,
},
{
name: '德州致雅口腔',
award: '洗牙卡',
count: 30,
},
{
name: '德州致雅口腔',
award: '高级电动牙刷',
count: 5,
},
{
name: '德州德之缘旅行社有限公司',
award: '云南双飞六日游',
count: 1,
},
];
var members = JSON.parse(localStorage.getItem('members')) || window.members;
this.batchNumber = +localStorage.getItem('batchNumber') || 20;
this.tableData = awards.map(function(item) {
return {
name: item.name,
count: item.count,
award: item.award,
editing: {},
};
});
this.memberSource = members.map(function(item) {
return {
name: item.name,
id: item.id,
editing: {},
};
});
this.saveData();
},
});
</script>
</body>
</html>