feat: 以图搜图返回 business_data 包含 name/spec_model/url,支持详情页跳转
This commit is contained in:
@ -47,6 +47,27 @@ export interface ImageSearchItem {
|
||||
spec_model: string
|
||||
image_url: string
|
||||
similarity: number
|
||||
module_name: string
|
||||
target_id: number
|
||||
business_data: {
|
||||
record_id: number
|
||||
name?: string
|
||||
spec_model?: string
|
||||
sku?: string
|
||||
barcode?: string
|
||||
serial_number?: string
|
||||
batch_number?: string
|
||||
status?: string
|
||||
warehouse_location?: string
|
||||
stock_quantity?: number
|
||||
sale_price?: number
|
||||
common_name?: string
|
||||
category?: string
|
||||
material_type?: string
|
||||
unit?: string
|
||||
module_name: string
|
||||
url: string
|
||||
}
|
||||
}
|
||||
|
||||
/** 以图搜图响应结构 */
|
||||
|
||||
@ -99,10 +99,13 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { Camera, Loading, Picture, WarningFilled } from '@element-plus/icons-vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { imageSearch, type ImageSearchItem } from '@/api/common/upload'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
}
|
||||
@ -200,7 +203,16 @@ const handleUse = (item: ImageSearchItem) => {
|
||||
}
|
||||
|
||||
const handleView = (item: ImageSearchItem) => {
|
||||
emit('view', item)
|
||||
// 从 business_data 获取跳转 URL
|
||||
const url = item.business_data?.url
|
||||
if (url) {
|
||||
router.push(url)
|
||||
} else {
|
||||
// 兜底:使用 product_name 作为 keyword 搜索
|
||||
ElMessage.info(`未找到详情页链接,已将 "${item.product_name}" 作为关键词搜索`)
|
||||
emit('view', item)
|
||||
}
|
||||
handleClose()
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
|
||||
Reference in New Issue
Block a user