index.vue
7.65 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
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
<template>
<div class="container">
<GLCombiForm :formObj="searchForm" :rowNumber="1" :formData="searchFormData" @handleOk="handleSearch"
@handleRest="handleReset"></GLCombiForm>
<div class="table-header">
<div class="header-text">已激活列表</div>
<div>
<el-button class="table-btn" @click="handleqrCode" :size="size" type="primary" plain mode="el-button">
企微接入授权
</el-button>
</div>
</div>
<GLTable ref="activeTable" :noDataImg="url" :getListApi="getListApi" :searchForm="searchForm"
:tableParams="tableParams" :pageConf="pageConf" @setTableFinishFun="setTableFinishFun">
<div slot="staffName" slot-scope="scope">
<div class="staffName">
<span>{{ scope.scope.staffName }}</span>
<span class="entmicroName" v-if="scope.scope.entmicroName">@{{ scope.scope.entmicroName }}</span>
</div>
</div>
<div slot="loginStatus" slot-scope="scope">
<div class="loginStatus">
<span class="cycle"
:style="{ background: scope.scope.loginStatus == '1' ? '#2CCA74' : scope.scope.loginStatus == '0' ? '#999999' : '' }"></span>
{{ scope.scope.loginStatus == '1' ? '在线' : scope.scope.loginStatus == '0' ? '离线' : '--' }}
</div>
</div>
</GLTable>
<GLDialog :title="'授权登入二维码'" mode="small" :visible.sync="qrCodeVisible">
<div v-loading="addLoading" class="qrIMGbox">
<img class="qrIMG" :src="qrcodeUrl"/>
</div>
<span slot="footer" class="dialog-footer">
<el-button size="small" disabled v-if="!show" class="count">{{ count }} s</el-button>
<el-button type="primary" size="small" v-if="show" @click="getCode">刷新</el-button>
</span>
</GLDialog>
</div>
</template>
<script>
import url from '@/assets/empty.png'
import setPromiseInterval, { clearPromiseInterval } from 'set-promise-interval'
import {utils} from 'glsx-common'
export default {
name: 'collocation',
data() {
return {
url,
show: true,
count: '',
timer: null,
verifyQRCodeFailsToOpen: false,
addLoading: false,
qrCodeInterval: null,
qrCodeIntervalList: [],
qrcodeUrl: '',
qrCodeVisible: false,
qrcodeId: '',
searchForm: {
loginStatus: ''
},
searchFormData: [
{
label: '所属企微',
name: 'entmicroName',
type: 'input',
isClear: true
},
{
label: '员工姓名',
name: 'staffName',
type: 'input',
isClear: true
},
{
label: '手机号码',
name: 'staffPhone',
type: 'input',
isClear: true
},
{
label: '状态',
name: 'loginStatus',
type: 'select',
optionList: [
{
label: '全部',
value: ''
},
{
label: '在线',
value: 1
},
{
label: '离线',
value: 0
}
],
optionId: 'value',
optionLabel: 'label',
isClear: true
}
],
tableParams: {
listName: 'data',
tableColumns: [
{
label: '员工企微',
prop: 'staffName',
addHtml: 'staffName',
minwidth: 110
},
{
label: '手机号码',
prop: 'staffPhone',
minwidth: 110
},
{
label: '所属门店',
prop: 'merchantName',
minwidth: 110
},
{
label: '最后同步时间',
prop: 'lastLoginTime',
minwidth: 110
},
{
label: '状态',
prop: 'loginStatus',
addHtml: 'loginStatus',
minwidth: 110
}
]
},
pageConf: {pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'count'},
getListApi: this.$apis.collocation.wechatDepositList
}
},
methods: {
handleSearch() {
this.$refs.activeTable.refreshTable()
},
// 重置搜索框搜索
handleReset() {
this.searchForm = {}
this.handleSearch()
},
setTableFinishFun() {
//接收到的数据为空
this.$refs.activeTable.data.length ? (this.$refs.activeTable.tableHeightValues = '') : this.$refs.activeTable.setTableHeightFun()
},
async handleqrCode() {
this.addLoading = true
this.qrCodeVisible = true
this.verifyQRCodeFailsToOpen = false
await this.$apis.collocation
.getLoginQcCode({})
.then(res => {
this.addLoading = false
;(this.verifyQRCodeFailsToOpen = true), (this.qrcodeUrl = `data:image/png;base64,${res.qcCodeUrl}`)
this.qrcodeId = res.id
})
.catch(err => {
this.qrCodeVisible = false
this.clearAllInterval()
})
},
clearAllInterval() {
console.log(this.qrCodeIntervalList)
this.qrCodeIntervalList.length && this.qrCodeIntervalList.forEach(item => {
clearInterval(item)
})
clearPromiseInterval(this.qrCodeInterval)
this.qrCodeIntervalList = [];
this.qrCodeInterval = null;
},
verifyQRCodeIsInvalid() {
this.qrCodeInterval = setPromiseInterval(() => this.qrcodeTimeoutApi(), 15000)
this.qrCodeIntervalList.push(this.qrCodeInterval)
},
getCode() {
this.clearAllInterval()
this.handleqrCode()
const TIME_COUNT = 10;
if (!this.timer) {
this.count = TIME_COUNT;
this.show = false;
this.timer = setInterval(() => {
if (this.count > 0 && this.count <= TIME_COUNT) {
this.count--;
} else {
this.show = true;
clearInterval(this.timer);
this.timer = null;
}
}, 1000)
}
},
async qrcodeTimeoutApi() {
await this.$apis.collocation.getQcCodeDetail({id: this.qrcodeId}).then(res => {
if (res == true) {
this.$message({
type: 'error',
message: '二维码已失效,请刷新'
})
this.verifyQRCodeFailsToOpen = false
clearInterval(this.qrCodeInterval)
return
}
})
}
},
computed: {
listenChange() {
const {verifyQRCodeFailsToOpen, qrCodeVisible} = this
return {verifyQRCodeFailsToOpen, qrCodeVisible}
}
},
watch: {
listenChange(val) {
if (val.qrCodeVisible == true && val.verifyQRCodeFailsToOpen == true) {
this.verifyQRCodeIsInvalid()
} else {
this.clearAllInterval()
}
}
}
}
</script>
<style lang="scss" scoped>
/deep/ {
.el-table th > .cell {
padding: 0 16px;
}
}
.container {
padding: 20px;
background-color: #fff;
.table-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 10px;
.header-text {
font-size: 16px;
color: #333333;
font-weight: 600;
}
}
.table-btn {
color: #5850ff;
border: 1px solid #5850ff;
}
.qrIMGbox {
display: flex;
align-items: center;
justify-content: center;
.qrIMG {
width: 150px;
height: 150px;
}
}
/deep/ .loginStatus {
display: flex;
align-items: center;
.cycle {
margin-right: 8px;
width: 6px;
height: 6px;
display: inline-block;
border-radius: 50%;
}
}
.staffName {
display: flex;
align-items: center;
.entmicroName {
font-size: 12px;
color: #fb8f28;
}
}
}
</style>