From 55d6f86eb7dc8aada306405dadd29a2716a6e009 Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期六, 23 五月 2026 14:46:41 +0800
Subject: [PATCH] 设备巡检只留一套图片上传
---
src/pages/inspectionUpload/attachment.vue | 704 ++++++++++++-------------
src/pages/inspectionUpload/components/formDia.vue | 720 ++++++++++++--------------
src/pages/inspectionUpload/upload.vue | 153 +----
src/pages/inspectionUpload/index.vue | 33
4 files changed, 711 insertions(+), 899 deletions(-)
diff --git a/src/pages/inspectionUpload/attachment.vue b/src/pages/inspectionUpload/attachment.vue
index c94efa5..1dfca58 100644
--- a/src/pages/inspectionUpload/attachment.vue
+++ b/src/pages/inspectionUpload/attachment.vue
@@ -1,53 +1,28 @@
<template>
<view class="attachment-page">
<!-- 椤甸潰澶撮儴 -->
- <PageHeader :title="`鏌ョ湅闄勪欢 - ${taskInfo?.taskName || ''}`" @back="goBack" />
-
+ <PageHeader :title="`鏌ョ湅闄勪欢 - ${taskInfo?.taskName || ''}`"
+ @back="goBack" />
<!-- 椤甸潰鍐呭 -->
<view class="attachment-content">
- <!-- 鍒嗙被鏍囩椤� -->
- <view class="attachment-tabs">
- <view
- class="tab-item"
- :class="{ active: currentViewType === 'before' }"
- @click="switchViewType('before')"
- >
- 鐢熶骇鍓� ({{ getAttachmentsByType(0).length }})
- </view>
- <view
- class="tab-item"
- :class="{ active: currentViewType === 'after' }"
- @click="switchViewType('after')"
- >
- 鐢熶骇涓� ({{ getAttachmentsByType(1).length }})
- </view>
- <view
- class="tab-item"
- :class="{ active: currentViewType === 'issue' }"
- @click="switchViewType('issue')"
- >
- 鐢熶骇鍚� ({{ getAttachmentsByType(2).length }})
- </view>
- </view>
-
<!-- 褰撳墠鍒嗙被鐨勯檮浠跺垪琛� -->
<view class="attachment-list-container">
- <view v-if="getCurrentViewAttachments().length > 0" class="attachment-list">
- <view
- v-for="(file, index) in getCurrentViewAttachments()"
- :key="index"
- class="attachment-item"
- @click="previewAttachment(file)"
- >
+ <view v-if="attachmentList.length > 0"
+ class="attachment-list">
+ <view v-for="(file, index) in attachmentList"
+ :key="index"
+ class="attachment-item"
+ @click="previewAttachment(file)">
<view class="attachment-preview-container">
- <image
- v-if="isImageFile(file)"
- :src="file.url || file.downloadUrl"
- class="attachment-preview"
- mode="aspectFill"
- />
- <view v-else class="attachment-video-preview">
- <u-icon name="video" size="40" color="#409eff"></u-icon>
+ <image v-if="isImageFile(file)"
+ :src="file.url || file.downloadUrl"
+ class="attachment-preview"
+ mode="aspectFill" />
+ <view v-else
+ class="attachment-video-preview">
+ <u-icon name="video"
+ size="40"
+ color="#409eff"></u-icon>
<text class="video-text">瑙嗛</text>
</view>
</view>
@@ -57,31 +32,37 @@
</view>
</view>
</view>
- <view v-else class="attachment-empty">
- <u-icon name="folder-open" size="60" color="#ccc"></u-icon>
+ <view v-else
+ class="attachment-empty">
+ <u-icon name="folder-open"
+ size="60"
+ color="#ccc"></u-icon>
<text class="empty-text">璇ュ垎绫绘殏鏃犻檮浠�</text>
</view>
</view>
</view>
-
<!-- 瑙嗛棰勮寮圭獥 -->
- <view v-if="showVideoDialog" class="video-modal-overlay" @click="closeVideoPreview">
- <view class="video-modal-container" @click.stop>
+ <view v-if="showVideoDialog"
+ class="video-modal-overlay"
+ @click="closeVideoPreview">
+ <view class="video-modal-container"
+ @click.stop>
<view class="video-modal-header">
<text class="video-modal-title">{{ currentVideoFile?.originalFilename || '瑙嗛棰勮' }}</text>
- <view class="close-btn-video" @click="closeVideoPreview">
- <u-icon name="close" size="20" color="#fff"></u-icon>
+ <view class="close-btn-video"
+ @click="closeVideoPreview">
+ <u-icon name="close"
+ size="20"
+ color="#fff"></u-icon>
</view>
</view>
<view class="video-modal-body">
- <video
- v-if="currentVideoFile"
- :src="currentVideoFile.url || currentVideoFile.downloadUrl"
- class="video-player"
- controls
- autoplay
- @error="handleVideoError"
- ></video>
+ <video v-if="currentVideoFile"
+ :src="currentVideoFile.url || currentVideoFile.downloadUrl"
+ class="video-player"
+ controls
+ autoplay
+ @error="handleVideoError"></video>
</view>
</view>
</view>
@@ -89,372 +70,351 @@
</template>
<script setup>
-import { ref } from 'vue';
-import { onLoad } from '@dcloudio/uni-app';
-import PageHeader from '@/components/PageHeader.vue';
-import config from '@/config';
+ import { ref } from "vue";
+ import { onLoad } from "@dcloudio/uni-app";
+ import PageHeader from "@/components/PageHeader.vue";
+ import config from "@/config";
-// 浠诲姟淇℃伅
-const taskInfo = ref(null);
+ // 浠诲姟淇℃伅
+ const taskInfo = ref(null);
-// 闄勪欢鍒楄〃
-const attachmentList = ref([]);
+ // 闄勪欢鍒楄〃
+ const attachmentList = ref([]);
-// 褰撳墠鏌ョ湅绫诲瀷
-const currentViewType = ref('before'); // 'before', 'after', 'issue'
+ // 瑙嗛棰勮鐩稿叧鐘舵��
+ const showVideoDialog = ref(false);
+ const currentVideoFile = ref(null);
-// 瑙嗛棰勮鐩稿叧鐘舵��
-const showVideoDialog = ref(false);
-const currentVideoFile = ref(null);
+ // 鏂囦欢璁块棶鍩虹鍩�
+ const filePreviewBase = config.fileUrl;
-// 鏂囦欢璁块棶鍩虹鍩�
-const filePreviewBase = config.fileUrl;
-
-// 椤甸潰鍔犺浇
-onLoad((options) => {
- if (options.taskInfo) {
- try {
- taskInfo.value = JSON.parse(decodeURIComponent(options.taskInfo));
- loadAttachments();
- } catch (e) {
- console.error('瑙f瀽浠诲姟淇℃伅澶辫触:', e);
- uni.showToast({
- title: '鍔犺浇澶辫触',
- icon: 'error'
- });
+ // 椤甸潰鍔犺浇
+ onLoad(options => {
+ if (options.taskInfo) {
+ try {
+ taskInfo.value = JSON.parse(decodeURIComponent(options.taskInfo));
+ loadAttachments();
+ } catch (e) {
+ console.error("瑙f瀽浠诲姟淇℃伅澶辫触:", e);
+ uni.showToast({
+ title: "鍔犺浇澶辫触",
+ icon: "error",
+ });
+ }
}
- }
-});
+ });
-// 鍔犺浇闄勪欢鏁版嵁
-const loadAttachments = () => {
- const task = taskInfo.value;
- if (!task) return;
+ // 鍔犺浇闄勪欢鏁版嵁
+ const loadAttachments = () => {
+ const task = taskInfo.value;
+ if (!task) return;
- attachmentList.value = [];
+ attachmentList.value = [];
- // 鍚庣鍙嶆樉瀛楁
- const allList = Array.isArray(task?.commonFileList) ? task.commonFileList : [];
- const beforeList = Array.isArray(task?.commonFileListBefore)
- ? task.commonFileListBefore
- : allList.filter((f) => f?.type === 10);
- const afterList = Array.isArray(task?.commonFileListAfter)
- ? task.commonFileListAfter
- : allList.filter((f) => f?.type === 11);
- const issueList = Array.isArray(task?.commonFileListIssue)
- ? task.commonFileListIssue
- : allList.filter((f) => f?.type === 12);
+ // 鑾峰彇闄勪欢鍒楄〃锛屼紭鍏堜粠 commonFileListBeforeVO 鑾峰彇
+ let rawList = [];
+ if (Array.isArray(task.commonFileListBeforeVO)) {
+ rawList = task.commonFileListBeforeVO;
+ } else if (Array.isArray(task.commonFileListBefore)) {
+ rawList = task.commonFileListBefore;
+ } else if (Array.isArray(task.commonFileList)) {
+ // 闄嶇骇锛氫粠閫氱敤鍒楄〃杩囨护 type 涓� 10 鐨�
+ rawList = task.commonFileList.filter(f => f?.type === 10);
+ }
- const mapToViewFile = (file, viewType) => {
- const u = normalizeFileUrl(file?.url || file?.downloadUrl || '');
- return {
- ...file,
- type: viewType,
- name: file?.name || file?.originalFilename || file?.bucketFilename,
- bucketFilename: file?.bucketFilename || file?.name,
- originalFilename: file?.originalFilename || file?.name,
- url: u,
- downloadUrl: u,
- size: file?.size || file?.byteSize,
+ const mapToViewFile = file => {
+ // 浼樺厛浣跨敤 previewURL 鎴� url
+ const rawUrl =
+ file?.previewURL ||
+ file?.url ||
+ file?.downloadUrl ||
+ file?.downloadURL ||
+ "";
+ const u = normalizeFileUrl(rawUrl);
+
+ return {
+ ...file,
+ name:
+ file?.name || file?.originalFilename || file?.bucketFilename || "闄勪欢",
+ bucketFilename:
+ file?.bucketFilename || file?.name || file?.originalFilename,
+ originalFilename: file?.originalFilename || file?.name,
+ url: u,
+ downloadUrl: u,
+ size: file?.size || file?.byteSize || 0,
+ };
};
+
+ attachmentList.value = rawList.map(f => mapToViewFile(f));
};
- attachmentList.value.push(...beforeList.map((f) => mapToViewFile(f, 0)));
- attachmentList.value.push(...afterList.map((f) => mapToViewFile(f, 1)));
- attachmentList.value.push(...issueList.map((f) => mapToViewFile(f, 2)));
-};
+ // 灏嗗悗绔繑鍥炵殑鏂囦欢鍦板潃瑙勮寖鎴愬彲璁块棶URL
+ const normalizeFileUrl = rawUrl => {
+ try {
+ if (!rawUrl || typeof rawUrl !== "string") return "";
+ const url = rawUrl.trim();
+ if (!url) return "";
+ if (/^https?:\/\//i.test(url)) return url;
+ if (url.startsWith("/")) return `${filePreviewBase}${url}`;
-// 灏嗗悗绔繑鍥炵殑鏂囦欢鍦板潃瑙勮寖鎴愬彲璁块棶URL
-const normalizeFileUrl = (rawUrl) => {
- try {
- if (!rawUrl || typeof rawUrl !== 'string') return '';
- const url = rawUrl.trim();
- if (!url) return '';
- if (/^https?:\/\//i.test(url)) return url;
- if (url.startsWith('/')) return `${filePreviewBase}${url}`;
-
- // Windows path -> web path
- if (/^[a-zA-Z]:\\/.test(url)) {
- const normalized = url.replace(/\\/g, '/');
- const idx = normalized.indexOf('/prod/');
- if (idx >= 0) {
- const relative = normalized.slice(idx + '/prod/'.length);
- return `${filePreviewBase}/${relative}`;
+ // Windows path -> web path
+ if (/^[a-zA-Z]:\\/.test(url)) {
+ const normalized = url.replace(/\\/g, "/");
+ const idx = normalized.indexOf("/prod/");
+ if (idx >= 0) {
+ const relative = normalized.slice(idx + "/prod/".length);
+ return `${filePreviewBase}/${relative}`;
+ }
+ return normalized;
}
- return normalized;
+
+ return `${filePreviewBase}/${url.replace(/^\//, "")}`;
+ } catch (e) {
+ return rawUrl || "";
}
+ };
- return `${filePreviewBase}/${url.replace(/^\//, '')}`;
- } catch (e) {
- return rawUrl || '';
- }
-};
+ // 杩斿洖涓婁竴椤�
+ const goBack = () => {
+ uni.navigateBack();
+ };
-// 杩斿洖涓婁竴椤�
-const goBack = () => {
- uni.navigateBack();
-};
+ // 鍒ゆ柇鏄惁涓哄浘鐗囨枃浠�
+ const isImageFile = file => {
+ if (file.contentType && file.contentType.startsWith("image/")) {
+ return true;
+ }
+ if (file.type === "image") return true;
-// 鍒囨崲鏌ョ湅绫诲瀷
-const switchViewType = (type) => {
- currentViewType.value = type;
-};
+ const name = file.bucketFilename || file.originalFilename || file.name || "";
+ const ext = name.split(".").pop()?.toLowerCase();
+ return ["jpg", "jpeg", "png", "gif", "webp"].includes(ext);
+ };
-// 鏍规嵁type鑾峰彇瀵瑰簲鍒嗙被鐨勯檮浠�
-const getAttachmentsByType = (typeValue) => {
- return attachmentList.value.filter((file) => file.type === typeValue) || [];
-};
+ // 棰勮闄勪欢
+ const previewAttachment = file => {
+ if (isImageFile(file)) {
+ const imageUrls = attachmentList.value
+ .filter(f => isImageFile(f))
+ .map(f => f.url || f.downloadUrl);
-// 鑾峰彇褰撳墠鏌ョ湅绫诲瀷鐨勯檮浠�
-const getCurrentViewAttachments = () => {
- switch (currentViewType.value) {
- case 'before':
- return getAttachmentsByType(0);
- case 'after':
- return getAttachmentsByType(1);
- case 'issue':
- return getAttachmentsByType(2);
- default:
- return [];
- }
-};
+ uni.previewImage({
+ urls: imageUrls,
+ current: file.url || file.downloadUrl,
+ });
+ } else {
+ showVideoPreview(file);
+ }
+ };
-// 鍒ゆ柇鏄惁涓哄浘鐗囨枃浠�
-const isImageFile = (file) => {
- if (file.contentType && file.contentType.startsWith('image/')) {
- return true;
- }
- if (file.type === 'image') return true;
+ // 鏄剧ず瑙嗛棰勮
+ const showVideoPreview = file => {
+ currentVideoFile.value = file;
+ showVideoDialog.value = true;
+ };
- const name = file.bucketFilename || file.originalFilename || file.name || '';
- const ext = name.split('.').pop()?.toLowerCase();
- return ['jpg', 'jpeg', 'png', 'gif', 'webp'].includes(ext);
-};
+ // 鍏抽棴瑙嗛棰勮
+ const closeVideoPreview = () => {
+ showVideoDialog.value = false;
+ currentVideoFile.value = null;
+ };
-// 棰勮闄勪欢
-const previewAttachment = (file) => {
- if (isImageFile(file)) {
- const imageUrls = getCurrentViewAttachments()
- .filter((f) => isImageFile(f))
- .map((f) => f.url || f.downloadUrl);
-
- uni.previewImage({
- urls: imageUrls,
- current: file.url || file.downloadUrl,
+ // 瑙嗛鎾斁閿欒澶勭悊
+ const handleVideoError = () => {
+ uni.showToast({
+ title: "瑙嗛鎾斁澶辫触",
+ icon: "error",
});
- } else {
- showVideoPreview(file);
- }
-};
+ };
-// 鏄剧ず瑙嗛棰勮
-const showVideoPreview = (file) => {
- currentVideoFile.value = file;
- showVideoDialog.value = true;
-};
-
-// 鍏抽棴瑙嗛棰勮
-const closeVideoPreview = () => {
- showVideoDialog.value = false;
- currentVideoFile.value = null;
-};
-
-// 瑙嗛鎾斁閿欒澶勭悊
-const handleVideoError = () => {
- uni.showToast({
- title: '瑙嗛鎾斁澶辫触',
- icon: 'error',
- });
-};
-
-// 鏍煎紡鍖栨枃浠跺ぇ灏�
-const formatFileSize = (size) => {
- if (!size) return '';
- if (size < 1024) return size + 'B';
- if (size < 1024 * 1024) return (size / 1024).toFixed(1) + 'KB';
- return (size / (1024 * 1024)).toFixed(1) + 'MB';
-};
+ // 鏍煎紡鍖栨枃浠跺ぇ灏�
+ const formatFileSize = size => {
+ if (!size) return "";
+ if (size < 1024) return size + "B";
+ if (size < 1024 * 1024) return (size / 1024).toFixed(1) + "KB";
+ return (size / (1024 * 1024)).toFixed(1) + "MB";
+ };
</script>
<style scoped>
-.attachment-page {
- min-height: 100vh;
- background-color: #f5f5f5;
-}
+ .attachment-page {
+ min-height: 100vh;
+ background-color: #f5f5f5;
+ }
-.attachment-content {
- padding: 15px;
-}
+ .attachment-content {
+ padding: 15px;
+ }
-/* 鏍囩椤垫牱寮� */
-.attachment-tabs {
- display: flex;
- background: #fff;
- border-radius: 12px;
- margin-bottom: 15px;
- padding: 4px;
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
-}
+ /* 鏍囩椤垫牱寮� */
+ .attachment-tabs {
+ display: flex;
+ background: #fff;
+ border-radius: 12px;
+ margin-bottom: 15px;
+ padding: 4px;
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
+ }
-.tab-item {
- flex: 1;
- text-align: center;
- padding: 12px 8px;
- font-size: 14px;
- color: #666;
- border-radius: 8px;
- transition: all 0.3s ease;
-}
+ .tab-item {
+ flex: 1;
+ text-align: center;
+ padding: 12px 8px;
+ font-size: 14px;
+ color: #666;
+ border-radius: 8px;
+ transition: all 0.3s ease;
+ }
-.tab-item.active {
- background: #409eff;
- color: #fff;
- font-weight: 500;
-}
+ .tab-item.active {
+ background: #409eff;
+ color: #fff;
+ font-weight: 500;
+ }
-/* 闄勪欢鍒楄〃鏍峰紡 */
-.attachment-list-container {
- background: #fff;
- border-radius: 12px;
- padding: 15px;
- min-height: 400px;
-}
+ /* 闄勪欢鍒楄〃鏍峰紡 */
+ .attachment-list-container {
+ background: #fff;
+ border-radius: 12px;
+ padding: 15px;
+ min-height: 400px;
+ }
-.attachment-list {
- display: flex;
- flex-wrap: wrap;
- gap: 15px;
-}
+ .attachment-list {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 15px;
+ }
-.attachment-item {
- width: calc(33.33% - 10px);
- background: #f8f9fa;
- border-radius: 12px;
- overflow: hidden;
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
- transition: all 0.3s ease;
-}
+ .attachment-item {
+ width: calc(33.33% - 10px);
+ background: #f8f9fa;
+ border-radius: 12px;
+ overflow: hidden;
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
+ transition: all 0.3s ease;
+ }
-.attachment-item:active {
- transform: scale(0.98);
-}
+ .attachment-item:active {
+ transform: scale(0.98);
+ }
-.attachment-preview-container {
- width: 100%;
- height: 120px;
- background: #e9ecef;
- display: flex;
- align-items: center;
- justify-content: center;
-}
+ .attachment-preview-container {
+ width: 100%;
+ height: 120px;
+ background: #e9ecef;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ }
-.attachment-preview {
- width: 100%;
- height: 100%;
- object-fit: cover;
-}
+ .attachment-preview {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ }
-.attachment-video-preview {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- gap: 8px;
-}
+ .attachment-video-preview {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ gap: 8px;
+ }
-.video-text {
- font-size: 12px;
- color: #666;
-}
+ .video-text {
+ font-size: 12px;
+ color: #666;
+ }
-.attachment-info {
- padding: 10px;
-}
+ .attachment-info {
+ padding: 10px;
+ }
-.attachment-name {
- font-size: 12px;
- color: #333;
- display: block;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- margin-bottom: 4px;
-}
+ .attachment-name {
+ font-size: 12px;
+ color: #333;
+ display: block;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ margin-bottom: 4px;
+ }
-.attachment-size {
- font-size: 10px;
- color: #999;
-}
+ .attachment-size {
+ font-size: 10px;
+ color: #999;
+ }
-/* 绌虹姸鎬佹牱寮� */
-.attachment-empty {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- padding: 80px 20px;
- color: #999;
-}
+ /* 绌虹姸鎬佹牱寮� */
+ .attachment-empty {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ padding: 80px 20px;
+ color: #999;
+ }
-.empty-text {
- margin-top: 15px;
- font-size: 14px;
-}
+ .empty-text {
+ margin-top: 15px;
+ font-size: 14px;
+ }
-/* 瑙嗛寮圭獥鏍峰紡 */
-.video-modal-overlay {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background: rgba(0, 0, 0, 0.9);
- z-index: 10000;
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 20px;
-}
+ /* 瑙嗛寮圭獥鏍峰紡 */
+ .video-modal-overlay {
+ position: fixed;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background: rgba(0, 0, 0, 0.9);
+ z-index: 10000;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ padding: 20px;
+ }
-.video-modal-container {
- width: 100%;
- max-width: 800px;
- background: #000;
- border-radius: 12px;
- overflow: hidden;
-}
+ .video-modal-container {
+ width: 100%;
+ max-width: 800px;
+ background: #000;
+ border-radius: 12px;
+ overflow: hidden;
+ }
-.video-modal-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 15px 20px;
- background: #1a1a1a;
-}
+ .video-modal-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: 15px 20px;
+ background: #1a1a1a;
+ }
-.video-modal-title {
- font-size: 16px;
- color: #fff;
- font-weight: 500;
-}
+ .video-modal-title {
+ font-size: 16px;
+ color: #fff;
+ font-weight: 500;
+ }
-.close-btn-video {
- width: 32px;
- height: 32px;
- display: flex;
- align-items: center;
- justify-content: center;
- background: rgba(255, 255, 255, 0.1);
- border-radius: 50%;
-}
+ .close-btn-video {
+ width: 32px;
+ height: 32px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ background: rgba(255, 255, 255, 0.1);
+ border-radius: 50%;
+ }
-.video-modal-body {
- padding: 20px;
-}
+ .video-modal-body {
+ padding: 20px;
+ }
-.video-player {
- width: 100%;
- height: 400px;
- border-radius: 8px;
-}
+ .video-player {
+ width: 100%;
+ height: 400px;
+ border-radius: 8px;
+ }
</style>
diff --git a/src/pages/inspectionUpload/components/formDia.vue b/src/pages/inspectionUpload/components/formDia.vue
index 62bf40f..25eb108 100644
--- a/src/pages/inspectionUpload/components/formDia.vue
+++ b/src/pages/inspectionUpload/components/formDia.vue
@@ -1,460 +1,398 @@
<template>
- <u-popup
- v-model="dialogVisitable"
- mode="center"
- :round="10"
- :closeable="true"
- @close="cancel"
- >
+ <u-popup v-model="dialogVisitable"
+ mode="center"
+ :round="10"
+ :closeable="true"
+ @close="cancel">
<view class="popup-content">
<view class="popup-header">
<text class="popup-title">宸℃璁板綍涓婁紶</text>
</view>
-
<view class="upload-container">
<!-- 寮傚父鐘舵�侀�夋嫨 -->
<view class="form-container">
<view class="title">宸℃鐘舵��</view>
<view class="exception-section">
<view class="exception-options">
- <view
- class="exception-option"
- :class="{ active: hasException === false }"
- @click="setExceptionStatus(false)"
- >
- <u-icon name="checkmark-circle" size="20" color="#52c41a"></u-icon>
+ <view class="exception-option"
+ :class="{ active: hasException === false }"
+ @click="setExceptionStatus(false)">
+ <u-icon name="checkmark-circle"
+ size="20"
+ color="#52c41a"></u-icon>
<text class="option-text">姝e父</text>
</view>
- <view
- class="exception-option"
- :class="{ active: hasException === true }"
- @click="setExceptionStatus(true)"
- >
- <u-icon name="close-circle" size="20" color="#ff4d4f"></u-icon>
+ <view class="exception-option"
+ :class="{ active: hasException === true }"
+ @click="setExceptionStatus(true)">
+ <u-icon name="close-circle"
+ size="20"
+ color="#ff4d4f"></u-icon>
<text class="option-text">瀛樺湪寮傚父</text>
</view>
</view>
</view>
</view>
-
<!-- 寮傚父鎻忚堪锛堜粎鍦ㄥ紓甯告椂鏄剧ず锛� -->
- <view class="form-container" v-if="hasException === true">
+ <view class="form-container"
+ v-if="hasException === true">
<view class="title">寮傚父鎻忚堪</view>
- <u-input
- v-model="exceptionDescription"
- type="textarea"
- :maxlength="500"
- placeholder="璇锋弿杩板紓甯告儏鍐�..."
- :customStyle="{ padding: '10px', backgroundColor: '#f5f5f5' }"
- />
+ <u-input v-model="exceptionDescription"
+ type="textarea"
+ :maxlength="500"
+ placeholder="璇锋弿杩板紓甯告儏鍐�..."
+ :customStyle="{ padding: '10px', backgroundColor: '#f5f5f5' }" />
</view>
-
<!-- 涓婁紶鍖哄煙锛堜粎鍦ㄥ紓甯告椂鏄剧ず锛� -->
<template v-if="hasException === true">
<view class="form-container">
- <view class="title">鐢熶骇鍓�</view>
- <u-upload
- :fileList="beforeModelValue"
- @afterRead="afterRead"
- @delete="deleteFile"
- name="before"
- multiple
- :maxCount="10"
- :maxSize="5 * 1024 * 1024"
- accept="image/*"
- :previewFullImage="true"
- ></u-upload>
- </view>
-
- <view class="form-container">
- <view class="title">鐢熶骇鍚�</view>
- <u-upload
- :fileList="afterModelValue"
- @afterRead="afterRead"
- @delete="deleteFile"
- name="after"
- multiple
- :maxCount="10"
- :maxSize="5 * 1024 * 1024"
- accept="image/*"
- :previewFullImage="true"
- ></u-upload>
- </view>
-
- <view class="form-container">
- <view class="title">鐢熶骇闂</view>
- <u-upload
- :fileList="issueModelValue"
- @afterRead="afterRead"
- @delete="deleteFile"
- name="issue"
- multiple
- :maxCount="10"
- :maxSize="5 * 1024 * 1024"
- accept="image/*"
- :previewFullImage="true"
- ></u-upload>
+ <view class="title">宸℃鐓х墖</view>
+ <u-upload :fileList="beforeModelValue"
+ @afterRead="afterRead"
+ @delete="deleteFile"
+ name="before"
+ multiple
+ :maxCount="10"
+ :maxSize="5 * 1024 * 1024"
+ accept="image/*"
+ :previewFullImage="true"></u-upload>
</view>
</template>
-
<!-- 姝e父鐘舵�佹彁绀� -->
- <view class="form-container normal-tip" v-if="hasException === false">
- <u-icon name="info-circle" size="40" color="#52c41a"></u-icon>
+ <view class="form-container normal-tip"
+ v-if="hasException === false">
+ <u-icon name="info-circle"
+ size="40"
+ color="#52c41a"></u-icon>
<text class="tip-text">璁惧杩愯姝e父锛屾棤闇�涓婁紶鐓х墖</text>
</view>
</view>
-
<view class="popup-footer">
- <u-button @click="cancel" :customStyle="{ marginRight: '10px' }">鍙栨秷</u-button>
- <u-button type="primary" @click="submitForm">淇濆瓨</u-button>
+ <u-button @click="cancel"
+ :customStyle="{ marginRight: '10px' }">鍙栨秷</u-button>
+ <u-button type="primary"
+ @click="submitForm">淇濆瓨</u-button>
</view>
</view>
</u-popup>
</template>
<script setup>
-import { ref, computed } from 'vue'
-import { submitInspectionRecord } from '@/api/equipmentManagement/inspection.js'
-import { getToken } from '@/utils/auth'
-import config from '@/config'
+ import { ref, computed } from "vue";
+ import { submitInspectionRecord } from "@/api/equipmentManagement/inspection.js";
+ import { getToken } from "@/utils/auth";
+ import config from "@/config";
-const emit = defineEmits(['closeDia'])
+ const emit = defineEmits(["closeDia"]);
-const dialogVisitable = ref(false)
-const beforeModelValue = ref([])
-const afterModelValue = ref([])
-const issueModelValue = ref([])
-const infoData = ref(null)
+ const dialogVisitable = ref(false);
+ const beforeModelValue = ref([]);
+ const infoData = ref(null);
-// 寮傚父鐘舵�侊細null=鏈�夋嫨, false=姝e父, true=寮傚父
-const hasException = ref(null)
-// 寮傚父鎻忚堪
-const exceptionDescription = ref('')
+ // 寮傚父鐘舵�侊細null=鏈�夋嫨, false=姝e父, true=寮傚父
+ const hasException = ref(null);
+ // 寮傚父鎻忚堪
+ const exceptionDescription = ref("");
-// 璁$畻涓婁紶URL
-const uploadFileUrl = computed(() => {
- let baseUrl = '';
-
- if (process.env.VUE_APP_BASE_API) {
- baseUrl = process.env.VUE_APP_BASE_API;
- } else {
- baseUrl = config.baseUrl;
- }
-
- return baseUrl + '/file/upload';
-})
+ // 璁$畻涓婁紶URL
+ const uploadFileUrl = computed(() => {
+ let baseUrl = "";
-const uploadSingleFile = async (fileItem, typeValue) => {
- const token = getToken()
- if (!token) throw new Error('鐢ㄦ埛鏈櫥褰�')
-
- // H5: u-upload 鍙兘缁欏師鐢� File锛坒ileItem.file锛�
- const rawFile = fileItem?.file
- if (rawFile) {
- const formData = new FormData()
- formData.append('file', rawFile, rawFile.name || 'image.jpg')
- formData.append('type', String(typeValue))
- const res = await fetch(uploadFileUrl.value, {
- method: 'POST',
- headers: { Authorization: 'Bearer ' + token },
- body: formData
- })
- const data = await res.json()
- if (data?.code !== 200) throw new Error(data?.msg || '涓婁紶澶辫触')
- return {
- url: data?.data?.url,
- name: rawFile.name || 'image.jpg',
- status: 'success'
+ if (process.env.VUE_APP_BASE_API) {
+ baseUrl = process.env.VUE_APP_BASE_API;
+ } else {
+ baseUrl = config.baseUrl;
}
- }
- // 闈� H5 / 鍏煎锛氳蛋 uni.uploadFile
- return await new Promise((resolve, reject) => {
- uni.uploadFile({
- url: uploadFileUrl.value,
- filePath: fileItem.url,
- name: 'file',
- header: {
- 'Authorization': `Bearer ${token}`
- },
- formData: {
- type: typeValue
- },
- success: (res) => {
- try {
- const data = JSON.parse(res.data)
- if (data.code === 200) {
- resolve({
- url: data.data.url,
- name: fileItem.name,
- status: 'success'
- })
- } else {
- reject(new Error(data.msg || '涓婁紶澶辫触'))
+ return baseUrl + "/file/upload";
+ });
+
+ const uploadSingleFile = async (fileItem, typeValue) => {
+ const token = getToken();
+ if (!token) throw new Error("鐢ㄦ埛鏈櫥褰�");
+
+ // H5: u-upload 鍙兘缁欏師鐢� File锛坒ileItem.file锛�
+ const rawFile = fileItem?.file;
+ if (rawFile) {
+ const formData = new FormData();
+ formData.append("file", rawFile, rawFile.name || "image.jpg");
+ formData.append("type", String(typeValue));
+ const res = await fetch(uploadFileUrl.value, {
+ method: "POST",
+ headers: { Authorization: "Bearer " + token },
+ body: formData,
+ });
+ const data = await res.json();
+ if (data?.code !== 200) throw new Error(data?.msg || "涓婁紶澶辫触");
+ return {
+ url: data?.data?.url,
+ name: rawFile.name || "image.jpg",
+ status: "success",
+ };
+ }
+
+ // 闈� H5 / 鍏煎锛氳蛋 uni.uploadFile
+ return await new Promise((resolve, reject) => {
+ uni.uploadFile({
+ url: uploadFileUrl.value,
+ filePath: fileItem.url,
+ name: "file",
+ header: {
+ Authorization: `Bearer ${token}`,
+ },
+ formData: {
+ type: typeValue,
+ },
+ success: res => {
+ try {
+ const data = JSON.parse(res.data);
+ if (data.code === 200) {
+ resolve({
+ url: data.data.url,
+ name: fileItem.name,
+ status: "success",
+ });
+ } else {
+ reject(new Error(data.msg || "涓婁紶澶辫触"));
+ }
+ } catch (e) {
+ reject(e);
}
- } catch (e) {
- reject(e)
+ },
+ fail: err => reject(err),
+ });
+ });
+ };
+
+ // 鏂囦欢涓婁紶澶勭悊
+ const afterRead = event => {
+ const { file } = event;
+
+ // 浠呬繚鐣欑敓浜у墠(typeValue=10)
+ let typeValue = 10;
+
+ const files = Array.isArray(file) ? file : [file];
+ Promise.resolve()
+ .then(async () => {
+ for (const f of files) {
+ const uploaded = await uploadSingleFile(f, typeValue);
+ beforeModelValue.value.push(uploaded);
}
- },
- fail: (err) => reject(err)
- })
- })
-}
-
-// 鏂囦欢涓婁紶澶勭悊
-const afterRead = (event) => {
- const { name, file } = event
-
- // 鏍规嵁涓婁紶绫诲瀷璁剧疆涓嶅悓鐨則ype鍊�
- let typeValue = 10 // 榛樿鍊�
- if (name === 'before') {
- typeValue = 10 // 鐢熶骇鍓�
- } else if (name === 'after') {
- typeValue = 11 // 鐢熶骇涓�
- } else if (name === 'issue') {
- typeValue = 12 // 鐢熶骇鍚�
- }
-
- const files = Array.isArray(file) ? file : [file]
- Promise.resolve().then(async () => {
- for (const f of files) {
- const uploaded = await uploadSingleFile(f, typeValue)
- if (name === 'before') {
- beforeModelValue.value.push(uploaded)
- } else if (name === 'after') {
- afterModelValue.value.push(uploaded)
- } else if (name === 'issue') {
- issueModelValue.value.push(uploaded)
- }
- }
- uni.showToast({ title: '涓婁紶鎴愬姛', icon: 'success' })
- }).catch((err) => {
- console.error('涓婁紶澶辫触:', err)
- uni.showToast({ title: '涓婁紶澶辫触', icon: 'error' })
- })
-}
-
-// 鍒犻櫎鏂囦欢
-const deleteFile = (event) => {
- const { name, index } = event
-
- if (name === 'before') {
- beforeModelValue.value.splice(index, 1)
- } else if (name === 'after') {
- afterModelValue.value.splice(index, 1)
- } else if (name === 'issue') {
- issueModelValue.value.splice(index, 1)
- }
-}
-
-// 璁剧疆寮傚父鐘舵��
-const setExceptionStatus = (status) => {
- hasException.value = status
-}
-
-// 鎻愪氦琛ㄥ崟
-const submitForm = async () => {
- try {
- // 妫�鏌ユ槸鍚﹂�夋嫨浜嗗贰妫�鐘舵��
- if (hasException.value === null) {
- uni.showToast({
- title: '璇烽�夋嫨宸℃鐘舵��',
- icon: 'none'
+ uni.showToast({ title: "涓婁紶鎴愬姛", icon: "success" });
})
- return
- }
+ .catch(err => {
+ console.error("涓婁紶澶辫触:", err);
+ uni.showToast({ title: "涓婁紶澶辫触", icon: "error" });
+ });
+ };
- // 濡傛灉鏄紓甯哥姸鎬侊紝妫�鏌ユ槸鍚︽湁涓婁紶鏂囦欢
- if (hasException.value === true) {
- const totalFiles = beforeModelValue.value.length + afterModelValue.value.length + issueModelValue.value.length
- if (totalFiles === 0) {
+ // 鍒犻櫎鏂囦欢
+ const deleteFile = event => {
+ const { index } = event;
+ beforeModelValue.value.splice(index, 1);
+ };
+
+ // 璁剧疆寮傚父鐘舵��
+ const setExceptionStatus = status => {
+ hasException.value = status;
+ };
+
+ // 鎻愪氦琛ㄥ崟
+ const submitForm = async () => {
+ try {
+ // 妫�鏌ユ槸鍚﹂�夋嫨浜嗗贰妫�鐘舵��
+ if (hasException.value === null) {
uni.showToast({
- title: '璇蜂笂浼犲紓甯哥収鐗�',
- icon: 'none'
- })
- return
+ title: "璇烽�夋嫨宸℃鐘舵��",
+ icon: "none",
+ });
+ return;
}
- // 妫�鏌ユ槸鍚﹀~鍐欎簡寮傚父鎻忚堪
- if (!exceptionDescription.value.trim()) {
- uni.showToast({
- title: '璇峰~鍐欏紓甯告弿杩�',
- icon: 'none'
- })
- return
+
+ // 濡傛灉鏄紓甯哥姸鎬侊紝妫�鏌ユ槸鍚︽湁涓婁紶鏂囦欢
+ if (hasException.value === true) {
+ if (beforeModelValue.value.length === 0) {
+ uni.showToast({
+ title: "璇蜂笂浼犲紓甯哥収鐗�",
+ icon: "none",
+ });
+ return;
+ }
+ // 妫�鏌ユ槸鍚﹀~鍐欎簡寮傚父鎻忚堪
+ if (!exceptionDescription.value.trim()) {
+ uni.showToast({
+ title: "璇峰~鍐欏紓甯告弿杩�",
+ icon: "none",
+ });
+ return;
+ }
}
- }
- let arr = []
- if (beforeModelValue.value.length > 0) {
- arr.push(...beforeModelValue.value.map(item => ({ ...item, statusType: 0 })))
- }
- if (afterModelValue.value.length > 0) {
- arr.push(...afterModelValue.value.map(item => ({ ...item, statusType: 1 })))
- }
- if (issueModelValue.value.length > 0) {
- arr.push(...issueModelValue.value.map(item => ({ ...item, statusType: 2 })))
- }
-
- // 鎻愪氦鏁版嵁
- infoData.value.storageBlobDTO = arr
- infoData.value.hasException = hasException.value
- infoData.value.exceptionDescription = exceptionDescription.value
- await submitInspectionRecord({ ...infoData.value })
-
- uni.showToast({
- title: '鎻愪氦鎴愬姛',
- icon: 'success'
- })
-
- cancel()
- } catch (error) {
- console.error('鎻愪氦澶辫触:', error)
- uni.showToast({
- title: '鎻愪氦澶辫触',
- icon: 'error'
- })
- }
-}
+ let arr = [];
+ if (beforeModelValue.value.length > 0) {
+ arr.push(
+ ...beforeModelValue.value.map(item => ({ ...item, statusType: 0 }))
+ );
+ }
-// 鎵撳紑寮规
-const openDialog = async (row) => {
- infoData.value = row
- dialogVisitable.value = true
-
- // 娓呯┖涔嬪墠鐨勬暟鎹�
- beforeModelValue.value = []
- afterModelValue.value = []
- issueModelValue.value = []
- hasException.value = null
- exceptionDescription.value = ''
-}
+ // 鎻愪氦鏁版嵁
+ infoData.value.storageBlobDTO = arr;
+ infoData.value.hasException = hasException.value;
+ infoData.value.exceptionDescription = exceptionDescription.value;
+ await submitInspectionRecord({ ...infoData.value });
-// 鍏抽棴寮规
-const cancel = () => {
- dialogVisitable.value = false
- emit('closeDia')
-}
+ uni.showToast({
+ title: "鎻愪氦鎴愬姛",
+ icon: "success",
+ });
-defineExpose({ openDialog })
+ cancel();
+ } catch (error) {
+ console.error("鎻愪氦澶辫触:", error);
+ uni.showToast({
+ title: "鎻愪氦澶辫触",
+ icon: "error",
+ });
+ }
+ };
+
+ // 鎵撳紑寮规
+ const openDialog = async row => {
+ infoData.value = row;
+ dialogVisitable.value = true;
+
+ // 娓呯┖涔嬪墠鐨勬暟鎹�
+ beforeModelValue.value = [];
+ hasException.value = null;
+ exceptionDescription.value = "";
+ };
+
+ // 鍏抽棴寮规
+ const cancel = () => {
+ dialogVisitable.value = false;
+ emit("closeDia");
+ };
+
+ defineExpose({ openDialog });
</script>
<style scoped lang="scss">
-.popup-content {
- width: 90vw;
- max-width: 400px;
- background-color: #fff;
- border-radius: 10px;
- overflow: hidden;
-}
-
-.popup-header {
- padding: 20px 20px 10px;
- text-align: center;
- border-bottom: 1px solid #f0f0f0;
-}
-
-.popup-title {
- font-size: 18px;
- font-weight: 600;
- color: #333;
-}
-
-.upload-container {
- padding: 20px;
- max-height: 60vh;
- overflow-y: auto;
-}
-
-.form-container {
- margin-bottom: 20px;
-
- &:last-child {
- margin-bottom: 0;
+ .popup-content {
+ width: 90vw;
+ max-width: 400px;
+ background-color: #fff;
+ border-radius: 10px;
+ overflow: hidden;
}
-}
-.title {
- font-size: 14px;
- color: #1890ff;
- line-height: 20px;
- font-weight: 600;
- padding-left: 10px;
- position: relative;
- margin: 6px 0 10px;
-
- &::before {
- content: "";
- position: absolute;
- left: 0;
- top: 3px;
- width: 4px;
- height: 14px;
- background-color: #1890ff;
+ .popup-header {
+ padding: 20px 20px 10px;
+ text-align: center;
+ border-bottom: 1px solid #f0f0f0;
}
-}
-.popup-footer {
- display: flex;
- justify-content: center;
- padding: 15px 20px;
- border-top: 1px solid #f0f0f0;
- background-color: #fafafa;
-}
-
-// 寮傚父鐘舵�侀�夋嫨鏍峰紡
-.exception-section {
- padding: 10px 0;
-}
-
-.exception-options {
- display: flex;
- gap: 15px;
-}
-
-.exception-option {
- flex: 1;
- display: flex;
- align-items: center;
- justify-content: center;
- gap: 8px;
- padding: 15px 20px;
- border: 2px solid #e0e0e0;
- border-radius: 8px;
- cursor: pointer;
- transition: all 0.3s;
- background-color: #fff;
-
- &.active {
- border-color: #1890ff;
- background-color: #e6f7ff;
+ .popup-title {
+ font-size: 18px;
+ font-weight: 600;
+ color: #333;
}
-
- &:active {
- opacity: 0.8;
+
+ .upload-container {
+ padding: 20px;
+ max-height: 60vh;
+ overflow-y: auto;
}
-}
-.option-text {
- font-size: 14px;
- color: #333;
- font-weight: 500;
-}
+ .form-container {
+ margin-bottom: 20px;
-// 姝e父鐘舵�佹彁绀烘牱寮�
-.normal-tip {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- padding: 40px 20px;
- background-color: #f6ffed;
- border: 1px dashed #b7eb8f;
- border-radius: 8px;
-
- .tip-text {
- margin-top: 15px;
+ &:last-child {
+ margin-bottom: 0;
+ }
+ }
+
+ .title {
font-size: 14px;
- color: #52c41a;
+ color: #1890ff;
+ line-height: 20px;
+ font-weight: 600;
+ padding-left: 10px;
+ position: relative;
+ margin: 6px 0 10px;
+
+ &::before {
+ content: "";
+ position: absolute;
+ left: 0;
+ top: 3px;
+ width: 4px;
+ height: 14px;
+ background-color: #1890ff;
+ }
}
-}
+
+ .popup-footer {
+ display: flex;
+ justify-content: center;
+ padding: 15px 20px;
+ border-top: 1px solid #f0f0f0;
+ background-color: #fafafa;
+ }
+
+ // 寮傚父鐘舵�侀�夋嫨鏍峰紡
+ .exception-section {
+ padding: 10px 0;
+ }
+
+ .exception-options {
+ display: flex;
+ gap: 15px;
+ }
+
+ .exception-option {
+ flex: 1;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: 8px;
+ padding: 15px 20px;
+ border: 2px solid #e0e0e0;
+ border-radius: 8px;
+ cursor: pointer;
+ transition: all 0.3s;
+ background-color: #fff;
+
+ &.active {
+ border-color: #1890ff;
+ background-color: #e6f7ff;
+ }
+
+ &:active {
+ opacity: 0.8;
+ }
+ }
+
+ .option-text {
+ font-size: 14px;
+ color: #333;
+ font-weight: 500;
+ }
+
+ // 姝e父鐘舵�佹彁绀烘牱寮�
+ .normal-tip {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ padding: 40px 20px;
+ background-color: #f6ffed;
+ border: 1px dashed #b7eb8f;
+ border-radius: 8px;
+
+ .tip-text {
+ margin-top: 15px;
+ font-size: 14px;
+ color: #52c41a;
+ }
+ }
</style>
diff --git a/src/pages/inspectionUpload/index.vue b/src/pages/inspectionUpload/index.vue
index bedc38f..d83eac8 100644
--- a/src/pages/inspectionUpload/index.vue
+++ b/src/pages/inspectionUpload/index.vue
@@ -296,18 +296,22 @@
};
const getFileStatus = record => {
- let _beforeProduction =
- record.beforeProduction && record.beforeProduction.length;
- let _afterProduction =
- record.afterProduction && record.afterProduction.length;
- let _productionIssues =
- record.productionIssues && record.productionIssues.length;
- if (_beforeProduction && _afterProduction && _productionIssues) {
- return 2;
- } else if (_beforeProduction || _afterProduction || _productionIssues) {
- return 1;
+ // 妫�鏌ユ槸鍚︽湁宸℃鐓х墖 (commonFileListBeforeVO)
+ const hasFiles =
+ (record.commonFileListBeforeVO &&
+ record.commonFileListBeforeVO.length > 0) ||
+ (record.commonFileListAfterVO && record.commonFileListAfterVO.length > 0) ||
+ (record.commonFileListVO && record.commonFileListVO.length > 0);
+
+ if (hasFiles) {
+ return 2; // 宸插畬鎴�
+ } else if (
+ record.inspectionResult !== undefined &&
+ record.inspectionResult !== null
+ ) {
+ return 1; // 宸℃涓� (宸叉湁缁撴灉浣嗘病鐓х墖锛屾垨鑰呮牴鎹笟鍔¢�昏緫瀹氫箟)
} else {
- return 0;
+ return 0; // 鏈贰妫�
}
};
@@ -400,7 +404,12 @@
// 鏌ョ湅闄勪欢 - 璺宠浆鍒伴檮浠堕〉闈�
const viewAttachments = async task => {
- const taskData = encodeURIComponent(JSON.stringify(task));
+ // 浠呬紶閫掑繀瑕佺殑浠诲姟淇℃伅鍜� commonFileListBeforeVO 闄勪欢鍒楄〃
+ const taskInfoToPass = {
+ taskName: task.taskName,
+ commonFileListBeforeVO: task.commonFileListBeforeVO || [],
+ };
+ const taskData = encodeURIComponent(JSON.stringify(taskInfoToPass));
uni.navigateTo({
url: `/pages/inspectionUpload/attachment?taskInfo=${taskData}`,
});
diff --git a/src/pages/inspectionUpload/upload.vue b/src/pages/inspectionUpload/upload.vue
index 6d95785..e85cba8 100644
--- a/src/pages/inspectionUpload/upload.vue
+++ b/src/pages/inspectionUpload/upload.vue
@@ -57,33 +57,17 @@
maxlength="500"
placeholder="璇锋弿杩板紓甯告儏鍐�..." />
</view>
- <!-- 鍒嗙被鏍囩椤碉紙浠呭湪寮傚父鏃舵樉绀猴級 -->
+ <!-- 涓婁紶鍖哄煙锛堜粎鍦ㄥ紓甯告椂鏄剧ず锛� -->
<view class="section-card"
v-if="hasException === true">
- <view class="upload-tabs">
- <view class="tab-item"
- :class="{ active: currentUploadType === 'before' }"
- @click="switchUploadType('before')">
- 鐢熶骇鍓�
- </view>
- <view class="tab-item"
- :class="{ active: currentUploadType === 'after' }"
- @click="switchUploadType('after')">
- 鐢熶骇涓�
- </view>
- <view class="tab-item"
- :class="{ active: currentUploadType === 'issue' }"
- @click="switchUploadType('issue')">
- 鐢熶骇鍚�
- </view>
- </view>
+ <view class="section-title">宸℃鐓х墖/瑙嗛</view>
<!-- 褰撳墠鍒嗙被鐨勪笂浼犲尯鍩� -->
<view class="upload-area">
<view class="upload-buttons">
<u-button type="primary"
@click="chooseMedia('image')"
:loading="uploading"
- :disabled="getCurrentFiles().length >= uploadConfig.limit"
+ :disabled="beforeModelValue.length >= uploadConfig.limit"
:customStyle="{ marginRight: '10px', flex: 1 }">
<u-icon name="camera"
size="18"
@@ -94,7 +78,7 @@
<u-button type="success"
@click="chooseMedia('video')"
:loading="uploading"
- :disabled="getCurrentFiles().length >= uploadConfig.limit"
+ :disabled="beforeModelValue.length >= uploadConfig.limit"
:customStyle="{ flex: 1 }">
<uni-icons type="videocam"
size="18"
@@ -111,9 +95,9 @@
activeColor="#409eff"></u-line-progress>
</view>
<!-- 褰撳墠鍒嗙被鐨勬枃浠跺垪琛� -->
- <view v-if="getCurrentFiles().length > 0"
+ <view v-if="beforeModelValue.length > 0"
class="file-list">
- <view v-for="(file, index) in getCurrentFiles()"
+ <view v-for="(file, index) in beforeModelValue"
:key="index"
class="file-item">
<view class="file-preview-container">
@@ -143,17 +127,15 @@
</view>
</view>
</view>
- <view v-if="getCurrentFiles().length === 0"
+ <view v-if="beforeModelValue.length === 0"
class="empty-state">
- <text>璇烽�夋嫨瑕佷笂浼犵殑{{ getUploadTypeText() }}鍥剧墖鎴栬棰�</text>
+ <text>璇烽�夋嫨瑕佷笂浼犵殑鍥剧墖鎴栬棰�</text>
</view>
</view>
<!-- 缁熻淇℃伅 -->
<view class="upload-summary">
<text class="summary-text">
- 鐢熶骇鍓�: {{ beforeModelValue.length }}涓枃浠� |
- 鐢熶骇涓�: {{ afterModelValue.length }}涓枃浠� |
- 鐢熶骇鍚�: {{ issueModelValue.length }}涓枃浠�
+ 宸蹭笂浼�: {{ beforeModelValue.length }}涓枃浠�
</text>
</view>
</view>
@@ -198,12 +180,7 @@
const uploadProgress = ref(0);
// 涓変釜鍒嗙被鐨勪笂浼犵姸鎬�
- const beforeModelValue = ref([]); // 鐢熶骇鍓�
- const afterModelValue = ref([]); // 鐢熶骇涓�
- const issueModelValue = ref([]); // 鐢熶骇鍚�
-
- // 褰撳墠婵�娲荤殑涓婁紶绫诲瀷
- const currentUploadType = ref("before"); // 'before', 'after', 'issue'
+ const beforeModelValue = ref([]); // 宸℃鐓х墖
// 寮傚父鐘舵��
const hasException = ref(null); // null: 鏈�夋嫨, true: 瀛樺湪寮傚父, false: 姝e父
@@ -258,24 +235,25 @@
});
};
- // 鏍规嵁鐢ㄦ埛瑕佹眰鏄犲皠锛欰fterDTO(鐢熶骇鍓�), DTO(鐢熶骇涓�), BeforeDTO(鐢熶骇鍚�)
+ // 鏍规嵁鐢ㄦ埛瑕佹眰鏄犲皠锛氫粎淇濈暀鐢熶骇鍓�
if (
info.commonFileListAfterVO &&
Array.isArray(info.commonFileListAfterVO)
) {
beforeModelValue.value = mapFiles(info.commonFileListAfterVO);
- }
- console.log(beforeModelValue.value, "beforeModelValue");
-
- if (info.commonFileListVO && Array.isArray(info.commonFileListVO)) {
- afterModelValue.value = mapFiles(info.commonFileListVO);
- }
- if (
+ } else if (
+ info.commonFileListVO &&
+ Array.isArray(info.commonFileListVO)
+ ) {
+ beforeModelValue.value = mapFiles(info.commonFileListVO);
+ } else if (
info.commonFileListBeforeVO &&
Array.isArray(info.commonFileListBeforeVO)
) {
- issueModelValue.value = mapFiles(info.commonFileListBeforeVO);
+ beforeModelValue.value = mapFiles(info.commonFileListBeforeVO);
}
+
+ console.log(beforeModelValue.value, "beforeModelValue");
// 濡傛灉鏈夊紓甯告弿杩帮紝涔熸仮澶�
if (info.abnormalDescription) {
@@ -293,12 +271,7 @@
}
// 鑷姩鍏滃簳锛氬鏋滃瓨鍦ㄥ凡涓婁紶鏂囦欢锛屽垯蹇呯劧鏄紓甯哥姸鎬侊紝纭繚 UI 姝e父鏄剧ず
- if (
- !hasException.value &&
- (beforeModelValue.value.length > 0 ||
- afterModelValue.value.length > 0 ||
- issueModelValue.value.length > 0)
- ) {
+ if (!hasException.value && beforeModelValue.value.length > 0) {
hasException.value = true;
}
} catch (e) {
@@ -310,39 +283,6 @@
// 杩斿洖涓婁竴椤�
const goBack = () => {
uni.navigateBack();
- };
-
- // 鍒囨崲涓婁紶绫诲瀷
- const switchUploadType = type => {
- currentUploadType.value = type;
- };
-
- // 鑾峰彇褰撳墠鍒嗙被鐨勬枃浠跺垪琛�
- const getCurrentFiles = () => {
- switch (currentUploadType.value) {
- case "before":
- return beforeModelValue.value || [];
- case "after":
- return afterModelValue.value || [];
- case "issue":
- return issueModelValue.value || [];
- default:
- return [];
- }
- };
-
- // 鑾峰彇涓婁紶绫诲瀷鏂囨湰
- const getUploadTypeText = () => {
- switch (currentUploadType.value) {
- case "before":
- return "鐢熶骇鍓�";
- case "after":
- return "鐢熶骇涓�";
- case "issue":
- return "鐢熶骇鍚�";
- default:
- return "";
- }
};
// 璁剧疆寮傚父鐘舵��
@@ -361,12 +301,8 @@
hasException: hasException.value,
inspectionResult: hasException.value ? 0 : 1, // 0-寮傚父锛�1-姝e父
commonFileListAfterDTO: beforeModelValue.value,
- commonFileListDTO: afterModelValue.value,
- commonFileListBeforeDTO: issueModelValue.value,
uploadedFiles: {
before: beforeModelValue.value,
- after: afterModelValue.value,
- issue: issueModelValue.value,
},
};
@@ -398,11 +334,7 @@
// 濡傛灉鏄紓甯哥姸鎬侊紝妫�鏌ユ槸鍚︽湁涓婁紶鏂囦欢鍜屾弿杩�
if (hasException.value === true) {
- const totalFiles =
- beforeModelValue.value.length +
- afterModelValue.value.length +
- issueModelValue.value.length;
- if (totalFiles === 0) {
+ if (beforeModelValue.value.length === 0) {
uni.showToast({
title: "璇蜂笂浼犲紓甯哥収鐗�",
icon: "none",
@@ -426,11 +358,7 @@
});
// 鎸夌収閫昏緫鍚堝苟鎵�鏈夊垎绫荤殑鏂囦欢鐢ㄤ簬鎻愬彇ID
- const allFiles = [
- ...beforeModelValue.value,
- ...afterModelValue.value,
- ...issueModelValue.value,
- ];
+ const allFiles = [...beforeModelValue.value];
// 浼犵粰鍚庣鐨勪复鏃舵枃浠禝D鍒楄〃
let tempFileIds = [];
@@ -444,8 +372,6 @@
const submitData = {
...taskInfo.value,
commonFileListAfterDTO: beforeModelValue.value, // 鐢熶骇鍓�
- commonFileListDTO: afterModelValue.value, // 鐢熶骇涓�
- commonFileListBeforeDTO: issueModelValue.value, // 鐢熶骇鍚�
hasException: hasException.value,
inspectionResult: hasException.value ? 0 : 1, // 0-寮傚父锛�1-姝e父
abnormalDescription: abnormalDescription.value,
@@ -498,7 +424,7 @@
// 鎷嶇収/鎷嶈棰�
const chooseMedia = type => {
- if (getCurrentFiles().length >= uploadConfig.limit) {
+ if (beforeModelValue.value.length >= uploadConfig.limit) {
uni.showToast({
title: `鏈�澶氬彧鑳介�夋嫨${uploadConfig.limit}涓枃浠禶,
icon: "none",
@@ -506,7 +432,7 @@
return;
}
- const remaining = uploadConfig.limit - getCurrentFiles().length;
+ const remaining = uploadConfig.limit - beforeModelValue.value.length;
// 浼樺厛浣跨敤 chooseMedia
if (typeof uni.chooseMedia === "function") {
@@ -612,7 +538,7 @@
Authorization: `Bearer ${token}`,
},
formData: {
- type: getTabType(),
+ type: 10,
},
success: res => {
try {
@@ -638,14 +564,8 @@
status: "success",
};
- // 鏍规嵁褰撳墠绫诲瀷娣诲姞鍒板搴旀暟缁�
- if (currentUploadType.value === "before") {
- beforeModelValue.value.push(uploadedFile);
- } else if (currentUploadType.value === "after") {
- afterModelValue.value.push(uploadedFile);
- } else if (currentUploadType.value === "issue") {
- issueModelValue.value.push(uploadedFile);
- }
+ // 浠呮坊鍔犲埌 beforeModelValue
+ beforeModelValue.value.push(uploadedFile);
uni.showToast({ title: "涓婁紶鎴愬姛", icon: "success" });
} else {
@@ -670,24 +590,9 @@
});
};
- // 鑾峰彇type鍊�
- const getTabType = () => {
- switch (currentUploadType.value) {
- case "before":
- return 10;
- case "after":
- return 11;
- case "issue":
- return 12;
- default:
- return 10;
- }
- };
-
// 鍒犻櫎鏂囦欢
const removeFile = index => {
- const files = getCurrentFiles();
- files.splice(index, 1);
+ beforeModelValue.value.splice(index, 1);
};
</script>
--
Gitblit v1.9.3