增加备注字段

This commit is contained in:
BianLzhaoMin 2025-11-26 11:01:46 +08:00
parent 53b8a63b38
commit b85889486c
3 changed files with 704 additions and 639 deletions

View File

@ -1,356 +1,397 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" >
<el-form-item prop="operaTime">
<el-date-picker
v-model="queryParams.operaTime"
type="date"
placeholder="标注日期"
<div class="app-container">
<el-form
:model="queryParams"
ref="queryForm"
size="small"
:inline="true"
>
</el-date-picker>
</el-form-item>
<el-form-item prop="operaTime">
<el-date-picker
v-model="queryParams.operaTime"
type="date"
placeholder="标注日期"
>
</el-date-picker>
</el-form-item>
<el-form-item label="" prop="contentImage">
<el-select
v-model="queryParams.operaName"
placeholder="请选择"
clearable
filterable
style="width: 240px"
>
<el-option
v-for="item in contentImageOptions"
:key="item.id"
:label="item.name"
:value="item.name"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="" prop="userName">
<el-input
v-model="queryParams.userName"
placeholder="审核人"
clearable
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="" prop="contentImage">
<el-select
v-model="queryParams.operaName"
placeholder="请选择"
clearable
filterable
style="width: 240px">
<el-option
v-for="item in contentImageOptions"
:key="item.id"
:label="item.name"
:value="item.name"
<el-form-item label="" prop="remark">
<el-input
v-model="queryParams.remark"
placeholder="备注"
clearable
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
size="mini"
@click="handleQuery"
>搜索</el-button
>
<el-button
icon="el-icon-refresh"
size="mini"
@click="resetQuery"
style="background: transparent; border-color: #b1c0cb"
>重置</el-button
>
<el-button
icon="el-icon-download"
size="mini"
@click="handleExport"
style="background: transparent; border-color: #b1c0cb"
>下载</el-button
>
</el-form-item>
</el-form>
<div class="content-area" ref="servicesGrid">
<div
:key="item.id"
class="services-grid"
v-for="item in showProMaterialsDuctList"
>
</el-option>
<!-- 图片区域 -->
<div class="card-image">
<ImagePreview
style="margin-top: 10px"
:height="192"
:borderRadius="10"
:width="itemWidth"
:src="item.bjUrl"
/>
</div>
</el-select>
</el-form-item>
<el-form-item label="" prop="userName">
<el-input
v-model="queryParams.userName"
placeholder="审核人"
clearable
style="width: 240px"
@keyup.enter.native="handleQuery"
<!-- 卡片内容 -->
<div class="card-content">
<div class="card-footer">
<div class="person-info">
<span class="name">{{ item.userName }}</span>
<span class="date">{{ item.createTime }}</span>
</div>
<div class="person-info">
<span class="name">{{ item.remark }}</span>
</div>
<div class="tags">
<span class="title-desc">{{
item.contentImage
}}</span>
<!-- <el-tooltip :content="item.contentImage" placement="top" :effect="'light'" :enterable="false">-->
<!-- <span class="title-desc">{{ item.contentImage }}</span>-->
<!-- </el-tooltip>-->
</div>
<div style="border-top: 1px solid #cfd4d7"></div>
<div class="action-buttons">
<el-button
type="danger"
size="mini"
@click="handleDelete(item)"
plain
icon="el-icon-delete"
>
删除
</el-button>
</div>
</div>
</div>
</div>
</div>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
:page-sizes="[8, 16, 32, 64]"
@pagination="getList"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery" style="background:transparent;border-color: #B1C0CB;">重置</el-button>
<el-button icon="el-icon-download" size="mini" @click="handleExport" style="background:transparent;border-color: #B1C0CB;">下载</el-button>
</el-form-item>
</el-form>
<div class="content-area" ref="servicesGrid">
<div
:key="item.id"
class="services-grid"
v-for="item in showProMaterialsDuctList"
>
<!-- 图片区域 -->
<div class="card-image">
<ImagePreview
style="margin-top: 10px;"
:height="192"
:borderRadius="10"
:width="itemWidth"
:src="item.bjUrl"
/>
</div>
<!-- 卡片内容 -->
<div class="card-content">
<div class="card-footer">
<div class="person-info">
<span class="name">{{ item.userName }}</span>
<span class="date">{{ item.createTime }}</span>
</div>
<div class="tags">
<span class="title-desc">{{ item.contentImage }}</span>
<!-- <el-tooltip :content="item.contentImage" placement="top" :effect="'light'" :enterable="false">-->
<!-- <span class="title-desc">{{ item.contentImage }}</span>-->
<!-- </el-tooltip>-->
</div>
<div style="border-top: 1px solid #CFD4D7;"></div>
<div class="action-buttons">
<el-button
type="danger"
size="mini"
@click="handleDelete(item)"
plain
icon="el-icon-delete"
>
删除
</el-button>
</div>
</div>
</div>
</div>
</div>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
:page-sizes="[8, 16, 32, 64]"
@pagination="getList"
/>
</div>
</template>
<script>
import {getAllImagelist, deleteFile, exportImages} from "@/api/imageCaptioning/imageLibrary";
import {getSelectedAPI} from "@/api/imageCaptioning/imageCaptioning";
import {
getAllImagelist,
deleteFile,
exportImages,
} from '@/api/imageCaptioning/imageLibrary'
import { getSelectedAPI } from '@/api/imageCaptioning/imageCaptioning'
export default {
name: "imageCaptioningLibrary",
data() {
return {
//
total: 0,
//
queryParams: {
pageNum: 1,
pageSize: 8,
operaTime: '',
operaType: 1,
operaName: '',
userName: ''
},
//
form: {},
proMaterialsListAll: [], //
showProMaterialsDuctList: [], //
itemWidth: 0, //
contentImageOptions:[]
}
},
created() {
this.getList();
this.getContentImageOptions();
},
mounted() {
this.getItemWidth()
},
methods: {
//
getItemWidth() {
this.itemWidth = (this.$refs.servicesGrid?.clientWidth - 320) / 4
name: 'imageCaptioningLibrary',
data() {
return {
//
total: 0,
//
queryParams: {
pageNum: 1,
pageSize: 8,
operaTime: '',
operaType: 1,
operaName: '',
userName: '',
},
//
form: {},
proMaterialsListAll: [], //
showProMaterialsDuctList: [], //
itemWidth: 0, //
contentImageOptions: [],
}
},
/** 查询角色列表 */
getList() {
getAllImagelist(this.queryParams).then(response => {
this.proMaterialsListAll = response.rows;
this.total = response.total || 0;
this.showProMaterialsDuctList = this.proMaterialsListAll;
})
created() {
this.getList()
this.getContentImageOptions()
},
getContentImageOptions() {
getSelectedAPI().then(response => {
this.contentImageOptions = response.data;
})
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
//
if (this.queryParams.operaTime) {
const date = new Date(this.queryParams.operaTime)
// 使getFullYeargetMonthgetDate
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
this.queryParams.operaTime = `${year}-${month}-${day}`
}
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm")
this.queryParams.operaTime = null
this.queryParams.operaName = ''
this.handleQuery()
mounted() {
this.getItemWidth()
},
/** 导出按钮操作 */
handleExport() {
const imageIds = this.showProMaterialsDuctList.map(item => item.imageId);
exportImages({
imageId: imageIds
}).then(response => {
//
const blob = new Blob([response]);
const link = document.createElement('a');
const fileName = `图片压缩包_${new Date().getTime()}.zip`;
link.href = URL.createObjectURL(blob);
link.download = fileName;
link.click();
URL.revokeObjectURL(link.href);
}).catch(error => {
console.error('下载失败:', error);
this.$message.error('下载失败');
});
},
//
handleDelete(item) {
this.$confirm('确认要删除该记录吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
//
console.log('删除:', item)
deleteFile({"imageId":item.imageId}).then(response => {
console.log('删除结果:', response)
if (response.code === 200) {
this.$message.success('删除成功')
methods: {
//
getItemWidth() {
this.itemWidth = (this.$refs.servicesGrid?.clientWidth - 320) / 4
},
/** 查询角色列表 */
getList() {
getAllImagelist(this.queryParams).then((response) => {
this.proMaterialsListAll = response.rows
this.total = response.total || 0
this.showProMaterialsDuctList = this.proMaterialsListAll
})
},
getContentImageOptions() {
getSelectedAPI().then((response) => {
this.contentImageOptions = response.data
})
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
//
if (this.queryParams.operaTime) {
const date = new Date(this.queryParams.operaTime)
// 使getFullYeargetMonthgetDate
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
this.queryParams.operaTime = `${year}-${month}-${day}`
}
this.getList()
} else {
this.$message.error('删除失败')
}
})
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm('queryForm')
this.queryParams.operaTime = null
this.queryParams.operaName = ''
this.handleQuery()
},
}).catch(() => {
this.$message.info('已取消删除')
})
}
}
/** 导出按钮操作 */
handleExport() {
const imageIds = this.showProMaterialsDuctList.map(
(item) => item.imageId,
)
exportImages({
imageId: imageIds,
})
.then((response) => {
//
const blob = new Blob([response])
const link = document.createElement('a')
const fileName = `图片压缩包_${new Date().getTime()}.zip`
link.href = URL.createObjectURL(blob)
link.download = fileName
link.click()
URL.revokeObjectURL(link.href)
})
.catch((error) => {
console.error('下载失败:', error)
this.$message.error('下载失败')
})
},
//
handleDelete(item) {
this.$confirm('确认要删除该记录吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
//
console.log('删除:', item)
deleteFile({ imageId: item.imageId }).then((response) => {
console.log('删除结果:', response)
if (response.code === 200) {
this.$message.success('删除成功')
this.getList()
} else {
this.$message.error('删除失败')
}
})
})
.catch(() => {
this.$message.info('已取消删除')
})
},
},
}
</script>
<style scoped>
.app-container {
overflow: hidden;
height: calc(100vh - 84px);
width: 100%;
background: url('../../../assets/images/imageCaptioning/login-bg-background.png') no-repeat center center;
background-size: 100% 100%;
overflow: hidden;
height: calc(100vh - 84px);
width: 100%;
background: url('../../../assets/images/imageCaptioning/login-bg-background.png')
no-repeat center center;
background-size: 100% 100%;
}
.content-area {
flex: 1;
height: calc(100vh - 218px);
padding-bottom: 20px;
padding-right: 12px;
padding-top: 2px;
overflow-y: auto;
display: flex;
flex-wrap: wrap;
row-gap: 30px;
flex: 1;
height: calc(100vh - 218px);
padding-bottom: 20px;
padding-right: 12px;
padding-top: 2px;
overflow-y: auto;
display: flex;
flex-wrap: wrap;
row-gap: 30px;
}
.services-grid {
width: 22%;
margin-left: 2.5%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
transition: all 0.3s ease;
border: 1px solid #d6d1d1;
border-radius: 10px;
align-content: flex-start;
justify-items: center;
height: 47%;
width: 22%;
margin-left: 2.5%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
transition: all 0.3s ease;
border: 1px solid #d6d1d1;
border-radius: 10px;
align-content: flex-start;
justify-items: center;
height: 47%;
}
.card-image {
height: 200px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
height: 200px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
}
.card-content {
width: 100%;
display: flex;
flex-direction: column;
font-size: 14px;
width: 100%;
display: flex;
flex-direction: column;
font-size: 14px;
}
.card-footer {
display: flex;
flex-direction: column;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 100%;
min-height: 24px;
margin-top: 4px;
display: flex;
flex-direction: column;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 100%;
min-height: 24px;
margin-top: 4px;
}
.person-info {
display: flex;
justify-content: space-between;
margin: 10px 18px 0 18px;
align-items: center;
display: flex;
justify-content: space-between;
margin: 10px 18px 0 18px;
align-items: center;
}
.name {
font-weight: bold;
color: #333;
font-weight: bold;
color: #333;
}
.date {
color: #666;
/*font-size: 12px;*/
color: #666;
/*font-size: 12px;*/
}
.tags {
display: flex;
flex-wrap: wrap;
margin: 10px 18px 5px 18px;
height: 20px;
display: flex;
flex-wrap: wrap;
margin: 10px 18px 5px 18px;
height: 20px;
}
.tag-item {
background-color: #e6f7ff;
color: #0066cc;
padding: 2px 6px;
border-radius: 4px;
font-size: 12px;
background-color: #e6f7ff;
color: #0066cc;
padding: 2px 6px;
border-radius: 4px;
font-size: 12px;
}
.action-buttons {
display: flex;
justify-content: flex-end;
margin: 10px 18px 10px 18px;
display: flex;
justify-content: flex-end;
margin: 10px 18px 10px 18px;
}
>>>.el-input__inner{
background: transparent !important;
color: #333333 !important;
border-color: #B5C4CC;
.el-input__inner {
background: transparent !important;
color: #333333 !important;
border-color: #b5c4cc;
}
.pagination-container{
background: transparent !important;
.pagination-container {
background: transparent !important;
}
.title-desc {
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
margin-right: 8px;
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
margin-right: 8px;
}
</style>

View File

@ -224,7 +224,7 @@ export default {
// params
const params = {
param: selectedTagNames,
remark: '备注996',
remark: this.remarkInfo,
id: this.addId,
}
formData.append('params', JSON.stringify(params))

View File

@ -1,385 +1,409 @@
<template>
<div class="image-captioning-container">
<!-- 左侧导航栏 -->
<Sidebar
:is-sidebar-visible="isSidebarVisible"
:label-list="labelList"
:selected-item="selectedItem"
@toggle-sidebar="toggleSidebar"
@create-new-label="createNewLabel"
@select-item="selectItem"
/>
<div class="image-captioning-container">
<!-- 左侧导航栏 -->
<Sidebar
:is-sidebar-visible="isSidebarVisible"
:label-list="labelList"
:selected-item="selectedItem"
@toggle-sidebar="toggleSidebar"
@create-new-label="createNewLabel"
@select-item="selectItem"
/>
<!-- 主内容区域 -->
<div class="main-content" v-if="showNewAnnotation">
<!-- 主内容区域-新增的 -->
<div class="add-content">
<!-- 标题 -->
<div class="welcome-message">
我是你的图像评估助理
<!-- 主内容区域 -->
<div class="main-content" v-if="showNewAnnotation">
<!-- 主内容区域-新增的 -->
<div class="add-content">
<!-- 标题 -->
<div class="welcome-message"> 我是你的图像评估助理 </div>
<!-- 输入备注 -->
<el-input
:rows="1"
placeholder="请输入备注"
type="textarea"
v-model="remarkInfo"
/>
<!-- 图片上传区域 -->
<FileUploader
:file-list="fileList"
@file-change="handleFileChange"
@remove-image="removeImage"
@start-upload="startUpload"
/>
</div>
</div>
<!-- 图片上传区域 -->
<FileUploader
:file-list="fileList"
@file-change="handleFileChange"
@remove-image="removeImage"
@start-upload="startUpload"
/>
</div>
<!-- 主内容区域-历史 -->
<div class="main-content" v-if="showNewAnnotationAdd">
<HistoryView
:image-results="imageResults"
:selected-images="selectedImages"
:file-list="fileList"
@hand-click="handleHandClick"
@confirm-results="confirmResults"
@file-change="handleFileChange"
@remove-image="removeImage"
@start-upload="startUpload"
/>
</div>
</div>
<!-- 主内容区域-历史 -->
<div class="main-content" v-if="showNewAnnotationAdd">
<HistoryView
:image-results="imageResults"
:selected-images="selectedImages"
:file-list="fileList"
@hand-click="handleHandClick"
@confirm-results="confirmResults"
@file-change="handleFileChange"
@remove-image="removeImage"
@start-upload="startUpload"
/>
</div>
</div>
</template>
<script>
import {
getImageListAPI,
getImageListDetailsAPI,
addImageEvaluateAPI,
updateImageSureAPI
} from "@/api/imageCaptioning/imageEvaluate";
getImageListAPI,
getImageListDetailsAPI,
addImageEvaluateAPI,
updateImageSureAPI,
} from '@/api/imageCaptioning/imageEvaluate'
import Sidebar from "../image-captioning/components/Sidebar";
import FileUploader from "../image-captioning/components/FileUploaderUn";
import HistoryView from "../image-captioning/components/HistoryViewUn";
import Sidebar from '../image-captioning/components/Sidebar'
import FileUploader from '../image-captioning/components/FileUploaderUn'
import HistoryView from '../image-captioning/components/HistoryViewUn'
export default {
name: "imageCaptioning",
components: {
Sidebar,
FileUploader,
HistoryView
},
data() {
return {
showNewAnnotation: true, //
showNewAnnotationAdd: false, //
name: 'imageCaptioning',
components: {
Sidebar,
FileUploader,
HistoryView,
},
data() {
return {
showNewAnnotation: true, //
showNewAnnotationAdd: false, //
//
labelList: [],
selectedItem: null,
//
labelList: [],
selectedItem: null,
//
fileList: [],
showImageResults: false,
//
fileList: [],
showImageResults: false,
//
imageResults: [],
selectedImages: {}, //
isSidebarVisible: true, // /
addId: '',
}
},
created() {
//
this.getImageListAPI()
},
methods: {
async getImageListAPI() {
try {
const res = await getImageListAPI({operaType: 2})
//
if (res.code === 200 && res.data && Array.isArray(res.data)) {
this.labelList = res.data.map(item => ({
id: item.id,
date: item.operaTime,
name: item.operaName
}))
//
imageResults: [],
selectedImages: {}, //
isSidebarVisible: true, // /
addId: '',
}
} catch (error) {
console.error('获取列表异常:', error)
}
},
createNewLabel() {
this.selectedItem = null;
this.fileList = [];
this.showImageResults = false;
this.imageResults = [];
this.selectedImages = {};
this.showNewAnnotation = true;
this.showNewAnnotationAdd = false;
this.addId ='';
created() {
//
this.getImageListAPI()
},
startUpload() {
console.log('开始上传')
if (this.fileList.length === 0) {
this.$message.warning('请上传图片')
return
}
// selectedImages
this.selectedImages = {};
//
const loading = this.$loading({
lock: true,
text: '正在上传和识别图片...',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
});
//
const originalFileList = [...this.fileList];
//
this.fileList = [];
// FormData
const formData = new FormData();
//
originalFileList.forEach(file => {
formData.append('files', file.raw); // 使 raw
});
const params = {
id: this.addId
};
formData.append('params', JSON.stringify(params));
// formData.append("id", this.addId)
addImageEvaluateAPI(formData)
.then(res => {
loading.close();
if (res.code === 200 && res.data && Array.isArray(res.data)) {
//
this.addId = res.data[0].operaId;
let allImageResults = [];
res.data.forEach(record => {
this.addId = record.operaId;
const fileResults = record.fileVoList.map((item, index) => ({
url: item.bjUrl || item.url,
id: item.imageId || index,
name: item.originalName,
contentImage: item.contentImage,
fileSize: item.fileSize,
operId: record.id,
overallScore: item.overallScore,
clarity: item.clarity,
cleanliness: item.cleanliness,
compressMarks: item.compressMarks,
impression: item.impression,
balance: item.balance,
detail: item.detail,
dictValue:item.dictValue
}));
allImageResults = allImageResults.concat(fileResults);
});
this.imageResults = allImageResults;
//
if (res.data.length > 0) {
this.refreshSidebarLabel(res.data[0].operaName, res.data[0].id);
methods: {
async getImageListAPI() {
try {
const res = await getImageListAPI({ operaType: 2 })
//
if (res.code === 200 && res.data && Array.isArray(res.data)) {
this.labelList = res.data.map((item) => ({
id: item.id,
date: item.operaTime,
name: item.operaName,
}))
}
} catch (error) {
console.error('获取列表异常:', error)
}
this.showImageResults = true;
this.showNewAnnotation = false;
this.showNewAnnotationAdd = true;
this.$message.success('上传和识别完成');
} else {
this.$message.error('上传失败');
}
})
.catch(error => {
loading.close();
console.error('上传异常:', error);
this.$message.error('上传过程中出现错误');
});
},
createNewLabel() {
this.selectedItem = null
this.fileList = []
this.showImageResults = false
this.imageResults = []
this.selectedImages = {}
this.showNewAnnotation = true
this.showNewAnnotationAdd = false
this.addId = ''
},
startUpload() {
console.log('开始上传')
if (this.fileList.length === 0) {
this.$message.warning('请上传图片')
return
}
// selectedImages
this.selectedImages = {}
//
const loading = this.$loading({
lock: true,
text: '正在上传和识别图片...',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)',
})
//
const originalFileList = [...this.fileList]
//
this.fileList = []
// FormData
const formData = new FormData()
//
originalFileList.forEach((file) => {
formData.append('files', file.raw) // 使 raw
})
const params = {
id: this.addId,
remark: this.remarkInfo,
}
formData.append('params', JSON.stringify(params))
// formData.append("id", this.addId)
addImageEvaluateAPI(formData)
.then((res) => {
loading.close()
if (
res.code === 200 &&
res.data &&
Array.isArray(res.data)
) {
//
this.addId = res.data[0].operaId
let allImageResults = []
res.data.forEach((record) => {
this.addId = record.operaId
const fileResults = record.fileVoList.map(
(item, index) => ({
url: item.bjUrl || item.url,
id: item.imageId || index,
name: item.originalName,
contentImage: item.contentImage,
fileSize: item.fileSize,
operId: record.id,
overallScore: item.overallScore,
clarity: item.clarity,
cleanliness: item.cleanliness,
compressMarks: item.compressMarks,
impression: item.impression,
balance: item.balance,
detail: item.detail,
dictValue: item.dictValue,
}),
)
allImageResults =
allImageResults.concat(fileResults)
})
this.imageResults = allImageResults
//
if (res.data.length > 0) {
this.refreshSidebarLabel(
res.data[0].operaName,
res.data[0].id,
)
}
this.showImageResults = true
this.showNewAnnotation = false
this.showNewAnnotationAdd = true
this.$message.success('上传和识别完成')
} else {
this.$message.error('上传失败')
}
})
.catch((error) => {
loading.close()
console.error('上传异常:', error)
this.$message.error('上传过程中出现错误')
})
},
refreshSidebarLabel(operaName, recordId) {
this.getImageListAPI()
setTimeout(() => {
const index = this.labelList.findIndex(
(item) => item.id === recordId,
)
if (index !== -1) {
this.labelList[index].name = operaName
}
//
this.selectedItem = recordId
}, 500) //
},
selectItem(item) {
this.selectedItem = item.id
//
this.loadRecordData(item.id)
},
loadRecordData(recordId) {
//
const record = this.labelList.find((r) => r.id === recordId)
if (record) {
this.showNewAnnotation = false
this.showNewAnnotationAdd = true
//
this.fileList = [] //
this.showImageResults = true //
this.selectedImages = {} //
//
this.generateTestData(recordId)
}
},
handleFileChange(file, fileList) {
if (file.raw) {
const reader = new FileReader()
reader.onload = (e) => {
file.url = e.target.result
}
reader.readAsDataURL(file.raw)
}
// fileListfile.url
setTimeout(() => {
this.fileList = fileList
}, 100)
},
removeImage(index) {
this.fileList.splice(index, 1)
this.$message.success('已删除文件')
},
//
handleHandClick(result, index) {
console.log('点击了图片:', index)
// 使
if (this.selectedImages[index]) {
console.log('取消选中:', index)
this.$set(this.selectedImages, index, false)
} else {
console.log('选中:', index)
this.$set(this.selectedImages, index, true)
}
},
async generateTestData(recordId) {
//
try {
const res = await getImageListDetailsAPI({
id: recordId,
operaType: 2,
})
//
if (res.code === 200 && res.data && Array.isArray(res.data)) {
this.addId = res.data[0].operaId
let allImageResults = []
res.data.forEach((record) => {
const fileResults = record.fileVoList.map(
(item, index) => ({
url: item.bjUrl || item.url,
id: item.imageId || index,
name: item.originalName,
contentImage: item.contentImage,
fileSize: item.fileSize,
operId: record.id,
overallScore: item.overallScore,
clarity: item.clarity,
cleanliness: item.cleanliness,
compressMarks: item.compressMarks,
impression: item.impression,
balance: item.balance,
detail: item.detail,
dictValue: item.dictValue,
}),
)
allImageResults = allImageResults.concat(fileResults)
})
this.imageResults = allImageResults
}
} catch (error) {
console.error('获取列表异常:', error)
}
},
confirmResults() {
const selectedItems = []
for (let index in this.selectedImages) {
const idx = parseInt(index)
if (this.selectedImages[idx]) {
selectedItems.push(this.imageResults[idx]) // index imageResults
}
}
if (selectedItems.length === 0) {
this.$message.warning('请至少选择一张图片')
return
}
// operId imageId
const imageIds = selectedItems.map((item) => item.id)
const operId = selectedItems[0].operId // operId
//
this.handleConfirm(operId, imageIds)
},
async handleConfirm(operId, imageIds) {
try {
//
const res = await updateImageSureAPI({
id: operId,
imageId: imageIds,
})
if (res.code === 200) {
this.$message.success('确认成功')
//
await this.generateTestData(operId)
} else {
this.$message.error('确认失败')
}
} catch (error) {
console.error('确认异常:', error)
this.$message.error('确认过程中出现错误')
}
},
toggleSidebar() {
this.isSidebarVisible = !this.isSidebarVisible
},
},
refreshSidebarLabel(operaName, recordId) {
this.getImageListAPI()
setTimeout(() => {
const index = this.labelList.findIndex(item => item.id === recordId);
if (index !== -1) {
this.labelList[index].name = operaName;
}
//
this.selectedItem = recordId;
}, 500); //
},
selectItem(item) {
this.selectedItem = item.id;
//
this.loadRecordData(item.id);
},
loadRecordData(recordId) {
//
const record = this.labelList.find(r => r.id === recordId);
if (record) {
this.showNewAnnotation = false;
this.showNewAnnotationAdd = true;
//
this.fileList = []; //
this.showImageResults = true; //
this.selectedImages = {}; //
//
this.generateTestData(recordId);
}
},
handleFileChange(file, fileList) {
if (file.raw) {
const reader = new FileReader();
reader.onload = (e) => {
file.url = e.target.result;
};
reader.readAsDataURL(file.raw);
}
// fileListfile.url
setTimeout(() => {
this.fileList = fileList;
}, 100);
},
removeImage(index) {
this.fileList.splice(index, 1);
this.$message.success('已删除文件');
},
//
handleHandClick(result, index) {
console.log("点击了图片:", index)
// 使
if (this.selectedImages[index]) {
console.log("取消选中:", index)
this.$set(this.selectedImages, index, false)
} else {
console.log("选中:", index)
this.$set(this.selectedImages, index, true)
}
},
async generateTestData(recordId) {
//
try {
const res = await getImageListDetailsAPI({id: recordId, operaType: 2})
//
if (res.code === 200 && res.data && Array.isArray(res.data)) {
this.addId = res.data[0].operaId;
let allImageResults = [];
res.data.forEach(record => {
const fileResults = record.fileVoList.map((item, index) => ({
url: item.bjUrl || item.url,
id: item.imageId || index,
name: item.originalName,
contentImage: item.contentImage,
fileSize: item.fileSize,
operId: record.id,
overallScore: item.overallScore,
clarity: item.clarity,
cleanliness: item.cleanliness,
compressMarks: item.compressMarks,
impression: item.impression,
balance: item.balance,
detail: item.detail,
dictValue:item.dictValue
}));
allImageResults = allImageResults.concat(fileResults);
});
this.imageResults = allImageResults;
}
} catch (error) {
console.error('获取列表异常:', error)
}
},
confirmResults(){
const selectedItems = [];
for (let index in this.selectedImages) {
const idx = parseInt(index);
if (this.selectedImages[idx]) {
selectedItems.push(this.imageResults[idx]); // index imageResults
}
}
if (selectedItems.length === 0) {
this.$message.warning('请至少选择一张图片');
return;
}
// operId imageId
const imageIds = selectedItems.map(item => item.id);
const operId = selectedItems[0].operId; // operId
//
this.handleConfirm(operId,imageIds);
},
async handleConfirm(operId,imageIds) {
try {
//
const res = await updateImageSureAPI({
id: operId,
imageId:imageIds
});
if (res.code === 200) {
this.$message.success('确认成功');
//
await this.generateTestData(operId);
} else {
this.$message.error('确认失败');
}
} catch (error) {
console.error('确认异常:', error);
this.$message.error('确认过程中出现错误');
}
},
toggleSidebar() {
this.isSidebarVisible = !this.isSidebarVisible;
}
},
}
</script>
<style scoped>
.image-captioning-container {
display: flex;
overflow: hidden;
height: calc(100vh - 84px);
width: 100%;
background: url('../../../assets/images/imageCaptioning/login-bg-background.png') no-repeat center center;
background-size: 100% 100%;
display: flex;
overflow: hidden;
height: calc(100vh - 84px);
width: 100%;
background: url('../../../assets/images/imageCaptioning/login-bg-background.png')
no-repeat center center;
background-size: 100% 100%;
}
.main-content {
flex: 1;
padding: 40px;
overflow-y: auto;
flex: 1;
padding: 40px;
overflow-y: auto;
}
.add-content {
height: 55%;
width: 60%;
margin-top: 15%;
margin-left: 22%;
height: 55%;
width: 60%;
margin-top: 15%;
margin-left: 22%;
}
.welcome-message {
text-align: center;
font-size: 20px;
margin-bottom: 50px;
font-weight: 600;
color: #334249;
font-style: normal;
text-transform: none;
text-align: center;
font-size: 20px;
margin-bottom: 50px;
font-weight: 600;
color: #334249;
font-style: normal;
text-transform: none;
}
</style>