chatListClassTab.vue
7.02 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
228
229
230
231
232
233
234
235
236
237
238
<template>
<div class="chatListClassTab" v-loading="loading">
<el-date-picker
v-model="dateRange"
type="daterange"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
align="right"
@change="getList(1)"
></el-date-picker>
<div class="list">
<template v-if="list.length">
<chatList :queryChat="queryChat" v-if="'all,image,video,link,'.includes(type)" :data="list"></chatList>
<el-table
v-else-if="type == 'file'"
:data="list"
stripe
style="width: 100%;"
:header-cell-style="{ background: '#fff' }"
>
<!-- <el-table-column prop="msgtype" label="类型"> </el-table-column> -->
<el-table-column label="名称">
<template slot-scope="{ row }">
{{ JSON.parse(row.contact).filename }}
</template>
</el-table-column>
<el-table-column label="大小">
<template slot-scope="{ row }">
{{ filterSize(JSON.parse(row.contact).filesize) }}
</template>
</el-table-column>
<el-table-column label="来源">
<template slot-scope="{ row }">
{{ row.name }}
</template>
</el-table-column>
<el-table-column label="发送时间">
<template slot-scope="{ row }">
{{ row.msgTime }}
</template>
</el-table-column>
<el-table-column prop="action" label="操作">
<template slot-scope="{ row }">
<el-button type="text" @click="downloadFile(row)">下载</el-button>
</template>
</el-table-column>
</el-table>
<el-table
v-else-if="'voice,meeting_voice_call'.includes(type)"
:data="list"
stripe
:header-cell-style="{ background: '#fff' }"
>
<el-table-column prop="date" label="发起人">
<template slot-scope="{ row }">
{{ row.name }}
</template>
</el-table-column>
<el-table-column prop="name" label="通话时间">
<template slot-scope="{ row }">
{{ row.msgTime }}
</template>
</el-table-column>
<el-table-column prop="address" label="时长" min-width="50">
<template slot-scope="{ row }">
<span v-if="row.msgType == 'voice'">{{ JSON.parse(row.contact).play_length }}s</span>
<span v-else>
{{ setDate(JSON.parse(row.contact).endtime, row.msgTime) }}
</span>
</template>
</el-table-column>
<el-table-column prop="msgType" label="类型">
<template slot-scope="{ row }">
{{ row.msgType === 'voice' ? '语音消息' : '语音通话' }}
</template>
</el-table-column>
<el-table-column prop="address" min-width="80" label="操作">
<template slot-scope="{ row }">
<!-- <el-button
type="text"
@click="voiceLook(JSON.parse(row.contact))"
>查看</el-button
> -->
<!-- <AudioPlayer
:audio-list="[JSON.parse(row.contact).attachment]"
ref="AudioPlayer"
/> -->
<voice :amrUrl="JSON.parse(row.contact)['attachment']"></voice>
<!-- <audio controls>
<source :src="JSON.parse(row.contact).attachment" type="audio/mpeg" />
</audio> -->
</template>
</el-table-column>
</el-table>
</template>
<el-empty v-else :image-size="100"></el-empty>
</div>
<el-pagination
v-if="total"
layout="prev, pager, next"
:current-page.sync="currentPage"
@current-change="getList"
:total="total"
/>
</div>
</template>
<script>
import chatList from './chatList.vue'
import * as api from '@/api/conversation/content.js'
import Voice from '@/components/Voice'
import { download } from '@/api/common.js'
import { diffDate } from '@/utils/index'
import { parseTime } from '@/utils/common'
export default {
name: '',
components: { chatList, Voice },
props: {
// 消息收发者
queryChat: {
type: Object,
default: () => ({})
},
// 消息类型
type: {
type: String | Number,
default: 0
}
},
data() {
return {
loading: false,
currentPage: 1,
dateRange: [],
list: [],
total: 0
}
},
computed: {},
watch: {
queryChat() {
this.getList(1)
}
},
created() {
this.getList(1)
},
mounted() {},
methods: {
setDate(start, end) {
return diffDate(end, parseTime(start))
},
getList(page) {
// if (!this.queryChat.fromId) {
// return //没有选择人
// }
this.loading = true
console.log(this.type)
let query = {
msgType: this.type == 'all' ? '' : this.type,
pageSize: '10',
orderByColumn: 't.msg_time',
isAsc: 'desc'
}
if (this.dateRange) {
query.beginTime = this.dateRange[0]
query.endTime = this.dateRange[1]
} else {
query.beginTime = ''
query.endTime = ''
}
page && (query.pageNum = this.currentPage = page)
Object.assign(query, this.queryChat)
api
.getChatList(query)
.then((res) => {
this.total = ~~res.total
this.list = res.rows
this.loading = false
})
.catch((err) => {
this.loading = false
})
},
filterSize(size) {
if (!size) return ''
if (size < pow1024(1)) return size + ' B'
if (size < pow1024(2)) return (size / pow1024(1)).toFixed(2) + ' KB'
if (size < pow1024(3)) return (size / pow1024(2)).toFixed(2) + ' MB'
if (size < pow1024(4)) return (size / pow1024(3)).toFixed(2) + ' GB'
return (size / pow1024(4)).toFixed(2) + ' TB'
function pow1024(num) {
return Math.pow(1024, num)
}
},
downloadFile(row) {
this.$confirm('是否确认下载该文件?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then((response) => {
this.downloadNet(JSON.parse(row.contact).attachment, JSON.parse(row.contact).filename)
})
.catch(function () {})
}
}
}
</script>
<style lang="scss" scoped>
.list {
height: calc(100vh - 420px);
margin-top: 10px;
background: white;
overflow-y: scroll;
border-bottom: 1px solid #efefef;
color: #999;
text-align: center;
::-webkit-scrollbar {
display: none;
}
}
.chatListClassTab {
padding: 10px 10px 0;
background: #fff;
text-align: left;
}
</style>