修复后台售后问题单固化验收图同一图片重复展示
This commit is contained in:
@@ -28,6 +28,7 @@ import {
|
|||||||
import type { UploadedFile, WorkerAfterSalesCase, WorkOrder } from '@/types/worker-platform'
|
import type { UploadedFile, WorkerAfterSalesCase, WorkOrder } from '@/types/worker-platform'
|
||||||
import { ADMIN_DEFAULT_PAGE_SIZE, buildAdminTablePagination } from '@/utils/admin-pagination'
|
import { ADMIN_DEFAULT_PAGE_SIZE, buildAdminTablePagination } from '@/utils/admin-pagination'
|
||||||
import { formatAdminDateTime } from '@/utils/admin-time'
|
import { formatAdminDateTime } from '@/utils/admin-time'
|
||||||
|
import { uniqueUploadedFiles } from '@/utils/image-identity'
|
||||||
import { asRecord, formatMoney } from './shared'
|
import { asRecord, formatMoney } from './shared'
|
||||||
|
|
||||||
type AfterSalesCreateFormValues = {
|
type AfterSalesCreateFormValues = {
|
||||||
@@ -447,24 +448,28 @@ function getAfterSalesSnapshotFiles(item: WorkerAfterSalesCase): UploadedFile[]
|
|||||||
const acceptance = asRecord(snapshot.acceptance)
|
const acceptance = asRecord(snapshot.acceptance)
|
||||||
const files = Array.isArray(acceptance.files) ? acceptance.files : []
|
const files = Array.isArray(acceptance.files) ? acceptance.files : []
|
||||||
const imageUrls = Array.isArray(acceptance.imageUrls) ? acceptance.imageUrls : []
|
const imageUrls = Array.isArray(acceptance.imageUrls) ? acceptance.imageUrls : []
|
||||||
return [
|
// 验收资料里同一张图会同时存在于 files 与 imageUrls(历史冗余表示),
|
||||||
...files.map((value) => asRecord(value)),
|
// 必须按图片身份去重,否则固化验收图会把同一张图重复渲染多次。
|
||||||
...imageUrls.map((url) => asRecord({ url: String(url || '') })),
|
return uniqueUploadedFiles(
|
||||||
]
|
[
|
||||||
.map((file) => {
|
...files.map((value) => asRecord(value)),
|
||||||
const url = String(file.url || '').trim()
|
...imageUrls.map((url) => asRecord({ url: String(url || '') })),
|
||||||
if (!url) return null
|
]
|
||||||
return {
|
.map((file) => {
|
||||||
objectKey: String(file.objectKey || file.object_key || ''),
|
const url = String(file.url || '').trim()
|
||||||
url,
|
if (!url) return null
|
||||||
thumbnailUrl: String(file.thumbnailUrl || file.thumbnail_url || url),
|
return {
|
||||||
mediumUrl: String(file.mediumUrl || file.medium_url || url),
|
objectKey: String(file.objectKey || file.object_key || ''),
|
||||||
filename: String(file.filename || '验收图片'),
|
url,
|
||||||
contentType: String(file.contentType || ''),
|
thumbnailUrl: String(file.thumbnailUrl || file.thumbnail_url || url),
|
||||||
size: Number(file.size || 0),
|
mediumUrl: String(file.mediumUrl || file.medium_url || url),
|
||||||
} satisfies UploadedFile
|
filename: String(file.filename || '验收图片'),
|
||||||
})
|
contentType: String(file.contentType || ''),
|
||||||
.filter((file): file is UploadedFile => file !== null)
|
size: Number(file.size || 0),
|
||||||
|
} satisfies UploadedFile
|
||||||
|
})
|
||||||
|
.filter((file): file is UploadedFile => file !== null),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AfterSalesPanel
|
export default AfterSalesPanel
|
||||||
|
|||||||
Reference in New Issue
Block a user