liuhairui 8 месяцев назад
Родитель
Сommit
258f573819
1 измененных файлов с 109 добавлено и 120 удалено
  1. 109 120
      src/view/performance/QualityAssessment/excessive.vue

+ 109 - 120
src/view/performance/QualityAssessment/excessive.vue

@@ -34,50 +34,51 @@
 	</el-descriptions>
 	
 	<el-descriptions
-	  title=""
-	  column="7"
-	  border
-	  class="queue-status-box"
-	>
-	  <el-descriptions-item label="总任务数">
-	    <el-tag type="info">{{ stats['总任务数'] }}</el-tag>
-	  </el-descriptions-item>
-	
-	  <el-descriptions-item label="待处理">
-	    <el-tag type="warning">{{ stats['待处理'] }}</el-tag>
-	  </el-descriptions-item>
-	
-	  <el-descriptions-item label="处理中">
-	    <el-tag type="primary">{{ stats['处理中'] }}</el-tag>
-	  </el-descriptions-item>
-	
-	  <el-descriptions-item label="成功">
-	    <el-tag type="success">{{ stats['成功'] }}</el-tag>
-	  </el-descriptions-item>
-	
-	  <el-descriptions-item label="失败">
-	    <el-tag type="danger">{{ stats['失败'] }}</el-tag>
-	  </el-descriptions-item>
-	
-	  <el-descriptions-item label="操作">
-	    <el-button
-	      type="danger"
-	      size="small"
-	      @click="stopQueueclick"
-	      :loading="isLoading"
-	      :disabled="isLoading"
-	    >停止处理
-	    </el-button>
-		<el-button
-		    type="primary"
-		    size="small"
-		    @click="handleViewQueue"
-		    :loading="isLoading"
-		  >
-		    任务列表
-		  </el-button>
-	  </el-descriptions-item>
-	</el-descriptions>
+		  title=""
+		  column="7"
+		  border
+		  class="queue-status-box"
+		>
+		  <el-descriptions-item label="总任务数">
+		    <el-tag type="info">{{ stats['总任务数'] }}</el-tag>
+		  </el-descriptions-item>
+		
+		  <el-descriptions-item label="待处理">
+		    <el-tag type="warning">{{ stats['待处理'] }}</el-tag>
+		  </el-descriptions-item>
+		
+		  <el-descriptions-item label="处理中">
+		    <el-tag type="primary">{{ stats['处理中'] }}</el-tag>
+		  </el-descriptions-item>
+		
+		  <el-descriptions-item label="成功">
+		    <el-tag type="success">{{ stats['成功'] }}</el-tag>
+		  </el-descriptions-item>
+		
+		  <el-descriptions-item label="失败">
+		    <el-tag type="danger">{{ stats['失败'] }}</el-tag>
+		  </el-descriptions-item>
+		
+		  <el-descriptions-item label="操作">
+		    <el-button
+		      type="danger"
+		      size="small"
+		      @click="stopQueueclick"
+		      :loading="isLoading"
+		      :disabled="isLoading"
+		    >停止处理
+		    </el-button>
+			<el-button
+			    type="primary"
+			    size="small"
+			    @click="handleViewQueue"
+			    :loading="isLoading"
+			  >
+			    任务列表
+			  </el-button>
+		  </el-descriptions-item>
+		</el-descriptions>
+		
 	<el-dialog
 	  v-model="queueDialogVisible"
 	  :before-close="queueDialog"
@@ -162,14 +163,13 @@
 	    </div>
 	
 	    <!-- 右侧描述信息,固定高度,可滚动 -->
-	    <div
-	      style="width: 350px; white-space: pre-wrap; overflow-y: auto; max-height: 63vh; border: 1px solid #f0f0f0; padding: 10px;"
-	    >
-	      {{ activeDescription }}
+	    <div style="width: 350px; white-space: pre-wrap; overflow-y: auto; max-height: 63vh; border: 1px solid #f0f0f0; padding: 10px;">
+			<span style="color: red;">文生图提示词</span>
+			{{ activeDescription }}
 	    </div>
 	  </div>
 	  <br />
-	  图片路径:<span>{{ path_image_url }}</span>
+	  <span>{{ path_image_url }}</span>
 	</el-dialog>
 
 	
@@ -209,15 +209,11 @@
 			>
 			  <el-table-column type="selection" width="50" align="center" />
 			  <el-table-column prop="id" label="ID" width="60" align="center"/>
-			  <!-- <el-table-column prop="created_time" label="日期" width="160" align="center"/> -->
-			 <!-- <el-table-column prop="width" label="宽度" width="70" align="center"/>
-			  <el-table-column prop="height" label="高度" width="70" align="center"/> -->
-			  <el-table-column label="原图尺码" width="100" align="center">
+			  <el-table-column label="原图尺码" width="120" align="center">
 			    <template #default="{ row }">
 			      {{ row.width }} x {{ row.height }}
 			    </template>
 			  </el-table-column>
-
 			  <el-table-column label="状态" width="90">
 				<template #default="{ row }">
 				  <el-tag type="success" v-if="row.is_processed === 1">已出图</el-tag>
@@ -281,6 +277,8 @@
 				</el-descriptions-item>
 				
 				<el-descriptions-item label="操作">
+					<el-button type="primary" @click="imgtotext" :loading="isLoading">执行图生文</el-button>
+					<el-button type="primary" @click="texttoimg" :loading="isLoading">执行文生图</el-button>
 					<el-button type="primary" @click="handleSelected" :loading="isLoading" :disabled="isLoading">执行选择任务</el-button>
 					<el-button type="primary" @click="handleAll" :loading="isLoading">执行全部任务</el-button>
 				</el-descriptions-item>
@@ -497,10 +495,10 @@ const handleSizeChange = (val) => {
 };
 
 //---------------选择框----------------
-const filterStatus = ref('全部') // 默认值为“全部”
+const filterStatus = ref('全部')
 const handleFilterChange = () => {
-  console.log('当前选择状态:', filterStatus.value);
-  page.value = 1; // 切换筛选条件时重置页码
+  // console.log('当前选择状态:', filterStatus.value);
+  page.value = 1;
   fetchPreviewImages();
 };
 
@@ -512,7 +510,7 @@ const _resrow = ref('')
 const record_deleteRow = async (row) => {
 	getPreviewSubDirslist()
 	_resrow.value = row;
-	page.value = 1; // 打开时默认从第一页开始
+	page.value = 1;
 	mlinventoryVisible.value = true;
 	
 	const res = await Template();
@@ -526,7 +524,6 @@ const record_deleteRow = async (row) => {
 //打包zip
 const packRow = async (row) => {
   isLoading.value = true;
-
   try {
     // 请求预览图接口获取图片路径
     const res = await getPreviewimg({
@@ -534,15 +531,12 @@ const packRow = async (row) => {
       page: 1,
       limit: 9999
     });
-
     if (res.code !== 0 || !res.data || res.data.length === 0) {
       ElMessage.warning('未找到出图记录');
       isLoading.value = false;
       return;
     }
-
    const imagePaths = res.data
-     // .map(item => item.custom_image_url || item.new_image_url)
 	 .map(item => item.custom_image_url)
      .filter(path => path && path.trim() !== '');
 
@@ -551,14 +545,12 @@ const packRow = async (row) => {
       isLoading.value = false;
       return;
     }
-
     // 发起打包请求
     const packRes = await packImagess({ paths: imagePaths });
 
     if (packRes.code === 0 && packRes.download_url) {
       ElMessage.success('打包成功,正在下载...');
-
-      // 自动触发浏览器下载 zip 文件
+    // 自动触发浏览器下载 zip 文件
     let url = packRes.download_url.replace('127.0.0.1', '20.0.16.128');
     const link = document.createElement('a');
     link.href = url;
@@ -573,7 +565,6 @@ const packRow = async (row) => {
     ElMessage.error('打包请求异常');
     console.error(err);
   }
-
   isLoading.value = false;
 };
 
@@ -581,12 +572,10 @@ const packRow = async (row) => {
 
 const imageList = ref([]);
 const _oldrow = ref('');
-
 //点击当前行
 const handleRowClick = async (row) => {
 	console.log("当前行信息",row)
 	_oldrow.value = row
-	
   const res = await getlsit({ path: row['path'] });
   if (res.data === null) {
     imageList.value = [];
@@ -607,8 +596,6 @@ const mlcloseDialog = () => {
   mlinventoryVisible.value = false
 }
 
-
-
 /**
  * 点击查看图片显示
 */
@@ -616,35 +603,25 @@ const activeDescription = ref('');
 const path_image_url = ref('');
 const new_image_url = ref('');
 const showDescDialog = ref(false);
-
 const showDescription = (img, type) => {
 	new_image_url.value = ''
 	path_image_url.value = ''
-	console.log(img)
-	console.log(type)
-	
-  
-  if (type === 'new') {
-    new_image_url.value = img.new_image_url || '';
-	path_image_url.value = img.new_image_url || '暂无说明';
-	activeDescription.value =  "文生图提示词:" + "\n" +  "\n" + img.chinese_description +  "\n" +  "\n" + img.english_description +  "\n" +  "\n" + img.img_name || '暂无说明';
-	// new_image_url.value = img.custom_image_url || '';
-	// path_image_url.value = img.custom_image_url || '暂无说明';
-	// activeDescription.value =  "文生图提示词:" + "\n" +  "\n" + img.chinese_description +  "\n" +  "\n" + img.english_description +  "\n" +  "\n" + img.img_name || '暂无说明';
-  }else if (type === 'custom'){
-	new_image_url.value = img.custom_image_url || '';
-	path_image_url.value = img.custom_image_url || '暂无说明';
-	activeDescription.value =  "文生图提示词:" + "\n" +  "\n" + img.chinese_description +  "\n" +  "\n" + img.english_description +  "\n" +  "\n" + img.img_name || '暂无说明';
-  } else if (type === 'old') { 
-    new_image_url.value = img.path || '';
-	path_image_url.value = img.path || '暂无说明';
-	activeDescription.value =  '暂无说明';
-	// activeDescription.value =  "图生文提示词:" + "\n" +  "\n" + img.old_description"";
-  }else{
+	if (type === 'new') {
+		new_image_url.value = img.new_image_url || '';
+		path_image_url.value = "新图片路径:" + img.new_image_url || '图片未生成';
+		activeDescription.value =  "\n" +  "\n" + img.chinese_description +  "\n" +  "\n" + img.english_description +  "\n" +  "\n" + img.img_name || '暂无说明';
+	}else if (type === 'custom'){
+		new_image_url.value = img.custom_image_url || '';
+		path_image_url.value = "新图片路径:" + img.custom_image_url || '图片未生成';
+		activeDescription.value =   "\n" +  "\n" + img.chinese_description +  "\n" +  "\n" + img.english_description +  "\n" +  "\n" + img.img_name || '暂无说明';
+	} else if (type === 'old') { 
+		new_image_url.value = img.path || '';
+		path_image_url.value =  "原图片路径:" + img.path || '暂无说明';
+		activeDescription.value =  '';
+	}else{
 	  console.log('无')
-  }
-
-  showDescDialog.value = true;
+	}
+	showDescDialog.value = true;
 };
 
 const hideDescription = () => {
@@ -655,57 +632,75 @@ const hideDescription = () => {
   
   
   
- // --------------------- 更新图片列表方法 ---------------------
- const updateImageList = async () => {
-   const res = await getlsit({ path: _oldrow.value['path'] })
-   if (res.data === null) {
-     imageList.value = []
-   } else {
-     imageList.value = res.data.map(item => ({
-       chinese_description: item.chinese_description,
-       new_image_url: item.new_image_url,
-       custom_image_url: item.custom_image_url,
-       size: item.size
-     }))
-   }
- }
+// --------------------- 更新图片列表方法 ---------------------
+const updateImageList = async () => {
+const res = await getlsit({ path: _oldrow.value['path'] })
+	if (res.data === null) {
+	 imageList.value = []
+	} else {
+	 imageList.value = res.data.map(item => ({
+	   chinese_description: item.chinese_description,
+	   new_image_url: item.new_image_url,
+	   custom_image_url: item.custom_image_url,
+	   size: item.size
+	 }))
+	}
+}
  
 const _parh = ref('')
 const SelectionChange = (rows) => {
 	console.log(rows)
 	// 提取所有选中项的 path 数组
 	_parh.value = rows.map(item => item.path);
-	console.log('选中的图片路径:', _parh.value);
+	// console.log('选中的图片路径:', _parh.value);
 };
 
 
 const isLoading = ref(false)
 const num = ref(1)
+//执行图生文、选择执行选择图片,没有选择执行当前页图片处理
+const imgtotext = () => {
+	if(_parh.value){
+		processImages(toRaw(_parh.value),'图生文');
+	}else{
+		const allPaths = toRaw(tableData_lsit.value).map(item => item.path);
+		processImages(allPaths,'图生文');
+	}
+};
+//执行文生图、选择执行选择图片,没有选择执行当前页图片处理
+const texttoimg = () => {
+	if(_parh.value){
+		processImages(toRaw(_parh.value),'文生图');
+	}else{
+		const allPaths = toRaw(tableData_lsit.value).map(item => item.path);
+		processImages(allPaths,'文生图');
+	}
+};
+//执行选择任务
 const handleSelected = () => {
   processImages(toRaw(_parh.value));
 };
-
+//执行全部任务
 const handleAll = () => {
   const allPaths = toRaw(tableData_lsit.value).map(item => item.path);
   processImages(allPaths);
 };
 
-const processImages = async (files) => {
+const processImages = async (files,type) => {
   if (!Array.isArray(files) || files.length === 0) {
     ElMessage.warning('请选择要处理的图片')
     return
   }
-
   // 限制尺寸校验放外面更合理
   if (width.value >= 1024 || height.value >= 1024) {
     ElMessage.warning('尺寸不可超过1024')
     return
   }
-
   isLoading.value = true
   let successCount = 0
   const failList = []
 	const payload = {
+	  type:type,
 	  prompt: textareaContent.value,
 	  batch:files,
 	  num:num.value,
@@ -714,19 +709,13 @@ const processImages = async (files) => {
 	}
 	try {
 	  const res = await imageToText(payload)
-	  
 	} catch (e) {
 	  failList.push(`第 ${batchStart + i + 1} 张 第 ${j + 1} 次`)
 	}
-  // 设定每 batch 执行的图片数量(如 20 张)
-  
-
   ElMessage.success(`共处理 ${files.length} 张 * ${num.value} 次,共 ${files.length * num.value} 次`)
-
   if (failList.length > 0) {
     console.warn('失败列表:', failList)
   }
-
   isLoading.value = false
 }