upper attachment-selector to lib
This commit is contained in:
+1
-1
@@ -28,7 +28,7 @@
|
||||
"echarts-wordcloud": "^2.1.0",
|
||||
"less": "^4.3.0",
|
||||
"pinia": "^3.0.2",
|
||||
"tdesign-mobile-vue": "^1.16.0",
|
||||
"tdesign-mobile-vue": "^1.16.2",
|
||||
"timi-tdesign-mobile": "link:E:/WebProject/timi-tdesign-mobile",
|
||||
"timi-web": "link:E:/WebProject/timi-web",
|
||||
"timi-web-api": "link:E:/WebProject/timi-web-api",
|
||||
|
||||
@@ -1,80 +1,21 @@
|
||||
diff --git a/es/swiper/props.mjs b/es/swiper/props.mjs
|
||||
--- a/es/swiper/props.mjs
|
||||
+++ b/es/swiper/props.mjs
|
||||
@@ -55,5 +55,5 @@
|
||||
},
|
||||
navigation: {
|
||||
- type: [Object, Function]
|
||||
+ type: [Boolean, Object, Function]
|
||||
},
|
||||
nextMargin: {
|
||||
diff --git a/esm/swiper/props.js b/esm/swiper/props.js
|
||||
--- a/esm/swiper/props.js
|
||||
+++ b/esm/swiper/props.js
|
||||
@@ -55,5 +55,5 @@
|
||||
},
|
||||
navigation: {
|
||||
- type: [Object, Function]
|
||||
+ type: [Boolean, Object, Function]
|
||||
},
|
||||
nextMargin: {
|
||||
diff --git a/lib/swiper/props.js b/lib/swiper/props.js
|
||||
--- a/lib/swiper/props.js
|
||||
+++ b/lib/swiper/props.js
|
||||
@@ -55,5 +55,5 @@
|
||||
},
|
||||
navigation: {
|
||||
- type: [Object, Function]
|
||||
+ type: [Boolean, Object, Function]
|
||||
},
|
||||
nextMargin: {
|
||||
diff --git a/cjs/swiper/props.js b/cjs/swiper/props.js
|
||||
index 5615922a8c3410f703f768e363d39afa3138e7b1..b9a192a32dba34970287d0521e7e2077ac5b034c 100644
|
||||
--- a/cjs/swiper/props.js
|
||||
+++ b/cjs/swiper/props.js
|
||||
@@ -59,5 +59,5 @@
|
||||
@@ -57,7 +57,7 @@ var props = {
|
||||
default: true
|
||||
},
|
||||
navigation: {
|
||||
- type: [Object, Function]
|
||||
+ type: [Boolean, Object, Function]
|
||||
},
|
||||
nextMargin: {
|
||||
diff --git a/es/swiper/type.d.ts b/es/swiper/type.d.ts
|
||||
--- a/es/swiper/type.d.ts
|
||||
+++ b/es/swiper/type.d.ts
|
||||
@@ -10,6 +10,6 @@
|
||||
height?: string | number;
|
||||
interval?: number;
|
||||
loop?: boolean;
|
||||
- navigation?: SwiperNavigation | TNode;
|
||||
+ navigation?: boolean | SwiperNavigation | TNode;
|
||||
nextMargin?: string | number;
|
||||
previousMargin?: string | number;
|
||||
diff --git a/esm/swiper/type.d.ts b/esm/swiper/type.d.ts
|
||||
--- a/esm/swiper/type.d.ts
|
||||
+++ b/esm/swiper/type.d.ts
|
||||
@@ -10,6 +10,6 @@
|
||||
height?: string | number;
|
||||
interval?: number;
|
||||
loop?: boolean;
|
||||
- navigation?: SwiperNavigation | TNode;
|
||||
+ navigation?: boolean | SwiperNavigation | TNode;
|
||||
nextMargin?: string | number;
|
||||
previousMargin?: string | number;
|
||||
diff --git a/lib/swiper/type.d.ts b/lib/swiper/type.d.ts
|
||||
--- a/lib/swiper/type.d.ts
|
||||
+++ b/lib/swiper/type.d.ts
|
||||
@@ -10,6 +10,6 @@
|
||||
height?: string | number;
|
||||
interval?: number;
|
||||
loop?: boolean;
|
||||
- navigation?: SwiperNavigation | TNode;
|
||||
+ navigation?: boolean | SwiperNavigation | TNode;
|
||||
nextMargin?: string | number;
|
||||
previousMargin?: string | number;
|
||||
type: [String, Number],
|
||||
diff --git a/cjs/swiper/type.d.ts b/cjs/swiper/type.d.ts
|
||||
index f72d82f2902ebd0636c091450a0d77ae00964917..75b7920cb3e94fac6fc7c1ef909c6972128d06f3 100644
|
||||
--- a/cjs/swiper/type.d.ts
|
||||
+++ b/cjs/swiper/type.d.ts
|
||||
@@ -10,6 +10,6 @@
|
||||
@@ -10,7 +10,7 @@ export interface TdSwiperProps {
|
||||
height?: string | number;
|
||||
interval?: number;
|
||||
loop?: boolean;
|
||||
@@ -82,10 +23,14 @@ diff --git a/cjs/swiper/type.d.ts b/cjs/swiper/type.d.ts
|
||||
+ navigation?: boolean | SwiperNavigation | TNode;
|
||||
nextMargin?: string | number;
|
||||
previousMargin?: string | number;
|
||||
onChange?: (current: number, context: {
|
||||
diff --git a/es/shared/hover.mjs b/es/shared/hover.mjs
|
||||
index 634ba6d66891d1c98d62c48d2069a0519a6633ed..20c84d3176f194afe1fa530d8db3a87b0faf2979 100644
|
||||
--- a/es/shared/hover.mjs
|
||||
+++ b/es/shared/hover.mjs
|
||||
@@ -50,29 +50,33 @@
|
||||
@@ -48,13 +48,15 @@ var Hover = {
|
||||
current: state,
|
||||
timers: [],
|
||||
add: function add() {
|
||||
- if (ctx.current.disabledHover || !ctx.current.className) return;
|
||||
- if (!el.classList.contains(ctx.current.className)) {
|
||||
@@ -103,8 +48,7 @@ diff --git a/es/shared/hover.mjs b/es/shared/hover.mjs
|
||||
},
|
||||
clearTimers: function clearTimers() {
|
||||
ctx.timers.forEach(function (t) {
|
||||
return window.clearTimeout(t);
|
||||
});
|
||||
@@ -63,18 +65,20 @@ var Hover = {
|
||||
ctx.timers = [];
|
||||
},
|
||||
downHandler: function downHandler() {
|
||||
@@ -127,3 +71,83 @@ diff --git a/es/shared/hover.mjs b/es/shared/hover.mjs
|
||||
- }, ctx.current.stayTime));
|
||||
+ }, current.stayTime));
|
||||
},
|
||||
cancelHandler: function cancelHandler() {
|
||||
ctx.clearTimers();
|
||||
diff --git a/es/swiper/props.mjs b/es/swiper/props.mjs
|
||||
index a48cee3e0abe71c2ef1f3e83303ec061cb098f8d..27511b26df36116f59a27b584120ea71451d7bf0 100644
|
||||
--- a/es/swiper/props.mjs
|
||||
+++ b/es/swiper/props.mjs
|
||||
@@ -53,7 +53,7 @@ var props = {
|
||||
default: true
|
||||
},
|
||||
navigation: {
|
||||
- type: [Object, Function]
|
||||
+ type: [Boolean, Object, Function]
|
||||
},
|
||||
nextMargin: {
|
||||
type: [String, Number],
|
||||
diff --git a/es/swiper/type.d.ts b/es/swiper/type.d.ts
|
||||
index f72d82f2902ebd0636c091450a0d77ae00964917..75b7920cb3e94fac6fc7c1ef909c6972128d06f3 100644
|
||||
--- a/es/swiper/type.d.ts
|
||||
+++ b/es/swiper/type.d.ts
|
||||
@@ -10,7 +10,7 @@ export interface TdSwiperProps {
|
||||
height?: string | number;
|
||||
interval?: number;
|
||||
loop?: boolean;
|
||||
- navigation?: SwiperNavigation | TNode;
|
||||
+ navigation?: boolean | SwiperNavigation | TNode;
|
||||
nextMargin?: string | number;
|
||||
previousMargin?: string | number;
|
||||
onChange?: (current: number, context: {
|
||||
diff --git a/esm/swiper/props.js b/esm/swiper/props.js
|
||||
index 1b4ac31d550b0cb1aac6cc0f4bca7590d6df16cb..c959b7eaa05bd34704bf724f77fe5be230dbb0ad 100644
|
||||
--- a/esm/swiper/props.js
|
||||
+++ b/esm/swiper/props.js
|
||||
@@ -53,7 +53,7 @@ var props = {
|
||||
default: true
|
||||
},
|
||||
navigation: {
|
||||
- type: [Object, Function]
|
||||
+ type: [Boolean, Object, Function]
|
||||
},
|
||||
nextMargin: {
|
||||
type: [String, Number],
|
||||
diff --git a/esm/swiper/type.d.ts b/esm/swiper/type.d.ts
|
||||
index f72d82f2902ebd0636c091450a0d77ae00964917..75b7920cb3e94fac6fc7c1ef909c6972128d06f3 100644
|
||||
--- a/esm/swiper/type.d.ts
|
||||
+++ b/esm/swiper/type.d.ts
|
||||
@@ -10,7 +10,7 @@ export interface TdSwiperProps {
|
||||
height?: string | number;
|
||||
interval?: number;
|
||||
loop?: boolean;
|
||||
- navigation?: SwiperNavigation | TNode;
|
||||
+ navigation?: boolean | SwiperNavigation | TNode;
|
||||
nextMargin?: string | number;
|
||||
previousMargin?: string | number;
|
||||
onChange?: (current: number, context: {
|
||||
diff --git a/lib/swiper/props.js b/lib/swiper/props.js
|
||||
index 1b4ac31d550b0cb1aac6cc0f4bca7590d6df16cb..c959b7eaa05bd34704bf724f77fe5be230dbb0ad 100644
|
||||
--- a/lib/swiper/props.js
|
||||
+++ b/lib/swiper/props.js
|
||||
@@ -53,7 +53,7 @@ var props = {
|
||||
default: true
|
||||
},
|
||||
navigation: {
|
||||
- type: [Object, Function]
|
||||
+ type: [Boolean, Object, Function]
|
||||
},
|
||||
nextMargin: {
|
||||
type: [String, Number],
|
||||
diff --git a/lib/swiper/type.d.ts b/lib/swiper/type.d.ts
|
||||
index f72d82f2902ebd0636c091450a0d77ae00964917..75b7920cb3e94fac6fc7c1ef909c6972128d06f3 100644
|
||||
--- a/lib/swiper/type.d.ts
|
||||
+++ b/lib/swiper/type.d.ts
|
||||
@@ -10,7 +10,7 @@ export interface TdSwiperProps {
|
||||
height?: string | number;
|
||||
interval?: number;
|
||||
loop?: boolean;
|
||||
- navigation?: SwiperNavigation | TNode;
|
||||
+ navigation?: boolean | SwiperNavigation | TNode;
|
||||
nextMargin?: string | number;
|
||||
previousMargin?: string | number;
|
||||
onChange?: (current: number, context: {
|
||||
|
||||
Generated
+9
-9
@@ -30,8 +30,8 @@ importers:
|
||||
specifier: ^3.0.2
|
||||
version: 3.0.4(typescript@5.8.3)(vue@3.5.40(typescript@5.8.3))
|
||||
tdesign-mobile-vue:
|
||||
specifier: ^1.16.0
|
||||
version: 1.16.0(vue@3.5.40(typescript@5.8.3))
|
||||
specifier: ^1.16.2
|
||||
version: 1.16.2(vue@3.5.40(typescript@5.8.3))
|
||||
timi-tdesign-mobile:
|
||||
specifier: link:E:/WebProject/timi-tdesign-mobile
|
||||
version: link:../timi-tdesign-mobile
|
||||
@@ -1735,13 +1735,13 @@ packages:
|
||||
resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
tdesign-icons-vue-next@0.4.7:
|
||||
resolution: {integrity: sha512-0TRVH0L9O7vAMQ7j2vU/VYBMzS5FI+OVf7bWjwAVMmWXArsAyJI8mzpNWThZok96B6hsRY+2hK/NSOFZy8hMqA==}
|
||||
tdesign-icons-vue-next@0.4.11:
|
||||
resolution: {integrity: sha512-lBkRUy8bdb6lQLFOOkSb1LPdl4CmZRewrc8SOUlmWkDD/DG3BTsSd/ZQ4Z767pPSlypyvxwSwcJgRv6+zjubAQ==}
|
||||
peerDependencies:
|
||||
vue: ^3.0.0
|
||||
|
||||
tdesign-mobile-vue@1.16.0:
|
||||
resolution: {integrity: sha512-Msn9PRrOkJD22hGFqSS3l0gvoaXTB2a5CTyvzazzPTITJmkY4CnC7ySbOsGxlA2qT/HyL44v+JJYauzUycQ1Fg==}
|
||||
tdesign-mobile-vue@1.16.2:
|
||||
resolution: {integrity: sha512-05lOApsyGeIFzlOuJvvm+P0o3h7FeHM9HsPcslRFPwOQXIZW1AvJhnvP7aon3mdFtUEFdeja6yq7uJB8Os4haQ==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
peerDependencies:
|
||||
vue: ^3.2.6
|
||||
@@ -3673,19 +3673,19 @@ snapshots:
|
||||
dependencies:
|
||||
has-flag: 4.0.0
|
||||
|
||||
tdesign-icons-vue-next@0.4.7(vue@3.5.40(typescript@5.8.3)):
|
||||
tdesign-icons-vue-next@0.4.11(vue@3.5.40(typescript@5.8.3)):
|
||||
dependencies:
|
||||
'@babel/runtime': 7.29.7
|
||||
vue: 3.5.40(typescript@5.8.3)
|
||||
|
||||
tdesign-mobile-vue@1.16.0(vue@3.5.40(typescript@5.8.3)):
|
||||
tdesign-mobile-vue@1.16.2(vue@3.5.40(typescript@5.8.3)):
|
||||
dependencies:
|
||||
'@babel/runtime': 7.29.7
|
||||
'@use-gesture/vanilla': 10.3.1
|
||||
'@vueuse/core': 10.7.0(vue@3.5.40(typescript@5.8.3))
|
||||
dayjs: 1.11.21
|
||||
lodash-es: 4.18.1
|
||||
tdesign-icons-vue-next: 0.4.7(vue@3.5.40(typescript@5.8.3))
|
||||
tdesign-icons-vue-next: 0.4.11(vue@3.5.40(typescript@5.8.3))
|
||||
tinycolor2: 1.6.0
|
||||
validator: 13.15.35
|
||||
vue: 3.5.40(typescript@5.8.3)
|
||||
|
||||
@@ -10,57 +10,28 @@
|
||||
<div class="content">
|
||||
<div v-text="confirmText" />
|
||||
<div v-if="canUpdate" class="photo-part">
|
||||
<media-selector
|
||||
<attachment-selector
|
||||
title="核销照片(可选)"
|
||||
:model-value="photoList"
|
||||
v-model:photo-items="photoItemList"
|
||||
:edit-mode="true"
|
||||
:loading="isPhotoUploading"
|
||||
:show-remove="false"
|
||||
:show-viewer-actions="false"
|
||||
@add="selectPhotoFile"
|
||||
@capture-photo="capturePhoto"
|
||||
@capture-video="captureVideo"
|
||||
/>
|
||||
v-model:items="photoItemList"
|
||||
:busy="isPhotoUploading"
|
||||
@select="handlePhotoSelected($event.files)"
|
||||
>
|
||||
<template #item-actions />
|
||||
</attachment-selector>
|
||||
</div>
|
||||
</div>
|
||||
</t-dialog>
|
||||
<input
|
||||
ref="photoInputRef"
|
||||
class="file-input"
|
||||
type="file"
|
||||
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 MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
|
||||
import type { EventRecord } from "@/types/EventRecord";
|
||||
import type { PhotoItem } from "@/types/Photo";
|
||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { compressUploadImageList } from "@/utils/imageCompression";
|
||||
import { Message } from "@/utils/message";
|
||||
import { saveCapturedFilesFromInput } from "@/utils/twaBridge";
|
||||
|
||||
defineOptions({
|
||||
name: "EventRecordVerifyDialog"
|
||||
@@ -83,9 +54,6 @@ const emit = defineEmits<{
|
||||
verified: [record: EventRecord];
|
||||
}>();
|
||||
|
||||
const photoInputRef = ref<HTMLInputElement>();
|
||||
const photoCameraInputRef = ref<HTMLInputElement>();
|
||||
const videoInputRef = ref<HTMLInputElement>();
|
||||
const photoItemList = ref<PhotoItem[]>([]);
|
||||
const isPhotoUploading = ref(false);
|
||||
const isSubmitting = ref(false);
|
||||
@@ -93,7 +61,6 @@ const visible = computed({
|
||||
get: () => props.visible,
|
||||
set: (value: boolean) => emit("update:visible", value)
|
||||
});
|
||||
const photoList = computed<string[]>(() => photoItemList.value.map(item => item.url));
|
||||
const confirmText = computed(() => `确定核销 ${props.record?.customer?.name || "未知客户"} 的 ${props.record?.event?.name || "未知事件"} 记录吗?`);
|
||||
|
||||
watch([() => props.visible, () => props.record?.id], ([isVisible]) => {
|
||||
@@ -114,25 +81,10 @@ function buildPhotoItemList(attachmentList?: Attachment[]): PhotoItem[] {
|
||||
}));
|
||||
}
|
||||
|
||||
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 || []);
|
||||
async function handlePhotoSelected(fileList: File[]): Promise<void> {
|
||||
if (!fileList.length) {
|
||||
return;
|
||||
}
|
||||
saveCapturedFilesFromInput(input, fileList);
|
||||
|
||||
isPhotoUploading.value = true;
|
||||
try {
|
||||
@@ -153,7 +105,6 @@ async function handlePhotoSelected(event: Event): Promise<void> {
|
||||
Message.error(getErrorMessage(error, "登记照片上传失败"));
|
||||
} finally {
|
||||
isPhotoUploading.value = false;
|
||||
input.value = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
<template>
|
||||
<shared-attachment-selector
|
||||
v-bind="$attrs"
|
||||
:items="attachmentItems"
|
||||
:busy="isBusy"
|
||||
:empty-text="props.emptyText"
|
||||
:readonly="props.readonly"
|
||||
:required="props.required"
|
||||
:title="props.title"
|
||||
:viewer-z-index="props.viewerZIndex"
|
||||
@select="handleSelect"
|
||||
@select-start="emit('select-start', $event)"
|
||||
@update:items="handleItemsUpdate"
|
||||
@open="handleOpen"
|
||||
>
|
||||
<template v-if="$slots.title" #title>
|
||||
<slot name="title" />
|
||||
</template>
|
||||
<template v-if="$slots['add-actions']" #add-actions="slotProps">
|
||||
<slot name="add-actions" v-bind="slotProps" />
|
||||
</template>
|
||||
<template v-if="$slots['capture-actions']" #capture-actions="slotProps">
|
||||
<slot name="capture-actions" v-bind="slotProps" />
|
||||
</template>
|
||||
<template v-if="$slots['item-label']" #item-label="slotProps">
|
||||
<slot name="item-label" :item="props.items[slotProps.index]" :index="slotProps.index" />
|
||||
</template>
|
||||
<template v-if="$slots['item-actions']" #item-actions="slotProps">
|
||||
<slot
|
||||
name="item-actions"
|
||||
:item="props.items[slotProps.index]"
|
||||
:index="slotProps.index"
|
||||
:remove="slotProps.remove"
|
||||
/>
|
||||
</template>
|
||||
<template v-if="$slots['viewer-actions']" #viewer-actions="slotProps">
|
||||
<slot
|
||||
name="viewer-actions"
|
||||
:item="props.items[slotProps.index]"
|
||||
:index="slotProps.index"
|
||||
:close="slotProps.close"
|
||||
/>
|
||||
</template>
|
||||
</shared-attachment-selector>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { AttachmentSelector as SharedAttachmentSelector } from "timi-tdesign-mobile";
|
||||
import type {
|
||||
AttachmentSelectorItem,
|
||||
AttachmentSelectorSelection
|
||||
} from "timi-tdesign-mobile";
|
||||
import type { PhotoItem } from "@/types/Photo.ts";
|
||||
import { getAttachmentReadURL } from "@/utils/attachment.ts";
|
||||
import { Message } from "@/utils/message.ts";
|
||||
import { saveCapturedFilesFromInput } from "@/utils/twaBridge";
|
||||
|
||||
defineOptions({
|
||||
inheritAttrs: false
|
||||
});
|
||||
|
||||
interface Props {
|
||||
items: readonly PhotoItem[];
|
||||
busy?: boolean;
|
||||
emptyText?: string;
|
||||
readonly?: boolean;
|
||||
required?: boolean;
|
||||
title?: string;
|
||||
upload?: (files: File[]) => Promise<PhotoItem[]>;
|
||||
viewerZIndex?: number;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
busy: false,
|
||||
items: () => [],
|
||||
readonly: false,
|
||||
required: false,
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
"update:items": [items: PhotoItem[]];
|
||||
select: [selection: AttachmentSelectorSelection];
|
||||
"select-start": [source: AttachmentSelectorSelection["source"]];
|
||||
open: [item: PhotoItem, index: number];
|
||||
}>();
|
||||
|
||||
const isUploading = ref(false);
|
||||
const isBusy = computed(() => props.busy || isUploading.value);
|
||||
const attachmentItems = computed(() => props.items.map(toAttachmentSelectorItem));
|
||||
|
||||
async function handleSelect(selection: AttachmentSelectorSelection): Promise<void> {
|
||||
saveCapturedFilesFromInput(selection.input, selection.files);
|
||||
if (!props.upload) {
|
||||
emit("select", selection);
|
||||
return;
|
||||
}
|
||||
if (isBusy.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
isUploading.value = true;
|
||||
try {
|
||||
const uploadedItems = await props.upload(selection.files);
|
||||
if (uploadedItems.length) {
|
||||
emit("update:items", [...props.items, ...uploadedItems.map((item, index) => ({
|
||||
...item,
|
||||
mimeType: item.mimeType || item.attachment?.mimeType || selection.files[index]?.type
|
||||
}))]);
|
||||
}
|
||||
} catch {
|
||||
Message.error("媒体上传失败");
|
||||
} finally {
|
||||
isUploading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function handleItemsUpdate(items: AttachmentSelectorItem[]): void {
|
||||
emit("update:items", items.map(toPhotoItem));
|
||||
}
|
||||
|
||||
function handleOpen(item: AttachmentSelectorItem, index: number): void {
|
||||
const photoItem = props.items[index];
|
||||
if (photoItem) {
|
||||
emit("open", photoItem, index);
|
||||
window.open(photoItem.url, "_blank", "noopener");
|
||||
return;
|
||||
}
|
||||
const nextItem = toPhotoItem(item);
|
||||
emit("open", nextItem, index);
|
||||
window.open(nextItem.url, "_blank", "noopener");
|
||||
}
|
||||
|
||||
function toAttachmentSelectorItem(item: PhotoItem): AttachmentSelectorItem {
|
||||
const attachmentId = item.attachment?.id;
|
||||
const thumbnailUrl = item.url.includes("thumbWidth=")
|
||||
? item.url
|
||||
: attachmentId ? getAttachmentReadURL(attachmentId, 128) : item.url;
|
||||
|
||||
return {
|
||||
...item,
|
||||
mimeType: item.mimeType || item.attachment?.mimeType,
|
||||
name: item.attachment?.name,
|
||||
thumbnailUrl
|
||||
};
|
||||
}
|
||||
|
||||
function toPhotoItem(item: AttachmentSelectorItem): PhotoItem {
|
||||
const photoItem = { ...item };
|
||||
delete photoItem.name;
|
||||
delete photoItem.thumbnailUrl;
|
||||
return photoItem as PhotoItem;
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,112 @@
|
||||
<template>
|
||||
<div class="viewer-action" @click.stop>
|
||||
<t-popover
|
||||
v-model:visible="visible"
|
||||
placement="bottom"
|
||||
theme="light"
|
||||
:show-arrow="false"
|
||||
>
|
||||
<t-button class="white" variant="text" :disabled="busy">
|
||||
<t-icon name="ellipsis" />
|
||||
</t-button>
|
||||
<template #content>
|
||||
<div class="actions" @click.stop>
|
||||
<div class="title">修改类型</div>
|
||||
<div class="type">
|
||||
<t-button
|
||||
v-for="item in attachmentTypeOptions"
|
||||
:key="item.value"
|
||||
:theme="item.value === attachType ? 'primary' : 'default'"
|
||||
variant="text"
|
||||
size="extra-small"
|
||||
:disabled="busy"
|
||||
@click="changeType(item.value)"
|
||||
>
|
||||
<span v-text="item.label" />
|
||||
</t-button>
|
||||
</div>
|
||||
<t-divider />
|
||||
<t-button
|
||||
class="delete-action"
|
||||
theme="danger"
|
||||
variant="text"
|
||||
size="extra-small"
|
||||
:disabled="busy"
|
||||
@click="remove"
|
||||
>
|
||||
<template #icon>
|
||||
<t-icon name="delete" />
|
||||
</template>
|
||||
删除
|
||||
</t-button>
|
||||
</div>
|
||||
</template>
|
||||
</t-popover>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const props = withDefaults(defineProps<{
|
||||
attachType?: string;
|
||||
busy?: boolean;
|
||||
}>(), {
|
||||
attachType: "PHOTO",
|
||||
busy: false
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
"change-type": [attachType: string];
|
||||
remove: [];
|
||||
}>();
|
||||
|
||||
const visible = ref(false);
|
||||
const attachmentTypeOptions = [
|
||||
{ label: "照片", value: "PHOTO" },
|
||||
{ label: "积分卡", value: "POINT_CARD" },
|
||||
{ label: "其他文件", value: "OTHER" }
|
||||
] as const;
|
||||
|
||||
function changeType(attachType: string): void {
|
||||
visible.value = false;
|
||||
if (!props.busy && props.attachType !== attachType) {
|
||||
emit("change-type", attachType);
|
||||
}
|
||||
}
|
||||
|
||||
function remove(): void {
|
||||
visible.value = false;
|
||||
if (!props.busy) {
|
||||
emit("remove");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.viewer-action {
|
||||
color: #fff;
|
||||
margin-left: -1rem;
|
||||
|
||||
.actions {
|
||||
min-width: 8rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.title {
|
||||
padding: 0 .75rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.type {
|
||||
margin-left: 1.5rem;
|
||||
display: flex;
|
||||
align-items: start;
|
||||
flex-direction: column;
|
||||
justify-content: start;
|
||||
}
|
||||
|
||||
.delete-action {
|
||||
justify-content: start;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,6 @@
|
||||
export type {
|
||||
AttachmentSelectorItem,
|
||||
AttachmentSelectorProps,
|
||||
AttachmentSelectorSelection,
|
||||
AttachmentSelectorViewerItem
|
||||
} from "timi-tdesign-mobile";
|
||||
@@ -1,276 +0,0 @@
|
||||
<template>
|
||||
<div v-bind="$attrs" class="media-selector">
|
||||
<div class="t-form__label" :class="{ required }">
|
||||
<slot name="title">
|
||||
<span v-text="title" />
|
||||
</slot>
|
||||
</div>
|
||||
<div class="photo-shell" :class="{ 'without-add': !showAdd }">
|
||||
<div class="items">
|
||||
<center-tips v-if="!displayMediaList.length" :content="emptyText" />
|
||||
<media-selector-item
|
||||
v-for="(item, index) in displayMediaList"
|
||||
:key="`${item.url}-${item.attachType}-${index}`"
|
||||
:item="item"
|
||||
:removable="hasRemovablePhotos"
|
||||
:show-remove="showRemove === true"
|
||||
:show-type-label="showTypeLabel === true"
|
||||
@preview="openMediaViewer(index)"
|
||||
@remove="removePhoto(index)"
|
||||
/>
|
||||
</div>
|
||||
<media-selector-add
|
||||
v-if="showAdd"
|
||||
:add-actions="props.addActions ?? []"
|
||||
:add-text="props.addText ?? '选择'"
|
||||
:busy="isBusy"
|
||||
:upload-enabled="!!props.upload"
|
||||
@add="handleAdd"
|
||||
@action="handleAddAction"
|
||||
@capture-photo="handleCapturePhoto"
|
||||
@capture-video="handleCaptureVideo"
|
||||
@file-change="handleFileChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<media-selector-viewer
|
||||
v-model:visible="photoViewerVisible"
|
||||
:images="photoViewerImages"
|
||||
:items="photoViewerItems"
|
||||
:viewer-z-index="props.viewerZIndex"
|
||||
:show-actions="showViewerActions === true"
|
||||
:submitting="isSubmitting"
|
||||
@change-type="changePhotoType"
|
||||
@remove="removePhotoBySourceIndex"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import MediaSelectorAdd from "./MediaSelectorAdd.vue";
|
||||
import MediaSelectorItem from "./MediaSelectorItem.vue";
|
||||
import MediaSelectorViewer from "./MediaSelectorViewer.vue";
|
||||
import type { MediaSelectorAddAction, MediaSelectorViewerItem } from "./types";
|
||||
import { getMediaPreviewURL, normalizePhotoItem } from "./utils";
|
||||
import type { PhotoItem } from "@/types/Photo.ts";
|
||||
import { Message } from "@/utils/message.ts";
|
||||
import { saveCapturedFilesFromInput } from "@/utils/twaBridge";
|
||||
|
||||
defineOptions({
|
||||
inheritAttrs: false
|
||||
});
|
||||
|
||||
interface Props {
|
||||
addActions?: readonly MediaSelectorAddAction[];
|
||||
addText?: string;
|
||||
editMode?: boolean;
|
||||
emptyText?: string;
|
||||
fallbackImage?: string;
|
||||
loading?: boolean;
|
||||
modelValue: string[];
|
||||
photoItems?: readonly PhotoItem[];
|
||||
required?: boolean;
|
||||
upload?: (fileList: File[]) => Promise<PhotoItem[]>;
|
||||
showViewerActions?: boolean;
|
||||
showAdd?: boolean;
|
||||
showRemove?: boolean;
|
||||
showTypeLabel?: boolean;
|
||||
submit?: (photoItems: PhotoItem[]) => Promise<void>;
|
||||
title?: string;
|
||||
viewerZIndex?: number;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
addActions: () => [],
|
||||
title: "媒体列表",
|
||||
addText: "选择",
|
||||
editMode: false,
|
||||
emptyText: "暂无照片",
|
||||
loading: false,
|
||||
required: false,
|
||||
showAdd: true,
|
||||
showRemove: true,
|
||||
showTypeLabel: false,
|
||||
showViewerActions: true
|
||||
});
|
||||
|
||||
type Emits = {
|
||||
add: [];
|
||||
action: [value: MediaSelectorAddAction];
|
||||
"capture-photo": [];
|
||||
"capture-video": [];
|
||||
"update:modelValue": [value: string[]];
|
||||
"update:photoItems": [value: PhotoItem[]];
|
||||
};
|
||||
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
function handleAddAction(action: MediaSelectorAddAction): void {
|
||||
emit("action", action);
|
||||
}
|
||||
|
||||
function handleAdd(): void {
|
||||
emit("add");
|
||||
}
|
||||
|
||||
function handleCapturePhoto(): void {
|
||||
emit("capture-photo");
|
||||
}
|
||||
|
||||
function handleCaptureVideo(): void {
|
||||
emit("capture-video");
|
||||
}
|
||||
|
||||
const photoViewerVisible = ref(false);
|
||||
const photoViewerImages = ref<string[]>([]);
|
||||
const photoViewerItems = ref<MediaSelectorViewerItem[]>([]);
|
||||
const isSubmitting = ref(false);
|
||||
const isUploading = ref(false);
|
||||
const isBusy = computed(() => props.loading || isSubmitting.value || isUploading.value);
|
||||
|
||||
const displayMediaList = computed<PhotoItem[]>(() => {
|
||||
if (props.photoItems?.length) {
|
||||
return props.photoItems.map(normalizePhotoItem);
|
||||
}
|
||||
if (props.modelValue.length) {
|
||||
return props.modelValue.map(url => ({ url, attachType: "PHOTO" }));
|
||||
}
|
||||
|
||||
return props.fallbackImage ? [{ url: props.fallbackImage, attachType: "PHOTO" }] : [];
|
||||
});
|
||||
const hasRemovablePhotos = computed(() => !!props.photoItems?.length || !!props.modelValue.length);
|
||||
|
||||
async function handleFileChange(event: Event): Promise<void> {
|
||||
const input = event.target as HTMLInputElement;
|
||||
const fileList = Array.from(input.files || []);
|
||||
if (!fileList.length || !props.upload) {
|
||||
return;
|
||||
}
|
||||
saveCapturedFilesFromInput(input, fileList);
|
||||
|
||||
isUploading.value = true;
|
||||
try {
|
||||
const uploadedPhotoItems = await props.upload(fileList);
|
||||
if (!uploadedPhotoItems.length) {
|
||||
return;
|
||||
}
|
||||
const nextPhotoItems = [...displayMediaList.value, ...uploadedPhotoItems.map((item, index) => ({
|
||||
...item,
|
||||
mimeType: item.mimeType || item.attachment?.mimeType || fileList[index]?.type
|
||||
}))];
|
||||
emit("update:photoItems", nextPhotoItems);
|
||||
emit("update:modelValue", nextPhotoItems.map(item => item.url));
|
||||
} catch {
|
||||
Message.error("媒体上传失败");
|
||||
} finally {
|
||||
isUploading.value = false;
|
||||
input.value = "";
|
||||
}
|
||||
}
|
||||
|
||||
async function removePhoto(index: number): Promise<void> {
|
||||
if (index < 0 || displayMediaList.value.length <= index) {
|
||||
return;
|
||||
}
|
||||
|
||||
await applyPhotoItems(displayMediaList.value.filter((_, itemIndex) => itemIndex !== index));
|
||||
}
|
||||
|
||||
function openMediaViewer(index: number): void {
|
||||
openPhotoViewer(index);
|
||||
}
|
||||
|
||||
function openPhotoViewer(index: number): void {
|
||||
const viewerItems = displayMediaList.value.map((item, sourceIndex) => ({ item, sourceIndex }));
|
||||
const imageIndex = viewerItems.findIndex(({ sourceIndex }) => sourceIndex === index);
|
||||
if (imageIndex < 0) {
|
||||
return;
|
||||
}
|
||||
const rotatedItems = [...viewerItems.slice(imageIndex), ...viewerItems.slice(0, imageIndex)];
|
||||
photoViewerItems.value = rotatedItems.map(({ item, sourceIndex }) => ({ ...item, sourceIndex }));
|
||||
photoViewerImages.value = photoViewerItems.value.map(getMediaPreviewURL);
|
||||
photoViewerVisible.value = true;
|
||||
}
|
||||
|
||||
async function changePhotoType(sourceIndex: number, attachType: string): Promise<void> {
|
||||
const currentItem = displayMediaList.value[sourceIndex];
|
||||
if (!currentItem || currentItem.attachType === attachType) {
|
||||
return;
|
||||
}
|
||||
|
||||
const nextPhotoItems = displayMediaList.value.map((item, index) => index === sourceIndex ? {
|
||||
...item,
|
||||
attachType
|
||||
} : item);
|
||||
await applyPhotoItems(nextPhotoItems);
|
||||
}
|
||||
|
||||
async function removePhotoBySourceIndex(sourceIndex: number): Promise<void> {
|
||||
if (!displayMediaList.value[sourceIndex]) {
|
||||
return;
|
||||
}
|
||||
|
||||
await applyPhotoItems(displayMediaList.value.filter((_, index) => index !== sourceIndex));
|
||||
}
|
||||
|
||||
async function applyPhotoItems(nextPhotoItems: PhotoItem[]): Promise<void> {
|
||||
if (isSubmitting.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!props.editMode && !props.submit) {
|
||||
Message.warning("展示模式未配置媒体保存方法");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!props.editMode) {
|
||||
isSubmitting.value = true;
|
||||
try {
|
||||
await props.submit!(nextPhotoItems);
|
||||
} catch {
|
||||
Message.error("媒体修改失败");
|
||||
return;
|
||||
} finally {
|
||||
isSubmitting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
emit("update:photoItems", nextPhotoItems);
|
||||
emit("update:modelValue", nextPhotoItems.map(item => item.url));
|
||||
photoViewerVisible.value = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.media-selector {
|
||||
gap: .375rem;
|
||||
width: 100%;
|
||||
display: grid;
|
||||
|
||||
.photo-shell {
|
||||
display: grid;
|
||||
gap: .75rem;
|
||||
grid-template-columns: minmax(0, 1fr) 5.5rem;
|
||||
align-items: start;
|
||||
|
||||
&.without-add {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.items {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
.t-form__label {
|
||||
&.required::before {
|
||||
color: var(--td-error-color, #e34d59);
|
||||
content: "*";
|
||||
margin-right: .25rem;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
:global(html.theme-dark) {
|
||||
}
|
||||
</style>
|
||||
@@ -1,210 +0,0 @@
|
||||
<template>
|
||||
<div class="add-trigger">
|
||||
<t-popover
|
||||
v-model:visible="capturePopoverVisible"
|
||||
placement="left"
|
||||
theme="light"
|
||||
>
|
||||
<t-button
|
||||
class="capture"
|
||||
theme="primary"
|
||||
variant="dashed"
|
||||
:loading="busy"
|
||||
:disabled="busy"
|
||||
>
|
||||
<template #icon>
|
||||
<t-icon name="camera" />
|
||||
</template>
|
||||
拍摄
|
||||
</t-button>
|
||||
<template #content>
|
||||
<div class="add-actions">
|
||||
<t-button
|
||||
v-for="(action, index) in captureActionList"
|
||||
:key="`${action.emit}-${index}`"
|
||||
variant="text"
|
||||
:theme="action.theme"
|
||||
class="add-action"
|
||||
:disabled="busy"
|
||||
@click="handleCaptureAction(action)"
|
||||
>
|
||||
<template #icon v-if="action.icon">
|
||||
<t-icon :name="action.icon" />
|
||||
</template>
|
||||
<span v-text="action.text" />
|
||||
</t-button>
|
||||
</div>
|
||||
</template>
|
||||
</t-popover>
|
||||
<t-button
|
||||
class="file"
|
||||
theme="primary"
|
||||
variant="dashed"
|
||||
:loading="busy"
|
||||
:disabled="busy"
|
||||
@click="handleFileAction"
|
||||
>
|
||||
<template #icon>
|
||||
<t-icon name="file-attachment" />
|
||||
</template>
|
||||
<span v-text="addText" />
|
||||
</t-button>
|
||||
</div>
|
||||
<input
|
||||
v-if="uploadEnabled"
|
||||
ref="fileInput"
|
||||
class="file-input"
|
||||
type="file"
|
||||
accept="*/*"
|
||||
multiple
|
||||
@change="handleFileChange"
|
||||
/>
|
||||
<input
|
||||
v-if="uploadEnabled"
|
||||
ref="photoFileInput"
|
||||
class="file-input"
|
||||
type="file"
|
||||
accept="image/*"
|
||||
capture="environment"
|
||||
@change="handleFileChange"
|
||||
/>
|
||||
<input
|
||||
v-if="uploadEnabled"
|
||||
ref="videoFileInput"
|
||||
class="file-input"
|
||||
type="file"
|
||||
accept="video/*"
|
||||
capture="environment"
|
||||
@change="handleFileChange"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { MediaSelectorAddAction } from "./types";
|
||||
|
||||
interface Props {
|
||||
addActions: readonly MediaSelectorAddAction[];
|
||||
addText: string;
|
||||
busy: boolean;
|
||||
uploadEnabled: boolean;
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
const emit = defineEmits<{
|
||||
add: [];
|
||||
action: [value: MediaSelectorAddAction];
|
||||
"capture-photo": [];
|
||||
"capture-video": [];
|
||||
"file-change": [value: Event];
|
||||
}>();
|
||||
|
||||
const capturePopoverVisible = ref(false);
|
||||
const fileInput = ref<HTMLInputElement>();
|
||||
const photoFileInput = ref<HTMLInputElement>();
|
||||
const videoFileInput = ref<HTMLInputElement>();
|
||||
const captureActionList = computed<readonly MediaSelectorAddAction[]>(() => [{
|
||||
icon: "camera",
|
||||
emit: "capture-photo",
|
||||
text: "拍照片",
|
||||
theme: "primary"
|
||||
}, {
|
||||
icon: "video-camera-1",
|
||||
emit: "capture-video",
|
||||
text: "录视频",
|
||||
theme: "primary"
|
||||
}, ...props.addActions]);
|
||||
|
||||
function handleFileAction(): void {
|
||||
capturePopoverVisible.value = false;
|
||||
if (props.uploadEnabled) {
|
||||
fileInput.value?.click();
|
||||
return;
|
||||
}
|
||||
emit("add");
|
||||
}
|
||||
|
||||
function handleCaptureAction(action: MediaSelectorAddAction): void {
|
||||
capturePopoverVisible.value = false;
|
||||
if (action.emit === "capture-photo") {
|
||||
if (props.uploadEnabled) {
|
||||
photoFileInput.value?.click();
|
||||
return;
|
||||
}
|
||||
emit("capture-photo");
|
||||
return;
|
||||
}
|
||||
if (action.emit === "capture-video") {
|
||||
if (props.uploadEnabled) {
|
||||
videoFileInput.value?.click();
|
||||
return;
|
||||
}
|
||||
emit("capture-video");
|
||||
return;
|
||||
}
|
||||
emit("action", action);
|
||||
}
|
||||
|
||||
function handleFileChange(event: Event): void {
|
||||
emit("file-change", event);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.add-trigger {
|
||||
--td-popover-padding: 0 .5rem;
|
||||
gap: .375rem;
|
||||
width: 5.5rem;
|
||||
height: 5.5rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
:deep(.t-popover__content) {
|
||||
border-radius: .875rem;
|
||||
}
|
||||
|
||||
.capture,
|
||||
.file {
|
||||
--td-button-border-radius: .875rem;
|
||||
|
||||
width: 5.5rem;
|
||||
height: 2.5625rem;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.add-actions {
|
||||
gap: .25rem;
|
||||
display: grid;
|
||||
padding: .5rem 0;
|
||||
|
||||
.add-action {
|
||||
--td-button-medium-height: 32px;
|
||||
--td-button-medium-padding-horizontal: 10px;
|
||||
|
||||
gap: .5rem;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
font-weight: unset;
|
||||
justify-content: start;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.file-input {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:global(html.theme-dark) {
|
||||
.capture,
|
||||
.file {
|
||||
background: rgba(37, 99, 235, .16);
|
||||
border-color: rgba(96, 165, 250, .28);
|
||||
|
||||
span {
|
||||
color: #93c5fd;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,137 +0,0 @@
|
||||
<template>
|
||||
<div class="item">
|
||||
<t-button variant="text" class="preview-trigger" @click="emit('preview')">
|
||||
<div v-if="isVideoItem(item)" class="video-thumbnail">
|
||||
<t-image
|
||||
v-if="getMediaThumbnailURL(item)"
|
||||
class="image"
|
||||
:src="getMediaThumbnailURL(item)"
|
||||
:alt="getAttachTypeText(item.attachType)"
|
||||
fit="cover"
|
||||
/>
|
||||
<video
|
||||
v-else
|
||||
:src="getMediaPreviewURL(item)"
|
||||
muted
|
||||
playsinline
|
||||
preload="metadata"
|
||||
/>
|
||||
<t-icon class="play" name="play-circle-filled" size="2rem" />
|
||||
</div>
|
||||
<t-image
|
||||
v-else
|
||||
class="image"
|
||||
:src="item.url"
|
||||
:alt="getAttachTypeText(item.attachType)"
|
||||
fit="cover"
|
||||
/>
|
||||
</t-button>
|
||||
<div
|
||||
v-if="showTypeLabel"
|
||||
class="type-label white glass-black clip-text"
|
||||
v-text="getAttachTypeText(item.attachType)"
|
||||
/>
|
||||
<t-button
|
||||
v-if="showRemove && removable"
|
||||
theme="danger"
|
||||
class="remove"
|
||||
shape="circle"
|
||||
size="extra-small"
|
||||
@click="emit('remove')"
|
||||
>
|
||||
<t-icon name="close" size="1rem" />
|
||||
</t-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { PhotoItem } from "@/types/Photo.ts";
|
||||
import {
|
||||
getAttachTypeText,
|
||||
getMediaPreviewURL,
|
||||
getMediaThumbnailURL,
|
||||
isVideoItem
|
||||
} from "./utils";
|
||||
|
||||
interface Props {
|
||||
item: PhotoItem;
|
||||
removable: boolean;
|
||||
showRemove: boolean;
|
||||
showTypeLabel: boolean;
|
||||
}
|
||||
|
||||
defineProps<Props>();
|
||||
const emit = defineEmits<{
|
||||
preview: [];
|
||||
remove: [];
|
||||
}>();
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.item {
|
||||
width: 5.5rem;
|
||||
height: 5.5rem;
|
||||
flex: 0 0 5.5rem;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
border-radius: 1rem;
|
||||
|
||||
.preview-trigger {
|
||||
padding: 0;
|
||||
border: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
cursor: pointer;
|
||||
background: transparent;
|
||||
|
||||
.image {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.video-thumbnail {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
background: #0f172a;
|
||||
|
||||
video {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.play {
|
||||
inset: 50% auto auto 50%;
|
||||
opacity: .7;
|
||||
position: absolute;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.type-label {
|
||||
width: 100%;
|
||||
bottom: 0;
|
||||
padding: .125rem .5rem;
|
||||
position: absolute;
|
||||
overflow: hidden;
|
||||
font-size: .875rem;
|
||||
text-align: center;
|
||||
line-height: 1.2;
|
||||
border-radius: 0 0 1rem 1rem;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.remove {
|
||||
top: .375rem;
|
||||
right: .375rem;
|
||||
position: absolute;
|
||||
|
||||
:deep(.t-button__content) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,237 +0,0 @@
|
||||
<template>
|
||||
<teleport to="body">
|
||||
<t-image-viewer
|
||||
v-model:visible="viewerVisible"
|
||||
:images="images"
|
||||
:style="{ zIndex: props.viewerZIndex }"
|
||||
show-index
|
||||
@close="handleClose"
|
||||
@index-change="handleIndexChange"
|
||||
>
|
||||
<template #image="params">
|
||||
<div
|
||||
v-if="isVideoViewerItem(params.index)"
|
||||
:class="[params.className, 'viewer-video-wrap']"
|
||||
:style="params.style"
|
||||
@click.stop
|
||||
@pointerdown.stop
|
||||
@pointermove.stop
|
||||
@pointerup.stop
|
||||
@touchstart.stop
|
||||
@touchmove.stop
|
||||
@touchend.stop
|
||||
>
|
||||
<video
|
||||
:src="getViewerMediaURL(params.index)"
|
||||
class="viewer-video"
|
||||
controls
|
||||
playsinline
|
||||
preload="metadata"
|
||||
@loadedmetadata="handleViewerVideoLoaded($event, params)"
|
||||
@transitionstart="params.onTransitionstart"
|
||||
@transitionend="params.onTransitionend"
|
||||
/>
|
||||
</div>
|
||||
<img
|
||||
v-else
|
||||
:src="params.src"
|
||||
:class="params.className"
|
||||
:style="params.style"
|
||||
:alt="getViewerAlt(params.index)"
|
||||
@load="params.onLoad"
|
||||
@transitionstart="params.onTransitionstart"
|
||||
@transitionend="params.onTransitionend"
|
||||
/>
|
||||
</template>
|
||||
<template #delete-btn>
|
||||
<div v-if="showActions" class="viewer-action" @click.stop>
|
||||
<t-popover
|
||||
v-model:visible="photoActionVisible"
|
||||
placement="bottom"
|
||||
theme="light"
|
||||
:show-arrow="false"
|
||||
>
|
||||
<t-button class="white" variant="text">
|
||||
<t-icon name="ellipsis" />
|
||||
</t-button>
|
||||
<template #content>
|
||||
<div class="actions" @click.stop>
|
||||
<div class="title">修改类型</div>
|
||||
<div class="type">
|
||||
<t-button
|
||||
v-for="item in attachTypeOptions"
|
||||
:key="item.value"
|
||||
:theme="item.value === currentPhotoItem?.attachType ? 'primary' : 'default'"
|
||||
variant="text"
|
||||
size="extra-small"
|
||||
:disabled="submitting"
|
||||
@click="changePhotoType(item.value)"
|
||||
>
|
||||
<span v-text="item.text" />
|
||||
</t-button>
|
||||
</div>
|
||||
<t-divider />
|
||||
<t-button
|
||||
class="button delete-action"
|
||||
theme="danger"
|
||||
size="extra-small"
|
||||
variant="text"
|
||||
:disabled="submitting"
|
||||
@click="removeCurrentPhoto"
|
||||
>
|
||||
<template #icon>
|
||||
<t-icon name="delete" />
|
||||
</template>
|
||||
删除
|
||||
</t-button>
|
||||
</div>
|
||||
</template>
|
||||
</t-popover>
|
||||
</div>
|
||||
</template>
|
||||
</t-image-viewer>
|
||||
</teleport>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { ImageSlotParams } from "tdesign-mobile-vue";
|
||||
import type { MediaSelectorViewerItem } from "./types";
|
||||
import { getAttachTypeText, getMediaPreviewURL, isVideoItem } from "./utils";
|
||||
|
||||
interface Props {
|
||||
images: string[];
|
||||
items: readonly MediaSelectorViewerItem[];
|
||||
showActions: boolean;
|
||||
submitting: boolean;
|
||||
visible: boolean;
|
||||
viewerZIndex?: number;
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
const emit = defineEmits<{
|
||||
(event: "update:visible", value: boolean): void;
|
||||
(event: "change-type", sourceIndex: number, attachType: string): void;
|
||||
(event: "remove", sourceIndex: number): void;
|
||||
}>();
|
||||
|
||||
const viewerVisible = computed({
|
||||
get: () => props.visible,
|
||||
set: value => emit("update:visible", value)
|
||||
});
|
||||
const viewerIndex = ref(0);
|
||||
const photoActionVisible = ref(false);
|
||||
const attachTypeOptions = [
|
||||
{ text: "照片", value: "PHOTO" },
|
||||
{ text: "积分卡", value: "POINT_CARD" },
|
||||
{ text: "其他文件", value: "OTHER" }
|
||||
] as const;
|
||||
const currentPhotoItem = computed(() => props.items[viewerIndex.value]);
|
||||
|
||||
watch(() => props.visible, value => {
|
||||
if (value) {
|
||||
viewerIndex.value = 0;
|
||||
photoActionVisible.value = false;
|
||||
}
|
||||
});
|
||||
|
||||
function handleClose(): void {
|
||||
photoActionVisible.value = false;
|
||||
emit("update:visible", false);
|
||||
}
|
||||
|
||||
function handleIndexChange(index: number): void {
|
||||
viewerIndex.value = index;
|
||||
photoActionVisible.value = false;
|
||||
}
|
||||
|
||||
function isVideoViewerItem(index?: number): boolean {
|
||||
const item = getViewerItem(index);
|
||||
return !!item && isVideoItem(item);
|
||||
}
|
||||
|
||||
function getViewerItem(index?: number): MediaSelectorViewerItem | undefined {
|
||||
return index === undefined ? undefined : props.items[index];
|
||||
}
|
||||
|
||||
function getViewerMediaURL(index?: number): string {
|
||||
const item = getViewerItem(index);
|
||||
return item ? getMediaPreviewURL(item) : "";
|
||||
}
|
||||
|
||||
function getViewerAlt(index?: number): string {
|
||||
return getAttachTypeText(getViewerItem(index)?.attachType);
|
||||
}
|
||||
|
||||
function handleViewerVideoLoaded(event: Event, params: ImageSlotParams): void {
|
||||
const video = event.currentTarget as HTMLVideoElement;
|
||||
if (video.videoHeight > 0) {
|
||||
video.height = video.videoHeight;
|
||||
}
|
||||
params.onLoad?.(event);
|
||||
}
|
||||
|
||||
function changePhotoType(attachType: string): void {
|
||||
const currentItem = currentPhotoItem.value;
|
||||
photoActionVisible.value = false;
|
||||
if (!currentItem || currentItem.attachType === attachType) {
|
||||
return;
|
||||
}
|
||||
emit("change-type", currentItem.sourceIndex, attachType);
|
||||
}
|
||||
|
||||
function removeCurrentPhoto(): void {
|
||||
const currentItem = currentPhotoItem.value;
|
||||
photoActionVisible.value = false;
|
||||
if (currentItem) {
|
||||
emit("remove", currentItem.sourceIndex);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.viewer-action {
|
||||
color: #fff;
|
||||
margin-left: -1rem;
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
min-width: 8rem;
|
||||
flex-direction: column;
|
||||
|
||||
.title {
|
||||
padding: 0 .75rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.type {
|
||||
display: flex;
|
||||
align-items: start;
|
||||
margin-left: 1.5rem;
|
||||
flex-direction: column;
|
||||
justify-content: start;
|
||||
}
|
||||
|
||||
.button {
|
||||
justify-content: start;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.viewer-video-wrap {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
max-height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.viewer-video {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
max-height: 100%;
|
||||
background: #0f172a;
|
||||
object-fit: contain;
|
||||
}
|
||||
</style>
|
||||
@@ -1,13 +0,0 @@
|
||||
import type { ButtonProps } from "tdesign-mobile-vue";
|
||||
import type { PhotoItem } from "@/types/Photo.ts";
|
||||
|
||||
export type MediaSelectorAddAction = {
|
||||
icon?: string;
|
||||
emit: string;
|
||||
text: string;
|
||||
theme?: ButtonProps["theme"];
|
||||
};
|
||||
|
||||
export type MediaSelectorViewerItem = PhotoItem & {
|
||||
sourceIndex: number;
|
||||
};
|
||||
@@ -1,55 +0,0 @@
|
||||
import type { PhotoItem } from "@/types/Photo.ts";
|
||||
import { getAttachmentReadURL } from "@/utils/attachment.ts";
|
||||
|
||||
const ATTACH_TYPE_TEXT_MAP: Record<string, string> = {
|
||||
ADDITIONAL: "附加照片",
|
||||
PHOTO: "照片",
|
||||
POINT_CARD: "积分卡",
|
||||
OTHER: "其他文件"
|
||||
};
|
||||
|
||||
/** 缩略图宽度查询串,地址中出现即表示已带缩略图参数 */
|
||||
const THUMBNAIL_WIDTH_QUERY = "thumbWidth=";
|
||||
|
||||
/** 缩略图兜底尺寸(像素),用于地址未带缩略图参数但可定位附件的场景 */
|
||||
const FALLBACK_THUMBNAIL_SIZE = 128;
|
||||
|
||||
export function getAttachTypeText(attachType?: string): string {
|
||||
return ATTACH_TYPE_TEXT_MAP[attachType || "PHOTO"] || "其他文件";
|
||||
}
|
||||
|
||||
export function getMediaPreviewURL(item: PhotoItem): string {
|
||||
return item.previewUrl || item.url;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析媒体缩略图地址。
|
||||
*
|
||||
* 后端读附件接口只要带缩略图参数,视频附件同样返回该视频的缩略帧,
|
||||
* 因此视频在列表中统一按图片渲染;临时上传文件没有缩略图,返回空字符串由调用方降级。
|
||||
*/
|
||||
export function getMediaThumbnailURL(item: PhotoItem): string {
|
||||
if (item.url.includes(THUMBNAIL_WIDTH_QUERY)) {
|
||||
return item.url;
|
||||
}
|
||||
|
||||
const attachmentId = item.attachment?.id;
|
||||
return attachmentId ? getAttachmentReadURL(attachmentId, FALLBACK_THUMBNAIL_SIZE) : "";
|
||||
}
|
||||
|
||||
export function isVideoItem(item: PhotoItem): boolean {
|
||||
const mimeType = (item.mimeType || item.attachment?.mimeType || "").toLowerCase();
|
||||
if (mimeType.startsWith("video/")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return /\.(avi|m4v|mkv|mov|mp4|mpeg|mpg|ogv|webm|wmv)(?:$|[?#])/i.test(item.url);
|
||||
}
|
||||
|
||||
export function normalizePhotoItem(item: PhotoItem): PhotoItem {
|
||||
return {
|
||||
...item,
|
||||
attachType: item.attachType || item.attachment?.attachType || "PHOTO",
|
||||
mimeType: item.mimeType || item.attachment?.mimeType
|
||||
};
|
||||
}
|
||||
@@ -79,17 +79,25 @@
|
||||
</t-cell>
|
||||
</t-cell-group>
|
||||
<card-container v-entrance-transition>
|
||||
<media-selector
|
||||
class="media-selector"
|
||||
:model-value="photoList"
|
||||
:photo-items="photoItemList"
|
||||
:show-viewer-actions="canUpdateCustomer"
|
||||
:show-add="false"
|
||||
:show-remove="false"
|
||||
:submit="submitPhotoItems"
|
||||
show-type-label
|
||||
<attachment-selector
|
||||
:readonly="true"
|
||||
class="attachment-selector"
|
||||
:items="photoItemList"
|
||||
title="照片列表"
|
||||
/>
|
||||
>
|
||||
<template #item-label="{ item }">
|
||||
<span v-text="getAttachmentTypeText(item.attachType)" />
|
||||
</template>
|
||||
<template #viewer-actions="{ item, index, close }">
|
||||
<attachment-viewer-actions
|
||||
v-if="canUpdateCustomer"
|
||||
:attach-type="item.attachType"
|
||||
:busy="isPhotoSaving"
|
||||
@change-type="changePhotoType(index, $event, close)"
|
||||
@remove="removePhoto(index, close)"
|
||||
/>
|
||||
</template>
|
||||
</attachment-selector>
|
||||
</card-container>
|
||||
<customer-tag-card
|
||||
v-if="canReadTag"
|
||||
@@ -191,7 +199,8 @@ import TagAPI from "@/api/TagAPI";
|
||||
import BodyAreaSelector from "@/components/BodyAreaSelector.vue";
|
||||
import CustomerRemoveDialog from "@/pages/customer/component/CustomerRemoveDialog.vue";
|
||||
import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
|
||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||
import AttachmentViewerActions from "@/components/attachmentSelector/AttachmentViewerActions.vue";
|
||||
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
|
||||
import TagSelector from "@/components/TagSelector.vue";
|
||||
import CustomerTagCard from "@/pages/customer/component/CustomerTagCard.vue";
|
||||
import type { PointAccount } from "@/types/Point";
|
||||
@@ -199,7 +208,7 @@ import type { PhotoItem } from "@/types/Photo";
|
||||
import type { GaoSalesOrderType } from "@/types/SalesOrder";
|
||||
import type { Tag } from "@/types/Tag";
|
||||
import { bodyAreaLabelMap } from "@/utils/bodyArea";
|
||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||
import { getAttachmentReadURL, getAttachmentTypeText } from "@/utils/attachment";
|
||||
import { normalizeBodyAreaValue } from "@/utils/customer";
|
||||
import { corePermissionCodes, permissionCodes } from "@/utils/permission";
|
||||
import { LunarCalendar } from "@/utils/LunarCalendar";
|
||||
@@ -275,7 +284,7 @@ const photoItemList = computed(() => (customer.value?.attachmentList || [])
|
||||
previewUrl: getAttachmentReadURL(item.id || ""),
|
||||
url: getAttachmentReadURL(item.id || "", 90)
|
||||
})));
|
||||
const photoList = computed(() => photoItemList.value.map(item => item.url));
|
||||
const isPhotoSaving = ref(false);
|
||||
|
||||
async function submitPhotoItems(photoItems: PhotoItem[]): Promise<void> {
|
||||
const currentCustomer = customer.value;
|
||||
@@ -297,6 +306,35 @@ async function submitPhotoItems(photoItems: PhotoItem[]): Promise<void> {
|
||||
};
|
||||
}
|
||||
|
||||
async function applyPhotoItems(photoItems: PhotoItem[], close: () => void): Promise<void> {
|
||||
if (isPhotoSaving.value) {
|
||||
return;
|
||||
}
|
||||
isPhotoSaving.value = true;
|
||||
try {
|
||||
await submitPhotoItems(photoItems);
|
||||
close();
|
||||
} catch {
|
||||
Message.error("媒体修改失败");
|
||||
} finally {
|
||||
isPhotoSaving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function changePhotoType(index: number, attachType: string, close: () => void): Promise<void> {
|
||||
if (!photoItemList.value[index] || photoItemList.value[index].attachType === attachType) {
|
||||
return;
|
||||
}
|
||||
await applyPhotoItems(photoItemList.value.map((item, itemIndex) => itemIndex === index ? { ...item, attachType } : item), close);
|
||||
}
|
||||
|
||||
async function removePhoto(index: number, close: () => void): Promise<void> {
|
||||
if (!photoItemList.value[index]) {
|
||||
return;
|
||||
}
|
||||
await applyPhotoItems(photoItemList.value.filter((_, itemIndex) => itemIndex !== index), close);
|
||||
}
|
||||
|
||||
function buildPhotoAttachmentList(photoItems: PhotoItem[]): Attachment[] {
|
||||
return photoItems.flatMap(item => {
|
||||
if (item.attachment) {
|
||||
@@ -621,7 +659,7 @@ onUnmounted(() => clearPageNavBarRight());
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.media-selector) {
|
||||
:deep(.attachment-selector) {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
|
||||
@@ -116,21 +116,28 @@
|
||||
</t-form-item>
|
||||
<t-form-item label-width="0">
|
||||
<div class="photo">
|
||||
<media-selector
|
||||
v-model="photoList"
|
||||
v-model:photo-items="photoItemList"
|
||||
:edit-mode="true"
|
||||
:show-add="!isCustomerBound"
|
||||
:show-remove="!isCustomerBound"
|
||||
:show-viewer-actions="!isCustomerBound"
|
||||
:add-actions="photoAddActions"
|
||||
:loading="isPhotoUploading"
|
||||
show-type-label
|
||||
@add="openPhotoPicker('OTHER')"
|
||||
@action="handlePhotoAction"
|
||||
@capture-photo="capturePhoto"
|
||||
@capture-video="captureVideo"
|
||||
/>
|
||||
<attachment-selector
|
||||
:readonly="!!isCustomerBound"
|
||||
v-model:items="photoItemList"
|
||||
:busy="isPhotoUploading"
|
||||
@select-start="handlePhotoPickerStart"
|
||||
@select="handlePhotoSelected($event.files)"
|
||||
>
|
||||
<template #capture-actions="{ capturePhoto }">
|
||||
<t-button
|
||||
class="add-action"
|
||||
variant="text"
|
||||
theme="primary"
|
||||
:disabled="isPhotoUploading"
|
||||
@click="handlePointCardCapture(capturePhoto)"
|
||||
>
|
||||
<template #icon>
|
||||
<t-icon name="camera" />
|
||||
</template>
|
||||
拍积分卡
|
||||
</t-button>
|
||||
</template>
|
||||
</attachment-selector>
|
||||
<div class="tips orange" v-if="!hasCustomerDeletePermission">当前账户权限编辑客户需要上传照片和积分卡</div>
|
||||
</div>
|
||||
</t-form-item>
|
||||
@@ -219,29 +226,6 @@
|
||||
/>
|
||||
</t-form-item>
|
||||
</t-form>
|
||||
<input
|
||||
ref="photoInputRef"
|
||||
class="file-input"
|
||||
type="file"
|
||||
accept="*/*"
|
||||
@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"
|
||||
>
|
||||
<customer-selector
|
||||
v-if="!isCustomerBound"
|
||||
v-model="introducerCustomerId"
|
||||
@@ -276,8 +260,8 @@ import BodyAreaSelector from "@/components/BodyAreaSelector.vue";
|
||||
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 type { MediaSelectorAddAction } from "@/components/mediaSelector/types";
|
||||
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
|
||||
import type { AttachmentSelectorSelection } from "@/components/attachmentSelector/types";
|
||||
import TagSelector from "@/components/TagSelector.vue";
|
||||
import CustomerTagCard from "@/pages/customer/component/CustomerTagCard.vue";
|
||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||
@@ -287,8 +271,7 @@ import { bodyAreaLabelMap } from "@/utils/bodyArea";
|
||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||
import { normalizeBodyAreaValue } from "@/utils/customer";
|
||||
import { corePermissionCodes, gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||
import { compressUploadImage } from "@/utils/imageCompression";
|
||||
import { saveCapturedFilesFromInput } from "@/utils/twaBridge";
|
||||
import { compressUploadImageList } from "@/utils/imageCompression";
|
||||
|
||||
const pageNavBarRight = reactive({
|
||||
icon: "",
|
||||
@@ -544,46 +527,21 @@ function confirmBodyAreaPicker(): void {
|
||||
bodyAreaPickerVisible.value = false;
|
||||
}
|
||||
|
||||
function openPhotoPicker(target: CustomerAttachmentType): void {
|
||||
if (isCustomerBound.value) {
|
||||
return;
|
||||
function handlePhotoPickerStart(source: AttachmentSelectorSelection["source"]): void {
|
||||
if (isPointCardCapture.value && source === "photo") {
|
||||
photoPickerTarget.value = "POINT_CARD";
|
||||
} else if (source === "photo") {
|
||||
photoPickerTarget.value = "PHOTO";
|
||||
} else {
|
||||
photoPickerTarget.value = "OTHER";
|
||||
}
|
||||
photoPickerTarget.value = target;
|
||||
photoInputRef.value?.click();
|
||||
isPointCardCapture.value = false;
|
||||
}
|
||||
|
||||
function capturePhoto(): void {
|
||||
if (isCustomerBound.value) {
|
||||
return;
|
||||
}
|
||||
photoPickerTarget.value = "PHOTO";
|
||||
photoCameraInputRef.value?.click();
|
||||
}
|
||||
|
||||
function capturePointCard(): void {
|
||||
if (isCustomerBound.value) {
|
||||
return;
|
||||
}
|
||||
photoPickerTarget.value = "POINT_CARD";
|
||||
photoCameraInputRef.value?.click();
|
||||
}
|
||||
|
||||
function captureVideo(): void {
|
||||
if (isCustomerBound.value) {
|
||||
return;
|
||||
}
|
||||
photoPickerTarget.value = "OTHER";
|
||||
videoInputRef.value?.click();
|
||||
}
|
||||
|
||||
function handlePhotoAction(action: MediaSelectorAddAction): void {
|
||||
if (action.emit === "add-point-card") {
|
||||
capturePointCard();
|
||||
return;
|
||||
}
|
||||
if (action.emit === "add-other") {
|
||||
openPhotoPicker("OTHER");
|
||||
}
|
||||
function handlePointCardCapture(capturePhoto: () => void): void {
|
||||
isPointCardCapture.value = true;
|
||||
capturePhoto();
|
||||
isPointCardCapture.value = false;
|
||||
}
|
||||
|
||||
watch(isCustomerBound, (value) => {
|
||||
@@ -675,29 +633,10 @@ watch(() => formData.birthdate, (value) => {
|
||||
|
||||
// ---------- 照片 ----------
|
||||
|
||||
const photoInputRef = ref<HTMLInputElement>();
|
||||
const photoCameraInputRef = ref<HTMLInputElement>();
|
||||
const videoInputRef = ref<HTMLInputElement>();
|
||||
const photoAddActions = [
|
||||
{
|
||||
icon: "cardmembership",
|
||||
text: "拍积分卡",
|
||||
emit: "add-point-card",
|
||||
theme: "primary"
|
||||
}
|
||||
] as const;
|
||||
const isPointCardCapture = ref(false);
|
||||
const photoPickerTarget = ref<CustomerAttachmentType>("PHOTO");
|
||||
const isPhotoUploading = ref(false);
|
||||
const photoItemList = ref<EditableCustomerPhoto[]>([]);
|
||||
const photoList = computed<string[]>({
|
||||
get() {
|
||||
return photoItemList.value.map(item => item.url);
|
||||
},
|
||||
set(value) {
|
||||
const urlSet = new Set(value);
|
||||
photoItemList.value = photoItemList.value.filter(item => urlSet.has(item.url));
|
||||
}
|
||||
});
|
||||
|
||||
function normalizeAttachmentType(attachType?: string): CustomerAttachmentType {
|
||||
if (attachType === "POINT_CARD" || attachType === "OTHER") {
|
||||
@@ -724,28 +663,26 @@ function validateCustomerPhotoList(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
async function handlePhotoSelected(event: Event): Promise<void> {
|
||||
const input = event.target as HTMLInputElement;
|
||||
const file = input.files?.[0];
|
||||
if (!file) {
|
||||
async function handlePhotoSelected(files: File[]): Promise<void> {
|
||||
if (!files.length) {
|
||||
return;
|
||||
}
|
||||
saveCapturedFilesFromInput(input, [file]);
|
||||
isPhotoUploading.value = true;
|
||||
try {
|
||||
const compressedFile = await compressUploadImage(file);
|
||||
const [tempFile] = await AttachmentAPI.upload(compressedFile);
|
||||
if (tempFile?.id) {
|
||||
const tempFileList = await AttachmentAPI.upload(await compressUploadImageList(files));
|
||||
for (const [index, tempFile] of tempFileList.entries()) {
|
||||
if (!tempFile.id) {
|
||||
continue;
|
||||
}
|
||||
photoItemList.value.push({
|
||||
attachType: photoPickerTarget.value,
|
||||
mimeType: file.type,
|
||||
mimeType: files[index]?.type,
|
||||
tempFileId: tempFile.id,
|
||||
url: AttachmentAPI.getTempReadURL(tempFile.id)
|
||||
});
|
||||
}
|
||||
} finally {
|
||||
isPhotoUploading.value = false;
|
||||
input.value = "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -919,6 +856,8 @@ function buildAttachmentList(): Attachment[] {
|
||||
.photo {
|
||||
width: 100%;
|
||||
|
||||
|
||||
|
||||
.tips {
|
||||
font-size: .875rem;
|
||||
text-align: center;
|
||||
|
||||
@@ -110,15 +110,21 @@
|
||||
核销登记记录
|
||||
</t-button>
|
||||
<div v-if="record" class="photo-wrapper" v-entrance-transition>
|
||||
<media-selector
|
||||
:model-value="recordPhotoList"
|
||||
:photo-items="recordPhotoItemList"
|
||||
:show-viewer-actions="canUpdateRecord"
|
||||
:show-add="false"
|
||||
:show-remove="false"
|
||||
:submit="submitPhotoItems"
|
||||
<attachment-selector
|
||||
:readonly="true"
|
||||
:items="recordPhotoItemList"
|
||||
title="登记照片"
|
||||
/>
|
||||
>
|
||||
<template #viewer-actions="{ item, index, close }">
|
||||
<attachment-viewer-actions
|
||||
v-if="canUpdateRecord"
|
||||
:attach-type="item.attachType"
|
||||
:busy="isPhotoSaving"
|
||||
@change-type="changePhotoType(index, $event, close)"
|
||||
@remove="removePhoto(index, close)"
|
||||
/>
|
||||
</template>
|
||||
</attachment-selector>
|
||||
</div>
|
||||
<t-button
|
||||
v-if="record && canDeleteRecord"
|
||||
@@ -149,7 +155,8 @@ import EventRecordAPI from "@/api/EventRecordAPI";
|
||||
import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
|
||||
import EventOptionSelector from "@/components/EventOptionSelector.vue";
|
||||
import EventRecordVerifyDialog from "@/components/EventRecordVerifyDialog.vue";
|
||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||
import AttachmentViewerActions from "@/components/attachmentSelector/AttachmentViewerActions.vue";
|
||||
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
|
||||
import type { PhotoItem } from "@/types/Photo";
|
||||
import type { PointLedgerChangeType } from "@/types/Point";
|
||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||
@@ -207,6 +214,7 @@ const record = ref<EventRecord>();
|
||||
const isLoading = ref(false);
|
||||
const isVerifying = ref(false);
|
||||
const isDeleting = ref(false);
|
||||
const isPhotoSaving = ref(false);
|
||||
const verifyDialogVisible = ref(false);
|
||||
|
||||
const isRetiredRecord = computed(() => isRetiredEvent(record.value?.event));
|
||||
@@ -222,8 +230,6 @@ const recordPhotoItemList = computed(() => (record.value?.attachmentList || [])
|
||||
previewUrl: getAttachmentReadURL(item.id || ""),
|
||||
url: getAttachmentReadURL(item.id || "", 64)
|
||||
})));
|
||||
const recordPhotoList = computed(() => recordPhotoItemList.value.map(item => item.url));
|
||||
|
||||
async function submitPhotoItems(photoItems: PhotoItem[]): Promise<void> {
|
||||
const currentRecord = record.value;
|
||||
if (!currentRecord?.id || isRetiredRecord.value) {
|
||||
@@ -242,6 +248,35 @@ async function submitPhotoItems(photoItems: PhotoItem[]): Promise<void> {
|
||||
};
|
||||
}
|
||||
|
||||
async function applyPhotoItems(photoItems: PhotoItem[], close: () => void): Promise<void> {
|
||||
if (isPhotoSaving.value) {
|
||||
return;
|
||||
}
|
||||
isPhotoSaving.value = true;
|
||||
try {
|
||||
await submitPhotoItems(photoItems);
|
||||
close();
|
||||
} catch (error) {
|
||||
Message.error(getErrorMessage(error, "登记照片修改失败"));
|
||||
} finally {
|
||||
isPhotoSaving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function changePhotoType(index: number, attachType: string, close: () => void): Promise<void> {
|
||||
if (!recordPhotoItemList.value[index] || recordPhotoItemList.value[index].attachType === attachType) {
|
||||
return;
|
||||
}
|
||||
await applyPhotoItems(recordPhotoItemList.value.map((item, itemIndex) => itemIndex === index ? { ...item, attachType } : item), close);
|
||||
}
|
||||
|
||||
async function removePhoto(index: number, close: () => void): Promise<void> {
|
||||
if (!recordPhotoItemList.value[index]) {
|
||||
return;
|
||||
}
|
||||
await applyPhotoItems(recordPhotoItemList.value.filter((_, itemIndex) => itemIndex !== index), close);
|
||||
}
|
||||
|
||||
function buildPhotoAttachmentList(photoItems: PhotoItem[]): Attachment[] {
|
||||
return photoItems.flatMap(item => {
|
||||
if (item.attachment) {
|
||||
|
||||
@@ -155,16 +155,12 @@
|
||||
</t-form-item>
|
||||
|
||||
<div class="photo-part">
|
||||
<media-selector
|
||||
<attachment-selector
|
||||
title="登记事件照片"
|
||||
:required="selectedRequiredPhotoEventList.length > 0"
|
||||
v-model="photoList"
|
||||
v-model:photo-items="photoItemList"
|
||||
:edit-mode="true"
|
||||
:loading="isPhotoUploading"
|
||||
@add="selectPhotoFile"
|
||||
@capture-photo="capturePhoto"
|
||||
@capture-video="captureVideo"
|
||||
v-model:items="photoItemList"
|
||||
:busy="isPhotoUploading"
|
||||
@select="handleRecordPhotoSelected($event.files)"
|
||||
/>
|
||||
</div>
|
||||
</t-form>
|
||||
@@ -213,30 +209,6 @@
|
||||
/>
|
||||
</div>
|
||||
</t-popup>
|
||||
<input
|
||||
ref="recordPhotoInputRef"
|
||||
class="file-input"
|
||||
type="file"
|
||||
accept="*/*"
|
||||
multiple
|
||||
@change="handleRecordPhotoSelected"
|
||||
>
|
||||
<input
|
||||
ref="recordPhotoCameraInputRef"
|
||||
class="file-input"
|
||||
type="file"
|
||||
accept="image/*"
|
||||
capture="environment"
|
||||
@change="handleRecordPhotoSelected"
|
||||
>
|
||||
<input
|
||||
ref="videoInputRef"
|
||||
class="file-input"
|
||||
type="file"
|
||||
accept="video/*"
|
||||
capture="environment"
|
||||
@change="handleRecordPhotoSelected"
|
||||
>
|
||||
</div>
|
||||
<t-popup v-model="registeredAtPickerVisible" placement="bottom">
|
||||
<t-date-time-picker
|
||||
@@ -264,7 +236,7 @@ import CustomerList from "@/components/CustomerList.vue";
|
||||
import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
|
||||
import CustomerSelector from "@/components/CustomerSelector.vue";
|
||||
import EventOptionSelector from "@/components/EventOptionSelector.vue";
|
||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
|
||||
import EventSelector from "@/components/EventSelector.vue";
|
||||
import { useEventRecordPhoto } from "@/pages/event/component/useEventRecordPhoto";
|
||||
import type { Customer } from "@/types/Customer";
|
||||
@@ -581,15 +553,8 @@ function validateNumberValueList(): boolean {
|
||||
// ---------- 照片 ----------
|
||||
|
||||
const {
|
||||
recordPhotoInputRef,
|
||||
recordPhotoCameraInputRef,
|
||||
videoInputRef,
|
||||
photoItemList,
|
||||
isPhotoUploading,
|
||||
photoList,
|
||||
capturePhoto,
|
||||
selectPhotoFile,
|
||||
captureVideo,
|
||||
handleRecordPhotoSelected,
|
||||
setExistingPhotoList,
|
||||
buildTempFileIdList,
|
||||
|
||||
@@ -1,45 +1,17 @@
|
||||
import { computed, ref } from "vue";
|
||||
import { ref } from "vue";
|
||||
import { AttachmentAPI, type Attachment } from "timi-web-api";
|
||||
import type { PhotoItem } from "@/types/Photo";
|
||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||
import { compressUploadImageList } from "@/utils/imageCompression";
|
||||
import { saveCapturedFilesFromInput } from "@/utils/twaBridge";
|
||||
|
||||
export function useEventRecordPhoto() {
|
||||
const recordPhotoInputRef = ref<HTMLInputElement>();
|
||||
const recordPhotoCameraInputRef = ref<HTMLInputElement>();
|
||||
const videoInputRef = ref<HTMLInputElement>();
|
||||
const photoItemList = ref<PhotoItem[]>([]);
|
||||
const isPhotoUploading = ref(false);
|
||||
const photoList = computed<string[]>({
|
||||
get() {
|
||||
return photoItemList.value.map(item => item.url);
|
||||
},
|
||||
set(value) {
|
||||
const urlSet = new Set(value);
|
||||
photoItemList.value = photoItemList.value.filter(item => urlSet.has(item.url));
|
||||
}
|
||||
});
|
||||
|
||||
function capturePhoto(): void {
|
||||
recordPhotoCameraInputRef.value?.click();
|
||||
}
|
||||
|
||||
function selectPhotoFile(): void {
|
||||
recordPhotoInputRef.value?.click();
|
||||
}
|
||||
|
||||
function captureVideo(): void {
|
||||
videoInputRef.value?.click();
|
||||
}
|
||||
|
||||
async function handleRecordPhotoSelected(event: Event): Promise<void> {
|
||||
const input = event.target as HTMLInputElement;
|
||||
const fileList = Array.from(input.files || []);
|
||||
async function handleRecordPhotoSelected(fileList: File[]): Promise<void> {
|
||||
if (!fileList.length) {
|
||||
return;
|
||||
}
|
||||
saveCapturedFilesFromInput(input, fileList);
|
||||
isPhotoUploading.value = true;
|
||||
try {
|
||||
const compressedFileList = await compressUploadImageList(fileList);
|
||||
@@ -56,7 +28,6 @@ export function useEventRecordPhoto() {
|
||||
}
|
||||
} finally {
|
||||
isPhotoUploading.value = false;
|
||||
input.value = "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,15 +64,8 @@ export function useEventRecordPhoto() {
|
||||
}
|
||||
|
||||
return {
|
||||
recordPhotoInputRef,
|
||||
recordPhotoCameraInputRef,
|
||||
videoInputRef,
|
||||
photoItemList,
|
||||
isPhotoUploading,
|
||||
photoList,
|
||||
capturePhoto,
|
||||
selectPhotoFile,
|
||||
captureVideo,
|
||||
handleRecordPhotoSelected,
|
||||
setExistingPhotoList,
|
||||
buildTempFileIdList,
|
||||
|
||||
@@ -70,12 +70,8 @@
|
||||
<t-cell-group title="跟进内容" theme="card" v-entrance-transition>
|
||||
<div class="content bg-white" v-text="detail.content || '未填写跟进内容'" />
|
||||
<div class="media-wrap bg-white">
|
||||
<media-selector
|
||||
:model-value="attachmentUrlList"
|
||||
:photo-items="attachmentItemList"
|
||||
:show-add="false"
|
||||
:show-remove="false"
|
||||
:show-viewer-actions="false"
|
||||
<attachment-selector :readonly="true"
|
||||
:items="attachmentItemList"
|
||||
empty-text="暂无附件"
|
||||
title="附件"
|
||||
/>
|
||||
@@ -133,7 +129,7 @@ import { Message } from "@/utils/message";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import FollowUpReminderAPI from "@/api/FollowUpReminderAPI";
|
||||
import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
|
||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
|
||||
import type { PhotoItem } from "@/types/Photo";
|
||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||
import { corePermissionCodes, permissionCodes } from "@/utils/permission";
|
||||
@@ -202,7 +198,6 @@ const attachmentItemList = computed<PhotoItem[]>(() => (detail.value?.attachment
|
||||
previewUrl: getAttachmentReadURL(item.id || ""),
|
||||
url: getAttachmentReadURL(item.id || "", 90)
|
||||
})));
|
||||
const attachmentUrlList = computed(() => attachmentItemList.value.map(item => item.url));
|
||||
|
||||
function hasChannel(channel: FollowUpReminderNotifyChannel): boolean {
|
||||
const item = detail.value;
|
||||
|
||||
@@ -80,14 +80,10 @@
|
||||
/>
|
||||
</t-form-item>
|
||||
<t-form-item label-width="0">
|
||||
<media-selector
|
||||
:model-value="photoUrlList"
|
||||
v-model:photo-items="photoItems"
|
||||
<attachment-selector
|
||||
v-model:items="photoItems"
|
||||
:upload="uploadReminderPhotoList"
|
||||
:edit-mode="true"
|
||||
:loading="isSaving || isUploading"
|
||||
add-text="选择照片"
|
||||
:show-type-label="false"
|
||||
:busy="isSaving || isUploading"
|
||||
title="附件照片"
|
||||
/>
|
||||
</t-form-item>
|
||||
@@ -163,7 +159,7 @@ import FollowUpReminderAPI from "@/api/FollowUpReminderAPI";
|
||||
import CustomerAPI from "@/api/CustomerAPI";
|
||||
import CustomerSelector from "@/components/CustomerSelector.vue";
|
||||
import ManagedUserSelector from "@/pages/followUpReminder/component/ManagedUserSelector.vue";
|
||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
|
||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||
import type { ManagedUser } from "@/types/ManagedUser";
|
||||
import type {
|
||||
@@ -252,7 +248,6 @@ const formModel = reactive({
|
||||
const selectedCustomer = ref<Customer>();
|
||||
const selectedResponsible = ref<ManagedUser>();
|
||||
const photoItems = ref<PhotoItem[]>([]);
|
||||
const photoUrlList = computed(() => photoItems.value.map(item => item.previewUrl || item.url));
|
||||
const customerSelectorVisible = ref(false);
|
||||
const responsibleSelectorVisible = ref(false);
|
||||
const customerPickerStoreId = computed(() => formModel.storeId || currentStoreStore.currentStoreId);
|
||||
|
||||
@@ -159,12 +159,10 @@
|
||||
<t-textarea v-model="remark" borderless autosize maxlength="500" />
|
||||
</t-form-item>
|
||||
<t-form-item label-width="0">
|
||||
<media-selector
|
||||
<attachment-selector
|
||||
v-if="order"
|
||||
:model-value="photoUrlList"
|
||||
v-model:photo-items="photoItems"
|
||||
v-model:items="photoItems"
|
||||
:upload="uploadPhotoList"
|
||||
:edit-mode="true"
|
||||
required
|
||||
title="履约凭证照片"
|
||||
/>
|
||||
@@ -192,7 +190,7 @@ import SalesOrderAPI from "@/api/SalesOrderAPI";
|
||||
import FulfillmentAPI from "@/api/FulfillmentAPI";
|
||||
import ProductAPI from "@/api/ProductAPI";
|
||||
import { Time } from "timi-web";
|
||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
|
||||
import ProductSkuTags from "@/components/ProductSkuTags.vue";
|
||||
import ProductStockPreview from "@/components/ProductStockPreview.vue";
|
||||
import { useUserStore } from "timi-web-api";
|
||||
@@ -277,7 +275,6 @@ const isStockChecking = ref(false);
|
||||
const stockPreviewList = ref<ProductStockPreviewItem[]>([]);
|
||||
let stockCheckToken = 0;
|
||||
let stockPreviewTimer: number | undefined;
|
||||
const photoUrlList = computed(() => photoItems.value.map(item => item.url));
|
||||
const isPackage = computed(() => order.value?.orderType === "PACKAGE");
|
||||
const expectedItemType = computed(() => isPackage.value ? "PACKAGE_ENTITLEMENT" : "DIRECT_PRODUCT");
|
||||
const sourceItems = computed<GaoSalesOrderItem[]>(() => (order.value?.itemList || []).filter(item => item.itemType === expectedItemType.value
|
||||
|
||||
@@ -22,12 +22,8 @@
|
||||
<t-cell v-if="fulfillment.reason" title="原因" :note="fulfillment.reason" />
|
||||
<t-cell v-if="fulfillment.remark" title="备注" :note="fulfillment.remark" />
|
||||
<div class="photo-wrap bg-white">
|
||||
<media-selector
|
||||
:model-value="fulfillmentPhotoURLList"
|
||||
:photo-items="fulfillmentPhotoItems"
|
||||
:show-add="false"
|
||||
:show-remove="false"
|
||||
:show-viewer-actions="false"
|
||||
<attachment-selector :readonly="true"
|
||||
:items="fulfillmentPhotoItems"
|
||||
title="履约照片"
|
||||
/>
|
||||
</div>
|
||||
@@ -134,7 +130,7 @@ import { useUserStore } from "timi-web-api";
|
||||
import FulfillmentAPI from "@/api/FulfillmentAPI";
|
||||
import ProductAPI from "@/api/ProductAPI";
|
||||
import SalesOrderAPI from "@/api/SalesOrderAPI";
|
||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
|
||||
import ProductSkuTags from "@/components/ProductSkuTags.vue";
|
||||
import ProductStockPreview from "@/components/ProductStockPreview.vue";
|
||||
import OrderFulfillmentRevoke from "@/pages/fulfillment/components/OrderFulfillmentRevoke.vue";
|
||||
@@ -176,7 +172,6 @@ const fulfillmentPhotoItems = computed<PhotoItem[]>(() => (fulfillment.value?.at
|
||||
previewUrl: getAttachmentReadURL(item.id || ""),
|
||||
url: getAttachmentReadURL(item.id || "", 90)
|
||||
})));
|
||||
const fulfillmentPhotoURLList = computed(() => fulfillmentPhotoItems.value.map(item => item.url));
|
||||
const isWaitingStock = computed(() => fulfillment.value?.status === "WAITING_STOCK");
|
||||
const isPending = computed(() => fulfillment.value?.status === "PENDING");
|
||||
const isVerified = computed(() => fulfillment.value?.status === "VERIFIED");
|
||||
|
||||
@@ -86,11 +86,9 @@
|
||||
</template>
|
||||
</t-cell>
|
||||
<div class="photo-wrap bg-white">
|
||||
<media-selector
|
||||
:model-value="photoUrlList"
|
||||
v-model:photo-items="photoItems"
|
||||
<attachment-selector
|
||||
v-model:items="photoItems"
|
||||
:upload="uploadPhotoList"
|
||||
:edit-mode="true"
|
||||
required
|
||||
title="履约凭证照片"
|
||||
/>
|
||||
@@ -134,7 +132,7 @@ import FulfillmentAPI from "@/api/FulfillmentAPI";
|
||||
import ProductAPI from "@/api/ProductAPI";
|
||||
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 ProductSelectPopup from "@/components/productSelector/ProductSelectPopup.vue";
|
||||
import ProductStockPreview from "@/components/ProductStockPreview.vue";
|
||||
import OrderFulfillmentQuickQuantity from "@/pages/fulfillment/components/OrderFulfillmentQuickQuantity.vue";
|
||||
@@ -199,7 +197,6 @@ const canDirectVerify = computed(() => userStore.hasRoles(gaoRoleCodes.storeMana
|
||||
&& userStore.hasPermissions(permissionCodes.orderFulfillment.create)
|
||||
&& userStore.hasPermissions(permissionCodes.orderFulfillment.verify)
|
||||
&& userStore.hasPermissions(permissionCodes.productStock.read));
|
||||
const photoUrlList = computed(() => photoItems.value.map(item => item.previewUrl || item.url));
|
||||
|
||||
// ---------- SKU 选择 ----------
|
||||
|
||||
|
||||
@@ -31,11 +31,9 @@
|
||||
<t-switch v-model="returnedToStore" />
|
||||
</t-form-item>
|
||||
<t-form-item label-width="0">
|
||||
<media-selector
|
||||
:model-value="photoUrlList"
|
||||
v-model:photo-items="photoItems"
|
||||
<attachment-selector
|
||||
v-model:items="photoItems"
|
||||
:upload="uploadPhotoList"
|
||||
:edit-mode="true"
|
||||
required
|
||||
title="冲正凭证照片"
|
||||
/>
|
||||
@@ -62,7 +60,7 @@
|
||||
import { BottomPopup } from "timi-tdesign-mobile";
|
||||
import type { Attachment } from "timi-web-api";
|
||||
import FulfillmentAPI from "@/api/FulfillmentAPI";
|
||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
|
||||
import type { OrderFulfillment } from "@/types/Fulfillment";
|
||||
import type { PhotoItem } from "@/types/Photo";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
@@ -90,7 +88,6 @@ const photoItems = ref<PhotoItem[]>([]);
|
||||
const reasonPickerVisible = ref(false);
|
||||
const reasonPickerDraft = ref<string[]>([]);
|
||||
const requestNo = ref("");
|
||||
const photoUrlList = computed(() => photoItems.value.map(item => item.url));
|
||||
const reasonOptions = [
|
||||
"客户申请撤销履约",
|
||||
"履约数量填写有误",
|
||||
|
||||
@@ -82,16 +82,12 @@
|
||||
</t-form-item>
|
||||
</t-form>
|
||||
<div v-if="showRecordPhotoInput" class="input-form photo-form content-margin">
|
||||
<media-selector
|
||||
<attachment-selector
|
||||
title="登记事件照片"
|
||||
:required="selectedRequiredPhotoEventList.length > 0"
|
||||
v-model="recordPhotoList"
|
||||
v-model:photo-items="recordPhotoItemList"
|
||||
:edit-mode="true"
|
||||
:loading="recordPhotoUploading"
|
||||
@add="selectPhotoFile"
|
||||
@capture-photo="capturePhoto"
|
||||
@capture-video="captureVideo"
|
||||
v-model:items="recordPhotoItemList"
|
||||
:busy="recordPhotoUploading"
|
||||
@select="handleRecordPhotoSelected($event.files)"
|
||||
/>
|
||||
</div>
|
||||
<t-cell-group
|
||||
@@ -120,30 +116,6 @@
|
||||
</template>
|
||||
</t-cell>
|
||||
</t-cell-group>
|
||||
<input
|
||||
ref="recordPhotoInputRef"
|
||||
class="file-input"
|
||||
type="file"
|
||||
accept="*/*"
|
||||
multiple
|
||||
@change="handleRecordPhotoSelected"
|
||||
>
|
||||
<input
|
||||
ref="recordPhotoCameraInputRef"
|
||||
class="file-input"
|
||||
type="file"
|
||||
accept="image/*"
|
||||
capture="environment"
|
||||
@change="handleRecordPhotoSelected"
|
||||
>
|
||||
<input
|
||||
ref="videoInputRef"
|
||||
class="file-input"
|
||||
type="file"
|
||||
accept="video/*"
|
||||
capture="environment"
|
||||
@change="handleRecordPhotoSelected"
|
||||
>
|
||||
</div>
|
||||
<bottom-popup
|
||||
v-model="eventPopupVisible"
|
||||
@@ -178,7 +150,7 @@ import EventRecordAPI from "@/api/EventRecordAPI";
|
||||
import CodeScanner from "@/components/CodeScanner.vue";
|
||||
import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
|
||||
import EventOptionSelector from "@/components/EventOptionSelector.vue";
|
||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
|
||||
import { useSettingStore } from "@/store/settingStore";
|
||||
import type { Customer } from "@/types/Customer";
|
||||
import type { EventItem, EventOptionSelectionMap } from "@/types/EventItem";
|
||||
@@ -190,7 +162,6 @@ import { resolveSelectedOptionGroupList, validateEventOptionSelection } from "@/
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
import { getEventRecordPhotoURL, hasPhotoAttachment } from "@/utils/eventRecord";
|
||||
import { compressUploadImageList } from "@/utils/imageCompression";
|
||||
import { saveCapturedFilesFromInput } from "@/utils/twaBridge";
|
||||
import { Storage, Time } from "timi-web";
|
||||
import { type Attachment, AttachmentAPI } from "timi-web-api";
|
||||
import EventSelector from "@/components/EventSelector.vue";
|
||||
@@ -423,41 +394,14 @@ function validateNumberValueList(): boolean {
|
||||
|
||||
// ---------- 照片 ----------
|
||||
|
||||
const recordPhotoInputRef = ref<HTMLInputElement>();
|
||||
const recordPhotoCameraInputRef = ref<HTMLInputElement>();
|
||||
const videoInputRef = ref<HTMLInputElement>();
|
||||
const recordPhotoItemList = ref<PhotoItem[]>([]);
|
||||
const recordPhotoUploading = ref(false);
|
||||
const showRecordPhotoInput = computed(() => selectedRequiredPhotoEventList.value.length > 0 || recordPhotoItemList.value.length > 0);
|
||||
const recordPhotoList = computed<string[]>({
|
||||
get() {
|
||||
return recordPhotoItemList.value.map(item => item.url);
|
||||
},
|
||||
set(value) {
|
||||
const urlSet = new Set(value);
|
||||
recordPhotoItemList.value = recordPhotoItemList.value.filter(item => urlSet.has(item.url));
|
||||
}
|
||||
});
|
||||
|
||||
function capturePhoto(): void {
|
||||
recordPhotoCameraInputRef.value?.click();
|
||||
}
|
||||
|
||||
function selectPhotoFile(): void {
|
||||
recordPhotoInputRef.value?.click();
|
||||
}
|
||||
|
||||
function captureVideo(): void {
|
||||
videoInputRef.value?.click();
|
||||
}
|
||||
|
||||
async function handleRecordPhotoSelected(event: Event): Promise<void> {
|
||||
const input = event.target as HTMLInputElement;
|
||||
const fileList = Array.from(input.files || []);
|
||||
async function handleRecordPhotoSelected(fileList: File[]): Promise<void> {
|
||||
if (!fileList.length) {
|
||||
return;
|
||||
}
|
||||
saveCapturedFilesFromInput(input, fileList);
|
||||
recordPhotoUploading.value = true;
|
||||
try {
|
||||
const compressedFileList = await compressUploadImageList(fileList);
|
||||
@@ -475,7 +419,6 @@ async function handleRecordPhotoSelected(event: Event): Promise<void> {
|
||||
}
|
||||
} finally {
|
||||
recordPhotoUploading.value = false;
|
||||
input.value = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -253,20 +253,16 @@
|
||||
</div>
|
||||
</t-form-item>
|
||||
<t-form-item v-if="(paymentVerified && parsedPaymentAmount) || (receiveFullPayment && parsedSaleAmount)" label-width="0">
|
||||
<media-selector
|
||||
:model-value="paymentPhotoUrlList"
|
||||
v-model:photo-items="paymentPhotoItems"
|
||||
<attachment-selector
|
||||
v-model:items="paymentPhotoItems"
|
||||
:upload="uploadPhotoList"
|
||||
:edit-mode="true"
|
||||
title="收款凭证照片(必要)"
|
||||
/>
|
||||
</t-form-item>
|
||||
<t-form-item v-if="fulfillAll" label-width="0">
|
||||
<media-selector
|
||||
:model-value="fulfillmentPhotoUrlList"
|
||||
v-model:photo-items="fulfillmentPhotoItems"
|
||||
<attachment-selector
|
||||
v-model:items="fulfillmentPhotoItems"
|
||||
:upload="uploadPhotoList"
|
||||
:edit-mode="true"
|
||||
title="履约凭证照片(必要)"
|
||||
/>
|
||||
</t-form-item>
|
||||
@@ -279,11 +275,9 @@
|
||||
/>
|
||||
</t-form-item>
|
||||
<t-form-item label-width="0">
|
||||
<media-selector
|
||||
:model-value="photoUrlList"
|
||||
v-model:photo-items="photoItems"
|
||||
<attachment-selector
|
||||
v-model:items="photoItems"
|
||||
:upload="uploadPhotoList"
|
||||
:edit-mode="true"
|
||||
title="订单照片"
|
||||
/>
|
||||
</t-form-item>
|
||||
@@ -383,7 +377,7 @@ import CodeScanner from "@/components/CodeScanner.vue";
|
||||
import CustomerList from "@/components/CustomerList.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 ProductSelectFormItem from "@/components/productSelector/ProductSelectFormItem.vue";
|
||||
import ProductStockPreview from "@/components/ProductStockPreview.vue";
|
||||
import { usePackagePurchase } from "@/pages/package/usePackagePurchase";
|
||||
@@ -599,9 +593,6 @@ const photoItems = ref<PhotoItem[]>([]);
|
||||
const paymentPhotoItems = ref<PhotoItem[]>([]);
|
||||
const fulfillmentPhotoItems = ref<PhotoItem[]>([]);
|
||||
const paymentAmountText = ref("0");
|
||||
const photoUrlList = computed(() => photoItems.value.map(item => item.url));
|
||||
const paymentPhotoUrlList = computed(() => paymentPhotoItems.value.map(item => item.url));
|
||||
const fulfillmentPhotoUrlList = computed(() => fulfillmentPhotoItems.value.map(item => item.url));
|
||||
const receiveFullPayment = ref(false);
|
||||
const fulfillAll = ref(false);
|
||||
const isStockChecking = ref(false);
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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"));
|
||||
|
||||
@@ -61,14 +61,10 @@
|
||||
<t-cell title="状态" :note="getProductStatusText(product.status)" />
|
||||
<t-cell title="备注" :note="Text.display(product.remark)"></t-cell>
|
||||
<t-cell>
|
||||
<media-selector
|
||||
:model-value="attachmentUrlList"
|
||||
:photo-items="attachmentItemList"
|
||||
<attachment-selector :readonly="true"
|
||||
:items="attachmentItemList"
|
||||
title="附件列表"
|
||||
:show-add="false"
|
||||
:show-remove="false"
|
||||
:show-viewer-actions="false"
|
||||
/>
|
||||
/>
|
||||
</t-cell>
|
||||
</t-cell-group>
|
||||
<t-cell-group theme="card" v-entrance-transition>
|
||||
@@ -153,15 +149,11 @@
|
||||
<t-cell v-if="selectedSku.remark" title="备注" :note="Text.display(selectedSku.remark)" />
|
||||
</t-cell-group>
|
||||
<div class="media-wrap">
|
||||
<media-selector
|
||||
<attachment-selector :readonly="true"
|
||||
v-if="skuPhotoItemList.length"
|
||||
:model-value="skuPhotoUrlList"
|
||||
:photo-items="skuPhotoItemList"
|
||||
:items="skuPhotoItemList"
|
||||
title="SKU 图片"
|
||||
:show-add="false"
|
||||
:show-remove="false"
|
||||
:show-viewer-actions="false"
|
||||
/>
|
||||
/>
|
||||
</div>
|
||||
<div class="unit">
|
||||
<div class="header">
|
||||
@@ -205,7 +197,7 @@ async function handlePageNavBarAction(action: NavBarAction): Promise<void> {
|
||||
await action.action();
|
||||
}
|
||||
|
||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
|
||||
|
||||
defineOptions({ name: "ProductDetail" });
|
||||
|
||||
@@ -225,7 +217,6 @@ const attachmentItemList = computed<PhotoItem[]>(() => (product.value?.attachmen
|
||||
previewUrl: getAttachmentReadURL(item.id || ""),
|
||||
url: getAttachmentReadURL(item.id || "", 90)
|
||||
})));
|
||||
const attachmentUrlList = computed(() => attachmentItemList.value.map(item => item.url));
|
||||
const skuPhotoItemList = computed<PhotoItem[]>(() => (selectedSku.value?.attachmentList || [])
|
||||
.filter(item => !!item.id)
|
||||
.map(item => ({
|
||||
@@ -234,7 +225,6 @@ const skuPhotoItemList = computed<PhotoItem[]>(() => (selectedSku.value?.attachm
|
||||
previewUrl: getAttachmentReadURL(item.id || ""),
|
||||
url: getAttachmentReadURL(item.id || "", 90)
|
||||
})));
|
||||
const skuPhotoUrlList = computed(() => skuPhotoItemList.value.map(item => item.url));
|
||||
const actionList = computed<NavBarAction[]>(() => {
|
||||
const list: NavBarAction[] = [];
|
||||
if (userStore.hasPermissions(permissionCodes.product.update)) {
|
||||
|
||||
@@ -68,18 +68,11 @@
|
||||
<t-textarea v-model="form.remark" borderless maxlength="255" autosize placeholder="可填写产品说明" />
|
||||
</t-form-item>
|
||||
<t-form-item label-width="0">
|
||||
<media-selector
|
||||
v-model="attachmentUrlList"
|
||||
v-model:photo-items="attachmentItemList"
|
||||
<attachment-selector
|
||||
v-model:items="attachmentItemList"
|
||||
title="产品公共图片及附件"
|
||||
:edit-mode="true"
|
||||
:loading="isAttachmentUploading"
|
||||
:show-viewer-actions="false"
|
||||
:add-actions="attachmentAddActions"
|
||||
@add="openAttachmentPicker('OTHER')"
|
||||
@action="handleAttachmentAction"
|
||||
@capture-photo="capturePhoto"
|
||||
@capture-video="captureVideo"
|
||||
:busy="isAttachmentUploading"
|
||||
@select="handleAttachmentSelected($event.files, $event.source)"
|
||||
/>
|
||||
</t-form-item>
|
||||
<t-form-item label="纯色封面" label-width="8rem" content-align="right">
|
||||
@@ -245,9 +238,6 @@
|
||||
>
|
||||
<t-color-picker v-if="coverColorPickerVisible" v-model="coverColorDraft" format="HEX" type="multiple" :swatch-colors="colorSwatchList" @palette-bar-change="updateCoverColorDraftFromPalette" />
|
||||
</bottom-popup>
|
||||
<input ref="attachmentInputRef" class="file-input" type="file" accept="*/*" @change="handleAttachmentSelected" />
|
||||
<input ref="photoInputRef" class="file-input" type="file" accept="image/*" capture="environment" @change="handleAttachmentSelected" />
|
||||
<input ref="videoInputRef" class="file-input" type="file" accept="video/*" capture="environment" @change="handleAttachmentSelected" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -256,21 +246,20 @@ import { BottomPopup } from "timi-tdesign-mobile";
|
||||
import { DialogPlugin, type ColorObject } from "tdesign-mobile-vue";
|
||||
import { type Attachment, AttachmentAPI, useUserStore } from "timi-web-api";
|
||||
import ProductAPI from "@/api/ProductAPI";
|
||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
|
||||
import ProductSkuEditor from "@/pages/product/component/ProductSkuEditor.vue";
|
||||
import ProductSkuUnitEditor from "@/pages/product/component/ProductSkuUnitEditor.vue";
|
||||
import ProductSkuUnitBatchEditor from "@/pages/product/component/ProductSkuUnitBatchEditor.vue";
|
||||
import type { MediaSelectorAddAction } from "@/components/mediaSelector/types";
|
||||
import type { AttachmentSelectorSelection } from "@/components/attachmentSelector/types";
|
||||
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 { compressUploadImage } from "@/utils/imageCompression";
|
||||
import { compressUploadImageList } from "@/utils/imageCompression";
|
||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { emitListDataChanged, listDataEventKeys } from "@/utils/listDataEvents";
|
||||
import { formatProductAmount, getProductStatusText, getProductTypeText, normalizeProductQuantity, parseProductAmount } from "@/utils/product";
|
||||
import { Message } from "@/utils/message";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
import { saveCapturedFilesFromInput } from "@/utils/twaBridge";
|
||||
|
||||
const pageNavBarRight = reactive({
|
||||
icon: "",
|
||||
@@ -345,10 +334,6 @@ const categoryList = ref<ProductCategory[]>([]);
|
||||
const typePickerVisible = ref(false);
|
||||
const categoryPickerVisible = ref(false);
|
||||
const statusPickerVisible = ref(false);
|
||||
const attachmentInputRef = ref<HTMLInputElement>();
|
||||
const photoInputRef = ref<HTMLInputElement>();
|
||||
const videoInputRef = ref<HTMLInputElement>();
|
||||
const attachmentPickerTarget = ref<ProductAttachmentType>("PHOTO");
|
||||
const isAttachmentUploading = ref(false);
|
||||
const coverColorPickerVisible = ref(false);
|
||||
const coverColorDraft = ref(DEFAULT_COVER_COLOR);
|
||||
@@ -364,17 +349,7 @@ const categoryOptions = computed(() => [{ label: "不设置分类", value: "" },
|
||||
const statusOptions = [{ label: "启用", value: "ACTIVE" }, { label: "停用", value: "INACTIVE" }];
|
||||
const colorSwatchList = ["#2F88FF", "#0EA5E9", "#10B981", "#22C55E", "#F59E0B", "#F97316", "#EF4444", "#EC4899", "#8B5CF6", "#64748B"];
|
||||
const selectedCategoryName = computed(() => categoryList.value.find(item => item.id === form.categoryId)?.name || "不设置分类");
|
||||
const attachmentAddActions = [
|
||||
{ icon: "file-attachment", text: "其他文件", emit: "add-other", theme: "default" }
|
||||
] as const;
|
||||
const attachmentItemList = ref<ProductAttachmentItem[]>([]);
|
||||
const attachmentUrlList = computed<string[]>({
|
||||
get: () => attachmentItemList.value.map(item => item.url),
|
||||
set: value => {
|
||||
const urlSet = new Set(value);
|
||||
attachmentItemList.value = attachmentItemList.value.filter(item => urlSet.has(item.url));
|
||||
}
|
||||
});
|
||||
const solidColorCoverColor = computed(() => attachmentItemList.value.find(item => item.isSolidColorCover)?.solidColor || "");
|
||||
const skuCombinationCount = computed(() => {
|
||||
if (!form.specList.length) {
|
||||
@@ -655,27 +630,6 @@ function confirmStatus(value: Array<string | number>): void {
|
||||
statusPickerVisible.value = false;
|
||||
}
|
||||
|
||||
function openAttachmentPicker(target: ProductAttachmentType): void {
|
||||
attachmentPickerTarget.value = target;
|
||||
attachmentInputRef.value?.click();
|
||||
}
|
||||
|
||||
function capturePhoto(): void {
|
||||
attachmentPickerTarget.value = "PHOTO";
|
||||
photoInputRef.value?.click();
|
||||
}
|
||||
|
||||
function captureVideo(): void {
|
||||
attachmentPickerTarget.value = "OTHER";
|
||||
videoInputRef.value?.click();
|
||||
}
|
||||
|
||||
function handleAttachmentAction(action: MediaSelectorAddAction): void {
|
||||
if (action.emit === "add-other") {
|
||||
openAttachmentPicker("OTHER");
|
||||
}
|
||||
}
|
||||
|
||||
function openCoverColorPicker(): void {
|
||||
coverColorDraft.value = solidColorCoverColor.value || DEFAULT_COVER_COLOR;
|
||||
coverColorPickerVisible.value = true;
|
||||
@@ -742,24 +696,30 @@ async function confirmCoverColorPicker(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleAttachmentSelected(event: Event): Promise<void> {
|
||||
const input = event.target as HTMLInputElement;
|
||||
const file = input.files?.[0];
|
||||
if (!file) {
|
||||
async function handleAttachmentSelected(files: File[], source: AttachmentSelectorSelection["source"]): Promise<void> {
|
||||
if (!files.length) {
|
||||
return;
|
||||
}
|
||||
saveCapturedFilesFromInput(input, [file]);
|
||||
const attachType: ProductAttachmentType = source === "photo" ? "PHOTO" : "OTHER";
|
||||
isAttachmentUploading.value = true;
|
||||
try {
|
||||
const tempFile = (await AttachmentAPI.upload(await compressUploadImage(file)))[0];
|
||||
if (tempFile?.id) {
|
||||
attachmentItemList.value.push({ attachType: attachmentPickerTarget.value, mimeType: file.type, tempFileId: tempFile.id, url: AttachmentAPI.getTempReadURL(tempFile.id) });
|
||||
const compressedFiles = await compressUploadImageList(files);
|
||||
const tempFileList = await AttachmentAPI.upload(compressedFiles);
|
||||
for (const [index, tempFile] of tempFileList.entries()) {
|
||||
if (!tempFile.id) {
|
||||
continue;
|
||||
}
|
||||
attachmentItemList.value.push({
|
||||
attachType,
|
||||
mimeType: files[index]?.type,
|
||||
tempFileId: tempFile.id,
|
||||
url: AttachmentAPI.getTempReadURL(tempFile.id)
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
Message.error(getErrorMessage(error, "产品附件上传失败"));
|
||||
} finally {
|
||||
isAttachmentUploading.value = false;
|
||||
input.value = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,15 +68,12 @@
|
||||
</div>
|
||||
</t-form-item>
|
||||
<t-form-item label-width="0">
|
||||
<media-selector
|
||||
:model-value="globalAttachmentUrlList"
|
||||
v-model:photo-items="productStockBatchStore.attachmentItems"
|
||||
<attachment-selector
|
||||
v-model:items="productStockBatchStore.attachmentItems"
|
||||
:upload="uploadPhotos"
|
||||
:edit-mode="true"
|
||||
:loading="isSaving"
|
||||
:show-remove="!isSaving"
|
||||
:busy="isSaving"
|
||||
title="共有入库记录(无专有记录时使用)"
|
||||
@update:photo-items="invalidateRequestNo"
|
||||
@update:items="invalidateRequestNo"
|
||||
/>
|
||||
</t-form-item>
|
||||
</t-form>
|
||||
@@ -160,16 +157,13 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<media-selector
|
||||
<attachment-selector
|
||||
v-if="isAttachmentVisible(item.sku.id || '')"
|
||||
:model-value="getAttachmentUrlList(item.attachmentItems)"
|
||||
v-model:photo-items="item.attachmentItems"
|
||||
v-model:items="item.attachmentItems"
|
||||
:upload="uploadPhotos"
|
||||
:edit-mode="true"
|
||||
title=""
|
||||
:loading="isSaving"
|
||||
:show-remove="!isSaving"
|
||||
@update:photo-items="invalidateRequestNo"
|
||||
:busy="isSaving"
|
||||
@update:items="invalidateRequestNo"
|
||||
/>
|
||||
</div>
|
||||
</t-form-item>
|
||||
@@ -185,7 +179,7 @@
|
||||
import { onBeforeRouteLeave } from "vue-router";
|
||||
import { useUserStore } from "timi-web-api";
|
||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
|
||||
import ProductAPI from "@/api/ProductAPI";
|
||||
import type { ProductSkuUnit, ProductStockManualInBatchItem, ProductStockManualInBatchRequest } from "@/types/Product";
|
||||
import type { PhotoItem } from "@/types/Photo";
|
||||
@@ -250,7 +244,6 @@ const unitPickerVisible = ref(false);
|
||||
const unitPickerSkuId = ref("");
|
||||
const unitPickerDraft = ref<PickerValue[]>([]);
|
||||
const quickRemarkText = "正常入库";
|
||||
const globalAttachmentUrlList = computed(() => productStockBatchStore.attachmentItems.map(item => item.url));
|
||||
const unitPickerOptions = computed(() => {
|
||||
const item = productStockBatchStore.selectedItemList.find(candidate => candidate.sku.id === unitPickerSkuId.value);
|
||||
return getSelectableUnits(item).map(unit => ({ label: unit.name || "未命名单位", value: unit.id || "" }));
|
||||
@@ -276,10 +269,6 @@ function isDefaultSku(item: ProductStockBatchSelection): boolean {
|
||||
return !item.sku.specValueIdList?.length;
|
||||
}
|
||||
|
||||
function getAttachmentUrlList(itemList: PhotoItem[]): string[] {
|
||||
return itemList.map(item => item.url);
|
||||
}
|
||||
|
||||
function getAttachmentList(itemList: PhotoItem[]): NonNullable<ProductStockManualInBatchItem["attachmentList"]> {
|
||||
return itemList.flatMap(item => item.tempFileId ? [{
|
||||
tempFileId: item.tempFileId,
|
||||
|
||||
@@ -90,12 +90,8 @@
|
||||
<span></span>
|
||||
</template>
|
||||
<template #description>
|
||||
<media-selector
|
||||
:model-value="photoURLList"
|
||||
:photo-items="photoItemList"
|
||||
:show-add="false"
|
||||
:show-remove="false"
|
||||
:show-viewer-actions="false"
|
||||
<attachment-selector :readonly="true"
|
||||
:items="photoItemList"
|
||||
title="操作照片"
|
||||
/>
|
||||
</template>
|
||||
@@ -126,11 +122,9 @@
|
||||
<t-textarea v-model="revokeRemark" borderless autosize maxlength="500" placeholder="请输入冲正备注" />
|
||||
</t-form-item>
|
||||
</t-form>
|
||||
<media-selector
|
||||
:model-value="revokePhotoUrlList"
|
||||
v-model:photo-items="revokePhotoItems"
|
||||
<attachment-selector
|
||||
v-model:items="revokePhotoItems"
|
||||
:upload="uploadPhotoList"
|
||||
:edit-mode="true"
|
||||
required
|
||||
title="冲正凭证照片"
|
||||
/>
|
||||
@@ -144,7 +138,7 @@ import { BottomPopup } from "timi-tdesign-mobile";
|
||||
import { TimeLabel } from "timi-web";
|
||||
import { useUserStore, type Attachment } from "timi-web-api";
|
||||
import ProductAPI from "@/api/ProductAPI";
|
||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
|
||||
import ProductSkuTags from "@/components/ProductSkuTags.vue";
|
||||
import type { StockBizType, StockRecord } from "@/types/Product";
|
||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||
@@ -170,7 +164,6 @@ const revokeVisible = ref(false);
|
||||
const revokeRemark = ref("");
|
||||
const revokeRequestNo = ref("");
|
||||
const revokePhotoItems = ref<PhotoItem[]>([]);
|
||||
const revokePhotoUrlList = computed(() => revokePhotoItems.value.map(item => item.url));
|
||||
const canManualRevoke = computed(() => {
|
||||
const operationType = record.value?.operationType;
|
||||
return (operationType === "MANUAL_IN" || operationType === "MANUAL_OUT")
|
||||
@@ -188,7 +181,6 @@ const photoItemList = computed<PhotoItem[]>(() => (record.value?.attachmentList
|
||||
previewUrl: getAttachmentReadURL(item.id || ""),
|
||||
url: getAttachmentReadURL(item.id || "", 128)
|
||||
})));
|
||||
const photoURLList = computed(() => photoItemList.value.map(item => item.url));
|
||||
|
||||
function getOperationTheme(value?: number | string): "success" | "danger" | "default" {
|
||||
const amount = Number(value || 0);
|
||||
|
||||
@@ -77,11 +77,9 @@
|
||||
<t-input v-model.trim="sku.remark" borderless maxlength="255" placeholder="选填" />
|
||||
</t-form-item>
|
||||
<div class="photo-wrap">
|
||||
<media-selector
|
||||
:model-value="photoUrlList"
|
||||
v-model:photo-items="sku.photoItemList"
|
||||
<attachment-selector
|
||||
v-model:items="sku.photoItemList"
|
||||
title="SKU 图片(选填)"
|
||||
:edit-mode="true"
|
||||
:viewer-z-index="skuEditorZIndex + 1"
|
||||
:upload="uploadPhotoList"
|
||||
/>
|
||||
@@ -110,7 +108,7 @@
|
||||
import { BottomPopup } from "timi-tdesign-mobile";
|
||||
import type { ProductType } from "@/types/Product";
|
||||
import type { ProductSkuForm, ProductSpecForm } from "@/types/ProductEditor";
|
||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
|
||||
import ProductSkuUnitList from "@/pages/product/component/ProductSkuUnitList.vue";
|
||||
import { uploadPhotoList } from "@/utils/photo";
|
||||
|
||||
@@ -130,7 +128,6 @@ const emit = defineEmits<{
|
||||
|
||||
const editorVisible = ref(false);
|
||||
const skuEditorZIndex = 12000;
|
||||
const photoUrlList = computed(() => sku.value.photoItemList.map(item => item.url));
|
||||
const skuTitle = computed(() => sku.value.name?.trim() || sku.value.specSummary?.trim() || (props.specList.length ? `SKU 明细 ${props.skuIndex + 1}` : "默认 SKU"));
|
||||
|
||||
function openEditor(): void {
|
||||
|
||||
@@ -60,11 +60,9 @@
|
||||
</div>
|
||||
</t-form-item>
|
||||
<t-form-item label-width="0">
|
||||
<media-selector
|
||||
:model-value="photoUrlList"
|
||||
v-model:photo-items="photoItems"
|
||||
<attachment-selector
|
||||
v-model:items="photoItems"
|
||||
:upload="uploadPhotoList"
|
||||
:edit-mode="true"
|
||||
title="操作照片"
|
||||
required
|
||||
/>
|
||||
@@ -99,7 +97,7 @@ import { watch } from "vue";
|
||||
import { BottomPopup } from "timi-tdesign-mobile";
|
||||
import { Time } from "timi-web";
|
||||
import ProductAPI from "@/api/ProductAPI";
|
||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
|
||||
import type {
|
||||
Product,
|
||||
ProductSku,
|
||||
@@ -137,7 +135,6 @@ const occurredAtText = ref("");
|
||||
const occurredAtDraftText = ref("");
|
||||
const occurredAtPickerVisible = ref(false);
|
||||
const photoItems = ref<PhotoItem[]>([]);
|
||||
const photoUrlList = computed(() => photoItems.value.map(item => item.url));
|
||||
const selectedUnitId = ref("");
|
||||
const unitPickerVisible = ref(false);
|
||||
const unitDraft = ref<PickerValue[]>([]);
|
||||
|
||||
@@ -49,14 +49,10 @@
|
||||
@click="toSalesOrder"
|
||||
/>
|
||||
<div class="photo-wrap bg-white">
|
||||
<media-selector
|
||||
:model-value="photoURLList"
|
||||
:photo-items="photoItems"
|
||||
<attachment-selector :readonly="true"
|
||||
:items="photoItems"
|
||||
title="业务照片"
|
||||
:show-add="false"
|
||||
:show-remove="false"
|
||||
:show-viewer-actions="false"
|
||||
/>
|
||||
/>
|
||||
</div>
|
||||
</t-cell-group>
|
||||
<t-cell-group theme="card" v-entrance-transition>
|
||||
@@ -131,7 +127,7 @@ import { DialogPlugin } from "tdesign-mobile-vue";
|
||||
import { TimeLabel, Text } from "timi-web";
|
||||
import { useUserStore } from "timi-web-api";
|
||||
import SalesOrderAPI from "@/api/SalesOrderAPI";
|
||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
|
||||
import type { PhotoItem } from "@/types/Photo";
|
||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
@@ -243,7 +239,6 @@ const photoItems = computed<PhotoItem[]>(() => (record.value?.attachmentList ||
|
||||
attachType: item.attachType || "PHOTO",
|
||||
url: getAttachmentReadURL(item.id || "")
|
||||
})));
|
||||
const photoURLList = computed(() => photoItems.value.map(item => item.url));
|
||||
|
||||
// ---------- 收款操作 ----------
|
||||
|
||||
|
||||
@@ -109,12 +109,10 @@
|
||||
/>
|
||||
</t-form-item>
|
||||
<div class="photo-wrap">
|
||||
<media-selector
|
||||
<attachment-selector
|
||||
v-if="record"
|
||||
:model-value="photoUrlList"
|
||||
v-model:photo-items="photoItems"
|
||||
v-model:items="photoItems"
|
||||
:upload="uploadPhotoList"
|
||||
:edit-mode="true"
|
||||
required
|
||||
title="冲正凭证照片"
|
||||
/>
|
||||
@@ -150,7 +148,7 @@
|
||||
import { Time } from "timi-web";
|
||||
import { useUserStore, type Attachment } from "timi-web-api";
|
||||
import SalesOrderAPI from "@/api/SalesOrderAPI";
|
||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
|
||||
import type { PhotoItem } from "@/types/Photo";
|
||||
import { createPackageRequestNo, formatPackageAmount } from "@/utils/package";
|
||||
import { getFundOperationText, getFundStatusText } from "@/utils/salesOrder";
|
||||
@@ -210,7 +208,6 @@ const photoItems = ref<PhotoItem[]>([]);
|
||||
const isLoading = ref(false);
|
||||
const isSaving = ref(false);
|
||||
const requestNo = ref("");
|
||||
const photoUrlList = computed(() => photoItems.value.map(item => item.url));
|
||||
const canReadSalesOrder = computed(() => userStore.hasPermissions(permissionCodes.salesOrder.read));
|
||||
const reasonOptions = [
|
||||
"客户申请撤销本次资金操作",
|
||||
|
||||
@@ -182,20 +182,16 @@
|
||||
</div>
|
||||
</t-form-item>
|
||||
<t-form-item v-if="(paymentVerified && paymentAmount) || (receiveFullPayment && totalAmount)" label-width="0">
|
||||
<media-selector
|
||||
:model-value="paymentPhotoUrlList"
|
||||
v-model:photo-items="paymentPhotoItems"
|
||||
<attachment-selector
|
||||
v-model:items="paymentPhotoItems"
|
||||
:upload="uploadPhotoList"
|
||||
:edit-mode="true"
|
||||
title="收款凭证照片(必要)"
|
||||
/>
|
||||
</t-form-item>
|
||||
<t-form-item v-if="fulfillAll" label-width="0">
|
||||
<media-selector
|
||||
:model-value="fulfillmentPhotoUrlList"
|
||||
v-model:photo-items="fulfillmentPhotoItems"
|
||||
<attachment-selector
|
||||
v-model:items="fulfillmentPhotoItems"
|
||||
:upload="uploadPhotoList"
|
||||
:edit-mode="true"
|
||||
title="履约凭证照片(必要)"
|
||||
/>
|
||||
</t-form-item>
|
||||
@@ -203,7 +199,7 @@
|
||||
<t-textarea v-model="remark" class="textarea" borderless autosize maxlength="500" placeholder="记录本单需要注意的内容" />
|
||||
</t-form-item>
|
||||
<div class="photo-part">
|
||||
<media-selector :model-value="photoUrlList" v-model:photo-items="photoItems" :upload="uploadPhotoList" :edit-mode="true" title="订单照片(选填)" />
|
||||
<attachment-selector v-model:items="photoItems" :upload="uploadPhotoList" title="订单照片(选填)" />
|
||||
</div>
|
||||
</t-form>
|
||||
<div class="submit-wrap glass-white bg-white">
|
||||
@@ -243,7 +239,7 @@ import SalesOrderAPI from "@/api/SalesOrderAPI";
|
||||
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 ProductSelectFormItem from "@/components/productSelector/ProductSelectFormItem.vue";
|
||||
import ProductStockPreview from "@/components/ProductStockPreview.vue";
|
||||
import type { Customer } from "@/types/Customer";
|
||||
@@ -281,9 +277,6 @@ const photoItems = ref<PhotoItem[]>([]);
|
||||
const paymentPhotoItems = ref<PhotoItem[]>([]);
|
||||
const fulfillmentPhotoItems = ref<PhotoItem[]>([]);
|
||||
const paymentAmountText = ref("0");
|
||||
const photoUrlList = computed(() => photoItems.value.map(item => item.url));
|
||||
const paymentPhotoUrlList = computed(() => paymentPhotoItems.value.map(item => item.url));
|
||||
const fulfillmentPhotoUrlList = computed(() => fulfillmentPhotoItems.value.map(item => item.url));
|
||||
const receiveFullPayment = ref(false);
|
||||
const fulfillAll = ref(false);
|
||||
const isStockChecking = ref(false);
|
||||
|
||||
@@ -42,13 +42,8 @@
|
||||
</t-form-item>
|
||||
<t-form-item label-width="0">
|
||||
<div class="photo-wrap" v-entrance-transition>
|
||||
<media-selector
|
||||
:model-value="photoURLList"
|
||||
v-model:photo-items="photoItems"
|
||||
:edit-mode="isEditing"
|
||||
:show-add="isEditing"
|
||||
:show-remove="isEditing"
|
||||
:show-viewer-actions="isEditing"
|
||||
<attachment-selector :readonly="!isEditing"
|
||||
v-model:items="photoItems"
|
||||
:upload="isEditing ? uploadPhotoList : undefined"
|
||||
title="订单照片"
|
||||
/>
|
||||
@@ -237,7 +232,7 @@ import { type Attachment, useUserStore } from "timi-web-api";
|
||||
import FulfillmentAPI from "@/api/FulfillmentAPI";
|
||||
import SalesOrderAPI from "@/api/SalesOrderAPI";
|
||||
import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
|
||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
|
||||
import ProductSkuTags from "@/components/ProductSkuTags.vue";
|
||||
import type { PhotoItem } from "@/types/Photo";
|
||||
import { convertPackageQuantity, formatPackageAmount, getPackageQuantityText } from "@/utils/package";
|
||||
@@ -278,7 +273,6 @@ const canRefund = computed(() => !!order.value && order.value.status === "CANCEL
|
||||
const canConfirmNoRefund = computed(() => !!order.value && order.value.status === "CANCELLED" && order.value.refundStatus === "PENDING" && userStore.hasPermissions(permissionCodes.fund.refund));
|
||||
const canCancel = computed(() => !!order.value && order.value.status === "ACTIVE" && !hasPendingFulfillment.value && userStore.hasPermissions(permissionCodes.salesOrder.cancel));
|
||||
const canFulfillByPayment = computed(() => order.value?.paymentStatus === "PAID" || userStore.hasRoles(gaoRoleCodes.storeManager));
|
||||
const photoURLList = computed(() => photoItems.value.map(item => item.url));
|
||||
|
||||
function toPhotoItems(attachmentList?: readonly Partial<Attachment>[]): PhotoItem[] {
|
||||
return (attachmentList || [])
|
||||
|
||||
@@ -117,13 +117,11 @@
|
||||
/>
|
||||
</t-form-item>
|
||||
<t-form-item label-width="0">
|
||||
<media-selector
|
||||
<attachment-selector
|
||||
v-if="order"
|
||||
:model-value="photoUrlList"
|
||||
v-model:photo-items="photoItems"
|
||||
v-model:items="photoItems"
|
||||
class="photo-field"
|
||||
:upload="uploadPhotoList"
|
||||
:edit-mode="true"
|
||||
required
|
||||
title="收款凭证照片"
|
||||
/>
|
||||
@@ -139,7 +137,7 @@
|
||||
<script setup lang="ts">
|
||||
import { useUserStore, type Attachment } from "timi-web-api";
|
||||
import { Time } from "timi-web";
|
||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
|
||||
import SalesOrderAPI from "@/api/SalesOrderAPI";
|
||||
import type { PhotoItem } from "@/types/Photo";
|
||||
import { createPackageRequestNo, formatPackageAmount, formatPackageAmountInput, parsePackageAmount } from "@/utils/package";
|
||||
@@ -195,7 +193,6 @@ const draftTime = ref("");
|
||||
const pickerVisible = ref(false);
|
||||
const remark = ref("");
|
||||
const photoItems = ref<PhotoItem[]>([]);
|
||||
const photoUrlList = computed(() => photoItems.value.map(item => item.url));
|
||||
const requestNo = ref("");
|
||||
const directVerify = ref(false);
|
||||
const canDirectVerify = computed(() => userStore.hasRoles(gaoRoleCodes.storeManager)
|
||||
|
||||
@@ -120,13 +120,11 @@
|
||||
/>
|
||||
</t-form-item>
|
||||
<t-form-item label-width="0">
|
||||
<media-selector
|
||||
<attachment-selector
|
||||
v-if="order"
|
||||
:model-value="photoUrlList"
|
||||
v-model:photo-items="photoItems"
|
||||
v-model:items="photoItems"
|
||||
class="photo-field"
|
||||
:upload="uploadPhotoList"
|
||||
:edit-mode="true"
|
||||
required
|
||||
title="退款凭证照片"
|
||||
/>
|
||||
@@ -161,7 +159,7 @@
|
||||
<script setup lang="ts">
|
||||
import { Time } from "timi-web";
|
||||
import { useUserStore, type Attachment } from "timi-web-api";
|
||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
|
||||
import SalesOrderAPI from "@/api/SalesOrderAPI";
|
||||
import type { PhotoItem } from "@/types/Photo";
|
||||
import { createPackageRequestNo, formatPackageAmount, formatPackageAmountInput, parsePackageAmount } from "@/utils/package";
|
||||
@@ -221,7 +219,6 @@ const refundReasonPickerDraft = ref<string[]>([]);
|
||||
const refundReasonPickerVisible = ref(false);
|
||||
const remark = ref("");
|
||||
const photoItems = ref<PhotoItem[]>([]);
|
||||
const photoUrlList = computed(() => photoItems.value.map(item => item.url));
|
||||
const requestNo = ref("");
|
||||
const refundableAmount = computed(() => (order.value?.paidAmount || 0) - (order.value?.refundedAmount || 0));
|
||||
const refundReasonOptions = [
|
||||
|
||||
@@ -57,13 +57,8 @@
|
||||
/>
|
||||
</header>
|
||||
<div v-if="additionalPhotoItemList.length" class="additional-photos-wrapper">
|
||||
<media-selector
|
||||
:model-value="additionalPhotoList"
|
||||
:photo-items="additionalPhotoItemList"
|
||||
:show-add="false"
|
||||
:show-remove="false"
|
||||
:show-type-label="false"
|
||||
:show-viewer-actions="false"
|
||||
<attachment-selector :readonly="true"
|
||||
:items="additionalPhotoItemList"
|
||||
title="附加照片"
|
||||
v-entrance-transition
|
||||
/>
|
||||
@@ -116,7 +111,7 @@ import { DialogPlugin } from "tdesign-mobile-vue";
|
||||
import { TimeLabel } from "timi-web";
|
||||
import { UserAPI, type Attachment, useUserStore } from "timi-web-api";
|
||||
import StoreDiaryAPI from "@/api/StoreDiaryAPI";
|
||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
|
||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||
import type { PhotoItem } from "@/types/Photo";
|
||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||
@@ -184,7 +179,6 @@ const additionalPhotoItemList = computed<PhotoItem[]>(() => (article.value?.atta
|
||||
previewUrl: getAttachmentReadURL(item.id || ""),
|
||||
url: getAttachmentReadURL(item.id || "", 90)
|
||||
})));
|
||||
const additionalPhotoList = computed(() => additionalPhotoItemList.value.map(item => item.url));
|
||||
|
||||
function resolveAttachmentUrl(attachmentId: string): string {
|
||||
return getAttachmentReadURL(attachmentId);
|
||||
|
||||
@@ -64,42 +64,12 @@
|
||||
/>
|
||||
</t-form-item>
|
||||
<section class="photo-wrapper" v-entrance-transition>
|
||||
<media-selector
|
||||
v-model="photoList"
|
||||
v-model:photo-items="photoItemList"
|
||||
<attachment-selector
|
||||
v-model:items="photoItemList"
|
||||
title="附加照片"
|
||||
:edit-mode="true"
|
||||
:loading="isPhotoUploading"
|
||||
:show-type-label="false"
|
||||
:show-viewer-actions="false"
|
||||
@add="openPhotoPicker"
|
||||
@capture-photo="capturePhoto"
|
||||
@capture-video="captureVideo"
|
||||
:busy="isPhotoUploading"
|
||||
@select="handlePhotoSelected($event.files)"
|
||||
/>
|
||||
<input
|
||||
ref="photoInputRef"
|
||||
class="file-input"
|
||||
type="file"
|
||||
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"
|
||||
>
|
||||
</section>
|
||||
<section class="editor-wrapper" v-entrance-transition>
|
||||
<article-editor
|
||||
@@ -126,7 +96,7 @@ import {
|
||||
} from "timi-tdesign-mobile";
|
||||
import { AttachmentAPI, type Attachment, useUserStore } from "timi-web-api";
|
||||
import StoreDiaryAPI from "@/api/StoreDiaryAPI";
|
||||
import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
|
||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||
import type { PhotoItem } from "@/types/Photo";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
@@ -134,7 +104,6 @@ import { compressUploadImage, compressUploadImageList } from "@/utils/imageCompr
|
||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||
import { Message } from "@/utils/message";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
import { saveCapturedFilesFromInput } from "@/utils/twaBridge";
|
||||
|
||||
const pageNavBarRight = reactive({
|
||||
icon: "",
|
||||
@@ -236,38 +205,13 @@ function getCreateTitle(): string {
|
||||
|
||||
// ---------- 附加照片 ----------
|
||||
|
||||
const photoInputRef = ref<HTMLInputElement>();
|
||||
const photoCameraInputRef = ref<HTMLInputElement>();
|
||||
const videoInputRef = ref<HTMLInputElement>();
|
||||
const photoItemList = ref<PhotoItem[]>([]);
|
||||
const isPhotoUploading = ref(false);
|
||||
const photoList = computed<string[]>({
|
||||
get: () => photoItemList.value.map(item => item.url),
|
||||
set: value => {
|
||||
const urlSet = new Set(value);
|
||||
photoItemList.value = photoItemList.value.filter(item => urlSet.has(item.url));
|
||||
}
|
||||
});
|
||||
|
||||
function openPhotoPicker(): void {
|
||||
photoInputRef.value?.click();
|
||||
}
|
||||
|
||||
function capturePhoto(): void {
|
||||
photoCameraInputRef.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 || []);
|
||||
async function handlePhotoSelected(fileList: File[]): Promise<void> {
|
||||
if (!fileList.length) {
|
||||
return;
|
||||
}
|
||||
saveCapturedFilesFromInput(input, fileList);
|
||||
|
||||
isPhotoUploading.value = true;
|
||||
try {
|
||||
@@ -287,7 +231,6 @@ async function handlePhotoSelected(event: Event): Promise<void> {
|
||||
Message.error(getErrorMessage(error, "附加照片上传失败"));
|
||||
} finally {
|
||||
isPhotoUploading.value = false;
|
||||
input.value = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,3 +19,16 @@ export function getAttachmentReadURL(id: string, thumbnailSize?: number): string
|
||||
const separator = url.includes("?") ? "&" : "?";
|
||||
return `${url}${separator}${params.toString()}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取业务附件类型的显示名称。
|
||||
*/
|
||||
export function getAttachmentTypeText(attachType?: string): string {
|
||||
if (attachType === "POINT_CARD") {
|
||||
return "积分卡";
|
||||
}
|
||||
if (attachType === "OTHER") {
|
||||
return "其他文件";
|
||||
}
|
||||
return "照片";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user