Result.vue
3.3 KB
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
<template>
<el-dialog
:visible="visible"
@close="$emit('update:visible', false)"
width="600px"
class="c-Result"
>
<div class="dialog-title" slot="title">
<span :style="{ fontSize: '18px' }">
抽奖结果
</span>
<span :style="{ fontSize: '14px', color: '#999', marginLeft: '10px' }">
(点击号码可以删除)
</span>
</div>
<div
v-for="(item, index) in resultList"
:key="index"
class="listrow"
@click="
event => {
deleteRes(event, item);
}
"
>
<span class="name">
{{ item.name }}
</span>
<span class="value">
<span v-if="item.value && item.value.length === 0">
暂未抽奖
</span>
<span
class="card"
v-for="(data, j) in item.value"
:key="j"
:data-res="data"
>
{{ data }}
</span>
</span>
</div>
</el-dialog>
</template>
<script>
import { conversionCategoryName, getDomData } from '@/helper/index';
export default {
name: 'c-Result',
props: {
visible: Boolean
},
computed: {
result: {
get() {
return this.$store.state.result;
},
set(val) {
this.$store.commit('setResult', val);
}
},
resultList() {
const list = [];
for (const key in this.result) {
if (this.result.hasOwnProperty(key)) {
const element = this.result[key];
let name = conversionCategoryName(key);
list.push({
label: key,
name,
value: element
});
}
}
return list;
}
},
methods: {
deleteRes(event, row) {
const Index = getDomData(event.target, 'res');
if (!Index) {
return;
}
this.$confirm('此操作将移除该中奖号码,确认删除?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
if (Index) {
const result = this.result;
result[row.label] = this.result[row.label].filter(
item => item !== Number(Index)
);
this.result = result;
this.$message({
type: 'success',
message: '删除成功!'
});
}
})
.catch(() => {
this.$message({
type: 'info',
message: '已取消'
});
});
}
}
};
</script>
<style lang="scss">
.c-Result {
.listrow {
display: flex;
line-height: 30px;
.name {
width: 80px;
font-weight: bold;
}
.value {
flex: 1;
}
.card {
display: inline-block;
width: 40px;
height: 40px;
line-height: 40px;
text-align: center;
font-size: 18px;
font-weight: bold;
border-radius: 4px;
border: 1px solid #ccc;
background-color: #f2f2f2;
margin-left: 5px;
margin-top: 5px;
position: relative;
cursor: pointer;
&:hover {
&::before {
content: '删除';
width: 100%;
height: 100%;
background-color: #ccc;
position: absolute;
left: 0;
top: 0;
color: red;
}
}
}
}
}
</style>