From 1833dd6d7cac01c35840af52fadc1199821e5805 Mon Sep 17 00:00:00 2001
From: Houjie <714924425@qq.com>
Date: 星期四, 15 五月 2025 09:28:16 +0800
Subject: [PATCH] 提交优化项

---
 pages/reportRepair/reportRepair.vue |  191 ++++++++++++++++++++---------------------------
 1 files changed, 82 insertions(+), 109 deletions(-)

diff --git a/pages/reportRepair/reportRepair.vue b/pages/reportRepair/reportRepair.vue
index e48e7d3..4141107 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="澶囨敞:">
@@ -70,6 +59,15 @@
 		mixins: [MescrollMixin], // 浣跨敤mixin
 		data() {
 			return {
+				// 鍥剧墖鍥炴樉
+				fileLists: [],
+				// 涓婁紶鍥剧墖鐨勬牱寮�
+				imageStyles: {
+					width: 90,
+					height: 90,
+				},
+				// uni.chooseImage鍊硷紝浠庣浉鍐岄�夋嫨锛屾媿鎽�
+				sourceType: ['album', 'camera'],
 				id: '',
 				equipmentList: [],
 				isTrueList: [{
@@ -207,17 +205,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 +237,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({
@@ -366,7 +339,7 @@
 							duration: 2000
 						});
 						this.$Router.replaceAll({
-							name: 'reportRepairList'
+							name: 'index'
 						})
 
 					}

--
Gitblit v1.9.3