From 77d0fbaf680094c8eedb6249902a18ef19a4ffda Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期五, 23 一月 2026 09:45:47 +0800
Subject: [PATCH] 湟水峡 1.添加客户拜访记录页面 2.新建记录附件查看修改
---
src/views/equipmentManagement/inspectionManagement/index.vue | 38 ++++++++----------
src/views/equipmentManagement/inspectionManagement/components/viewFiles.vue | 74 +++++++++++++++++++++++++++++++++----
2 files changed, 83 insertions(+), 29 deletions(-)
diff --git a/src/views/equipmentManagement/inspectionManagement/components/viewFiles.vue b/src/views/equipmentManagement/inspectionManagement/components/viewFiles.vue
index d1c9d8d..b7c4e58 100644
--- a/src/views/equipmentManagement/inspectionManagement/components/viewFiles.vue
+++ b/src/views/equipmentManagement/inspectionManagement/components/viewFiles.vue
@@ -100,7 +100,7 @@
<!-- 瑙嗛 -->
<div v-else-if="mediaType === 'video'" style="position: relative;">
- <Video
+ <video
:src="mediaList[currentMediaIndex]"
autoplay
controls
@@ -134,25 +134,83 @@
const mediaList = ref([]); // 瀛樺偍褰撳墠瑕佹煡鐪嬬殑濯掍綋鍒楄〃锛堝惈鍥剧墖鍜岃棰戝璞★級
const mediaType = ref('image'); // image | video
+// 澶勭悊 URL锛氬皢 Windows 璺緞杞崲涓哄彲璁块棶鐨� URL
+function processFileUrl(fileUrl) {
+ if (!fileUrl) return '';
+
+ const baseUrl = import.meta.env.VITE_APP_BASE_API;
+
+ // 濡傛灉 URL 鏄� Windows 璺緞鏍煎紡锛堝寘鍚弽鏂滄潬锛夛紝闇�瑕佽浆鎹�
+ if (fileUrl && fileUrl.indexOf('\\') > -1) {
+ // 鏌ユ壘 uploads 鍏抽敭瀛楃殑浣嶇疆锛屼粠閭i噷寮�濮嬫彁鍙栫浉瀵硅矾寰�
+ const uploadsIndex = fileUrl.toLowerCase().indexOf('uploads');
+ if (uploadsIndex > -1) {
+ // 浠� uploads 寮�濮嬫彁鍙栬矾寰勶紝骞跺皢鍙嶆枩鏉犳浛鎹负姝f枩鏉�
+ const relativePath = fileUrl.substring(uploadsIndex).replace(/\\/g, '/');
+ fileUrl = '/' + relativePath;
+ } else {
+ // 濡傛灉娌℃湁鎵惧埌 uploads锛屾彁鍙栨渶鍚庝竴涓洰褰曞拰鏂囦欢鍚�
+ const parts = fileUrl.split('\\');
+ const fileName = parts[parts.length - 1];
+ fileUrl = '/uploads/' + fileName;
+ }
+ }
+
+ // 纭繚鎵�鏈夐潪 http 寮�澶寸殑 URL 閮芥嫾鎺� baseUrl
+ if (fileUrl && !fileUrl.startsWith('http')) {
+ // 纭繚璺緞浠� / 寮�澶�
+ if (!fileUrl.startsWith('/')) {
+ fileUrl = '/' + fileUrl;
+ }
+ // 鎷兼帴 baseUrl
+ fileUrl = baseUrl + fileUrl;
+ }
+
+ return fileUrl;
+}
+
// 澶勭悊姣忎竴绫绘暟鎹細鍒嗙鍥剧墖鍜岃棰�
function processItems(items) {
const images = [];
const videos = [];
+
+ // 妫�鏌� items 鏄惁瀛樺湪涓斾负鏁扮粍
+ if (!items || !Array.isArray(items)) {
+ return { images, videos };
+ }
+
items.forEach(item => {
- if (item.contentType?.startsWith('image/')) {
- images.push(item.url);
- } else if (item.contentType?.startsWith('video/')) {
- videos.push(item.url);
+ if (!item || !item.url) return;
+
+ // 澶勭悊鏂囦欢 URL
+ const fileUrl = processFileUrl(item.url);
+
+ // 鏍规嵁鏂囦欢鎵╁睍鍚嶅垽鏂槸鍥剧墖杩樻槸瑙嗛
+ const urlLower = fileUrl.toLowerCase();
+ if (urlLower.match(/\.(jpg|jpeg|png|gif|bmp|webp)$/)) {
+ images.push(fileUrl);
+ } else if (urlLower.match(/\.(mp4|avi|mov|wmv|flv|mkv|webm)$/)) {
+ videos.push(fileUrl);
+ } else if (item.contentType) {
+ // 濡傛灉鏈� contentType锛屼娇鐢� contentType 鍒ゆ柇
+ if (item.contentType.startsWith('image/')) {
+ images.push(fileUrl);
+ } else if (item.contentType.startsWith('video/')) {
+ videos.push(fileUrl);
+ }
}
});
+
return { images, videos };
}
// 鎵撳紑寮圭獥骞跺姞杞芥暟鎹�
const openDialog = async (row) => {
- const { images: beforeImgs, videos: beforeVids } = processItems(row.beforeProduction);
- const { images: afterImgs, videos: afterVids } = processItems(row.afterProduction);
- const { images: issueImgs, videos: issueVids } = processItems(row.productionIssues);
+ // 浣跨敤姝g‘鐨勫瓧娈靛悕锛歝ommonFileListBefore, commonFileListAfter
+ // productionIssues 鍙兘涓嶅瓨鍦紝浣跨敤绌烘暟缁�
+ const { images: beforeImgs, videos: beforeVids } = processItems(row.commonFileListBefore || []);
+ const { images: afterImgs, videos: afterVids } = processItems(row.commonFileListAfter || []);
+ const { images: issueImgs, videos: issueVids } = processItems(row.productionIssues || []);
beforeProductionImgs.value = beforeImgs;
beforeProductionVideos.value = beforeVids;
diff --git a/src/views/equipmentManagement/inspectionManagement/index.vue b/src/views/equipmentManagement/inspectionManagement/index.vue
index 3e4e31e..c82921e 100644
--- a/src/views/equipmentManagement/inspectionManagement/index.vue
+++ b/src/views/equipmentManagement/inspectionManagement/index.vue
@@ -33,15 +33,21 @@
</el-space>
</div>
<div>
- <div>
- <PIMTable :table-loading="tableLoading"
- :table-data="tableData"
- :column="tableColumns"
- @selection-change="handleSelectionChange"
- :is-selection="true"
- :border="true"
- :table-style="{ width: '100%', height: 'calc(100vh - 23em)' }"
- >
+ <PIMTable :table-loading="tableLoading"
+ :table-data="tableData"
+ :column="tableColumns"
+ @selection-change="handleSelectionChange"
+ @pagination="handlePagination"
+ :is-selection="true"
+ :border="true"
+ :page="{
+ current: pageNum,
+ size: pageSize,
+ total: total,
+ layout: 'total, sizes, prev, pager, next, jumper'
+ }"
+ :table-style="{ width: '100%', height: 'calc(100vh - 23em)' }"
+ >
<template #inspector="{ row }">
<div class="person-tags">
<!-- 璋冭瘯淇℃伅锛屼笂绾挎椂鍒犻櫎 -->
@@ -60,16 +66,7 @@
<span v-else class="no-data">--</span>
</div>
</template>
- </PIMTable>
- </div>
- <pagination
- v-if="total>0"
- :page="pageNum"
- :limit="pageSize"
- :total="total"
- @pagination="handlePagination"
- :layout="'total, prev, pager, next, jumper'"
- />
+ </PIMTable>
</div>
</el-card>
<form-dia ref="formDia" @closeDia="handleQuery"></form-dia>
@@ -83,7 +80,6 @@
import { ElMessageBox } from "element-plus";
// 缁勪欢寮曞叆
-import Pagination from "@/components/Pagination/index.vue";
import PIMTable from "@/components/PIMTable/PIMTable.vue";
import FormDia from "@/views/equipmentManagement/inspectionManagement/components/formDia.vue";
import ViewFiles from "@/views/equipmentManagement/inspectionManagement/components/viewFiles.vue";
@@ -224,7 +220,7 @@
// 鍒嗛〉澶勭悊
const handlePagination = (val) => {
pageNum.value = val.page;
- pageSize.value = val.size;
+ pageSize.value = val.limit;
getList();
};
// 鑾峰彇鍒楄〃鏁版嵁
--
Gitblit v1.9.3