PeopleLabel.vue
14.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
<template>
<a-layout class="PeopleLabel">
<div style="display: flex;justify-content: space-between">
标注
<a-button @click="goBack">返回上一页</a-button>
</div>
<div>
图片数量:
<el-input v-model.trim="countGTE" @input="onCountGteChange" size="mini" style="width: 150px"></el-input>
至
<el-input v-model.trim="countLTE" @input="onCountLteChange" size="mini" style="width: 150px"></el-input>
<a-button @click="getPeopleImageFolderList" type="primary">搜索</a-button>
</div>
<div>
文件夹ID:
<el-input v-model.trim="searchedFolderId" size="mini" style="width: 300px"></el-input>
<a-button @click="searchFolder" type="primary">搜索</a-button>
</div>
<el-row>
<el-col :span="18">
<el-menu mode="horizontal" @select="onMenuSelect" :default-active="'1'">
<el-menu-item :index="'1'">
待标注
</el-menu-item>
<el-menu-item :index="'2'">
标注中
</el-menu-item>
<el-menu-item :index="'3'">
完成标注
</el-menu-item>
<el-menu-item :index="'-1'">
被回收
</el-menu-item>
<el-menu-item :index="'4'">
优质
</el-menu-item>
<el-menu-item :index="'7'">
低质
</el-menu-item>
<el-menu-item :index="''">
全部
</el-menu-item>
<el-menu-item :index="'我的完成标注'">
我的完成标注
</el-menu-item>
</el-menu>
</el-col>
<el-col :span="6" v-if="isReviewAccessed">
<el-button @click="confirmSubmitReview(6)" type="success" size="small">审核通过</el-button>
<el-button @click="confirmSubmitReview(5)" type="danger" size="small">审核驳回</el-button>
</el-col>
</el-row>
<div style="height: 100%; overflow: scroll" v-loading="isLoading">
<el-row v-for="row in pagedTableData">
<el-col :span="6" v-for="item in row">
<el-checkbox @change="selectImageFolder(Object.keys(item)[0])" v-if="isReviewAccessed" :key="Object.keys(item)[0]">选择文件夹</el-checkbox>
<div @click="enterLabeling(Object.keys(item)[0])"
class="folder"
:style="'border: 1px solid ' + getFolderColor(Object.values(item)[0][0].status)"
>
<div class="folder-title"
:style="'background: ' + getFolderColor(Object.values(item)[0][0].status)"
>
{{ getFolderTitle(Object.values(item)[0][0].status) }}
</div>
<div class="folder-body ">
<div class="folder-cover-image">
<el-image :src="getImageUrl(Object.values(item)[0][0].picId)"
:fit="'contain'"
style="height: 300px;">
</el-image>
</div>
<el-row>
<el-col :span="6" class="column-title-font">文件夹ID:</el-col>
<el-col :span="18">{{ Object.keys(item)[0] }}</el-col>
</el-row>
<el-row>
<el-col :span="6" class="column-title-font">标注人:</el-col>
<el-col :span="18">{{ Object.values(item)[0][0].labelUserName }}</el-col>
</el-row>
<el-row>
<el-col :span="6" class="column-title-font">图片数量:</el-col>
<el-col :span="18">{{ Object.values(item)[0].length }}</el-col>
</el-row>
<!-- <el-row>-->
<!-- <el-col :span="10" class="column-title-font">创建时间:</el-col>-->
<!-- <el-col :span="14">{{ item.createTime }}</el-col>-->
<!-- </el-row>-->
<!-- <el-row>-->
<!-- <el-col :span="10" class="column-title-font">完成时间:</el-col>-->
<!-- <el-col :span="14">2020-2-3 23:23:43</el-col>-->
<!-- </el-row>-->
</div>
</div>
</el-col>
</el-row>
<el-pagination @current-change="handlePageNumChange"
@size-change="handlePageSizeChange"
:current-page="pageNum"
:page-size="pageSize"
:total="total"
:page-sizes="[12, 24, 36, 48]"
layout="total, sizes, prev, pager, next, jumper"
style="text-align:center"
>
</el-pagination>
</div>
</a-layout>
</template>
<script>
import {computed, defineComponent, reactive, ref, toRefs, watch} from 'vue'
import {useRoute, useRouter} from 'vue-router'
import peopleLabelApi from '@/views/DataLabel/PeopleLabel/PeopleLabelApi'
import {
formatPaginatedTableData,
getCountGte,
getCountLte, getFolderColor,
getFolderTitle,
getImageUrl,
getPagedList,
} from '@/PublicUtil/PublicUtil'
import {message} from 'ant-design-vue'
import router from '@/router'
import {isEmptyValue, isNotEmptyValue} from '@/PublicUtil/Judgment'
import {ElMessage} from 'element-plus'
export default defineComponent(
{
setup() {
const getPageNum = function() {
const pageNum = useRoute().query.pageNum
if (isEmptyValue(pageNum))
{
return 1
}
else
{
return pageNum
}
}
const pageNum = ref(getPageNum())
const pageSize = ref(12)
const total = ref(Number.MAX_SAFE_INTEGER)
const isLoading = ref(false)
const packId = useRoute().query.packId
const isReviewAccessed = useRoute().query.isReviewAccessed === 'true'
const router = useRouter()
const imageData = ref()
const countGTE = ref(getCountGte())
const countLTE = ref(getCountLte())
const searchedFolderId = ref()
let selectedMenuIndex = '1'
const pagedTableData = computed(
() => {
return getPagedList(peopleFolderList.value, 4)
}
)
// sequence
const peopleFolderList = ref([])
let selectedImageFolderIdList = []
// function
const handlePageNumChange = function(num) {
pageNum.value = num
selectedImageFolderIdList = []
getPeopleImageFolderList()
if (isNotEmptyValue(pageNum.value))
{
localStorage.setItem('pageNum', pageNum.value)
}
}
const handlePageSizeChange = function(size) {
pageNum.value = 1
pageSize.value = size
selectedImageFolderIdList = []
getPeopleImageFolderList()
if (isNotEmptyValue(pageNum.value))
{
localStorage.setItem('pageNum', pageNum.value)
}
}
const enterLabeling = function(personUnid) {
peopleLabelApi.enterLabeling(personUnid, packId).then(
(r) => {
if (r.msg === '正在被其他人标注')
{
message.info('正在被其他人标注')
}
else
{
router.push(
{
path: '/DataLabel/Labeling',
query: {
packId: packId,
personUnid: personUnid,
status: selectedMenuIndex,
}
}
)
}
}
)
}
const getPeopleImageFolderList = function() {
isLoading.value = true
const data = {
packId: packId,
status: selectedMenuIndex === '我的完成标注' ? undefined : selectedMenuIndex,
annotatorId: selectedMenuIndex === '我的完成标注' ? localStorage.getItem('currentUserId') : undefined,
pageNum: pageNum.value,
pageSize: pageSize.value,
countGTE: getCountGte(),
countLTE: getCountLte(),
}
peopleLabelApi.getPeopleImageFolderList(data).then(
({data}) => {
formatPaginatedTableData(
peopleFolderList,
data,
total,
)
isLoading.value = false
}
)
}
const searchFolder = function() {
isLoading.value = true
const data = {
personUnid_like: searchedFolderId.value,
packId: packId,
}
peopleLabelApi.searchFolder(data).then(
({data}) => {
isLoading.value = false
let l = []
for (let key in data)
{
const value = data[key]
l.push(
{
[key]: value
}
)
}
peopleFolderList.value = l
// total.value = data.length
}
)
}
const goBack = function() {
router.push(
{
path: '/DataLabel/ImagePackage',
}
)
}
const getFolderTitleBorderColor = function(status) {
switch (status)
{
case 1:
{
return 'folder-title-toBeLabeled'
}
case 2:
{
return 'folder-title-labeling'
}
case 3:
{
return 'folder-title-labeled'
}
case -1:
{
return 'folder-title-beRecycled'
}
case 4:
{
return 'folder-title-highQuality'
}
default:
{
return ''
}
}
}
const onMenuSelect = function(index) {
selectedMenuIndex = index
getPeopleImageFolderList()
}
const onCountGteChange = function(v) {
localStorage.setItem('countGTE', v)
}
const onCountLteChange = function(v) {
localStorage.setItem('countLTE', v)
}
const selectImageFolder = function(personUnid) {
if (selectedImageFolderIdList.includes(personUnid))
{
selectedImageFolderIdList.splice(selectedImageFolderIdList.indexOf(personUnid), 1)
}
else
{
selectedImageFolderIdList.push(personUnid)
}
}
const confirmSubmitReview = function(status) {
const data = {
personUnidArr: selectedImageFolderIdList,
status: status,
}
peopleLabelApi.submitReview(data).then(
(r) => {
const message = r.msg
ElMessage(
{
message: `${message}`,
}
)
}
)
}
const initialize = function() {
getPeopleImageFolderList()
}
initialize()
return {
// scalar
pageNum,
pageSize,
total,
isLoading,
imageData,
countGTE,
countLTE,
searchedFolderId,
isReviewAccessed,
// sequence
peopleFolderList,
pagedTableData,
// mapping
// function
handlePageNumChange,
handlePageSizeChange,
getPeopleImageFolderList,
goBack,
getFolderTitle,
getFolderColor,
getFolderTitleBorderColor,
enterLabeling,
onMenuSelect,
getImageUrl,
onCountGteChange,
onCountLteChange,
searchFolder,
selectImageFolder,
confirmSubmitReview,
}
},
}
)
</script>
<style lang="less" scoped>
@import "./PeopleLabel.less";
</style>