fix:文件上传优化

This commit is contained in:
zhangzq
2026-02-24 19:23:19 +08:00
parent 2e2b36ddf8
commit 2cbf0e063c
15 changed files with 143 additions and 61 deletions

View File

@@ -325,6 +325,7 @@ function addDeviceFromTemplate(template, x, y) {
name: `${template.name}`,
type: template.type,
icon: template.icon,
path: template.path,
x: x,
y: y,
angle: 0,
@@ -364,10 +365,10 @@ function renderDevice(device) {
let iconHtml;
if (isImageUrl(template.icon)) {
iconHtml = `<img src="${template.icon}"
alt="${device.name}"
iconHtml = `<img src="${template.icon}"
alt="${device.name}"
class="device-icon-img"
style="width: 100%; height: 100%; object-fit: contain; transform: rotate(${device.angle || 0}deg);"
style="width: 100%; height: 100%; object-fit: contain; transform: rotate(${device.angle || 0}deg);"
onerror="this.style.display='none'; this.parentElement.innerHTML='📍';">`;
} else {
iconHtml = `<span style="font-size: ${iconFontSize}px; transform: rotate(${device.angle || 0}deg); display: inline-block;">${template.icon || '📍'}</span>`;

View File

@@ -190,8 +190,8 @@
if (res) {
// 保存文件ID到表单数据
const fileId = res.id || res
formData.value.icon = fileId
formData.value.path = res.storagePath
formData.value.fileId = fileId
formData.value.icon = res.storagePath
message.success('上传成功')
// 加载新上传的图片预览

View File

@@ -48,9 +48,9 @@
<template v-if="column.dataIndex === 'code'">
<span>{{ record.code }}</span>
</template>
<template v-if="column.dataIndex === 'icon'">
<a-image v-if="record.icon && getImageUrl(record.icon)" :width="50" :src="getImageUrl(record.icon)" />
<a-spin v-else-if="record.icon" size="small" />
<template v-if="column.dataIndex === 'fileId'">
<a-image v-if="record.fileId && getImageUrl(record.fileId)" :width="50" :src="getImageUrl(record.fileId)" />
<a-spin v-else-if="record.fileId" size="small" />
<span v-else>-</span>
</template>
<template v-if="column.dataIndex === 'action'">
@@ -104,8 +104,8 @@
dataIndex: 'editParam'
},
{
title: '图片路径',
dataIndex: 'path'
title: '图片文件ID',
dataIndex: 'fileId'
},
{
title: '所属区域',
@@ -191,8 +191,8 @@
// 加载所有图片
if (res.records && res.records.length > 0) {
res.records.forEach((item) => {
if (item.icon) {
loadImageById(item.icon)
if (item.fileId) {
loadImageById(item.fileId)
}
})
}