index.vue
6.4 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
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
<template>
<section class="checkcode-container">
<!--工具条-->
<div class="toolbar">
<el-input width="200" v-model="filters.openid" placeholder="请输入用户openid"></el-input>
<el-switch
style="display: block"
v-model="switchValue"
active-color="#13ce66"
inactive-color="#ff4949"
active-text="只看发送失败"
inactive-text="全部结果"
></el-switch>
<el-button type="primary" :disabled="loading" v-on:click="reqGetDrawsnQuery">查询</el-button>
</div>
<template>
<div class="app-container" v-for="(application,index) in applications" :key="index">
<h3>{{application.appName}} {{application.appDir}}</h3>
<el-table
class="table"
highlight-current-row
v-loading="application.loading || loading"
:data="application.list"
>
<el-table-column label="openid" prop="openid"></el-table-column>
<el-table-column label="头像">
<template slot-scope="scope">
<div class="avatar">
<img v-show="scope.row.avatar" :src="scope.row.avatar" />
</div>
</template>
</el-table-column>
<el-table-column label="昵称" prop="nickname"></el-table-column>
<el-table-column label="串码" prop="drawSn"></el-table-column>
<el-table-column label="奖品名称" prop="prizeName"></el-table-column>
<el-table-column label="派发结果">
<template slot-scope="scope">
<el-tag type="success" v-if="scope.row.sendSuccess == 1">成功</el-tag>
<el-tooltip
v-if="scope.row.sendSuccess == 0"
class="item"
effect="dark"
:content="scope.row.failureReason"
placement="top-start"
>
<el-tag type="danger">失败</el-tag>
</el-tooltip>
</template>
</el-table-column>
<el-table-column label="中奖时间" :formatter="formatDate"></el-table-column>
<el-table-column label="派发结果">
<template slot-scope="scope">
<el-button
type="primary"
plain
v-if="scope.row.sendSuccess == 0"
@click="markSuccess(application,index,scope.row)"
:disabled="loading"
>标记成功</el-button>
</template>
</el-table-column>
</el-table>
<div class="tips">*标记成功的数据将于当日发送到portal平台</div>
</div>
</template>
<!--列表-->
<!-- <template>
<el-table
class="table"
highlight-current-row
v-loading="loading"
style="width: 100%;"
>
<el-table-column label="头像">
<template slot-scope="scope">
<div class="avatar">
<img v-show="scope.row.avatar" :src="scope.row.avatar" />
</div>
</template>
</el-table-column>
</el-table>
</template>-->
</section>
</template>
<script>
Date.prototype.format = function(fmt) {
var o = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
"h+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
S: this.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt))
fmt = fmt.replace(
RegExp.$1,
(this.getFullYear() + "").substr(4 - RegExp.$1.length)
);
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt))
fmt = fmt.replace(
RegExp.$1,
RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)
);
return fmt;
};
let urls = {
applications: "/admin/kd/application/available",
query: "/admin/kd/record/query",
change: "/admin/kd/record/success"
};
import { request } from "./../../api/api.js";
import { formatDate } from "./../../common/utils.js";
export default {
data() {
return {
loading: false,
filters: {
openid: "oUzSMtz0_YXWTTfi5WJfm2yqZa1I"
},
switchValue: true,
applications: [],
total: 0,
page: 1,
pageSize: 20,
searchNeedMinLength: 3
};
},
methods: {
init() {
request.get(urls.applications).then(res => {
this.applications = res.data.content;
console.log("this.applications==", this.applications);
this.applications.forEach(element => {
element.loading = false;
element.list = [];
});
});
},
markSuccess(application, index, row) {
let params = {
appCode: application.appCode,
recordCodes: [row.recordCode]
};
this.$confirm("请确保红包下发给用户后再标记成功哦!", "提示", {
confirmButtonText: "已经下发成功",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
this.loading = true;
request.post(urls.change, params).then(res => {
this.loading = false;
this._requestResult(index, application);
});
})
.catch(() => {});
},
formatDate: function(row, column) {
return row.createAt
? new Date(row.createAt).format("yyyy-MM-dd hh:mm:ss")
: "-";
},
reqGetDrawsnQuery() {
for (let index in this.applications) {
let application = this.applications[index];
this._requestResult(index, application);
}
},
_requestResult(index, application) {
let params = {
appCode: application.appCode,
onlyFailure: this.switchValue ? 1 : 0,
openid: this.filters.openid
};
application.loading = true;
this.$set(this.applications, index, application);
request.get(urls.query, params).then(res => {
application.list = res.data.content;
application.loading = false;
this.$set(this.applications, index, application);
console.log(this.applications);
});
}
},
mounted() {
this.init();
}
};
</script>
<style scoped lang="less">
.toolbar {
display: flex;
align-items: center;
}
.el-input {
width: 200px;
}
.el-switch {
margin: 0 20px;
}
.app-container {
width: 100%;
margin-top: 20px;
padding: 20px;
img {
max-width: 50px;
max-height: 50px;
}
}
.tips {
text-align: right;
color: #ff0000;
}
</style>