From ad9726ecf2e02f4666cd1d554d6a4748a963c183 Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期一, 18 五月 2026 13:54:39 +0800
Subject: [PATCH] 设备巡检上传接口报错问题,以及设备保养上传问题,上传组件更新
---
src/pages/equipmentManagement/upkeep/maintain.vue | 97 ++++++++----------------------------------------
1 files changed, 16 insertions(+), 81 deletions(-)
diff --git a/src/pages/equipmentManagement/upkeep/maintain.vue b/src/pages/equipmentManagement/upkeep/maintain.vue
index f86006c..3abfc58 100644
--- a/src/pages/equipmentManagement/upkeep/maintain.vue
+++ b/src/pages/equipmentManagement/upkeep/maintain.vue
@@ -100,81 +100,9 @@
<!-- 涓婁紶闄勪欢 -->
<u-form-item v-if="form.status == '1'"
label="淇濆吇闄勪欢"
+ prop="storageBlobDTOs"
border-bottom>
- <view class="simple-upload-area">
- <view class="upload-buttons">
- <u-button type="primary"
- @click="chooseMedia('image')"
- :loading="uploading"
- :disabled="uploadFiles.length >= uploadConfig.limit"
- :customStyle="{ marginRight: '10px', flex: 1 }">
- <u-icon name="camera"
- size="18"
- color="#fff"
- style="margin-right: 5px;"></u-icon>
- {{ uploading ? '涓婁紶涓�...' : '鎷嶇収' }}
- </u-button>
- <!-- <u-button type="success"
- @click="chooseMedia('video')"
- :loading="uploading"
- :disabled="uploadFiles.length >= uploadConfig.limit"
- :customStyle="{ flex: 1 }">
- <uni-icons type="videocam"
- name="videocam"
- size="18"
- color="#fff"
- style="margin-right: 5px;"></uni-icons>
- {{ uploading ? '涓婁紶涓�...' : '鎷嶈棰�' }}
- </u-button> -->
- </view>
- <!-- 涓婁紶杩涘害 -->
- <view v-if="uploading"
- class="upload-progress">
- <u-line-progress :percentage="uploadProgress"
- :showText="true"
- activeColor="#409eff"></u-line-progress>
- </view>
- <!-- 涓婁紶鐨勬枃浠跺垪琛� -->
- <view v-if="uploadFiles.length > 0"
- class="file-list">
- <view v-for="(file, index) in uploadFiles"
- :key="index"
- class="file-item">
- <view class="file-preview-container">
- <!-- {{formatFileUrl(file.url)}} -->
- <image v-if="file.type === 'image' || isImageFile(file)"
- :src="formatFileUrl(file.url || file.tempFilePath || file.path || file.downloadUrl)"
- class="file-preview"
- mode="aspectFill" />
- <view v-else-if="file.type === 'video'"
- class="video-preview">
- <uni-icons type="videocam"
- name="videocam"
- size="18"
- color="#fff"
- style="margin-right: 5px;"></uni-icons>
- <text class="video-text">瑙嗛</text>
- </view>
- <!-- 鍒犻櫎鎸夐挳 -->
- <view class="delete-btn"
- @click="removeFile(index)">
- <u-icon name="close"
- size="12"
- color="#fff"></u-icon>
- </view>
- </view>
- <view class="file-info">
- <text class="file-name">{{ file.bucketFilename || file.name || (file.type === 'image' ? '鍥剧墖' : '瑙嗛')
- }}</text>
- <text class="file-size">{{ formatFileSize(file.size) }}</text>
- </view>
- </view>
- </view>
- <view v-if="uploadFiles.length === 0"
- class="empty-state">
- <text>璇烽�夋嫨瑕佷笂浼犵殑淇濆吇鍥剧墖</text>
- </view>
- </view>
+ <CommonUpload v-model="form.storageBlobDTOs" />
</u-form-item>
<!-- 鎻愪氦鎸夐挳 -->
<view class="footer-btns">
@@ -235,6 +163,7 @@
import { ref, onMounted, reactive } from "vue";
import { onShow } from "@dcloudio/uni-app";
import PageHeader from "@/components/PageHeader.vue";
+ import CommonUpload from "@/components/CommonUpload.vue";
import { addMaintenance } from "@/api/equipmentManagement/upkeep";
import { getSparePartsList } from "@/api/equipmentManagement/repair";
import useUserStore from "@/store/modules/user";
@@ -275,7 +204,6 @@
const sparePartsQtyRaw = ref("");
// 鏂囦欢涓婁紶鐩稿叧
- const uploadFiles = ref([]);
const uploading = ref(false);
const uploadProgress = ref(0);
const number = ref(0);
@@ -316,6 +244,7 @@
maintenanceResult: undefined, // 淇濆吇缁撴灉
maintenanceActuallyTime: dayjs().format("YYYY-MM-DD HH:mm:ss"), // 瀹為檯淇濆吇鏃ユ湡锛堝彧鏄剧ず鏃ユ湡锛�
sparePartsIds: undefined, // 璁惧澶囦欢ID
+ storageBlobDTOs: [], // 淇濆吇闄勪欢
});
// 娓呴櫎琛ㄥ崟鏍¢獙鐘舵��
@@ -330,6 +259,7 @@
maintenanceResult: undefined,
maintenanceActuallyTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
sparePartsIds: [],
+ storageBlobDTOs: [],
};
maintenancestatusText.value = "";
selectedSpareParts.value = [];
@@ -374,7 +304,11 @@
} else if (form.value.maintenanceResult === undefined) {
isValid = false;
errorMessage = "璇烽�夋嫨淇濆吇缁撴灉";
- } else if (uploadFiles.value.length === 0 && form.value.status == "1") {
+ } else if (
+ (!form.value.storageBlobDTOs ||
+ form.value.storageBlobDTOs.length === 0) &&
+ form.value.status == "1"
+ ) {
isValid = false;
errorMessage = "璇蜂笂浼犱繚鍏荤収鐗�";
}
@@ -436,7 +370,6 @@
const submitData = {
...form.value,
- imagesFile: form.value.status == "1" ? uploadFiles.value : [],
sparePartsIds: spareIds.length ? spareIds.join(",") : "",
sparePartsQty: spareIds.length
? spareIds.map(pid => sparePartQtyMap?.[pid] ?? 1).join(",")
@@ -605,7 +538,7 @@
// 閲嶇疆閫夋嫨鐨勫浠�
selectedSpareParts.value = [];
// 閲嶇疆涓婁紶鐨勬枃浠�
- uploadFiles.value = [];
+ form.value.storageBlobDTOs = [];
uploading.value = false;
uploadProgress.value = 0;
maintenancestatusText.value = "";
@@ -655,8 +588,10 @@
sparePartsIds.value = itemData.sparePartsIds;
// 濉厖闄勪欢鏁版嵁
- if (itemData.files && itemData.files.length > 0) {
- uploadFiles.value = itemData.files.map(file => ({
+ if (itemData.storageBlobVOs && itemData.storageBlobVOs.length > 0) {
+ form.value.storageBlobDTOs = itemData.storageBlobVOs;
+ } else if (itemData.files && itemData.files.length > 0) {
+ form.value.storageBlobDTOs = itemData.files.map(file => ({
id: file.id,
name: file.name || file.bucketFilename || file.originalFilename,
url: file.url || file.downloadUrl,
@@ -668,7 +603,7 @@
size: file.size || file.byteSize,
}));
} else if (itemData.uploadFiles && itemData.uploadFiles.length > 0) {
- uploadFiles.value = itemData.uploadFiles.map(file => ({
+ form.value.storageBlobDTOs = itemData.uploadFiles.map(file => ({
id: file.id,
name: file.name || file.bucketFilename || file.originalFilename,
url: file.url || file.downloadUrl || file.tempFilePath || file.path,
--
Gitblit v1.9.3