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
<template>
<div class="sms">
<el-form ref="searchFrom" :model="searchFrom" label-width="100px" inline>
<el-form-item label="类型">
<el-select v-model="searchFrom.type" placeholder="请选择" @change="getList" clearable>
<el-option
v-for="item in TypeList"
:key="item.status"
:label="item.value"
:value="item.status">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="手机号">
<el-input v-model="searchFrom.mobile" @change="getList"></el-input>
</el-form-item>
<el-form-item label="发送结果">
<el-select v-model="searchFrom.status" placeholder="请选择" @change="getList" clearable>
<el-option
v-for="item in useTypeList"
:key="item.status"
:label="item.value"
:value="item.status">
</el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="getList">搜索</el-button>
</el-form-item>
</el-form>
<el-table
:data="list"
style="width: 100%">
<el-table-column
prop="mobile"
label="手机号">
</el-table-column>
<el-table-column
prop="sms_code"
label="短信验证码">
</el-table-column>
<el-table-column
prop="nickname"
label="发送人">
</el-table-column>
<el-table-column
label="发送结果">
<template slot-scope="scope">
<div v-if="scope.row.status==0">
{{scope.row.status | filterStatus}}
</div>
<div v-if="scope.row.status != 0">
{{scope.row.status | filterStatus}} / {{scope.row.result}}
</div>
</template>
</el-table-column>
<el-table-column
prop="created_at"
label="发送时间" sortable>
</el-table-column>
</el-table>
<page :nowPage="nowPage" :total="total" @pageChange="onPageChange" @sizeChange="onSizeChange"/>
</div>
</template>
<script>
import page from '../framework/page'
import {getsmsRecordApi} from "../../service/api";
export default {
name: "smsRecord",
components:{
page
},
data(){
return {
nowPage: 1,
total: 0,
limit: 10,
useTypeList:[
{
status:0,
value:'发送成功'
},
{
status:1,
value:'发送失败'
},
],
TypeList:[
{
status:1,
value:'注册验证码'
},
],
searchFrom: {
type: '',
mobile:'',
status:''
},
list: []
}
},
filters:{
filterStatus:function (value) {
let msg = '';
if(value === 0){
msg = '发送成功'
}else{
msg = '发送失败'
}
return msg;
}
},
mounted(){
this.getList()
},
methods: {
onPageChange(val){
this.nowPage = val;
this.getList()
},
onSizeChange(val){
this.nowPage = 1;
this.limit = val;
this.getList()
},
getList(){
let json = {
limit: this.limit,
page: this.nowPage,
};
if(this.searchFrom.type){
json.type = this.searchFrom.type
}
if(this.searchFrom.status || this.searchFrom.status==0){
json.status = this.searchFrom.status
}
if(this.searchFrom.mobile){
json.mobile = this.searchFrom.mobile
}
getsmsRecordApi(json).then((res)=>{
console.log(res.list)
this.total = res.total;
this.list = res.list ? res.list : []
})
}
}
}
</script>
<style scoped>
.sms{
padding: 20px 0;
}
.avatar {
width:50px;
height: 50px;
border-radius: 50%;
}
</style>
<style>
.userInfo >div{
display: flex;
flex-flow: row nowrap;
justify-content: flex-start;
align-items: center;
}
</style>