upper attachment-selector to lib

This commit is contained in:
Timi
2026-10-21 16:24:00 +08:00
parent e40c912dd9
commit c870bcdd39
43 changed files with 678 additions and 1663 deletions
+3 -6
View File
@@ -117,11 +117,9 @@
</t-form-item>
</template>
<div class="photo-wrap">
<media-selector
v-model="photoUrls"
v-model:photo-items="photos"
<attachment-selector
v-model:items="photos"
:upload="uploadPhotoList"
edit-mode
required
title="兑换凭证照片"
/>
@@ -179,7 +177,7 @@ import PointAPI from "@/api/PointAPI";
import CodeScanner from "@/components/CodeScanner.vue";
import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
import CustomerSelector from "@/components/CustomerSelector.vue";
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
import type { Customer } from "@/types/Customer";
import type { PhotoItem } from "@/types/Photo";
import type { PointAccount, PointRedeemSku } from "@/types/Point";
@@ -245,7 +243,6 @@ const requestNo = ref("");
const saving = ref(false);
const canReadPointAccount = computed(() => userStore.hasPermissions(permissionCodes.point.accountRead));
const canAdjust = computed(() => userStore.hasPermissions(permissionCodes.pointRedemption.pointAdjust));
const photoUrls = computed(() => photos.value.map(item => item.url));
const customerName = computed(() => customer.value?.name);
const skuName = computed(() => selectedSku.value ? `${selectedSku.value.product?.name || selectedSku.value.sku?.name || "未命名产品"} · ${selectedSku.value.unit?.name || ""}` : "");
const quantityStep = computed(() => getProductQuantityStep(selectedSku.value?.sku));
+15 -14
View File
@@ -22,11 +22,8 @@
<t-cell title="兑换时间" :note="timeText(item.redeemedAt)" />
<t-cell v-if="item.remark" title="备注" :note="item.remark" />
<div class="photo-wrap bg-white">
<media-selector
:model-value="attachmentUrls"
:show-add="false"
:show-remove="false"
:show-viewer-actions="false"
<attachment-selector :readonly="true"
:items="redemptionPhotoItems"
title="兑换凭证照片"
/>
</div>
@@ -69,11 +66,9 @@
<t-textarea v-model.trim="returnRemark" maxlength="500" autosize />
</t-form-item>
<t-form-item label-width="0">
<media-selector
v-model="returnPhotoUrls"
v-model:photo-items="returnPhotos"
<attachment-selector
v-model:items="returnPhotos"
:upload="uploadPhotoList"
edit-mode
required
title="冲正凭证照片"
/>
@@ -85,13 +80,14 @@
<script setup lang="ts">
import { BottomPopup } from "timi-tdesign-mobile";
import { AttachmentAPI, useUserStore } from "timi-web-api";
import { useUserStore } from "timi-web-api";
import CustomerAPI from "@/api/CustomerAPI";
import PointAPI from "@/api/PointAPI";
import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
import type { Customer } from "@/types/Customer";
import type { PhotoItem } from "@/types/Photo";
import { getAttachmentReadURL } from "@/utils/attachment";
import type { PointRedemption, PointRedemptionReturn, PointRedemptionStatus } from "@/types/Point";
import { getErrorMessage } from "@/utils/error";
import { Message } from "@/utils/message";
@@ -114,10 +110,15 @@ const returnRemark = ref("");
const returnPhotos = ref<PhotoItem[]>([]);
const returnRequestNo = ref("");
const returning = ref(false);
const attachmentUrls = computed(() => (item.value?.attachmentList || [])
const redemptionPhotoItems = computed<PhotoItem[]>(() => (item.value?.attachmentList || [])
.filter(attachment => !!attachment.id)
.map(attachment => AttachmentAPI.getReadURL(attachment.id!)));
const returnPhotoUrls = computed(() => returnPhotos.value.map(photo => photo.url));
.map(attachment => ({
attachment,
attachType: attachment.attachType || "PHOTO",
mimeType: attachment.mimeType,
previewUrl: getAttachmentReadURL(attachment.id || ""),
url: getAttachmentReadURL(attachment.id || "", 90)
})));
const canReturn = computed(() => userStore.hasPermissions(permissionCodes.pointRedemption.return)
&& (item.value?.status === "COMPLETED" || item.value?.status === "PARTIALLY_RETURNED")
&& 0 < comparePackageQuantity(remaining(), "0"));