From 2fda34643bc22e25f6c569415da5f955c81536bf Mon Sep 17 00:00:00 2001
From: Houjie <714924425@qq.com>
Date: 星期二, 03 六月 2025 09:37:08 +0800
Subject: [PATCH] 设备详情通过ID过滤/设备详情增加上传附件

---
 pages/reportRepair/reportRepair.vue |  224 +++++++++++++++++++++++++++-----------------------------
 1 files changed, 108 insertions(+), 116 deletions(-)

diff --git a/pages/reportRepair/reportRepair.vue b/pages/reportRepair/reportRepair.vue
index e48e7d3..5c506e0 100644
--- a/pages/reportRepair/reportRepair.vue
+++ b/pages/reportRepair/reportRepair.vue
@@ -11,42 +11,31 @@
 					<uni-data-select v-model="formData.num" :localdata="equipmentList" @change="changeEquipmentList"
 						placeholder="璇烽�夋嫨" />
 				</uni-forms-item> -->
-				<uni-forms-item required name="num" label="璁惧缂栧彿:">
+				<uni-forms-item required :label-width="100" name="num" label="璁惧缂栧彿:">
 					<uni-easyinput v-model=" formData.numSear" placeholder="璇烽�夋嫨" :disabled="true" suffixIcon="search"
 						@iconClick="OnenterpriseId()" />
 				</uni-forms-item>
-				<uni-forms-item required name="name" label="鏁呴殰绠�绉�:">
+				<uni-forms-item required :label-width="100" name="name" label="鏁呴殰绠�绉�:">
 					<uni-data-select v-model="formData.faultName" :localdata="formData.faultNameList"
 						@change="changefaultNameList" placeholder="璇烽�夋嫨" />
 				</uni-forms-item>
-				<uni-forms-item required name="faultType" label="鏁呴殰鍒嗙被:">
+				<uni-forms-item required :label-width="100" name="faultType" label="鏁呴殰鍒嗙被:">
 					<uni-easyinput v-model="formData.faultType" :disabled='true' />
 				</uni-forms-item>
-				<uni-forms-item required name="faultDescription" label="鏁呴殰鎻忚堪:">
+				<uni-forms-item required :label-width="100" name="faultDescription" label="鏁呴殰鎻忚堪:">
 					<uni-easyinput v-model="formData.faultDescription" :disabled='true' />
 				</uni-forms-item>
-
-				<uni-forms-item required name="desc" label="鏁呴殰寮�濮嬫椂闂�:">
-					<uni-datetime-picker type="datetime" v-model="formData.loadTime" />
-				</uni-forms-item>
-				<uni-forms-item required name="name" label="鏄惁鍋滄満:">
+				<uni-forms-item required name="name" :label-width="100" label="鏄惁鍋滄満:">
 					<uni-data-select v-model="formData.breakdownFlag" :localdata="isTrueList" @change="changeisTrueList"
 						placeholder="璇烽�夋嫨" />
 				</uni-forms-item>
-				<uni-forms-item name="outNum" label="鎶ヤ慨鍥剧墖:">
-					<view class="grid col-4 grid-square flex-sub">
-						<view class="bg-img" v-for="(item,index) in imgList" :key="index" @tap="ViewImage"
-							:data-url="imgList[index]">
-							<image :src="imgList[index]" mode="aspectFill"></image>
-							<view class="cu-tag bg-red radius" @tap.stop="DelImg" :data-index="index">
-								<text class='cuIcon-close'></text>
-							</view>
-						</view>
-						<view class="solids" @tap="ChooseImage" v-if="imgList.length<1">
-							<text class='cuIcon-cameraadd'></text>
-						</view>
-					</view>
+				<uni-forms-item required :label-width="110" name="desc" label="鏁呴殰寮�濮嬫椂闂�:">
+					<uni-datetime-picker type="datetime" v-model="formData.loadTime" />
+				</uni-forms-item>
 
+				<uni-forms-item name="outNum" label="鎶ヤ慨鍥剧墖:">
+					<uni-file-picker limit="9" :value="fileLists" :image-styles="imageStyles" :sourceType="sourceType"
+						@select="select" @progress="progress" @success="success" @fail="fail" @delete="deletea" />
 				</uni-forms-item>
 
 				<uni-forms-item name="faultDescription" label="澶囨敞:">
@@ -57,7 +46,7 @@
 
 		<view class="padding flex flex-direction">
 			<view class="flex-sub bg-blue padding-sm margin-xl radius text-sm text-center text-white"
-				@click.stop="ProductionTask()" hover-class="is-hover">鎻愪氦</view>
+				@click.stop="ProductionTask()"   hover-class="is-hover">鎻愪氦</view>
 		</view>
 
 
@@ -68,8 +57,18 @@
 	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
 	export default {
 		mixins: [MescrollMixin], // 浣跨敤mixin
+		
 		data() {
 			return {
+				// 鍥剧墖鍥炴樉
+				fileLists: [],
+				// 涓婁紶鍥剧墖鐨勬牱寮�
+				imageStyles: {
+					width: 90,
+					height: 90,
+				},
+				// uni.chooseImage鍊硷紝浠庣浉鍐岄�夋嫨锛屾媿鎽�
+				sourceType: ['album', 'camera'],
 				id: '',
 				equipmentList: [],
 				isTrueList: [{
@@ -92,7 +91,7 @@
 					faultNameList: [],
 					faultName: '',
 					faultType: '',
-					breakdownFlag: '',
+					breakdownFlag: '1',
 					loadTime: Date.now(),
 					faultDescription: ''
 				},
@@ -128,7 +127,9 @@
 				announcement1: [],
 				msg1Count: 0,
 				msg2Count: 0,
-				msg1Title: ""
+				msg1Title: "",
+				equipmentId: '',
+				AuthLsit:[]
 			}
 		},
 		computed: {
@@ -166,7 +167,7 @@
 			this.getSera()
 		},
 		created() {
-			// this.getEquipment();
+			
 			this.getfaultReasonList();
 		},
 		methods: {
@@ -186,6 +187,7 @@
 					console.log(this.announcement1);
 					//璁剧疆鍒楄〃鏁版嵁
 					if (res.data.success) {
+						this.equipmentId = this.announcement1.id
 						this.formData.numSear = this.announcement1.equipmentCode + '[' + this.announcement1
 							.equipmentName +
 							']'
@@ -207,17 +209,21 @@
 			},
 			changefaultNameList(e) {
 				this.formData.faultName = e;
-				if (e == '1902250920983339009') {
-					this.formData.faultType = this.formData.faultNameList[0].faultCategory_dictText;
-					this.formData.faultDescription = this.formData.faultNameList[0].faultDescription;
-				} else if (e == '1909114668383875074') {
-					this.formData.faultType = this.formData.faultNameList[1].faultCategory_dictText;
-					this.formData.faultDescription = this.formData.faultNameList[1].faultDescription;
-				} else if (e == '1909877534952710145') {
-					this.formData.faultType = this.formData.faultNameList[2].faultCategory_dictText;
-					this.formData.faultDescription = this.formData.faultNameList[2].faultDescription;
+
+				this.setFaultReason(this.formData.faultName)
+
+			},
+			setFaultReason(value) {
+				for (let i = 0; i < this.formData.faultNameList.length; i++) {
+					if (this.formData.faultNameList[i].id === value) {
+						this.formData.faultType = this.formData.faultNameList[i].faultCategory_dictText
+						this.formData.faultDescription = this.formData.faultNameList[i].faultDescription
+					}
+
 				}
 			},
+
+
 			getfaultReasonList() {
 				this.$http.get(this.url.faultReasonList).then(res => {
 					//璁剧疆鍒楄〃鏁版嵁
@@ -235,96 +241,67 @@
 					this.$tip.error("鑱旂綉澶辫触")
 				})
 			},
-			// getEquipment() {
-			// 	this.$http.get(this.url.getEquipmentList).then(res => {
-			// 		//璁剧疆鍒楄〃鏁版嵁
-			// 		if (res.data.success) {
-			// 			this.equipmentList = res.data.result
-			// 		} else {
-			// 			uni.showToast({
-			// 				icon: "error",
-			// 				title: res.data.message,
-			// 				duration: 2000
-			// 			});
 
-			// 		}
-			// 	}).catch(() => {
-			// 		this.$tip.error("鑱旂綉澶辫触")
-			// 	})
-			// },
-			// changeEquipmentList(e) {
-			// 	this.formData.num = e;
-			// },
 			changeisTrueList(e) {
 				this.formData.breakdownFlag = e;
 			},
+			select(e) {
+				const tempFilePaths = e.tempFilePaths;
 
-			ChooseImage() {
-				var that = this;
-				uni.chooseImage({
-					count: 4,
-					sizeType: ['original', 'compressed'], // 鍙互鎸囧畾鏄師鍥捐繕鏄帇缂╁浘锛岄粯璁や簩鑰呴兘鏈�
-					sourceType: ['album'], // 浠庣浉鍐岄�夋嫨
-					success: (res) => {
-						// 瀛樺偍閫夋嫨鐨勫浘鐗囪矾寰�
-						that.imgList = res.tempFilePaths;
+				// if (!Array.isArray(tempFilePaths) || tempFilePaths.length === 0) {
+				// 	uni.showToast({
+				// 		title: '璇烽�夋嫨鏂囦欢',
+				// 		icon: 'none'
+				// 	});
+				// 	return;
+				// }
 
-						// 鍒濆鍖� formData.avatar 涓虹┖瀛楃涓�
-						that.formData.avatar = [];
+				uni.showLoading({
+					title: '涓婁紶涓�...'
+				});
 
-						// 鍒涘缓涓婁紶浠诲姟鐨� Promise 鏁扮粍
-						const uploadPromises = res.tempFilePaths.map((filePath, index) => {
-							return new Promise((resolve, reject) => {
-								that.$http.upload(that.url.upload, {
-										filePath: filePath,
-										name: 'file'
-									})
-									.then(uploadRes => {
-										// 鍋囪鏈嶅姟鍣ㄨ繑鍥炵殑缁撴灉涓寘鍚枃浠惰矾寰�
-										const filePath = uploadRes.data.result[0];
-										this.formData.avatar.push(filePath)
-										resolve(filePath);
-									})
-									.catch(err => {
-										console.error('鍥剧墖' + index + '涓婁紶澶辫触:', err);
-										reject(err);
-									});
-							});
-						});
-
-						// 骞跺彂鎵ц鎵�鏈変笂浼犱换鍔�
-						Promise.all(uploadPromises)
-							.then((uploadedFilePaths) => {
-								console.log('鎵�鏈夊浘鐗囦笂浼犳垚鍔�:', that.formData.avatar);
+				const uploadPromises = tempFilePaths.map((filePath, index) => {
+					return new Promise((resolve, reject) => {
+						this.$http.upload(this.url.upload, {
+								filePath: filePath,
+								name: 'file'
 							})
-							.catch((err) => {
-								console.error('鍥剧墖涓婁紶澶辫触:', err);
-								that.$tip.error('鍥剧墖涓婁紶澶辫触');
+							.then(uploadRes => {
+								// 鍋囪鏈嶅姟鍣ㄨ繑鍥炵殑缁撴灉涓寘鍚枃浠惰矾寰�
+								const serverFilePath = uploadRes.data.result[0];
+								this.formData.avatar.push(serverFilePath);
+								resolve(uploadRes); // 杩斿洖缁撴灉缁� Promise.all
+							})
+							.catch(err => {
+								console.error(`鍥剧墖 ${index + 1} 涓婁紶澶辫触:`, err);
+								reject(err);
 							});
-					}
+					});
 				});
-			},
-			ViewImage(e) {
-				uni.previewImage({
-					urls: this.imgList,
-					current: e.currentTarget.dataset.url
-				});
-			},
-			DelImg(e) {
-				uni.showModal({
-					title: '鎻愮ず',
-					content: '纭畾瑕佸垹闄よ繖娈靛洖蹇嗗悧锛�',
-					cancelText: '鍐嶇湅鐪�',
-					confirmText: '鍐嶈',
-					success: res => {
-						if (res.confirm) {
-							this.imgList.splice(e.currentTarget.dataset.index, 1)
-						}
-					}
-				})
+
+				Promise.all(uploadPromises)
+					.then(() => {
+						uni.hideLoading();
+						uni.showToast({
+							title: '鍏ㄩ儴涓婁紶鎴愬姛'
+						});
+					})
+					.catch(err => {
+						uni.hideLoading();
+						uni.showToast({
+							title: '閮ㄥ垎涓婁紶澶辫触',
+							icon: 'none'
+						});
+						console.error('涓婁紶寮傚父:', err);
+					});
 			},
 
 
+
+			// 鍒犻櫎
+			deletea(e) {
+				console.log('鍒犻櫎鍥剧墖', e);
+			},
 			ProductionTask() {
 				if (this.formData.num == 0 || this.formData.num == undefined) {
 					uni.showToast({
@@ -338,6 +315,14 @@
 					uni.showToast({
 						icon: "none",
 						title: '鏁呴殰绠�绉颁负绌�!',
+						duration: 2000
+					});
+					return false
+				}
+				if (this.formData.breakdownFlag == 0 || this.formData.breakdownFlag == undefined) {
+					uni.showToast({
+						icon: "none",
+						title: '鏄惁鍋滄満涓虹┖!',
 						duration: 2000
 					});
 					return false
@@ -365,16 +350,23 @@
 							title: '鎻愪氦鎴愬姛',
 							duration: 2000
 						});
-						this.$Router.replaceAll({
-							name: 'reportRepairList'
+						console.log(this.equipmentId)
+						uni.reLaunch({
+							url: `/pages/reportRepair/reportRepairList/reportRepairList?equipmentId=${this.equipmentId}`
 						})
 
+					} else {
+						uni.showToast({
+							icon: "error",
+							title: res.data.message,
+							duration: 2000
+						});
 					}
 				}).catch(() => {
-					this.$tip.loaded();
+					uni.hideLoading();
 					uni.showToast({
 						icon: "error",
-						title: '鎻愪氦澶辫触',
+						title: '缃戠粶杩炴帴澶辫触',
 						duration: 2000
 					});
 				});

--
Gitblit v1.9.3