SnapshotRecord.vue
13.5 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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
<template>
<a-form :model="queryForm" layout="inline" :label-col="{ style: { width: '70px' } }">
<a-form-item label="集团:" style="padding: 5px 0">
<a-select v-model:value="queryForm.account_id" style="width: 280px" mode="multiple" :maxTagCount="1"
@change="onAccountChange" :options="accountList" optionFilterProp="label" show-search>
</a-select>
</a-form-item>
<a-form-item label="广场:" style="padding: 5px 0">
<a-select v-model:value="queryForm.plaza_id" style="width: 280px" mode="multiple" :maxTagCount="1"
@change="onPlazaChange" :options="plazaList" optionFilterProp="label" show-search>
</a-select>
</a-form-item>
<a-form-item label="区域信息:" style="padding: 5px 0">
<a-select v-model:value="queryForm.zone_id" style="width: 280px" mode="multiple" :maxTagCount="1"
@change="onZoneChange" :options="zoneList" optionFilterProp="label" show-search>
</a-select>
</a-form-item>
<a-form-item label="监控点:" style="padding: 5px 0">
<a-select v-model:value="queryForm.gate_id" style="width: 280px" mode="multiple" :maxTagCount="1"
:options="gateList" optionFilterProp="label" show-search>
</a-select>
</a-form-item>
<a-form-item label="选择日期:" style="padding: 5px 0">
<a-date-picker v-model:value="queryForm.date" :format="'YYYY-MM-DD'" style="width: 280px" />
</a-form-item>
<a-form-item label="选择时间:" style="padding: 5px 0">
<a-time-picker v-model:value="queryForm.startTime" style="width: 140px" />
<span style="padding: 0 4px">至</span>
<a-time-picker v-model:value="queryForm.endTime" style="width: 140px" />
</a-form-item>
<a-form-item style="padding: 5px 0">
<a-button type="primary" @click="clickSearch" :loading="isLoading">查询</a-button>
</a-form-item>
<a-form-item style="padding: 5px 0">
<a-upload :file-list="fileList" :before-upload="beforeUpload">
<a-button type="primary">
<upload-outlined></upload-outlined>
导入
</a-button>
</a-upload>
</a-form-item>
<a-form-item style="padding: 5px 0">
<a-button type="primary" @click="deleteBatches">删除</a-button>
</a-form-item>
</a-form>
<div v-loading="isLoading">
<div class="resultContent" :style="{'height':contentHeight+'px'}">
<el-row v-for="row in pagedTableDataList">
<el-col :span="3" v-for="item in row">
<div style="margin: 0 5px;cursor: pointer;" @click="handleClick(item)" :class="currentItemId==item.id?'actived':''">
<el-image :src="item.picture_url" :fit="'fill'" class="single-image">
</el-image>
<div style="width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">unid:{{ item.unid }}</div>
<div>时间:{{ item.counttime }}</div>
<div>性别:{{ formatGender(item.gender) }}({{item.age}})</div>
<div>地点:{{ item.gate_name }}</div>
</div>
</el-col>
</el-row>
</div>
<a-pagination v-model:current="pageNum" v-model:pageSize="pageSize" :total="total"
:show-total="total => `共 ${total} 条`" :pageSizeOptions="['24', '48', '96', '192']" @change="onPageNumChange"
@showSizeChange="onPageSizeChange" show-size-changer show-quick-jumper style="text-align:center" />
</div>
<DetailDialog ref="DetailDialogRef" />
</template>
<script>
import {
computed,
reactive,
ref,
toRaw
} from 'vue'
import snapshotRecordApi from '@/views/TestDriveHospitality/SnapshotRecord/SnapshotRecordApi'
import {
isArray
} from '@/PublicUtil/Judgment'
import moment from 'moment'
import {
filterEmptyValueInObject,
formatDate,
formatTime,
getPagedList
} from '@/PublicUtil/PublicUtil'
// import imgDialog from '../imgDialog.vue'
import {
ElMessage,
ElMessageBox
} from 'element-plus'
import Cookies from "js-cookie"
import DetailDialog from "../../ComparisonCapturedPictures/DetailDialog.vue";
export default {
components: {
// imgDialog ,
DetailDialog
},
setup() {
// scalar
const pageNum = ref(1)
const pageSize = ref(24)
const total = ref()
const isLoading = ref(false)
// sequence
const dataList = ref([])
const accountList = ref([])
const plazaList = ref([])
const zoneList = ref([])
const gateList = ref([])
const currentItemId = ref()
const currobj = ref({})
const DetailDialogRef = ref();
const pagedTableDataList = computed(
() => {
return getPagedList(dataList.value, 8)
}
)
const queryForm = reactive({
account_id: [],
plaza_id: [],
zone_id: [],
gate_id: [],
date: moment(moment().format('YYYY-MM-DD'), 'YYYY-MM-DD'),
startTime: moment('00:00:00', 'HH:mm:ss'),
endTime: moment('23:59:59', 'HH:mm:ss'),
})
const searchCondition = ref({})
if (window.localStorage.getItem('searchCondition')) {
searchCondition.value = JSON.parse(window.localStorage.getItem('searchCondition'));
queryForm.account_id = searchCondition.value.account_id;
queryForm.plaza_id = searchCondition.value.plaza_id;
queryForm.zone_id = searchCondition.value.zone_id;
queryForm.gate_id = searchCondition.value.gate_id;
queryForm.date = searchCondition.value.date;
// queryForm.startTime = searchCondition.value.startTime;
// queryForm.endTime = searchCondition.value.endTime;
}
const onPageNumChange = function(num) {
pageNum.value = num
confirmSearch()
}
const onPageSizeChange = function(current, size) {
pageNum.value = 1
pageSize.value = size
confirmSearch()
}
const onAccountChange = function() {
getPlazaList(1)
}
const onPlazaChange = function() {
getZoneList()
getGateList()
}
const onZoneChange = function() {
getGateList()
}
const getPlazaList = function(val) {
queryForm.plaza_id = []
plazaList.value = []
snapshotRecordApi.getPlazaList({
account_id: queryForm.account_id.toString()
}).then(
(r) => {
if (isArray(r)) {
for (const item of r) {
plazaList.value.push({
value: item.id,
label: item.name,
})
}
if (plazaList.value.length) {
if (!val && searchCondition.value.plaza_id && searchCondition.value.plaza_id.length > 0) {
queryForm.plaza_id = searchCondition.value.plaza_id
} else {
queryForm.plaza_id.push(plazaList.value[0].value)
}
getZoneList(1)
getGateList(1)
confirmSearch()
}
}
}
)
}
const getZoneList = function(val) {
queryForm.zone_id = []
zoneList.value = []
snapshotRecordApi.getZoneList({
account_id: queryForm.account_id.toString(),
plaza_id: queryForm.plaza_id.toString(),
}).then(
(r) => {
if (isArray(r)) {
for (const item of r) {
zoneList.value.push({
value: item.id,
label: item.name,
})
}
if (zoneList.value.length) {
if (val && searchCondition.value.zone_id && searchCondition.value.zone_id.length > 0) {
queryForm.zone_id = searchCondition.value.zone_id
} else {
queryForm.zone_id = []
}
} else {
queryForm.zone_id = []
}
}
}
)
}
const getGateList = function(val) {
gateList.value = []
snapshotRecordApi.getGateList({
account_id: queryForm.account_id.toString(),
plaza_id: queryForm.plaza_id.toString(),
zone_id: queryForm.zone_id.toString(),
type:0,
}).then(
(r) => {
if (isArray(r.data)) {
for (const item of r.data) {
gateList.value.push({
value: item.id,
label: item.name,
})
}
if (gateList.value.length) {
if (val && searchCondition.value.gate_id && searchCondition.value.gate_id.length > 0) {
queryForm.gate_id = searchCondition.value.gate_id
} else {
queryForm.gate_id = []
}
} else {
queryForm.gate_id = []
}
}
}
)
}
const getAccountList = function() {
queryForm.account_id = []
accountList.value = []
snapshotRecordApi.getAccountList().then(
(r) => {
if (isArray(r)) {
for (const item of r) {
accountList.value.push({
value: item.id,
label: item.name,
})
}
if (accountList.value.length) {
if (searchCondition.value.account_id && searchCondition.value.account_id.length > 0) {
queryForm.account_id = searchCondition.value.account_id
} else {
queryForm.account_id.push(accountList.value[0].value)
}
getPlazaList()
}
}
}
)
}
const confirmSearch = function() {
isLoading.value = true
const rawData = toRaw(queryForm)
console.log(rawData)
const data = filterEmptyValueInObject({
mallId: rawData.plaza_id?rawData.plaza_id.toString():'',
zoneIds: rawData.zone_id?rawData.zone_id.toString():'',
gateIds: rawData.gate_id?rawData.gate_id.toString():'',
startTime: formatDate(rawData.date) + ' ' + formatTime(rawData.startTime),
endTime: formatDate(rawData.date) + ' ' + formatTime(rawData.endTime),
pageNum: pageNum.value - 1,
pageSize: pageSize.value,
})
const storageData = filterEmptyValueInObject({
account_id: rawData.account_id,
plaza_id: rawData.plaza_id,
zone_id: rawData.zone_id,
gate_id: rawData.gate_id,
date: rawData.date,
startTime: rawData.startTime,
endTime: rawData.endTime,
})
let searchCondition = JSON.parse(window.localStorage.getItem('searchCondition'));
let newSearchCondition = {
...searchCondition,
...storageData
}
window.localStorage.setItem('searchCondition',JSON.stringify(newSearchCondition))
snapshotRecordApi.getSnapshotRecordList(data).then(
(r) => {
isLoading.value = false
r.data.pageData.forEach((item) => {
if (item.features_url) {
item.features_url = window._baseImgUrl + item.features_url
}
if (item.picture_url) {
item.picture_url = window._baseImgUrl + item.picture_url
}
if (item.track_url) {
item.track_url = window._baseImgUrl + item.track_url
}
})
dataList.value = r.data.pageData
total.value = r.data.total
document.getElementsByClassName('resultContent')[0].scrollTop = 0
}
)
}
const formatGender = function(number) {
switch (number) {
case 1: {
return '男'
}
case -1: {
return '未知'
}
case 0: {
return '女'
}
default: {
break
}
}
}
const handleClick = function(data) {
currentItemId.value = data.id
currobj.value = data;
}
const comparativeFun = function() {
if (currobj.value == {}) {
ElMessage({
message: `请选择图片进行对比验证`,
type: 'warning'
});
return false
}
if (!currobj.value.picture_url) {
ElMessage({
message: `该图片没有特征,请选择有效的图片`,
type: 'warning'
})
return
}
const rawData = toRaw(queryForm)
let parmas = {
plaza_id: currobj.value.mall_id,
pic_type: rawData.picType,
pic_id: currobj.value.id,
ip: window._baseImgUrl,
countdate: formatDate(rawData.date)
}
DetailDialogRef.value.initDialog(currobj.value, parmas);
}
const clickSearch = function() {
pageNum.value = 1
confirmSearch()
}
// 删除试乘记录
const deleteBatches = function() {
if (!currentItemId.value) {
ElMessage({
message: `请选择图片`,
type: 'warning'
})
return
}
if (!currobj.value.picture_url) {
ElMessage({
message: `请选择有效的图片`,
type: 'warning'
})
return
}
ElMessageBox.confirm('是否确认删除该试乘记录?', {
confirmButtonText: '确认',
cancelButtonText: '取消',
}).then(() => {
snapshotRecordApi.deleteOneDrive({
id: currentItemId.value
}).then(
(res) => {
console.log(res)
if (res.code == 200) {
ElMessage({
message: `删除成功`,
type: 'success'
})
confirmSearch()
currentItemId.value = ''
currobj.value = {};
} else {
ElMessage({
message: `删除失败`,
type: 'warning'
})
}
}
)
}).catch(() => {})
}
const contentHeight = ref(0)
const __main = function() {
getAccountList()
contentHeight.value = window.innerHeight - 310
}
const fileList = ([]);
const beforeUpload= function(file) {
const formData = new FormData();
formData.append('file', file);
snapshotRecordApi.uploadDrive(formData).then((res) => {
if (res.code == 200) {
ElMessage({
message: `上传成功`,
type: 'success'
})
clickSearch()
} else {
ElMessage({
message: `上传失败`,
type: 'warning'
})
}
})
return false;
};
__main()
return {
beforeUpload,
fileList,
isLoading,
pageNum,
pageSize,
total,
currobj,
accountList,
plazaList,
zoneList,
gateList,
pagedTableDataList,
currentItemId,
contentHeight,
queryForm,
onPageNumChange,
onPageSizeChange,
onAccountChange,
onPlazaChange,
onZoneChange,
confirmSearch,
handleClick,
comparativeFun,
formatGender,
clickSearch,
deleteBatches,
DetailDialogRef,
}
}
}
</script>
<style lang="less" scoped>
@import "./SnapshotRecord";
.actived {
border: 3px solid #1890ff;
}
.resultContent {
overflow: auto;
min-height: 500px;
}
.downBtn {
color: #409EFF;
font-size: 15px;
cursor: pointer;
display: inline-block;
width: auto;
}
.downBtn1 {
float: right;
}
</style>