change type in PhotoScroller
This commit is contained in:
@@ -33,8 +33,10 @@
|
||||
<photo-scroller
|
||||
:model-value="photoList"
|
||||
:photo-items="photoItemList"
|
||||
:show-viewer-actions="canUpdateCustomer"
|
||||
:show-add="false"
|
||||
:show-remove="false"
|
||||
:submit="submitPhotoItems"
|
||||
title="照片列表"
|
||||
/>
|
||||
</template>
|
||||
@@ -152,7 +154,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Message } from "@/utils/message";
|
||||
import { PassTimeLabel, Text, useUserStore } from "timi-web";
|
||||
import { PassTimeLabel, Text, useUserStore, type Attachment } from "timi-web";
|
||||
import CustomerAPI from "@/api/CustomerAPI";
|
||||
import PointAPI from "@/api/PointAPI";
|
||||
import TagAPI from "@/api/TagAPI";
|
||||
@@ -164,6 +166,7 @@ import CustomerTagCard from "@/pages/customer/component/CustomerTagCard.vue";
|
||||
import { useNavBarStore } from "@/store/navBarStore";
|
||||
import type { BodyAreaValue, Customer } from "@/types/Customer";
|
||||
import type { PointAccount } from "@/types/Point";
|
||||
import type { PhotoItem } from "@/types/Photo";
|
||||
import type { Tag } from "@/types/Tag";
|
||||
import { bodyAreaLabelMap } from "@/utils/bodyArea";
|
||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||
@@ -189,6 +192,7 @@ const canReadStat = computed(() => userStore.hasPermissions(permissionCodes.stat
|
||||
const canReadPointAccount = computed(() => userStore.hasPermissions(permissionCodes.point.accountRead));
|
||||
const canReadTag = computed(() => userStore.hasPermissions(corePermissionCodes.tag.read));
|
||||
const canApplyTag = computed(() => userStore.hasPermissions(corePermissionCodes.tag.apply));
|
||||
const canUpdateCustomer = computed(() => userStore.hasPermissions(permissionCodes.customer.update));
|
||||
const removeCustomerName = computed(() => removeTarget.value?.name || "");
|
||||
const canConfirmRemove = computed(() => !!removeCustomerName.value && removeConfirmName.value === removeCustomerName.value);
|
||||
|
||||
@@ -204,11 +208,50 @@ const inviteeCountText = computed(() => `${customer.value?.invitedCount ?? 0}
|
||||
const photoItemList = computed(() => (customer.value?.attachmentList || [])
|
||||
.filter(item => !!item.id)
|
||||
.map(item => ({
|
||||
attachment: item,
|
||||
attachType: item.attachType || "PHOTO",
|
||||
previewUrl: getAttachmentReadURL(item.id || ""),
|
||||
url: getAttachmentReadURL(item.id || "", 90)
|
||||
})));
|
||||
const photoList = computed(() => photoItemList.value.map(item => item.url));
|
||||
|
||||
async function submitPhotoItems(photoItems: PhotoItem[]): Promise<void> {
|
||||
const currentCustomer = customer.value;
|
||||
if (!currentCustomer?.id || !currentCustomer.name) {
|
||||
throw new Error("客户资料不完整");
|
||||
}
|
||||
|
||||
const attachmentList = buildPhotoAttachmentList(photoItems);
|
||||
const payload: Customer = {
|
||||
...currentCustomer,
|
||||
attachmentList
|
||||
};
|
||||
delete payload.tagApply;
|
||||
delete payload.introducerCustomer;
|
||||
await CustomerAPI.update(payload);
|
||||
customer.value = {
|
||||
...currentCustomer,
|
||||
attachmentList
|
||||
};
|
||||
}
|
||||
|
||||
function buildPhotoAttachmentList(photoItems: PhotoItem[]): Attachment[] {
|
||||
return photoItems.flatMap(item => {
|
||||
if (item.attachment) {
|
||||
return [{
|
||||
...item.attachment,
|
||||
attachType: item.attachType || item.attachment.attachType || "PHOTO"
|
||||
}];
|
||||
}
|
||||
if (item.tempFileId) {
|
||||
return [{
|
||||
attachType: item.attachType || "PHOTO",
|
||||
tempFileId: item.tempFileId
|
||||
}];
|
||||
}
|
||||
return [];
|
||||
});
|
||||
}
|
||||
const selectedAreas = computed<BodyAreaValue>({
|
||||
get() {
|
||||
return normalizeBodyAreaValue(customer.value?.conditioningPart);
|
||||
|
||||
Reference in New Issue
Block a user