From 4a407279f0c9757f0714eaf385fdd5cd68c038c2 Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期四, 21 五月 2026 16:55:43 +0800
Subject: [PATCH] Merge branch 'dev_NEW_pro' of http://114.132.189.42:9002/r/product-inventory-management into dev_NEW_pro
---
src/views/equipmentManagement/inspectionManagement/components/viewFiles.vue | 335 +++++++++++++++++++++++++++++++++----------------------
1 files changed, 198 insertions(+), 137 deletions(-)
diff --git a/src/views/equipmentManagement/inspectionManagement/components/viewFiles.vue b/src/views/equipmentManagement/inspectionManagement/components/viewFiles.vue
index 66867e3..b5604fe 100644
--- a/src/views/equipmentManagement/inspectionManagement/components/viewFiles.vue
+++ b/src/views/equipmentManagement/inspectionManagement/components/viewFiles.vue
@@ -1,210 +1,226 @@
<template>
<div>
- <el-dialog title="鏌ョ湅闄勪欢"
- v-model="dialogVisitable" width="800px" @close="cancel">
+ <el-dialog title="鏌ョ湅闄勪欢" v-model="dialogVisitable" width="800px" @close="cancel">
<div class="upload-container">
- <!-- 鐢熶骇鍓� -->
<div class="form-container">
<div class="title">鐢熶骇鍓�</div>
-
- <!-- 鍥剧墖鍒楄〃 -->
- <div style="display: flex; flex-wrap: wrap;">
- <img v-for="(item, index) in beforeProductionImgs" :key="index"
- @click="showMedia(beforeProductionImgs, index, 'image')"
- :src="item" style="max-width: 100px; height: 100px; margin: 5px;" alt="">
+
+ <div class="media-list">
+ <img
+ v-for="(item, index) in beforeProductionImgs"
+ :key="`before-img-${index}`"
+ :src="item"
+ alt=""
+ class="media-image"
+ @click="showMedia(beforeProductionImgs, index, 'image')"
+ />
</div>
-
- <!-- 瑙嗛鍒楄〃 -->
- <div style="display: flex; flex-wrap: wrap;">
+
+ <div class="media-list">
<div
- v-for="(videoUrl, index) in beforeProductionVideos"
- :key="index"
- @click="showMedia(beforeProductionVideos, index, 'video')"
- style="position: relative; margin: 10px; cursor: pointer;"
+ v-for="(videoUrl, index) in beforeProductionVideos"
+ :key="`before-video-${index}`"
+ class="video-item"
+ @click="showMedia(beforeProductionVideos, index, 'video')"
>
- <div style="width: 160px; height: 90px; background-color: #333; display: flex; align-items: center; justify-content: center;">
- <img src="@/assets/images/video.png" alt="鎾斁" style="width: 30px; height: 30px; opacity: 0.8;" />
+ <div class="video-thumb">
+ <img src="@/assets/images/video.png" alt="鎾斁" class="video-icon" />
</div>
- <div style="text-align: center; font-size: 12px; color: #666;">鐐瑰嚮鎾斁</div>
+ <div class="video-text">鐐瑰嚮鎾斁</div>
</div>
</div>
</div>
-
- <!-- 鐢熶骇鍚� -->
+
+ <div class="form-container">
+ <div class="title">鐢熶骇涓�</div>
+
+ <div class="media-list">
+ <img
+ v-for="(item, index) in afterProductionImgs"
+ :key="`during-img-${index}`"
+ :src="item"
+ alt=""
+ class="media-image"
+ @click="showMedia(afterProductionImgs, index, 'image')"
+ />
+ </div>
+
+ <div class="media-list">
+ <div
+ v-for="(videoUrl, index) in afterProductionVideos"
+ :key="`during-video-${index}`"
+ class="video-item"
+ @click="showMedia(afterProductionVideos, index, 'video')"
+ >
+ <div class="video-thumb">
+ <img src="@/assets/images/video.png" alt="鎾斁" class="video-icon" />
+ </div>
+ <div class="video-text">鐐瑰嚮鎾斁</div>
+ </div>
+ </div>
+ </div>
+
<div class="form-container">
<div class="title">鐢熶骇鍚�</div>
-
- <!-- 鍥剧墖鍒楄〃 -->
- <div style="display: flex; flex-wrap: wrap;">
- <img v-for="(item, index) in afterProductionImgs" :key="index"
- @click="showMedia(afterProductionImgs, index, 'image')"
- :src="item" style="max-width: 100px; height: 100px; margin: 5px;" alt="">
+
+ <div class="media-list">
+ <img
+ v-for="(item, index) in productionIssuesImgs"
+ :key="`after-img-${index}`"
+ :src="item"
+ alt=""
+ class="media-image"
+ @click="showMedia(productionIssuesImgs, index, 'image')"
+ />
</div>
-
- <!-- 瑙嗛鍒楄〃 -->
- <div style="display: flex; flex-wrap: wrap;">
+
+ <div class="media-list">
<div
- v-for="(videoUrl, index) in afterProductionVideos"
- :key="index"
- @click="showMedia(afterProductionVideos, index, 'video')"
- style="position: relative; margin: 10px; cursor: pointer;"
+ v-for="(videoUrl, index) in productionIssuesVideos"
+ :key="`after-video-${index}`"
+ class="video-item"
+ @click="showMedia(productionIssuesVideos, index, 'video')"
>
- <div style="width: 160px; height: 90px; background-color: #333; display: flex; align-items: center; justify-content: center;">
- <img src="@/assets/images/video.png" alt="鎾斁" style="width: 30px; height: 30px; opacity: 0.8;" />
+ <div class="video-thumb">
+ <img src="@/assets/images/video.png" alt="鎾斁" class="video-icon" />
</div>
- <div style="text-align: center; font-size: 12px; color: #666;">鐐瑰嚮鎾斁</div>
- </div>
- </div>
- </div>
-
- <!-- 鐢熶骇闂 -->
- <div class="form-container">
- <div class="title">鐢熶骇闂</div>
-
- <!-- 鍥剧墖鍒楄〃 -->
- <div style="display: flex; flex-wrap: wrap;">
- <img v-for="(item, index) in productionIssuesImgs" :key="index"
- @click="showMedia(productionIssuesImgs, index, 'image')"
- :src="item" style="max-width: 100px; height: 100px; margin: 5px;" alt="">
- </div>
-
- <!-- 瑙嗛鍒楄〃 -->
- <div style="display: flex; flex-wrap: wrap;">
- <div
- v-for="(videoUrl, index) in productionIssuesVideos"
- :key="index"
- @click="showMedia(productionIssuesVideos, index, 'video')"
- style="position: relative; margin: 10px; cursor: pointer;"
- >
- <div style="width: 160px; height: 90px; background-color: #333; display: flex; align-items: center; justify-content: center;">
- <img src="@/assets/images/video.png" alt="鎾斁" style="width: 30px; height: 30px; opacity: 0.8;" />
- </div>
- <div style="text-align: center; font-size: 12px; color: #666;">鐐瑰嚮鎾斁</div>
+ <div class="video-text">鐐瑰嚮鎾斁</div>
</div>
</div>
</div>
</div>
</el-dialog>
-
- <!-- 缁熶竴濯掍綋鏌ョ湅鍣� -->
+
<div v-if="isMediaViewerVisible" class="media-viewer-overlay" @click.self="closeMediaViewer">
<div class="media-viewer-content" @click.stop>
- <!-- 鍥剧墖 -->
<vue-easy-lightbox
- v-if="mediaType === 'image'"
- :visible="isMediaViewerVisible"
- :imgs="mediaList"
- :index="currentMediaIndex"
- @hide="closeMediaViewer"
- ></vue-easy-lightbox>
-
- <!-- 瑙嗛 -->
- <div v-else-if="mediaType === 'video'" style="position: relative;">
- <video
- :src="mediaList[currentMediaIndex]"
- autoplay
- controls
- style="max-width: 90vw; max-height: 80vh;"
- />
+ v-if="mediaType === 'image'"
+ :visible="isMediaViewerVisible"
+ :imgs="mediaList"
+ :index="currentMediaIndex"
+ @hide="closeMediaViewer"
+ />
+
+ <div v-else-if="mediaType === 'video'" class="video-player-wrap">
+ <video :src="mediaList[currentMediaIndex]" autoplay controls class="video-player" />
</div>
</div>
</div>
</div>
</template>
-<script setup>
-import { ref } from 'vue';
-import VueEasyLightbox from 'vue-easy-lightbox';
-const { proxy } = getCurrentInstance();
-// 鎺у埗寮圭獥鏄剧ず
+<script setup>
+import { ref } from "vue";
+import VueEasyLightbox from "vue-easy-lightbox";
+
const dialogVisitable = ref(false);
-// 鍥剧墖鏁扮粍
const beforeProductionImgs = ref([]);
const afterProductionImgs = ref([]);
const productionIssuesImgs = ref([]);
-// 瑙嗛鏁扮粍
const beforeProductionVideos = ref([]);
const afterProductionVideos = ref([]);
const productionIssuesVideos = ref([]);
-// 濯掍綋鏌ョ湅鍣ㄧ姸鎬�
const isMediaViewerVisible = ref(false);
const currentMediaIndex = ref(0);
-const mediaList = ref([]); // 瀛樺偍褰撳墠瑕佹煡鐪嬬殑濯掍綋鍒楄〃锛堝惈鍥剧墖鍜岃棰戝璞★級
-const mediaType = ref('image'); // image | video
+const mediaList = ref([]);
+const mediaType = ref("image");
-// 澶勭悊姣忎竴绫绘暟鎹細鍒嗙鍥剧墖鍜岃棰�
-function processItems(items) {
+const processFileUrl = fileUrl => {
+ if (!fileUrl) return "";
+
+ let currentUrl = String(fileUrl);
+ if (currentUrl.includes("\\")) {
+ const uploadsIndex = currentUrl.toLowerCase().indexOf("uploads");
+ if (uploadsIndex > -1) {
+ currentUrl = `/${currentUrl.substring(uploadsIndex).replace(/\\/g, "/")}`;
+ } else {
+ const fileName = currentUrl.split("\\").pop();
+ currentUrl = `/uploads/${fileName}`;
+ }
+ }
+
+ if (currentUrl && !currentUrl.startsWith("http")) {
+ if (!currentUrl.startsWith("/")) {
+ currentUrl = `/${currentUrl}`;
+ }
+ currentUrl = __BASE_API__ + currentUrl;
+ }
+
+ return currentUrl;
+};
+
+const processItems = items => {
const images = [];
const videos = [];
-
- // 妫�鏌� items 鏄惁瀛樺湪涓斾负鏁扮粍
- if (!items || !Array.isArray(items)) {
+
+ if (!Array.isArray(items)) {
return { images, videos };
}
-
+
items.forEach(item => {
- if (!item || !item.previewURL || !item.contentType) return;
+ if (!item) return;
-
- // 澶勭悊鏂囦欢 URL
- const fileUrl = item.previewURL;
- const contentType = String(item.contentType).toLowerCase();
+ const fileUrl = processFileUrl(
+ item.previewURL || item.url || item.downloadUrl || item.path || ""
+ );
+ const contentType = String(item.contentType || "").toLowerCase();
- // 鏍规嵁 contentType 鍒ゆ柇鏄浘鐗囪繕鏄棰�
- if (contentType.startsWith('image/')) {
- images.push(fileUrl);
- } else if (contentType.startsWith('video/')) {
+ if (!fileUrl) return;
+
+ if (contentType.startsWith("video/")) {
videos.push(fileUrl);
+ return;
}
- });
-
- return { images, videos };
-}
-// 鎵撳紑寮圭獥骞跺姞杞芥暟鎹�
-const openDialog = async (row) => {
- // 浣跨敤姝g‘鐨勫瓧娈靛悕锛歝ommonFileListBefore, commonFileListAfter
- const { images: beforeImgs, videos: beforeVids } = processItems(row.commonFileListBeforeVO || []);
- const { images: afterImgs, videos: afterVids } = processItems(row.commonFileListAfterVO || []);
- const { images: issueImgs, videos: issueVids } = processItems(row.commonFileListVO || []);
-
+ images.push(fileUrl);
+ });
+
+ return { images, videos };
+};
+
+const openDialog = row => {
+ const { images: beforeImgs, videos: beforeVids } = processItems(
+ row.commonFileListBeforeVO || []
+ );
+ const { images: afterImgs, videos: afterVids } = processItems(
+ row.commonFileListVO || []
+ );
+ const { images: issueImgs, videos: issueVids } = processItems(
+ row.commonFileListAfterVO || []
+ );
+
beforeProductionImgs.value = beforeImgs;
beforeProductionVideos.value = beforeVids;
-
afterProductionImgs.value = afterImgs;
afterProductionVideos.value = afterVids;
-
productionIssuesImgs.value = issueImgs;
productionIssuesVideos.value = issueVids;
-
dialogVisitable.value = true;
};
-// 鏄剧ず濯掍綋锛堝浘鐗� or 瑙嗛锛�
-function showMedia(mediaArray, index, type) {
- mediaList.value = mediaArray;
+const showMedia = (items, index, type) => {
+ mediaList.value = items;
currentMediaIndex.value = index;
mediaType.value = type;
isMediaViewerVisible.value = true;
-}
+};
-// 鍏抽棴濯掍綋鏌ョ湅鍣�
-function closeMediaViewer() {
+const closeMediaViewer = () => {
isMediaViewerVisible.value = false;
mediaList.value = [];
- mediaType.value = 'image';
-}
+ mediaType.value = "image";
+};
-// 琛ㄥ崟鍏抽棴鏂规硶
const cancel = () => {
dialogVisitable.value = false;
};
defineExpose({ openDialog });
</script>
+
<style scoped lang="scss">
.upload-container {
display: flex;
@@ -213,7 +229,7 @@
padding: 20px;
border: 1px solid #dcdfe6;
box-sizing: border-box;
-
+
.form-container {
flex: 1;
width: 100%;
@@ -229,7 +245,7 @@
padding-left: 10px;
position: relative;
margin: 6px 0;
-
+
&::before {
content: "";
position: absolute;
@@ -241,12 +257,48 @@
}
}
+.media-list {
+ display: flex;
+ flex-wrap: wrap;
+}
+
+.media-image {
+ max-width: 100px;
+ height: 100px;
+ margin: 5px;
+ cursor: pointer;
+}
+
+.video-item {
+ position: relative;
+ margin: 10px;
+ cursor: pointer;
+}
+
+.video-thumb {
+ width: 160px;
+ height: 90px;
+ background-color: #333;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+
+.video-icon {
+ width: 30px;
+ height: 30px;
+ opacity: 0.8;
+}
+
+.video-text {
+ text-align: center;
+ font-size: 12px;
+ color: #666;
+}
+
.media-viewer-overlay {
position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
+ inset: 0;
background-color: rgba(0, 0, 0, 0.8);
z-index: 9999;
display: flex;
@@ -260,4 +312,13 @@
max-height: 90vh;
overflow: hidden;
}
-</style>
\ No newline at end of file
+
+.video-player-wrap {
+ position: relative;
+}
+
+.video-player {
+ max-width: 90vw;
+ max-height: 80vh;
+}
+</style>
--
Gitblit v1.9.3