From 66f29ab451014ca2e72fa9a5ff6373ab507ff67c Mon Sep 17 00:00:00 2001
From: xwt <2740516069@qq.com>
Date: 星期四, 17 七月 2025 18:32:42 +0800
Subject: [PATCH] 入库检,来料检获取附件—70%

---
 pages/QC/LLJ/Add.vue |  345 ++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 292 insertions(+), 53 deletions(-)

diff --git a/pages/QC/LLJ/Add.vue b/pages/QC/LLJ/Add.vue
index 3f4ffb0..68da812 100644
--- a/pages/QC/LLJ/Add.vue
+++ b/pages/QC/LLJ/Add.vue
@@ -152,6 +152,7 @@
 			<button class="secondary-btn" @click="addDestruction" v-if="this.current">鐮村潖瀹為獙</button>
 			<button class="secondary-btn" @click="uploadImages">涓婁紶/鏌ョ湅鍥剧墖</button>
 			<button class="secondary-btn" @click="fetchDrawingNumber">璋冨彇PLM鍥剧焊</button>
+			<button class="secondary-btn" @click="viewAttachmentInfo">鏌ョ湅闄勪欢淇℃伅</button>
 			<button class="secondary-btn" @click="addDefectDescription" v-if="this.current">娣诲姞涓嶈壇鎻忚堪</button>
 			<button class="primary-btn" @click="submitInspection" v-if="this.current">妫�楠屾彁浜�</button>
 		</view>
@@ -213,6 +214,58 @@
 				</uni-table>
 			</u-modal>
 		</view>
+		<!-- 闄勪欢璇︽儏寮圭獥 -->
+		<view v-if="showAttachmentDetail" class="overlay">
+			<view class="popup attachment-detail-popup">
+				<h3 class="attachment-popup-title">闄勪欢璇︽儏</h3>
+				<div class="attachment-popup-divider"></div>
+				<div v-if="selectedAttachment" class="attachment-detail-content">
+					<div class="attachment-detail-row"><span class="attachment-label">ID锛�</span><span>{{ Math.trunc(selectedAttachment.id) }}</span></div>
+					<div class="attachment-detail-row"><span class="attachment-label">闄勪欢鍚嶏細</span><span>{{ selectedAttachment.fattach }}</span></div>
+					<div class="attachment-detail-row"><span class="attachment-label">绫诲瀷锛�</span><span>{{ selectedAttachment.ftype }}</span></div>
+					<div class="attachment-detail-row"><span class="attachment-label">鐗堟湰锛�</span><span>{{ selectedAttachment.fversion }}</span></div>
+					<div class="attachment-detail-row"><span class="attachment-label">鍙楁帶鏃ユ湡锛�</span><span>{{ selectedAttachment.fdate }}</span></div>
+					<div class="attachment-detail-row"><span class="attachment-label">涓婁紶浜猴細</span><span>{{ selectedAttachment.createBy }}</span></div>
+					<div class="attachment-detail-row"><span class="attachment-label">涓婁紶鏃堕棿锛�</span><span>{{ selectedAttachment.createDate }}</span></div>
+					<div v-if="isPreviewable(selectedAttachment.fattach)" class="attachment-preview-area">
+						<div v-if="['pdf','jpg','jpeg','png','gif'].includes(selectedAttachment.fattach.trim().split('.').pop().toLowerCase())">
+							<iframe :src="getAttachmentUrl(selectedAttachment)" style="width:100%;height:320px;border-radius:10px;background:#f8fafc;" frameborder="0"></iframe>
+						</div>
+						<div v-else-if="['txt'].includes(selectedAttachment.fattach.trim().split('.').pop().toLowerCase())">
+							<iframe :src="getAttachmentUrl(selectedAttachment)" style="width:100%;height:320px;border-radius:10px;background:#f8fafc;" frameborder="0"></iframe>
+						</div>
+						<div v-else-if="['doc','docx','xls','xlsx'].includes(selectedAttachment.fattach.trim().split('.').pop().toLowerCase())">
+							<iframe :src="'https://view.officeapps.live.com/op/view.aspx?src=' + encodeURIComponent(getAttachmentUrl(selectedAttachment))" style="width:100%;height:320px;border-radius:10px;background:#f8fafc;" frameborder="0"></iframe>
+						</div>
+					</div>
+					<div v-else class="attachment-download-area">
+						<button class="attachment-download-link" @click="downloadAttachment(selectedAttachment)">涓嬭浇闄勪欢</button>
+					</div>
+				</div>
+				<div v-else class="attachment-detail-empty">鏆傛棤闄勪欢淇℃伅</div>
+				<button class="attachment-popup-close" @click="closeAttachmentDetail">杩斿洖闄勪欢鍒楄〃</button>
+			</view>
+		</view>
+		<!-- 闄勪欢鍒楄〃寮圭獥 -->
+		<view v-if="showAttachmentPopup" class="overlay">
+			<view class="popup" style="width: 60vw; max-width: 500px;">
+				<h3>闄勪欢鍒楄〃</h3>
+				<div v-if="attachmentsLoading">鍔犺浇涓�...</div>
+				<div v-else-if="attachments.length === 0">鏆傛棤闄勪欢</div>
+				<ul class="attachment-list" v-else>
+					<li v-for="item in attachments" :key="item.id">
+						<span class="attachment-name" @click="showAttachmentDetailDialog(item)">
+							{{ item.fattach }}
+						</span>
+						<div class="attachment-actions">
+							<button class="secondary-btn" @click="showAttachmentDetailDialog(item)">璇︽儏</button>
+							<button class="secondary-btn" @click="downloadAttachment(item)">涓嬭浇</button>
+						</div>
+					</li>
+				</ul>
+				<button class="attachment-popup-close" @click="closeAttachmentPopup">鍏抽棴</button>
+			</view>
+		</view>
 	</view>
 	
 </template>
@@ -267,6 +320,11 @@
 				destructionPopup: false,
 				PHSY: '',
 				isInteger: true,
+				attachments: [],
+				showAttachmentPopup: false,
+				attachmentsLoading: false,
+				selectedAttachment: null,
+				showAttachmentDetail: false,
 				
 			}
 		},
@@ -306,6 +364,10 @@
 
 			}
 			 if (this.$loginInfo.account === 'PL017') {this.hasEmergencyPermission = true;}
+
+			 // 娴嬭瘯闄勪欢鏈嶅姟鍣ㄨ繛鎺�
+			 
+
 
 		},
 		methods: {
@@ -472,6 +534,9 @@
 
 										// 濡傛灉鏈夐〉闈㈣烦杞紝闇�瑕佺敤瀹氭椂鍣ㄥ欢杩�
 										setTimeout(() => {
+											// 璁剧疆涓�涓爣璁帮紝鍛婅瘔List椤甸潰闇�瑕佸埛鏂�
+											getApp().globalData = getApp().globalData || {};
+											getApp().globalData.needRefreshList = true;
 											uni.redirectTo({
 												url: 'List'
 											});
@@ -525,7 +590,12 @@
 								duration: 2000
 							})
 							// 濡傛灉鏈夐〉闈㈣烦杞紝闇�瑕佺敤瀹氭椂鍣ㄥ欢杩�
-							setTimeout(() => {uni.navigateBack();}, 2000); // 淇濇寔涓� duration 鐩稿悓鐨勬椂闀�
+							setTimeout(() => {
+								// 璁剧疆涓�涓爣璁帮紝鍛婅瘔List椤甸潰闇�瑕佸埛鏂�
+								getApp().globalData = getApp().globalData || {};
+								getApp().globalData.needRefreshList = true;
+								uni.navigateBack();
+							}, 2000); // 淇濇寔涓� duration 鐩稿悓鐨勬椂闀�
 						} else {
 							uni.showModal({
 								title: "鎻愮ず",
@@ -1205,6 +1275,89 @@
 					}
 				})
 			},
+			viewAttachmentInfo() {
+				this.showAttachmentPopup = true; // 鍏堝脊绐�
+				this.attachmentsLoading = true;
+				this.attachments = [];
+				this.$post({
+					url: "/LLJ/getAttachments",
+					data: { releaseNo: this.formData.releaseNo }
+				}).then(res => {
+					this.attachmentsLoading = false;
+					if (res.status === 0) {
+						this.attachments = res.data.tbBillList;
+					} else if (res.status === 1 && res.message === "璇ユ楠屽崟鏈笂浼犻檮浠朵俊鎭紒") {
+						uni.showToast({ title: res.message, icon: "none" });
+					} else {
+						uni.showToast({ title: "鑾峰彇闄勪欢澶辫触", icon: "none" });
+					}
+				});
+			},
+			closeAttachmentPopup() {
+				this.showAttachmentPopup = false;
+			},
+			getAttachmentUrl(item) {
+				const baseUrl = "http://192.168.1.22:10054";
+				// 鍘婚櫎鎵�鏈夌┖鐧藉瓧绗︼紙鍖呮嫭涓嫳鏂囩┖鏍笺�佸埗琛ㄧ绛夛級
+				let fileName = item.fattach.replace(/[\s\u3000]+/g, '').trim();
+				return baseUrl + "/api/LLJ/DownloadAttachment?itemNo=" + encodeURIComponent(item.itemNo) + "&fileName=" + encodeURIComponent(fileName);
+			},
+			showAttachmentDetailDialog(item) {
+				console.log('鏌ョ湅璇︽儏', item);
+				this.selectedAttachment = item;
+				this.showAttachmentPopup = false;
+				this.showAttachmentDetail = true;
+				console.log('showAttachmentDetail:', this.showAttachmentDetail);
+			},
+			closeAttachmentDetail() {
+				this.showAttachmentDetail = false;
+				this.selectedAttachment = null;
+				this.showAttachmentPopup = true;
+			},
+			isPreviewable(filename) {
+				if (!filename) return false;
+				const ext = filename.trim().split('.').pop().toLowerCase();
+				// 鏀寔鍦ㄧ嚎棰勮鐨勬枃浠剁被鍨�
+				return [
+					'pdf', 'jpg', 'jpeg', 'png', 'gif', 'txt', 'doc', 'docx', 'xls', 'xlsx'
+				].includes(ext);
+			},
+			// 澶勭悊闄勪欢涓嬭浇閿欒
+			handleAttachmentError(item) {
+				uni.showModal({
+					title: '涓嬭浇澶辫触',
+					content: `鏃犳硶涓嬭浇闄勪欢锛�${item.fattach}\n璇锋鏌ョ綉缁滆繛鎺ユ垨鑱旂郴绠$悊鍛榒,
+					showCancel: false
+				});
+			},
+			downloadAttachment(item) {
+				const baseUrl = "http://192.168.1.22:10054"; // 濡傛湁闇�瑕佽鏀逛负浣犵殑鍚庣瀹為檯鍦板潃
+				// 鍘婚櫎鎵�鏈夌┖鏍笺�佸叏瑙掔┖鏍笺�佸洖杞︺�佹崲琛�
+				const fileName = item.fattach.replace(/[\s\u3000\r\n]+/g, '').trim();
+				const url = baseUrl + "/api/Llj/DownloadFtpFile?itemNo=" + encodeURIComponent(item.itemNo) + "&fileName=" + encodeURIComponent(fileName);
+				uni.downloadFile({
+					url: url,
+					success: (res) => {
+						if (res.statusCode === 200) {
+							if (typeof plus !== 'undefined' && plus.runtime && plus.runtime.openFile) {
+								plus.runtime.openFile({ path: res.tempFilePath }, () => {
+									uni.showToast({ title: '鎵撳紑鎴愬姛', icon: 'success' });
+								}, (e) => {
+									uni.showModal({ title: '鎻愮ず', content: '鏂囦欢涓嬭浇鎴愬姛锛屼絾鏃犳硶鑷姩鎵撳紑銆傝鍦ㄦ枃浠剁鐞嗕腑鎵嬪姩鏌ユ壘骞舵墦寮�銆�', showCancel: false });
+								});
+							} else {
+								uni.showModal({ title: '鎻愮ず', content: '鏂囦欢涓嬭浇鎴愬姛锛屼絾褰撳墠鐜鏃犳硶鑷姩鎵撳紑銆傝鍦ㄦ枃浠剁鐞嗕腑鎵嬪姩鏌ユ壘骞舵墦寮�銆�', showCancel: false });
+							}
+						} else {
+							uni.showModal({ title: '涓嬭浇澶辫触', content: `涓嬭浇澶辫触锛岀姸鎬佺爜锛�${res.statusCode}`, showCancel: false });
+						}
+					},
+					fail: (error) => {
+						uni.showModal({ title: '涓嬭浇澶辫触', content: `涓嬭浇澶辫触锛岃妫�鏌ョ綉缁滆繛鎺ャ��${error.errMsg}`, showCancel: false });
+					}
+				});
+			},
+
 		}
 	}
 </script>
@@ -1450,63 +1603,149 @@
 		z-index: 10;
 	}
 
-	.popup {
-		background-color: #fff;
-		padding: 20px;
-		border: 1px solid #ccc;
-		box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
-		width: 68vw;
-		/* 璁剧疆瀹藉害涓鸿鍙e搴︾殑80% */
-		height: 25vh;
-		/* 璁剧疆楂樺害涓鸿鍙i珮搴︾殑80% */
+	/* 寮圭獥鏁翠綋缇庡寲 */
+	.popup, .attachment-detail-popup {
+		background: #fff;
+		border-radius: 16px;
+		box-shadow: 0 8px 32px rgba(60,60,60,0.18);
+		padding: 28px 28px 18px 28px;
+		border: none;
+		position: relative;
+		min-width: 260px;
 	}
-
-	.form-group {
+	.attachment-popup-title {
+		font-size: 22px;
+		font-weight: 700;
+		color: #222;
+		margin-bottom: 8px;
+		letter-spacing: 1px;
+		text-align: center;
+	}
+	.attachment-popup-divider {
+		height: 1px;
+		background: linear-gradient(90deg,#e0e7ef 0%,#f5f7fa 100%);
+		margin-bottom: 18px;
+	}
+	.attachment-detail-content {
+		margin-bottom: 18px;
+	}
+	.attachment-detail-row {
 		display: flex;
 		align-items: center;
-		border-bottom: 1px solid #c9c9c9;
+		margin-bottom: 8px;
+		font-size: 15px;
 	}
-
-	.updateBut {
-		background-color: #3498db;
-		color: white;
+	.attachment-label {
+		min-width: 80px;
+		color: #1976d2;
+		font-weight: 500;
+		margin-right: 8px;
 	}
-
-	/* 鍝嶅簲寮忚璁� */
-	@media (max-width: 500px) {
-
-		.info-row,
-		.info-block {
-			flex-direction: column;
-			align-items: flex-start;
-		}
-
-		.doc-links {
-			margin-left: 0;
-			margin-top: 10px;
-		}
-
-		.action-buttons {
-			flex-direction: column;
-		}
-
-		.inspection-table table {
-			display: block;
-			overflow-x: auto;
-		}
-
-		.click-wd {
-			color: #056cba;
-			font-size: 1.25rem;
-			text-decoration: underline;
-		}
-
+	.attachment-preview-area {
+		margin: 18px 0 8px 0;
+		border-radius: 10px;
+		background: #f8fafc;
+		padding: 10px;
+		box-shadow: 0 2px 8px rgba(60,60,60,0.06);
 	}
-	
-	.error-message {
-		color: #e74c3c;
-		font-size: 14px;
-		margin-top: 5px;
-		margin-bottom: 10px;
+	.attachment-download-area {
+		margin: 18px 0 8px 0;
+		text-align: center;
+	}
+	.attachment-download-link {
+		display: inline-block;
+		padding: 7px 18px;
+		background: linear-gradient(90deg,#4f8cff 0%,#1976d2 100%);
+		color: #fff;
+		border-radius: 6px;
+		font-weight: 500;
+		text-decoration: none;
+		transition: background 0.2s;
+		box-shadow: 0 2px 8px rgba(60,60,60,0.08);
+	}
+	.attachment-download-link:hover {
+		background: linear-gradient(90deg,#1976d2 0%,#4f8cff 100%);
+	}
+	.attachment-detail-empty {
+		color: #888;
+		text-align: center;
+		margin: 30px 0;
+		font-size: 16px;
+	}
+	.attachment-popup-close {
+		margin-top: 18px;
+		width: 100%;
+		background: linear-gradient(90deg,#e0e0e0 0%,#f5f7fa 100%);
+		color: #444;
+		border-radius: 8px;
+		font-size: 16px;
+		padding: 10px 0;
+		border: none;
+		font-weight: 600;
+		letter-spacing: 1px;
+		transition: background 0.2s, color 0.2s;
+		box-shadow: 0 2px 8px rgba(60,60,60,0.06);
+	}
+	.attachment-popup-close:hover {
+		background: linear-gradient(90deg,#bdbdbd 0%,#e0e0e0 100%);
+		color: #1976d2;
+	}
+	/* 鍒楄〃寮圭獥缇庡寲锛堜繚鐣欏師鏈夛級 */
+	.attachment-list {
+		padding: 0;
+		margin: 0;
+		list-style: none;
+		max-height: 300px;
+		overflow-y: auto;
+	}
+	.attachment-list li {
+		display: flex;
+		align-items: center;
+		justify-content: space-between;
+		padding: 8px 0;
+		border-bottom: 1px solid #f0f0f0;
+	}
+	.attachment-name {
+		flex: 1;
+		color: #3498db;
+		cursor: pointer;
+		font-weight: 500;
+		transition: color 0.2s;
+		margin-right: 10px;
+	}
+	.attachment-name:hover {
+		color: #217dbb;
+		text-decoration: underline;
+	}
+	.attachment-actions {
+		display: flex;
+		gap: 8px;
+	}
+	.attachment-list .secondary-btn {
+		padding: 4px 10px;
+		font-size: 13px;
+		border-radius: 3px;
+		background: #f5f7fa;
+		color: #333;
+		border: 1px solid #dbe2ea;
+		transition: background 0.2s, color 0.2s;
+	}
+	.attachment-list .secondary-btn:hover {
+		background: #e6f0fa;
+		color: #1976d2;
+	}
+	.attachment-popup-close {
+		margin-top: 18px;
+		width: 100%;
+		background: #e0e0e0;
+		color: #444;
+		border-radius: 4px;
+		font-size: 15px;
+		padding: 8px 0;
+		border: none;
+		transition: background 0.2s;
+	}
+	.attachment-popup-close:hover {
+		background: #bdbdbd;
 	}
 </style>
\ No newline at end of file

--
Gitblit v1.9.3