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 |  390 +++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 315 insertions(+), 75 deletions(-)

diff --git a/pages/device/deviceWebDeils/deviceWebDeils.vue b/pages/device/deviceWebDeils/deviceWebDeils.vue
index b2519bf..dceca9c 100644
--- a/pages/device/deviceWebDeils/deviceWebDeils.vue
+++ b/pages/device/deviceWebDeils/deviceWebDeils.vue
@@ -2,13 +2,12 @@
 	<view class="container">
 		<cu-custom :bgColor="NavBarColor" :isBack="true" backRouterName="productionTask">
 			<block slot="backText">杩斿洖</block>
-			<!-- <cu-custom :bgColor="NavBarColor" backRouterName="index">
-			<block slot="right">
-				<view @tap="$debounce(BackPage)">
-					<view class="cuIcon-back back">杩斿洖</view>
-				</view>
-			</block> -->
 			<block slot="content">璁惧璇︽儏</block>
+			<block slot="right">
+				<view @click="goHome">
+					<image class="search" src="/static/icon/icon_home.png" style="width: 25px; height: 25px;" alt="" />
+				</view>
+			</block>
 		</cu-custom>
 		<view class="container">
 
@@ -16,58 +15,71 @@
 			<uni-forms ref="form" :modelValue="formData" validate-trigger="bind" err-show-type="undertext">
 				<uni-group top="1">
 
-					<uni-forms-item name="num" label="璁惧鍥剧墖:">
-						<image style="height: 100px; width: 300px;"
-							:src="formData.equipmentImagel?formData.equipmentImage:'/static/zhanwei.png'"></image>
-					</uni-forms-item>
-					<uni-forms-item required name="num" 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 name="remark" label="璁惧鍚嶇О:">
+					<uni-forms-item :label-width="100" name="remark" label="璁惧鍚嶇О:">
 						<uni-easyinput v-model="formData.equipmentName" :disabled="true" />
 					</uni-forms-item>
-					<uni-forms-item name="remark" label="璁惧鍨嬪彿:">
-						<uni-easyinput v-model="formData.equipmentModel" :disabled="true" />
-					</uni-forms-item>
-					<uni-forms-item name="outNum" label="璁惧瑙勬牸:">
-						<uni-easyinput v-model="formData.equipmentSpecification" :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 name="taskCode" label="璁惧鍒嗙被:">
-						<uni-easyinput :disabled="true" v-model="formData.equipmentCategory" />
+					<uni-forms-item :label-width="100" name="taskCode" label="缁翠慨鐘舵��:">
+						<uni-easyinput :disabled="true" v-model="formData.repairStatus_dictText" />
 					</uni-forms-item>
-					<uni-forms-item name="endLocation" label="鍑哄巶鏃ユ湡:">
-						<uni-easyinput :disabled="true" v-model="formData.leaveFactoryDate" />
+					<uni-forms-item :label-width="100" name="endLocation" label="淇濆吇鐘舵��:">
+						<uni-easyinput :disabled="true" v-model="formData.maintenanceStatus_dictText" />
 
 					</uni-forms-item>
-					<uni-forms-item name="endLocation" label="楠屾敹鏃ユ湡:">
-						<uni-easyinput :disabled="true" v-model="formData.acceptanceCheckDate" />
+					<uni-forms-item :label-width="100" name="endLocation" label="浣跨敤杞﹂棿:">
+						<uni-easyinput :disabled="true" v-model="formData.orgId_dictText" />
 
 					</uni-forms-item>
 
-					<uni-forms-item name="endLocation" label="瀹夎浣嶇疆:">
+					<uni-forms-item :label-width="100" name="endLocation" label="瀹夎浣嶇疆:">
 						<uni-easyinput :disabled="true" v-model="formData.installationPosition" />
 					</uni-forms-item>
-					<uni-forms-item name="endLocation" label="璧勪骇鐘舵��:">
-						<uni-easyinput :disabled="true" v-model="formData.assetStatus" />
+					<uni-forms-item :label-width="100" name="endLocation" label="鎶�鏈姸鎬�:">
+						<uni-easyinput :disabled="true" v-model="formData.technologyStatus_dictText" />
 					</uni-forms-item>
-					<uni-forms-item name="endLocation" label="璁惧绠$悊鍛�:">
-						<uni-easyinput :disabled="true" v-model="formData.equipmentManager" />
+					<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 class="flex">
-				<button class="flex-sub  cu-btn bg-blue margin-sm  padding-sm lg" hover-class="is-hover"
-					@click="getSera()">鐐规</button>
-				<button class="flex-sub  cu-btn bg-blue margin-sm  padding-sm lg" hover-class="is-hover"
-					@click="resetTask">淇濆吇</button>
-				<button class="flex-sub  cu-btn bg-blue margin-sm  padding-sm lg" hover-class="is-hover"
-					@click="resetTask">缁翠慨</button>
-				<button class="flex-sub  cu-btn bg-blue margin-sm  padding-sm lg" hover-class="is-hover"
-					@click="resetTask">鍛ㄥ吇</button>
+					</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 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>
+				<button class="flex-sub  cu-btn bg-blue margin-sm   lg" hover-class="is-hover"
+					@click="goBaoZhou()">鍛ㄤ繚</button>
+				<button class="flex-sub  cu-btn bg-blue margin-sm   lg" hover-class="is-hover"
+					@click="goMaintenance()">缁翠慨</button>
 			</view>
 		</view>
 	</view>
@@ -78,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: {
@@ -112,7 +133,11 @@
 				msg1Title: ""
 			}
 		},
+		
 		computed: {
+			authList() {
+				return this.$store.getters.getAuth || []
+			},
 			top() {
 				return this.CustomBar * 2 + 160
 			},
@@ -127,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({
@@ -164,41 +184,261 @@
 		},
 		created() {},
 		methods: {
-			getSera() {
-				console.log('getSera 鏂规硶琚皟鐢�');
-				uni.navigateTo({
-					url: '/pages/TaskManager/TaskManagerList'
+			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'
+					});
 				});
 			},
-		upCallback() {
-			console.log("id", this.id)
-			this.$http.get(this.url.stallList, {
-				params: {
-					pageNo: 999,
-					pageSize: 1,
-					order: 'asc',
-					column: 'createTime',
-					id: this.id
-				},
+			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 || [];
 
-			}).then(res => {
-				this.announcement1 = res.data.result
-				console.log("url", res)
-				//璁剧疆鍒楄〃鏁版嵁
-				if (res.data.success) {
-					console.log("res", res.data.result.equipmentCode)
-					this.formData = this.announcement1
+					}
+				}).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;
 				}
-			}).catch(() => {
-				//鑱旂綉澶辫触, 缁撴潫鍔犺浇
-			})
-		},
+				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'
+				})
+			},
+			/**
+			 * 鎶ヤ慨
+			 */
+			goReportRepair() {
+				uni.redirectTo({
+					url: `/pages/reportRepair/reportRepair?equipmentId=${encodeURIComponent(this.id)}`
+				});
+			},
+			/**
+			 * 鐐规
+			 */
+			goCheck() {
+				uni.redirectTo({
+					// url: '/pages/checkList/checkList',
+					url: `/pages/checkList/checkList?equipmentId=${encodeURIComponent(this.id)}`
+				});
+			},
+			/**
+			 * 鍛ㄤ繚
+			 */
+			goBaoZhou() {
+				uni.redirectTo({
+					// url: '/pages/baoZhou/baoZhou',
+					url: `/pages/baoZhou/baoZhou?equipmentId=${encodeURIComponent(this.id)}`
+				});
+			},
+			/**
+			 * 鍛ㄤ繚
+			 */
+			goMaintenance() {
+				uni.redirectTo({
+					// url: '/pages/maintenanceReport/maintenanceReport',
+					url: `/pages/maintenanceReport/maintenanceReport?equipmentId=${encodeURIComponent(this.id)}`
+				});
+			},
+			upCallback() {
+				console.log("id", this.id)
+				this.$http.get(this.url.stallList, {
+					params: {
+						pageNo: 999,
+						pageSize: 1,
+						order: 'asc',
+						column: 'createTime',
+						id: this.id
+					},
 
-		mescrollInit(mescroll) {
-			console.log('mescrollInit')
-			this.mescroll = mescroll;
+				}).then(res => {
+					this.announcement1 = res.data.result
+					console.log("url", res)
+					//璁剧疆鍒楄〃鏁版嵁
+					if (res.data.success) {
+						console.log("res", res.data.result.equipmentCode)
+						this.formData = this.announcement1
+					}
+				}).catch(() => {
+					//鑱旂綉澶辫触, 缁撴潫鍔犺浇
+				})
+			},
+
+			mescrollInit(mescroll) {
+				console.log('mescrollInit')
+				this.mescroll = mescroll;
+			},
 		},
-	},
 
 	}
 </script>

--
Gitblit v1.9.3