bonus-ui/src/views/dataCenter/annotationTask/child/dataAnnotations.vue

464 lines
12 KiB
Vue
Raw Normal View History

2024-11-27 09:00:55 +08:00
<template>
2024-11-27 13:43:59 +08:00
<div class="div-main">
<!-- 顶部区域 -->
<div class="top-part">
<div class="top-content">
2024-12-01 15:08:48 +08:00
2024-11-27 13:43:59 +08:00
<!-- 右侧选择框和设置按钮 -->
<div class="top-content-right">
<el-select
v-model="taskId"
placeholder="请选择标注任务"
clearable
class="select-task"
2024-11-28 12:27:07 +08:00
@change="selectTask"
2024-11-27 13:43:59 +08:00
>
<el-option
2024-11-28 12:27:07 +08:00
v-for="dict in taskList"
:key="dict.taskId"
:label="dict.taskName"
:value="dict.taskId"
2024-11-27 13:43:59 +08:00
/>
</el-select>
2024-12-01 15:08:48 +08:00
<!-- <span class="settings-icon">
<i class="el-icon-setting"></i>
</span>-->
2024-11-27 13:43:59 +08:00
</div>
</div>
</div>
<!-- 底部区域 -->
<div class="bottom-part">
<div class="bottom-content">
<div class="bottom-content-left">
<div class="bottom-content-left-top">
<div>
<el-button
type="primary"
2024-11-28 12:27:07 +08:00
:class="{'is-selected': annotationType===0}"
2024-11-27 13:43:59 +08:00
plain
size="mini"
2024-11-28 12:27:07 +08:00
@click="toggleSelected(0)"
>全部
</el-button>
2024-11-27 13:43:59 +08:00
<el-button
type="primary"
2024-11-28 12:27:07 +08:00
:class="{'is-selected': annotationType===1}"
2024-11-27 13:43:59 +08:00
plain
size="mini"
2024-11-28 12:27:07 +08:00
@click="toggleSelected(1)"
>已标注
</el-button>
2024-11-27 13:43:59 +08:00
<el-button
type="primary"
2024-11-28 12:27:07 +08:00
:class="{'is-selected': annotationType===2}"
2024-11-27 13:43:59 +08:00
plain
size="mini"
2024-11-28 12:27:07 +08:00
@click="toggleSelected(2)"
>未标注
</el-button>
2024-11-27 13:43:59 +08:00
<el-button
type="primary"
2024-11-28 12:27:07 +08:00
:class="{'is-selected': annotationType===3}"
2024-11-27 13:43:59 +08:00
plain
size="mini"
2024-11-28 12:27:07 +08:00
@click="toggleSelected(3)"
>审核驳回
</el-button>
2024-11-27 13:43:59 +08:00
</div>
</div>
<div class="bottom-content-left-bottom">
<div>
<ul>
2024-12-01 15:08:48 +08:00
<li v-for="(item, index) in images" :key="item.fileId" class="list-item">
<div @click="setItem(item, index)">
<input type="checkbox" :checked="item.fileAnnotationStatus==='1'" disabled>
<span :class="{'highlighted': itemIndex === index}" style="font-size: 14px; margin-left: 5px;"
>{{ item.fileName }}</span>
2024-11-28 12:27:07 +08:00
</div>
2024-11-27 13:43:59 +08:00
</li>
</ul>
</div>
</div>
</div>
<div class="bottom-content-center">
2024-11-28 12:27:07 +08:00
<div>
2024-12-01 15:08:48 +08:00
<custom-label-studio :annotations="annotationResult" :taskId="taskId" :item-index="itemIndex"
:config="labelConfig" :id="task.id" :file-url="task.data.image"
@update-itemIndex="updateItemIndex"
></custom-label-studio>
2024-11-28 12:27:07 +08:00
</div>
2024-11-27 13:43:59 +08:00
</div>
</div>
</div>
2024-11-27 09:00:55 +08:00
</div>
</template>
<script>
2024-11-28 12:27:07 +08:00
import customLabelStudio from './customLabelStudio.vue'
2024-12-01 15:08:48 +08:00
import { getMyNoAnnotatedTask, getMyAnnotationFiles } from '../../../../api/dataCenter/annotationTask'
2024-11-28 12:27:07 +08:00
2024-11-27 09:00:55 +08:00
export default {
2024-11-27 13:43:59 +08:00
dicts: ['ai_annotate_type'],
2024-11-28 12:27:07 +08:00
components: { customLabelStudio },
2024-11-27 09:00:55 +08:00
data() {
return {
2024-12-01 15:08:48 +08:00
itemIndex: 0,
annotationResult: [],
item: {},
taskList: [],
2024-11-28 12:27:07 +08:00
task: {
2024-12-01 15:08:48 +08:00
id: 0,
2024-11-28 12:27:07 +08:00
data: {
2024-12-01 15:08:48 +08:00
image: ''
2024-11-28 12:27:07 +08:00
}
},
2024-12-01 15:08:48 +08:00
labelConfig: `
<View>
<Image name="image" value="$image"/>
<RectangleLabels name="label" toName="image">
<Label value="人" background="#ff0000"/>
<Label value="车" background="#00ff00"/>
</RectangleLabels>
</View>
`,
2024-11-27 13:43:59 +08:00
taskId: undefined, // 当前选中的任务 ID
leftIcons: [
'el-icon-circle-plus-outline',
'el-icon-remove-outline',
'el-icon-search',
'el-icon-search',
'el-icon-search',
2024-11-28 12:27:07 +08:00
'el-icon-search'
2024-11-27 13:43:59 +08:00
], // 顶部左侧按钮的图标
2024-11-28 12:27:07 +08:00
count: 600,
annotationType: 0,
images: []
}
},
created() {
2024-12-01 15:08:48 +08:00
this.loadTaskList(); // 初始化时加载任务列表
2024-11-27 09:00:55 +08:00
},
2024-11-28 12:27:07 +08:00
methods: {
2024-12-01 15:08:48 +08:00
// 更新项的索引并切换任务数据
updateItemIndex(val) {
const item = this.images[val];
this.images[val - 1].fileAnnotationStatus = '1';
this.itemIndex = val;
this.updateTaskData(item);
2024-11-28 12:27:07 +08:00
},
2024-12-01 15:08:48 +08:00
// 加载未标注的任务列表
loadTaskList() {
getMyNoAnnotatedTask().then(res => {
this.taskList = res.data;
});
2024-11-28 12:27:07 +08:00
},
2024-12-01 15:08:48 +08:00
// 根据任务ID选择任务并加载对应的文件
selectTask(id) {
this.resetImages();
this.taskId = id;
this.fetchImages();
2024-11-28 12:27:07 +08:00
},
2024-12-01 15:08:48 +08:00
// 切换标注类型并加载任务文件
2024-11-28 12:27:07 +08:00
toggleSelected(type) {
2024-12-01 15:08:48 +08:00
if (this.annotationType === type) return;
this.annotationType = type;
this.resetImages();
this.fetchImages();
},
// 设置标注项,更新任务数据和标注结果
setItem(item, index) {
this.annotationResult = JSON.parse(item.annotationResult);
this.itemIndex = index;
this.updateTaskData(item);
},
// 重置图像数据
resetImages() {
2024-11-28 12:27:07 +08:00
this.images = [];
2024-12-01 15:08:48 +08:00
//this.annotationType = 0;
},
// 获取当前任务ID和标注类型的图像数据
fetchImages() {
if (!this.taskId) return;
getMyAnnotationFiles(this.annotationType, this.taskId).then(response => {
this.itemIndex = 0;
this.images = response.data;
this.updateTaskData(this.images[this.itemIndex]);
});
2024-11-28 12:27:07 +08:00
},
2024-12-01 15:08:48 +08:00
// 更新任务的数据
updateTaskData(item) {
this.task.data.image = `http://192.168.0.14:9090/bonus/${item.fileUrl}`;
this.task.id = item.fileId;
this.annotationResult = JSON.parse(item.annotationResult);
2024-11-27 09:00:55 +08:00
}
}
2024-11-28 12:27:07 +08:00
}
2024-11-27 09:00:55 +08:00
</script>
2024-11-27 13:43:59 +08:00
<style scoped lang="scss">
2024-11-28 12:27:07 +08:00
/* 默认按钮样式 */
.el-button {
transition: all 0.3s ease;
}
/* 选中时的样式 */
.el-button.is-selected {
background-color: #007bff !important; /* 设置选中背景色 */
border-color: #007bff !important; /* 设置选中边框色 */
color: white !important; /* 设置字体颜色 */
}
2024-11-27 13:43:59 +08:00
.div-main {
width: 100%;
height: calc(100vh - 84px);
/* 顶部样式 */
.top-part {
width: 100%;
height: 60px;
padding: 10px;
.top-content {
display: flex;
align-items: center;
justify-content: space-between;
height: 100%;
width: 100%;
padding-left: 10px;
padding-right: 10px;
background-color: #f5f7fa;
border: 1px solid #dfe4ed;
.top-content-left {
display: flex;
align-items: center;
gap: 10px; /* 按钮之间的间距 */
}
.top-content-right {
display: flex;
align-items: center;
gap: 10px;
.select-task {
flex-shrink: 0; /* 防止选择框缩小 */
}
.settings-icon {
font-size: 24px;
display: flex;
align-items: center;
}
}
}
}
/* 底部样式 */
.bottom-part {
width: 100%;
height: calc(100% - 60px);
2024-11-28 12:27:07 +08:00
padding-bottom: 10px;
padding-left: 10px;
padding-right: 10px;
2024-11-27 13:43:59 +08:00
.bottom-content {
display: flex;
align-items: center;
height: 100%;
width: 100%;
background-color: #ffffff;
border: 1px solid #dfe4ed;
.bottom-content-left,
.bottom-content-center,
.bottom-content-right {
height: 100%;
}
.bottom-content-left {
width: 20%;
.bottom-content-left-bottom,
2024-11-28 12:27:07 +08:00
.bottom-content-left-top {
2024-11-27 13:43:59 +08:00
width: 100%;
padding: 5px;
}
2024-11-28 12:27:07 +08:00
.bottom-content-left-top {
2024-11-27 13:43:59 +08:00
height: 50px;
2024-11-28 12:27:07 +08:00
div {
2024-11-27 13:43:59 +08:00
width: 100%;
height: 100%;
background-color: #f5f7fa;
border: 1px solid #dfe4ed;
display: flex;
align-items: center;
2024-11-28 12:27:07 +08:00
justify-content: space-evenly;
2024-11-27 13:43:59 +08:00
}
}
2024-11-28 12:27:07 +08:00
.bottom-content-left-bottom {
2024-11-27 13:43:59 +08:00
height: calc(100% - 50px);
2024-11-28 12:27:07 +08:00
> div {
2024-11-27 13:43:59 +08:00
width: 100%;
height: 100%;
background-color: #f5f7fa;
border: 1px solid #dfe4ed;
display: flex;
align-items: center;
justify-content: center;
2024-11-28 12:27:07 +08:00
ul {
2024-11-27 13:43:59 +08:00
width: 100%;
height: 100%;
overflow: auto;
padding: 0;
list-style: none; /* 移除默认的点样式 */
li {
width: 100%;
2024-11-28 12:27:07 +08:00
padding: 1px;
background-color: #FFFFFF;
div {
height: 40px;
padding-left: 2px;
display: flex;
cursor: pointer; /* 手势效果 */
align-items: center;
background-color: #f5f7fa;
}
input[type="checkbox"] {
appearance: none; /* 隐藏默认复选框样式 */
width: 15px;
height: 15px;
border: 1px solid #4d4e51;
border-radius: 4px; /* 圆角方框 */
cursor: pointer;
}
input[type="checkbox"]:checked::after {
content: '✔'; /* 显示勾符号 */
color: white;
font-size: 10px;
display: flex;
align-items: center;
justify-content: center;
}
input[type="checkbox"]:checked {
background-color: rgb(64, 158, 255); /* 改变选中颜色 */
border-color: rgb(64, 158, 255);
}
2024-11-27 13:43:59 +08:00
}
}
2024-11-28 12:27:07 +08:00
2024-11-27 13:43:59 +08:00
/* 针对自定义滚动条样式 */
ul::-webkit-scrollbar {
cursor: default; /* 对滚动条自定义光标 */
width: 5px;
}
2024-11-28 12:27:07 +08:00
2024-11-27 13:43:59 +08:00
ul::-webkit-scrollbar-thumb {
background-color: #888;
cursor: pointer; /* 手势效果 */
}
2024-11-28 12:27:07 +08:00
2024-11-27 13:43:59 +08:00
ul::-webkit-scrollbar-thumb:hover {
background-color: #555;
}
}
}
}
.bottom-content-center {
2024-12-01 15:08:48 +08:00
width: 80%;
2024-11-27 13:43:59 +08:00
padding: 5px;
2024-11-28 12:27:07 +08:00
div {
2024-11-27 13:43:59 +08:00
width: 100%;
height: 100%;
background-color: #f5f7fa;
border: 1px solid #dfe4ed;
}
}
.bottom-content-right {
width: 20%;
padding: 5px;
2024-11-28 12:27:07 +08:00
.bottom-content-right-center {
2024-11-27 13:43:59 +08:00
width: 100%;
height: 100%;
background-color: #f5f7fa;
border: 1px solid #dfe4ed;
display: flex;
align-items: center;
2024-11-28 12:27:07 +08:00
flex-direction: column;
.bottom-content-right-top {
width: 100%;
height: calc(50% - 25px);
padding: 5px;
div {
width: 100%;
height: 100%;
background-color: #f5f7fa;
border: 1px solid #dfe4ed;
}
}
.bottom-content-right-middle {
width: 100%;
height: calc(50% - 25px);
padding: 5px;
div {
width: 100%;
height: 100%;
background-color: #f5f7fa;
border: 1px solid #dfe4ed;
}
}
.bottom-content-right-bottom {
width: 100%;
height: 50px;
padding: 5px;
2024-11-27 13:43:59 +08:00
2024-11-28 12:27:07 +08:00
div {
width: 100%;
height: 100%;
background-color: #f5f7fa;
border: 1px solid #dfe4ed;
display: flex;
align-items: center;
justify-content: space-evenly;
}
}
2024-11-27 13:43:59 +08:00
}
}
}
}
}
2024-12-01 15:08:48 +08:00
.highlighted {
color: rgb(64, 158, 255); /* 选中项文本颜色 */
font-size: 16px; /* 选中项字体大小 */
}
2024-11-27 13:43:59 +08:00
</style>