ComparisonCapturedPictures.vue
28.6 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
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
<template>
<a-row>
<a-col :span='14'>
<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: 230px" 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: 230px" 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.type" style="width: 230px">
<a-select-option :value="0">全场</a-select-option>
<a-select-option :value="1">广场出入口</a-select-option>
<a-select-option :value="2">楼层出入口</a-select-option>
<a-select-option :value="3">店铺出入口</a-select-option>
<a-select-option :value="4">其他</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="区域信息:" style="padding: 5px 0" v-if='queryForm.type==0 || queryForm.type==3'>
<a-select v-model:value="queryForm.zone_id" style="width: 230px" 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: 230px" mode="multiple" :maxTagCount="1"
:options="gateList" optionFilterProp="label" show-search>
</a-select>
</a-form-item>
<a-form-item label="方向:" style="padding: 5px 0">
<a-select v-model:value="queryForm.direction" mode="multiple" :maxTagCount="1" style="width: 230px">
<a-select-option :value="1">进</a-select-option>
<a-select-option :value="-1">出</a-select-option>
<a-select-option :value="0">横穿</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="抓拍类型:" style="padding: 5px 0">
<a-select v-model:value="queryForm.picType" style="width: 230px">
<a-select-option :value="1">半身照</a-select-option>
<a-select-option :value="2">全身照</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="人员类型:" style="padding: 5px 0">
<a-select v-model:value="queryForm.personType" mode="multiple" :maxTagCount="1"
style="width: 230px">
<a-select-option :value="1">店员</a-select-option>
<a-select-option :value="0">顾客</a-select-option>
</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: 230px" />
</a-form-item>
<a-form-item label="选择时间:" style="padding: 5px 0">
<a-time-picker v-model:value="queryForm.startTime" style="width: 120px" />
<a-time-picker v-model:value="queryForm.endTime" style="width: 120px" />
</a-form-item>
<a-form-item label="图片数量:" style="padding: 5px 0">
<a-input-number v-model:value="queryForm.minPic" :min="0" style="width: 100px"/>至
<a-input-number v-model:value="queryForm.maxPic" :min="0" style="width: 100px"/>
</a-form-item>
<a-form-item style="padding: 5px 0">
<a-button type="primary" @click="confirmSearch" :loading="isLoading">查询</a-button>
</a-form-item>
</a-form>
<div v-loading="isLoading">
<a-row v-for="row in pagedTableDataList">
<a-col class='colItem' :span="4" v-for="(item,index) in row">
<div style="margin: 0 5px" draggable="true" @dragstart="dragStart(item,$event)">
<el-image :src="item.picture_url" :fit="'fill'" class="single-image">
</el-image>
<div>时间:{{ item.counttime }}</div>
<div>类型:{{ formatPersonType(item.personType) }}</div>
<div>地点:{{ item.gate_name }}</div>
</div>
</a-col>
</a-row>
<a-pagination v-model:current="pageNum" v-model:pageSize="pageSize" :total="total"
:show-total="total => `共 ${total} 条`" :pageSizeOptions="['10', '20']"
@change="onPageNumChange" @showSizeChange="onPageSizeChange" show-size-changer show-quick-jumper
style="text-align:center" />
</div>
</a-col>
<a-col :span='10'>
<div class="imgbox1">
<div class="btns">
<a-button type="primary" @click="featureComparison" >特征对比</a-button>
<a-button type="primary" @click="shoperFeatureComparison" >店员特征对比</a-button>
</div>
<div class='comparsionBox' v-loading='isLoadingComparison'>
<p v-if='boxListLeft.length>0'><span>{{boxListLeft[0].person_unid}}</span> <span style="float: right;">共{{boxListLeft.length}}张</span></p>
<a-row @dragenter="dragEnter($event)" @dragleave="dragLeave($event)" @drop="dropLeft($event)"
@dragover="allowDrop($event)" >
<a-col :span="6" v-for="item in boxListLeft">
<div class="itemBox" :class="item.id==currentItemId?'actived':''" @click="clickItem(item)">
<el-image :src="item.picture_url" :fit="'fill'" class="single-image">
</el-image>
<span class="el-icon-document downloadFile" @click="downloadFile(item,$event)"></span>
<span class="el-icon-picture-outline openImage" @click="openImage(item,$event)"></span>
<div>时间:{{ item.counttime }}</div>
<div>方向:{{ formatDirection(item.direction) }}</div>
<div>地点:{{ item.gate_name }}</div>
</div>
</a-col>
<a-empty v-if='boxListLeft.length==0' description="拖拽图片到此处"></a-empty>
</a-row>
</div>
<div class='comparsionBox' v-loading='isLoadingComparisonRight' style="margin-top: 15px;">
<p v-if='boxListRight.length>0'><span>{{boxListRight[0].person_unid}}</span> <span style="float: right;">共{{boxListRight.length}}张</span></p>
<a-row @dragenter="dragEnter($event)" @dragleave="dragLeave($event)" @drop="dropRight($event)"
@dragover="allowDrop($event)">
<a-col :span="6" v-for="item in boxListRight">
<div class="itemBox" :class="item.id==currentItemId?'actived':''" @click="clickItem(item)">
<el-image :src="item.picture_url" :fit="'fill'" class="single-image">
</el-image>
<span class="el-icon-document downloadFile" @click="downloadFile(item,$event)"></span>
<span class="el-icon-picture-outline openImage" @click="openImage(item,$event)"></span>
<div>时间:{{ item.counttime }}</div>
<div>方向:{{ formatDirection(item.direction) }}</div>
<div>地点:{{ item.gate_name }}</div>
</div>
</a-col>
<a-empty v-if='boxListRight.length==0' description="拖拽图片到此处"></a-empty>
</a-row>
</div>
</div>
</a-col>
</a-row>
<DetailDialog ref="DetailDialogRef" />
<DetailDialogComparison ref="DetailDialogComparisonRef" />
<imgOtherDialog ref="imgOtherDialogRef" />
</template>
<script>
import {
computed,
reactive,
ref,
toRaw
} from 'vue'
import comparsionResultApi from '@/views/ComparisonCapturedPictures/api'
import snapshotRecordApi from '@/views/SnapshotCluster/SnapshotRecord/SnapshotRecordApi'
import {
isArray
} from '@/PublicUtil/Judgment'
import moment from 'moment'
import {
filterEmptyValueInObject,
formatDate,
formatTime,
getPagedList
} from '@/PublicUtil/PublicUtil'
import {ElMessage} from 'element-plus'
import DetailDialog from "./DetailDialog.vue";
import DetailDialogComparison from "./DetailDialogComparison.vue";
import imgOtherDialog from "./imgOtherDialog.vue";
export default {
components: {
DetailDialog,
DetailDialogComparison,
imgOtherDialog
},
setup() {
// scalar
const pageNum = ref(1)
const pageSize = ref(10)
const total = ref()
const isLoading = ref(false)
const isLoadingComparison = ref(false)
const isLoadingComparisonRight = ref(false)
// sequence
const dataList = ref([])
const accountList = ref([])
const plazaList = ref([])
const zoneList = ref([])
const gateList = ref([])
// ref
const DetailDialogRef = ref();
const DetailDialogComparisonRef = ref();
const imgOtherDialogRef = ref()
const pagedTableDataList = computed(
() => {
return getPagedList(dataList.value, 10)
}
)
const queryForm = reactive({
account_id: [],
plaza_id: [],
zone_id: [],
gate_id: [],
type: 0,
direction: [1, -1, 0],
picType: 2,
personType: [1, 0],
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'),
minPic:'',
maxPic:'',
})
// function
const onPageNumChange = function(num) {
pageNum.value = num
confirmSearch()
}
const onPageSizeChange = function(current, size) {
pageNum.value = 1
pageSize.value = size
confirmSearch()
}
const onAccountChange = function() {
getPlazaList()
// getZoneList()
// getGateList()
}
const onPlazaChange = function() {
getZoneList()
getGateList()
}
const onZoneChange = function() {
getGateList()
}
const getPlazaList = function() {
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>0){
queryForm.plaza_id.push(plazaList.value[0].value)
getZoneList()
getGateList()
confirmSearch()
}
}
}
)
}
const getZoneList = function() {
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,
})
}
}
}
)
}
const getGateList = function() {
queryForm.gate_id = []
gateList.value = []
snapshotRecordApi.getGateList({
account_id: queryForm.account_id.toString(),
plaza_id: queryForm.plaza_id.toString(),
zone_id: queryForm.zone_id.toString(),
type: queryForm.type,
}).then(
(r) => {
if (isArray(r.data)) {
for (const item of r.data) {
gateList.value.push({
value: item.id,
label: item.name,
})
}
}
}
)
}
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){
queryForm.account_id.push(accountList.value[0].value)
getPlazaList(1)
}
}
}
)
}
const confirmSearch = function() {
const rawData = toRaw(queryForm)
if(rawData.minPic>rawData.maxPic){
ElMessage(
{
message: `请输入正确的图片数量范围`,
type: 'warning'
}
)
return
}
isLoading.value = true
const data = filterEmptyValueInObject({
account_id: rawData.account_id.toString(),
type: rawData.type,
plaza_id: rawData.plaza_id.toString(),
zone_id: rawData.zone_id.toString(),
gate_id: rawData.gate_id.toString(),
direction: rawData.direction.toString(),
picType: rawData.picType,
personType: rawData.personType.toString(),
startTime: formatDate(rawData.date) + ' ' + formatTime(rawData.startTime),
endTime: formatDate(rawData.date) + ' ' + formatTime(rawData.endTime),
minPic:rawData.minPic,
maxPic:rawData.maxPic,
page: pageNum.value - 1,
pageSize: pageSize.value,
})
comparsionResultApi.getPersonGroupList(data).then(
(r) => {
isLoading.value = false
r.data.persons.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
}
})
dataList.value = r.data.persons
total.value = r.data.pageNum
// boxListLeft.value = []
// boxListRight.value = []
// boxObj.value = {}
}
)
}
const formatDirection = function(number) {
switch (number) {
case 1: {
return '进'
}
case -1: {
return '出'
}
case 0: {
return '横穿'
}
default: {
break
}
}
}
const formatPersonType = function(number){
switch (number) {
case 1: {
return '店员'
}
case 0: {
return '顾客'
}
default: {
break
}
}
}
const __main = function() {
getAccountList()
}
let boxObjStart = ref({})
let boxObj = ref({})
let boxListLeft = ref([])
let boxListRight = ref([])
const currentItemId = ref()
const dragStart= function (item,event) {
boxObjStart.value = item
}
const dragEnter= function (event) {
console.log('进入')
}
const dragLeave= function (event) {
console.log('出去')
}
const allowDrop= function (event) {
event.preventDefault();
}
const clickItemObj = ref({})
const clickItem = function(item){
clickItemObj.value = item
currentItemId.value = item.id
}
const dropLeft= function (event) {
event.preventDefault();
boxObj.value = boxObjStart.value
isLoadingComparison.value = true;
boxListLeft.value = [];
const rawData = toRaw(queryForm)
let parmas = {
account_id: rawData.account_id.toString(),
plaza_id: rawData.plaza_id.toString(),
zone_id: rawData.zone_id.toString(),
gate_id: rawData.gate_id.toString(),
type: rawData.type,
direction: rawData.direction.toString(),
picType: rawData.picType,
personType: rawData.personType.toString(),
startTime: formatDate(rawData.date) + ' ' + formatTime(rawData.startTime),
endTime: formatDate(rawData.date) + ' ' + formatTime(rawData.endTime),
person_unid:boxObj.value.person_unid,
}
comparsionResultApi.getPersonsDetailList(parmas).then((r) => {
isLoadingComparison.value = false
if (r.msg_code==200 && isArray(r.data.personList)) {
if(r.data.personList.length>0){
r.data.personList.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
}
})
boxListLeft.value = r.data.personList
}
}
}
)
}
const dropRight= function (event) {
event.preventDefault();
boxListRight.value = [];
boxObj.value = boxObjStart.value
const rawData = toRaw(queryForm)
isLoadingComparisonRight.value = true
let parmas = {
account_id: rawData.account_id.toString(),
plaza_id: rawData.plaza_id.toString(),
zone_id: rawData.zone_id.toString(),
gate_id: rawData.gate_id.toString(),
type: rawData.type,
direction: rawData.direction.toString(),
picType: rawData.picType,
personType: rawData.personType.toString(),
startTime: formatDate(rawData.date) + ' ' + formatTime(rawData.startTime),
endTime: formatDate(rawData.date) + ' ' + formatTime(rawData.endTime),
person_unid:boxObj.value.person_unid,
}
comparsionResultApi.getPersonsDetailList(parmas).then((r) => {
isLoadingComparisonRight.value = false
if (r.msg_code==200 && isArray(r.data.personList)) {
if(r.data.personList.length>0){
r.data.personList.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
}
})
boxListRight.value = r.data.personList
}
}
}
)
}
// 特征对比
const featureComparison = function(){
const rawData = toRaw(queryForm)
if(!clickItemObj.value.id){
ElMessage(
{
message: `请选择拖拽的图片`,
type: 'warning'
}
)
return
}
if(!clickItemObj.value.picture_url){
ElMessage(
{
message: `该图片没有特征,请选择有效的图片`,
type: 'warning'
}
)
return
}
let parmas = {
mall_id:clickItemObj.value.mall_id,
picType:rawData.picType,
pic_id:clickItemObj.value.id,
countdate:formatDate(rawData.date)
}
parmas.persionlistLeft = boxListLeft.value
parmas.persionlistRight = boxListRight.value
DetailDialogComparisonRef.value.initDialog(clickItemObj.value,parmas);
}
// 店员特征对比
const shoperFeatureComparison = function(){
const rawData = toRaw(queryForm)
if(!clickItemObj.value.id){
ElMessage(
{
message: `请选择拖拽的图片`,
type: 'warning'
}
)
return
}
if(!clickItemObj.value.picture_url){
ElMessage(
{
message: `该图片没有特征,请选择有效的图片`,
type: 'warning'
}
)
return
}
let parmas = {
plaza_id:clickItemObj.value.mall_id,
pic_type:rawData.picType,
pic_id:clickItemObj.value.id,
ip:window._baseImgUrl,
countdate:formatDate(rawData.date)
}
DetailDialogRef.value.initDialog(clickItemObj.value,parmas);
}
const downloadFile = function(item,event){
event.stopPropagation()
if(item.features_url){
window.open(item.features_url)
}else{
ElMessage(
{
message: `该图片没有特征`,
type: 'warning'
}
)
return
}
}
const openImage = function(item,event){
event.stopPropagation()
if(item.features_url){
let url = item.picture_url
imgOtherDialogRef.value.initDialog(url.split('0.jpg')[0]+'1.jpg')
}else{
ElMessage(
{
message: `该图片没有特征`,
type: 'warning'
}
)
return
}
}
__main()
return {
// scalar
isLoading,
pageNum,
pageSize,
total,
isLoadingComparison,
isLoadingComparisonRight,
currentItemId,
// sequence
accountList,
plazaList,
zoneList,
gateList,
pagedTableDataList,
boxListLeft,
boxListRight,
// mapping
queryForm,
// function
onPageNumChange,
onPageSizeChange,
onAccountChange,
onPlazaChange,
onZoneChange,
confirmSearch,
formatDirection,
formatPersonType,
dragStart,
dragEnter,
dragLeave,
allowDrop,
dropLeft,
dropRight,
featureComparison,
shoperFeatureComparison,
clickItem,
downloadFile,
openImage,
// ref
DetailDialogRef,
DetailDialogComparisonRef,
imgOtherDialogRef
}
}
}
</script>
<style scoped="scoped" lang="less">
.single-image {
height: 300px;
width: 100%;
}
.actived{
border: 1px solid #1890ff;
}
.imgbox1{
margin-top: 20px;
.btns{
margin-top: 10px;
margin-bottom: 10px;
}
button{
margin-right: 10px;
}
}
.colItem{
flex: 0 0 20%;
max-width: 20%;
}
.itemBox{
margin: 0 5px;
position: relative;
.downloadFile{
position: absolute;
color: #1890ff;
font-size: 32px;
top: 0;
right: 0;
cursor: pointer;
}
.openImage{
position: absolute;
color: #1890ff;
font-size: 32px;
top: 0;
right: 30px;
cursor: pointer;
}
}
.comparsionBox{
padding-top: 5px;
border: 2px dashed #ccc;
height: 430px;
overflow-y: auto;
p{
// text-align: right;
margin-right: 20px;
margin-left: 20px;
}
.ant-empty{
margin: 0 auto;
margin-top: 50px;
}
}
</style>