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/upload.vue | 153 +++++++++-----------------------------------------
1 files changed, 29 insertions(+), 124 deletions(-)
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