From 0a48655d2162b709ecb80d249a4085971add6140 Mon Sep 17 00:00:00 2001
From: Houjie <714924425@qq.com>
Date: 星期一, 07 七月 2025 17:26:30 +0800
Subject: [PATCH] 企业微信

---
 pages/device/deviceWebDeils/deviceWebDeils.vue |  297 ++++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 254 insertions(+), 43 deletions(-)

diff --git a/pages/device/deviceWebDeils/deviceWebDeils.vue b/pages/device/deviceWebDeils/deviceWebDeils.vue
index f4502ee..dceca9c 100644
--- a/pages/device/deviceWebDeils/deviceWebDeils.vue
+++ b/pages/device/deviceWebDeils/deviceWebDeils.vue
@@ -14,46 +14,65 @@
 
 			<uni-forms ref="form" :modelValue="formData" validate-trigger="bind" err-show-type="undertext">
 				<uni-group top="1">
-					
-				<uni-forms-item  :label-width="100" required name="num" label="璁惧缂栧彿:">
-					<uni-easyinput v-model="formData.equipmentCode" :disabled="true" />
-				</uni-forms-item>
-				
-				<uni-forms-item :label-width="100" name="remark" label="璁惧鍚嶇О:">
-					<uni-easyinput v-model="formData.equipmentName" :disabled="true" />
-				</uni-forms-item>
-				<!-- <uni-forms-item :label-width="100" name="outNum" label="鍏抽敭璁惧鏍囪瘑:">
+
+					<uni-forms-item :label-width="100" required name="num" label="璁惧缂栧彿:">
+						<uni-easyinput v-model="formData.equipmentCode" :disabled="true" />
+					</uni-forms-item>
+
+					<uni-forms-item :label-width="100" name="remark" label="璁惧鍚嶇О:">
+						<uni-easyinput v-model="formData.equipmentName" :disabled="true" />
+					</uni-forms-item>
+					<!-- <uni-forms-item :label-width="100" name="outNum" label="鍏抽敭璁惧鏍囪瘑:">
 					<uni-easyinput v-model="formData.equipmentImportance" :disabled="true" />
 				</uni-forms-item> -->
-				<view class="text-gray margin-bottom-lg">鈥斺�斺�斺�斺�斺�斺�斺�斺�斺�� 鍩烘湰淇℃伅 鈥斺�斺�斺�斺�斺�斺�斺�斺�斺��</view>
-				<uni-forms-item  :label-width="100" name="taskCode" label="缁翠慨鐘舵��:">
-					<uni-easyinput :disabled="true" v-model="formData.repairStatus_dictText" />
-				</uni-forms-item>
-				<uni-forms-item :label-width="100" name="endLocation" label="淇濆吇鐘舵��:">
-					<uni-easyinput :disabled="true" v-model="formData.maintenanceStatus_dictText" />
-				
-				</uni-forms-item>
-				<uni-forms-item :label-width="100" name="endLocation" label="浣跨敤杞﹂棿:">
-					<uni-easyinput :disabled="true" v-model="formData.orgId_dictText" />
-				
-				</uni-forms-item>
-				
-				<uni-forms-item  :label-width="100" name="endLocation" label="瀹夎浣嶇疆:">
-					<uni-easyinput :disabled="true" v-model="formData.installationPosition" />
-				</uni-forms-item>
-				<uni-forms-item  :label-width="100" name="endLocation" label="鎶�鏈姸鎬�:">
-					<uni-easyinput :disabled="true" v-model="formData.technologyStatus_dictText" />
-				</uni-forms-item>
-				<uni-forms-item  :label-width="100" name="endLocation" label="璁惧绠$悊鍛�:">
-					<uni-easyinput :disabled="true" v-model="formData.equipmentManager_dictText" />
-				</uni-forms-item>
-				<uni-forms-item  :label-width="100" name="endLocation" label="鍑哄巶鏃ユ湡:">
-					<uni-easyinput :disabled="true" v-model="formData.leaveFactoryDate" />
-				</uni-forms-item>
+					<view class="text-gray margin-bottom-lg">鈥斺�斺�斺�斺�斺�斺�斺�斺�斺�� 鍩烘湰淇℃伅 鈥斺�斺�斺�斺�斺�斺�斺�斺�斺��</view>
+					<uni-forms-item :label-width="100" name="taskCode" label="缁翠慨鐘舵��:">
+						<uni-easyinput :disabled="true" v-model="formData.repairStatus_dictText" />
+					</uni-forms-item>
+					<uni-forms-item :label-width="100" name="endLocation" label="淇濆吇鐘舵��:">
+						<uni-easyinput :disabled="true" v-model="formData.maintenanceStatus_dictText" />
+
+					</uni-forms-item>
+					<uni-forms-item :label-width="100" name="endLocation" label="浣跨敤杞﹂棿:">
+						<uni-easyinput :disabled="true" v-model="formData.orgId_dictText" />
+
+					</uni-forms-item>
+
+					<uni-forms-item :label-width="100" name="endLocation" label="瀹夎浣嶇疆:">
+						<uni-easyinput :disabled="true" v-model="formData.installationPosition" />
+					</uni-forms-item>
+					<uni-forms-item :label-width="100" name="endLocation" label="鎶�鏈姸鎬�:">
+						<uni-easyinput :disabled="true" v-model="formData.technologyStatus_dictText" />
+					</uni-forms-item>
+					<uni-forms-item :label-width="100" name="endLocation" label="璁惧绠$悊鍛�:">
+						<uni-easyinput :disabled="true" v-model="formData.equipmentManager_dictText" />
+					</uni-forms-item>
+					<uni-forms-item :label-width="100" name="endLocation" label="鍑哄巶鏃ユ湡:">
+						<uni-easyinput :disabled="true" v-model="formData.leaveFactoryDate" />
+					</uni-forms-item>
 				</uni-group>
 			</uni-forms>
+			<view class="file-list margin-sm">
+				<view class="file-item" v-for="(file, index) in this.selectedFiles" :key="index">
+					<view class="file-icon">
+						<!-- 鏂囦欢鍥炬爣 -->
+						<image src="/static/icon_file.png" style="height: 25px;  width: 25px; margin-right: 10px;"
+							mode='aspectFit' class="zai-logo "></image>
+
+					</view>
+					<view class="file-name">
+						<!-- 鏂囦欢鍚� -->
+						{{file.fileName}}
+					</view>
+					<view class="file-actions">
+						<!-- 涓嬭浇鎸夐挳 -->
+						<image v-show="showBtn" src="/static/icon_down.png" @click="downloadFile(file)"
+							style="height: 25px;  width: 25px; margin-right: 10px;"></image>
+					</view>
+				</view>
+			</view>
 			<view class="flex  margin-bottom-xs">
-				<button class="flex-sub  cu-btn bg-blue margin-sm   lg" hover-class="is-hover"
+				<button v-if="authIncludes('eam:reportRepair:add')"  class="flex-sub  cu-btn bg-blue margin-sm   lg" hover-class="is-hover"
 					@click="goReportRepair()">鎶ヤ慨</button>
 				<button class="flex-sub  cu-btn bg-blue margin-sm   lg" hover-class="is-hover"
 					@click="goCheck()">鐐规</button>
@@ -71,15 +90,24 @@
 		stringify
 	} from "querystring";
 	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
+	import {
+		saveAs
+	} from 'file-saver'; // 寮曞叆 file-saver 搴�
 	export default {
 		mixins: [MescrollMixin], // 浣跨敤mixin
 		data() {
 			return {
 
-				formData: {},
+				formData: {
+					fileLists: []
+				},
+				fileLists: [],
 				NavBarColor: this.NavBarColor,
 				url: {
-					stallList: "/eam/equipment/queryById"
+					stallList: "/eam/equipment/queryById",
+					add: 'eam/equipmentAttachment/add',
+					upload: "/eam/sysFiles/batch_upload",
+					downloadFile: 'eam/equipmentAttachment/downloadFile'
 				},
 				id: '',
 				upOption: {
@@ -105,7 +133,11 @@
 				msg1Title: ""
 			}
 		},
+		
 		computed: {
+			authList() {
+				return this.$store.getters.getAuth || []
+			},
 			top() {
 				return this.CustomBar * 2 + 160
 			},
@@ -120,11 +152,6 @@
 		onLoad(options) {
 			const decodedEquipmentId = decodeURIComponent(options.equipmentId);
 			this.id = decodedEquipmentId;
-			// const data = options.query;
-			// this.id = JSON.parse(data).equipmentId;
-			// console.log(data)
-			// this.id = options.equipmentId;
-			// console.log(options)
 			console.log(this.id)
 			if (!this.id) {
 				uni.showModal({
@@ -157,7 +184,192 @@
 		},
 		created() {},
 		methods: {
+			authIncludes(code) {
+				return this.authList.some(auth => auth.action === code)
+			},
+			downloadFile(item) {
+				uni.showModal({
+					title: '鎻愮ず',
+					content: '纭瑕佷笅杞藉悧',
+					cancelText: '鍙栨秷',
+					confirmText: '纭',
+					success: res => {
+						if (res.confirm) {
+							this.downFile(item)
+						}
+					}
+				})
 
+			},
+
+
+			downFile(item) {
+				this.$http.download(this.url.downloadFile, {
+					params: {
+						id: item.id
+					},
+					responseType: 'blob' // 纭繚鍝嶅簲绫诲瀷涓� blob
+				}).then(response => {
+					console.log('Response:', response); // 鏌ョ湅瀹屾暣鍝嶅簲缁撴瀯
+
+					// 鑾峰彇 tempFilePath锛圔lob URL锛�
+					const tempFilePath = response.tempFilePath;
+
+					if (!tempFilePath) {
+						uni.showToast({
+							title: '鏂囦欢涓嬭浇澶辫触',
+							icon: 'none'
+						});
+						return;
+					}
+
+					let fileName = item.fileName;
+
+					// 鍒涘缓 <a> 鏍囩骞惰Е鍙戜笅杞�
+					const link = document.createElement('a');
+					link.href = tempFilePath;
+					link.setAttribute('download', fileName);
+					link.style.display = 'none';
+
+					document.body.appendChild(link);
+					link.click();
+
+					// 娓呯悊璧勬簮
+					document.body.removeChild(link);
+
+				}).catch(err => {
+					console.error('Download error:', err);
+					uni.showToast({
+						title: '鏂囦欢涓嬭浇澶辫触',
+						icon: 'none'
+					});
+				});
+			},
+			getFileList() {
+				this.$http.get(this.url.fileList, {
+					params: {
+						equipmentId: this.id,
+						pageNo: 1,
+						pageSize: 999,
+						column: 'createTime',
+						order: 'desc'
+					},
+				}).then(res => {
+					if (res.data.success) {
+						this.selectedFiles = res.data.result.records || [];
+
+					}
+				}).catch(() => {
+					uni.showToast({
+						title: '鑾峰彇鏂囦欢鍒楄〃澶辫触',
+						icon: 'none'
+					});
+				});
+			},
+			uploadFail(e) {
+				console.log('涓婁紶澶辫触锛�', e)
+			},
+
+
+
+			onFileSelect(e) {
+				const tempFilePaths = e.tempFilePaths;
+
+				uni.showLoading({
+					title: '涓婁紶涓�...'
+				});
+
+				const uploadPromises = tempFilePaths.map((filePath, index) => {
+					return new Promise((resolve, reject) => {
+						this.$http.upload(this.url.upload, {
+								filePath: filePath,
+								name: 'file'
+							})
+							.then(uploadRes => {
+								const serverFile = uploadRes.data.result[0];
+								console.log(serverFile);
+								// 鎻愬彇fileSuffix骞舵嫾鎺�
+								if (serverFile.fileSuffix && serverFile.fileName && !serverFile
+									.fileName.includes('.')) {
+									serverFile.fileName += '.' + serverFile.fileSuffix;
+								}
+								this.fileLists = [];
+								// 闃叉閲嶅娣诲姞锛堟牴鎹� id 鎴� fileName 鍒ゆ柇锛�
+								if (!this.fileLists.some(file => file.id === serverFile.id)) {
+									this.fileLists.push(serverFile);
+								}
+								resolve();
+							})
+							.catch(err => {
+								console.error(`鏂囦欢 ${index + 1} 涓婁紶澶辫触`, err);
+								uni.showToast({
+									title: `绗� ${index + 1} 涓枃浠朵笂浼犲け璐,
+									icon: 'none'
+								});
+								reject(err);
+							});
+					});
+				});
+
+				Promise.all(uploadPromises)
+					.then(() => {
+						uni.hideLoading();
+						uni.showToast({
+							title: '鍏ㄩ儴涓婁紶鎴愬姛锛屾鍦ㄦ彁浜�...'
+						});
+						this.submitFileList(); // 鑷姩鎻愪氦鎵�鏈夋枃浠�
+					})
+					.catch(() => {
+						uni.hideLoading();
+						uni.showToast({
+							title: '閮ㄥ垎涓婁紶澶辫触',
+							icon: 'none'
+						});
+					});
+			},
+			// 鏂囦欢鍒犻櫎鍥炶皟
+			onFileDelete(e) {
+				console.log('鍒犻櫎鏂囦欢:', e.index);
+			},
+
+			// 鍒犻櫎鍗曚釜鏂囦欢
+			deleteFile(index) {
+				this.fileLists.splice(index, 1);
+			},
+
+
+			submitFileList() {
+				if (!this.fileLists.length) {
+					uni.showToast({
+						title: '娌℃湁鍙彁浜ょ殑鏂囦欢',
+						icon: 'none'
+					});
+					return;
+				}
+				console.log(this.fileLists)
+				this.$http.post(this.url.add, {
+					equipmentId: this.id,
+					fileList: this.fileLists
+				}).then(res => {
+					if (res.data.success) {
+						uni.showToast({
+							title: '鎻愪氦鎴愬姛'
+						});
+						this.getFileList();
+					} else {
+						uni.showToast({
+							title: '鎻愪氦澶辫触',
+							icon: 'none'
+						});
+					}
+				}).catch(err => {
+					uni.showToast({
+						title: '鎻愪氦寮傚父',
+						icon: 'none'
+					});
+					console.error('鎻愪氦澶辫触:', err);
+				});
+			},
 			goHome() {
 				uni.reLaunch({
 					url: '/pages/index/index'
@@ -167,7 +379,6 @@
 			 * 鎶ヤ慨
 			 */
 			goReportRepair() {
-				console.log('getSera 鏂规硶琚皟鐢�');
 				uni.redirectTo({
 					url: `/pages/reportRepair/reportRepair?equipmentId=${encodeURIComponent(this.id)}`
 				});

--
Gitblit v1.9.3