update AIChart, customer followup, media selector
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
<div class="content">
|
||||
<div v-text="confirmText" />
|
||||
<div v-if="canUpdate" class="photo-part">
|
||||
<photo-scroller
|
||||
<media-selector
|
||||
title="核销照片(可选)"
|
||||
:model-value="photoList"
|
||||
v-model:photo-items="photoItemList"
|
||||
@@ -18,7 +18,9 @@
|
||||
:loading="isPhotoUploading"
|
||||
:show-remove="false"
|
||||
:show-viewer-actions="false"
|
||||
@add="capturePhoto"
|
||||
@add="selectPhotoFile"
|
||||
@capture-photo="capturePhoto"
|
||||
@capture-video="captureVideo"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -27,15 +29,31 @@
|
||||
ref="photoInputRef"
|
||||
class="file-input"
|
||||
type="file"
|
||||
accept="image/*"
|
||||
accept="*/*"
|
||||
multiple
|
||||
@change="handlePhotoSelected"
|
||||
>
|
||||
<input
|
||||
ref="photoCameraInputRef"
|
||||
class="file-input"
|
||||
type="file"
|
||||
accept="image/*"
|
||||
capture="environment"
|
||||
@change="handlePhotoSelected"
|
||||
>
|
||||
<input
|
||||
ref="videoInputRef"
|
||||
class="file-input"
|
||||
type="file"
|
||||
accept="video/*"
|
||||
capture="environment"
|
||||
@change="handlePhotoSelected"
|
||||
>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { AttachmentAPI, type Attachment } from "timi-web-api";
|
||||
import PhotoScroller from "@/components/PhotoScroller.vue";
|
||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||
import type { EventRecord } from "@/types/EventRecord";
|
||||
import type { PhotoItem } from "@/types/Photo";
|
||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||
@@ -65,6 +83,8 @@ const emit = defineEmits<{
|
||||
}>();
|
||||
|
||||
const photoInputRef = ref<HTMLInputElement>();
|
||||
const photoCameraInputRef = ref<HTMLInputElement>();
|
||||
const videoInputRef = ref<HTMLInputElement>();
|
||||
const photoItemList = ref<PhotoItem[]>([]);
|
||||
const isPhotoUploading = ref(false);
|
||||
const isSubmitting = ref(false);
|
||||
@@ -87,15 +107,24 @@ function buildPhotoItemList(attachmentList?: Attachment[]): PhotoItem[] {
|
||||
.map(item => ({
|
||||
attachment: item,
|
||||
attachType: item.attachType || "PHOTO",
|
||||
mimeType: item.mimeType,
|
||||
previewUrl: getAttachmentReadURL(item.id || ""),
|
||||
url: getAttachmentReadURL(item.id || "", 90)
|
||||
}));
|
||||
}
|
||||
|
||||
function capturePhoto(): void {
|
||||
photoCameraInputRef.value?.click();
|
||||
}
|
||||
|
||||
function selectPhotoFile(): void {
|
||||
photoInputRef.value?.click();
|
||||
}
|
||||
|
||||
function captureVideo(): void {
|
||||
videoInputRef.value?.click();
|
||||
}
|
||||
|
||||
async function handlePhotoSelected(event: Event): Promise<void> {
|
||||
const input = event.target as HTMLInputElement;
|
||||
const fileList = Array.from(input.files || []);
|
||||
@@ -107,12 +136,13 @@ async function handlePhotoSelected(event: Event): Promise<void> {
|
||||
try {
|
||||
const compressedFileList = await compressUploadImageList(fileList);
|
||||
const tempFileList = await AttachmentAPI.upload(compressedFileList);
|
||||
for (const item of tempFileList) {
|
||||
for (const [index, item] of tempFileList.entries()) {
|
||||
if (!item.id) {
|
||||
continue;
|
||||
}
|
||||
photoItemList.value.push({
|
||||
attachType: "PHOTO",
|
||||
mimeType: fileList[index]?.type,
|
||||
tempFileId: item.id,
|
||||
url: AttachmentAPI.getTempReadURL(item.id)
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user