fix miss photo for product

This commit is contained in:
Timi
2026-10-30 00:47:08 +08:00
parent d656725334
commit eb6b781d7b
+4 -6
View File
@@ -47,7 +47,7 @@
v-model:items="attachmentItemList" v-model:items="attachmentItemList"
title="产品公共图片及附件" title="产品公共图片及附件"
:busy="isAttachmentUploading" :busy="isAttachmentUploading"
@select="handleAttachmentSelected($event.files, $event.source)" @select="handleAttachmentSelected($event.files)"
/> />
</t-form-item> </t-form-item>
<t-form-item label="纯色封面" label-width="8rem" content-align="right"> <t-form-item label="纯色封面" label-width="8rem" content-align="right">
@@ -227,8 +227,7 @@ import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelect
import ProductSkuEditor from "@/pages/product/component/ProductSkuEditor.vue"; import ProductSkuEditor from "@/pages/product/component/ProductSkuEditor.vue";
import ProductSkuUnitEditor from "@/pages/product/component/ProductSkuUnitEditor.vue"; import ProductSkuUnitEditor from "@/pages/product/component/ProductSkuUnitEditor.vue";
import ProductSkuUnitBatchEditor from "@/pages/product/component/ProductSkuUnitBatchEditor.vue"; import ProductSkuUnitBatchEditor from "@/pages/product/component/ProductSkuUnitBatchEditor.vue";
import type { AttachmentSelectorSelection } from "@/components/attachmentSelector/types"; import type { Product, ProductCategory, ProductSku, ProductSkuUnit, ProductSpec, ProductType } from "@/types/Product";
import type { Product, ProductAttachmentType, ProductCategory, ProductSku, ProductSkuUnit, ProductSpec, ProductType } from "@/types/Product";
import type { ProductAttachmentItem, ProductForm, ProductSkuForm as SkuForm, ProductSkuUnitForm as UnitForm, ProductSpecForm as SpecForm, ProductSpecValueForm as SpecValueForm } from "@/types/ProductEditor"; import type { ProductAttachmentItem, ProductForm, ProductSkuForm as SkuForm, ProductSkuUnitForm as UnitForm, ProductSpecForm as SpecForm, ProductSpecValueForm as SpecValueForm } from "@/types/ProductEditor";
import { compressUploadImageList } from "@/utils/imageCompression"; import { compressUploadImageList } from "@/utils/imageCompression";
import { getAttachmentReadURL } from "@/utils/attachment"; import { getAttachmentReadURL } from "@/utils/attachment";
@@ -642,11 +641,10 @@ async function confirmCoverColorPicker(): Promise<void> {
} }
} }
async function handleAttachmentSelected(files: File[], source: AttachmentSelectorSelection["source"]): Promise<void> { async function handleAttachmentSelected(files: File[]): Promise<void> {
if (!files.length) { if (!files.length) {
return; return;
} }
const attachType: ProductAttachmentType = source === "photo" ? "PHOTO" : "OTHER";
isAttachmentUploading.value = true; isAttachmentUploading.value = true;
try { try {
const compressedFiles = await compressUploadImageList(files); const compressedFiles = await compressUploadImageList(files);
@@ -656,7 +654,7 @@ async function handleAttachmentSelected(files: File[], source: AttachmentSelecto
continue; continue;
} }
attachmentItemList.value.push({ attachmentItemList.value.push({
attachType, attachType: files[index]?.type.startsWith("image/") ? "PHOTO" : "OTHER",
mimeType: files[index]?.type, mimeType: files[index]?.type,
tempFileId: tempFile.id, tempFileId: tempFile.id,
url: AttachmentAPI.getTempReadURL(tempFile.id) url: AttachmentAPI.getTempReadURL(tempFile.id)