From c870bcdd3962538695450ade5f2b780313d4ed2f Mon Sep 17 00:00:00 2001 From: Timi Date: Wed, 21 Oct 2026 16:24:00 +0800 Subject: [PATCH] upper attachment-selector to lib --- package.json | 2 +- patches/tdesign-mobile-vue@1.16.0.patch | 160 +++++----- pnpm-lock.yaml | 18 +- src/components/EventRecordVerifyDialog.vue | 67 +---- .../attachmentSelector/AttachmentSelector.vue | 153 ++++++++++ .../AttachmentViewerActions.vue | 112 +++++++ src/components/attachmentSelector/types.ts | 6 + .../mediaSelector/MediaSelector.vue | 276 ------------------ .../mediaSelector/MediaSelectorAdd.vue | 210 ------------- .../mediaSelector/MediaSelectorItem.vue | 137 --------- .../mediaSelector/MediaSelectorViewer.vue | 237 --------------- src/components/mediaSelector/types.ts | 13 - src/components/mediaSelector/utils.ts | 55 ---- src/pages/customer/CustomerDetail.vue | 66 ++++- src/pages/customer/CustomerEdit.vue | 157 +++------- src/pages/event/EventRecordDetail.vue | 57 +++- src/pages/event/EventRecordEdit.vue | 45 +-- .../event/component/useEventRecordPhoto.ts | 40 +-- .../FollowUpReminderDetail.vue | 11 +- .../followUpReminder/FollowUpReminderEdit.vue | 13 +- .../fulfillment/OrderFulfillmentCreate.vue | 9 +- .../fulfillment/OrderFulfillmentDetail.vue | 11 +- .../fulfillment/OrderFulfillmentQuick.vue | 9 +- .../components/OrderFulfillmentRevoke.vue | 9 +- src/pages/home/QuickSignInPage.vue | 69 +---- src/pages/package/PackagePurchase.vue | 23 +- src/pages/point/PointRedemptionCreate.vue | 9 +- src/pages/point/PointRedemptionDetail.vue | 29 +- src/pages/product/ProductDetail.vue | 24 +- src/pages/product/ProductEdit.vue | 84 ++---- .../product/ProductStockBatchConfigure.vue | 29 +- .../product/ProductStockRecordDetail.vue | 18 +- .../product/component/ProductSkuEditor.vue | 9 +- .../component/ProductStockOperationPopup.vue | 9 +- src/pages/salesOrder/FundRecordDetail.vue | 13 +- src/pages/salesOrder/FundRecordRevoke.vue | 9 +- src/pages/salesOrder/SalesOrderCreate.vue | 19 +- src/pages/salesOrder/SalesOrderDetail.vue | 12 +- src/pages/salesOrder/SalesOrderPayment.vue | 9 +- src/pages/salesOrder/SalesOrderRefund.vue | 9 +- src/pages/store/StoreDiaryDetail.vue | 12 +- src/pages/store/StoreDiaryEdit.vue | 69 +---- src/utils/attachment.ts | 13 + 43 files changed, 678 insertions(+), 1663 deletions(-) create mode 100644 src/components/attachmentSelector/AttachmentSelector.vue create mode 100644 src/components/attachmentSelector/AttachmentViewerActions.vue create mode 100644 src/components/attachmentSelector/types.ts delete mode 100644 src/components/mediaSelector/MediaSelector.vue delete mode 100644 src/components/mediaSelector/MediaSelectorAdd.vue delete mode 100644 src/components/mediaSelector/MediaSelectorItem.vue delete mode 100644 src/components/mediaSelector/MediaSelectorViewer.vue delete mode 100644 src/components/mediaSelector/types.ts delete mode 100644 src/components/mediaSelector/utils.ts diff --git a/package.json b/package.json index b91e6e8..fb01304 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/patches/tdesign-mobile-vue@1.16.0.patch b/patches/tdesign-mobile-vue@1.16.0.patch index 682a5dd..8e56773 100644 --- a/patches/tdesign-mobile-vue@1.16.0.patch +++ b/patches/tdesign-mobile-vue@1.16.0.patch @@ -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: { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2863f09..f06ec76 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -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) diff --git a/src/components/EventRecordVerifyDialog.vue b/src/components/EventRecordVerifyDialog.vue index cd6d730..ba67cb9 100644 --- a/src/components/EventRecordVerifyDialog.vue +++ b/src/components/EventRecordVerifyDialog.vue @@ -10,57 +10,28 @@
- + v-model:items="photoItemList" + :busy="isPhotoUploading" + @select="handlePhotoSelected($event.files)" + > + diff --git a/src/components/attachmentSelector/AttachmentViewerActions.vue b/src/components/attachmentSelector/AttachmentViewerActions.vue new file mode 100644 index 0000000..79470a1 --- /dev/null +++ b/src/components/attachmentSelector/AttachmentViewerActions.vue @@ -0,0 +1,112 @@ + + + + + diff --git a/src/components/attachmentSelector/types.ts b/src/components/attachmentSelector/types.ts new file mode 100644 index 0000000..6e8858c --- /dev/null +++ b/src/components/attachmentSelector/types.ts @@ -0,0 +1,6 @@ +export type { + AttachmentSelectorItem, + AttachmentSelectorProps, + AttachmentSelectorSelection, + AttachmentSelectorViewerItem +} from "timi-tdesign-mobile"; diff --git a/src/components/mediaSelector/MediaSelector.vue b/src/components/mediaSelector/MediaSelector.vue deleted file mode 100644 index 399a8c5..0000000 --- a/src/components/mediaSelector/MediaSelector.vue +++ /dev/null @@ -1,276 +0,0 @@ - - - - - diff --git a/src/components/mediaSelector/MediaSelectorAdd.vue b/src/components/mediaSelector/MediaSelectorAdd.vue deleted file mode 100644 index db84b87..0000000 --- a/src/components/mediaSelector/MediaSelectorAdd.vue +++ /dev/null @@ -1,210 +0,0 @@ - - - - - diff --git a/src/components/mediaSelector/MediaSelectorItem.vue b/src/components/mediaSelector/MediaSelectorItem.vue deleted file mode 100644 index 1ca9ab6..0000000 --- a/src/components/mediaSelector/MediaSelectorItem.vue +++ /dev/null @@ -1,137 +0,0 @@ - - - - - diff --git a/src/components/mediaSelector/MediaSelectorViewer.vue b/src/components/mediaSelector/MediaSelectorViewer.vue deleted file mode 100644 index 8193fa5..0000000 --- a/src/components/mediaSelector/MediaSelectorViewer.vue +++ /dev/null @@ -1,237 +0,0 @@ - - - - - diff --git a/src/components/mediaSelector/types.ts b/src/components/mediaSelector/types.ts deleted file mode 100644 index 93d8fa4..0000000 --- a/src/components/mediaSelector/types.ts +++ /dev/null @@ -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; -}; diff --git a/src/components/mediaSelector/utils.ts b/src/components/mediaSelector/utils.ts deleted file mode 100644 index 184491d..0000000 --- a/src/components/mediaSelector/utils.ts +++ /dev/null @@ -1,55 +0,0 @@ -import type { PhotoItem } from "@/types/Photo.ts"; -import { getAttachmentReadURL } from "@/utils/attachment.ts"; - -const ATTACH_TYPE_TEXT_MAP: Record = { - 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 - }; -} diff --git a/src/pages/customer/CustomerDetail.vue b/src/pages/customer/CustomerDetail.vue index 8c18e4b..5cc7d2c 100644 --- a/src/pages/customer/CustomerDetail.vue +++ b/src/pages/customer/CustomerDetail.vue @@ -79,17 +79,25 @@ - + > + + + (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 { const currentCustomer = customer.value; @@ -297,6 +306,35 @@ async function submitPhotoItems(photoItems: PhotoItem[]): Promise { }; } +async function applyPhotoItems(photoItems: PhotoItem[], close: () => void): Promise { + 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 { + 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 { + 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; } diff --git a/src/pages/customer/CustomerEdit.vue b/src/pages/customer/CustomerEdit.vue index 4e47200..e208431 100644 --- a/src/pages/customer/CustomerEdit.vue +++ b/src/pages/customer/CustomerEdit.vue @@ -116,21 +116,28 @@
- + + +
当前账户权限编辑客户需要上传照片和积分卡
@@ -219,29 +226,6 @@ /> - - - void): void { + isPointCardCapture.value = true; + capturePhoto(); + isPointCardCapture.value = false; } watch(isCustomerBound, (value) => { @@ -675,29 +633,10 @@ watch(() => formData.birthdate, (value) => { // ---------- 照片 ---------- -const photoInputRef = ref(); -const photoCameraInputRef = ref(); -const videoInputRef = ref(); -const photoAddActions = [ - { - icon: "cardmembership", - text: "拍积分卡", - emit: "add-point-card", - theme: "primary" - } -] as const; +const isPointCardCapture = ref(false); const photoPickerTarget = ref("PHOTO"); const isPhotoUploading = ref(false); const photoItemList = ref([]); -const photoList = computed({ - 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 { - const input = event.target as HTMLInputElement; - const file = input.files?.[0]; - if (!file) { +async function handlePhotoSelected(files: File[]): Promise { + 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; diff --git a/src/pages/event/EventRecordDetail.vue b/src/pages/event/EventRecordDetail.vue index 7f1ba3e..3a447cc 100644 --- a/src/pages/event/EventRecordDetail.vue +++ b/src/pages/event/EventRecordDetail.vue @@ -110,15 +110,21 @@ 核销登记记录
- + > + +
(); 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 { const currentRecord = record.value; if (!currentRecord?.id || isRetiredRecord.value) { @@ -242,6 +248,35 @@ async function submitPhotoItems(photoItems: PhotoItem[]): Promise { }; } +async function applyPhotoItems(photoItems: PhotoItem[], close: () => void): Promise { + 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 { + 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 { + 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) { diff --git a/src/pages/event/EventRecordEdit.vue b/src/pages/event/EventRecordEdit.vue index b882490..5b3851e 100644 --- a/src/pages/event/EventRecordEdit.vue +++ b/src/pages/event/EventRecordEdit.vue @@ -155,16 +155,12 @@
-
@@ -213,30 +209,6 @@ />
- - -
(); - const recordPhotoCameraInputRef = ref(); - const videoInputRef = ref(); const photoItemList = ref([]); const isPhotoUploading = ref(false); - const photoList = computed({ - 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 { - const input = event.target as HTMLInputElement; - const fileList = Array.from(input.files || []); + async function handleRecordPhotoSelected(fileList: File[]): Promise { 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, diff --git a/src/pages/followUpReminder/FollowUpReminderDetail.vue b/src/pages/followUpReminder/FollowUpReminderDetail.vue index 8801631..edd2b8c 100644 --- a/src/pages/followUpReminder/FollowUpReminderDetail.vue +++ b/src/pages/followUpReminder/FollowUpReminderDetail.vue @@ -70,12 +70,8 @@
- @@ -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(() => (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; diff --git a/src/pages/followUpReminder/FollowUpReminderEdit.vue b/src/pages/followUpReminder/FollowUpReminderEdit.vue index f02994b..acdb9b7 100644 --- a/src/pages/followUpReminder/FollowUpReminderEdit.vue +++ b/src/pages/followUpReminder/FollowUpReminderEdit.vue @@ -80,14 +80,10 @@ /> - @@ -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(); const selectedResponsible = ref(); const photoItems = ref([]); -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); diff --git a/src/pages/fulfillment/OrderFulfillmentCreate.vue b/src/pages/fulfillment/OrderFulfillmentCreate.vue index e410683..0b6ac6e 100644 --- a/src/pages/fulfillment/OrderFulfillmentCreate.vue +++ b/src/pages/fulfillment/OrderFulfillmentCreate.vue @@ -159,12 +159,10 @@ - @@ -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([]); 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(() => (order.value?.itemList || []).filter(item => item.itemType === expectedItemType.value diff --git a/src/pages/fulfillment/OrderFulfillmentDetail.vue b/src/pages/fulfillment/OrderFulfillmentDetail.vue index a11c059..a223048 100644 --- a/src/pages/fulfillment/OrderFulfillmentDetail.vue +++ b/src/pages/fulfillment/OrderFulfillmentDetail.vue @@ -22,12 +22,8 @@
-
@@ -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(() => (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"); diff --git a/src/pages/fulfillment/OrderFulfillmentQuick.vue b/src/pages/fulfillment/OrderFulfillmentQuick.vue index e6d3479..64243c6 100644 --- a/src/pages/fulfillment/OrderFulfillmentQuick.vue +++ b/src/pages/fulfillment/OrderFulfillmentQuick.vue @@ -86,11 +86,9 @@
- @@ -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 选择 ---------- diff --git a/src/pages/fulfillment/components/OrderFulfillmentRevoke.vue b/src/pages/fulfillment/components/OrderFulfillmentRevoke.vue index af4034d..f1a1dc9 100644 --- a/src/pages/fulfillment/components/OrderFulfillmentRevoke.vue +++ b/src/pages/fulfillment/components/OrderFulfillmentRevoke.vue @@ -31,11 +31,9 @@ - @@ -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([]); const reasonPickerVisible = ref(false); const reasonPickerDraft = ref([]); const requestNo = ref(""); -const photoUrlList = computed(() => photoItems.value.map(item => item.url)); const reasonOptions = [ "客户申请撤销履约", "履约数量填写有误", diff --git a/src/pages/home/QuickSignInPage.vue b/src/pages/home/QuickSignInPage.vue index 2343128..6d577fe 100644 --- a/src/pages/home/QuickSignInPage.vue +++ b/src/pages/home/QuickSignInPage.vue @@ -82,16 +82,12 @@
-
- - -
(); -const recordPhotoCameraInputRef = ref(); -const videoInputRef = ref(); const recordPhotoItemList = ref([]); const recordPhotoUploading = ref(false); const showRecordPhotoInput = computed(() => selectedRequiredPhotoEventList.value.length > 0 || recordPhotoItemList.value.length > 0); -const recordPhotoList = computed({ - 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 { - const input = event.target as HTMLInputElement; - const fileList = Array.from(input.files || []); +async function handleRecordPhotoSelected(fileList: File[]): Promise { 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 { } } finally { recordPhotoUploading.value = false; - input.value = ""; } } diff --git a/src/pages/package/PackagePurchase.vue b/src/pages/package/PackagePurchase.vue index ff86c28..95a17ad 100644 --- a/src/pages/package/PackagePurchase.vue +++ b/src/pages/package/PackagePurchase.vue @@ -253,20 +253,16 @@
- - @@ -279,11 +275,9 @@ /> - @@ -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([]); const paymentPhotoItems = ref([]); const fulfillmentPhotoItems = ref([]); 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); diff --git a/src/pages/point/PointRedemptionCreate.vue b/src/pages/point/PointRedemptionCreate.vue index 7683e5d..2f09482 100644 --- a/src/pages/point/PointRedemptionCreate.vue +++ b/src/pages/point/PointRedemptionCreate.vue @@ -117,11 +117,9 @@
- @@ -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)); diff --git a/src/pages/point/PointRedemptionDetail.vue b/src/pages/point/PointRedemptionDetail.vue index d26cbb0..b2dff16 100644 --- a/src/pages/point/PointRedemptionDetail.vue +++ b/src/pages/point/PointRedemptionDetail.vue @@ -22,11 +22,8 @@
-
@@ -69,11 +66,9 @@ - @@ -85,13 +80,14 @@