From e6044ce7c9513de2733ffbfb76cc953bcf7bd5d3 Mon Sep 17 00:00:00 2001
From: 展杰 <1240968267@qq.com>
Date: 星期三, 03 七月 2024 14:12:49 +0800
Subject: [PATCH] 看图纸

---
 manifest.json                       |    2 
 package.json                        |    6 +
 pages/inspection/inspectionInfo.vue |  257 ++++++++++++++++++++++++++++----------------------
 pages/index/index.vue               |    1 
 4 files changed, 151 insertions(+), 115 deletions(-)

diff --git a/manifest.json b/manifest.json
index f21c206..efc7b9c 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,6 +1,6 @@
 {
     "name" : "MES",
-    "appid" : "__UNI__48029C9",
+    "appid" : "__UNI__A155799",
     "description" : "",
     "versionName" : "1.2.2",
     "versionCode" : 101,
diff --git a/package.json b/package.json
index 331e274..4c6f340 100644
--- a/package.json
+++ b/package.json
@@ -14,5 +14,9 @@
             "鍓嶇缁勪欢",
             "閫氱敤缁勪欢"
         ]
+    },
+    "dependencies": {
+        "@dcloudio/uni-ui": "^1.5.5",
+        "uview-ui": "^2.0.37"
     }
-}
\ No newline at end of file
+}
diff --git a/pages/index/index.vue b/pages/index/index.vue
index 70d771e..7bdd24c 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -1,3 +1,4 @@
+
 <template>
 	<view>
 		<u-grid :col="3" @click="gotoPage" border>
diff --git a/pages/inspection/inspectionInfo.vue b/pages/inspection/inspectionInfo.vue
index ae31139..8553222 100644
--- a/pages/inspection/inspectionInfo.vue
+++ b/pages/inspection/inspectionInfo.vue
@@ -75,25 +75,17 @@
 							<label>{{item.OPERATE_MAN}} / {{item.FTYPE}}</label>
 						</u-col>
 					</u-row>
-					<u-button text="鐢熸垚妫�楠岃祫鏂�" type="primary" :plain="true" style="width: 200px;height: 100px;position: absolute;top: 30%;right: 10%;" @click="generate()"></u-button>
+					<u-button text="鐢熸垚妫�楠岃祫鏂�" type="primary" :plain="true"
+						style="width: 200px;height: 100px;position: absolute;top: 30%;right: 10%;"
+						@click="generate()"></u-button>
 				</view>
-			
-				
-				 <view class="container">
-				     <button @click="fetchDrawingNumber">鏌ョ湅鍥惧彿</button>
-				 
-				     <!-- 寮瑰嚭绐楀彛 -->
-				     <view v-if="pdfVisible" class="modal">
-				       <view class="modal-content">
-				         <view class="modal-header">
-				           <text>PDF棰勮</text>
-				           <button @click="closeModal">鍏抽棴</button>
-				         </view>
-				         <web-view v-if="pdfLink" :src="pdfLink" class="pdf-view"></web-view>
-				       </view>
-				     </view>
-				   </view>
-				
+
+				<view class="container">
+					<button @click="fetchDrawingNumber">鏌ョ湅鍥惧彿</button>
+
+					
+				</view>
+
 			</uni-card>
 		</view>
 
@@ -131,17 +123,15 @@
 						<u-tag
 							v-if="item.UP_ALLOW && (parseFloat(item.VALUE) <= parseFloat(item.UP_ALLOW) && parseFloat(item.VALUE) >= parseFloat(item.DOWN_ALLOW)) || (!item.UP_ALLOW && item.VALUE == '鍚堟牸')"
 							text="鍚堟牸" type="success"></u-tag>
-						<u-tag
-							v-else
-							text="涓嶅悎鏍�" type="error"></u-tag>
+						<u-tag v-else text="涓嶅悎鏍�" type="error"></u-tag>
 					</uni-td>
 					<uni-td>
-<!-- 						<view class="content" @click="useOutClickSide">
+						<!-- 						<view class="content" @click="useOutClickSide">
 							<easy-select ref="easySelect" size="medium" :value="item.BAD_REASON" @selectOne="selectOne($event,index)"></easy-select>
 						</view> -->
 						<view class="login">
-							<w-select style="margin-left: 20rpx;" v-model='chooseValue' defaultValue="璇烽�夋嫨" 
-							:list='list' valueName='CONTENT' keyName="ID" @change='change(index)'>
+							<w-select style="margin-left: 20rpx;" v-model='chooseValue' defaultValue="璇烽�夋嫨" :list='list'
+								valueName='CONTENT' keyName="ID" @change='change(index)'>
 							</w-select>
 						</view>
 					</uni-td>
@@ -159,6 +149,21 @@
 				<u--textarea v-model="remeke" placeholder="璇疯緭鍏ュ唴瀹�"></u--textarea>
 			</u-row>
 		</view>
+		<!-- 寮瑰嚭绐楀彛 -->
+		<view v-if="pdfVisible" class="modal">
+			<view class="modal-content">
+				<view class="modal-header">
+					<text>PDF棰勮</text>
+					<button @click="closeModal">鍏抽棴</button>
+				</view>
+				<!-- 			<web-view v-if="pdfLink" :src="pdfLink" class="pdf-view"></web-view> -->
+				<view class="pdf-view">
+					<!-- 鍦ㄦ澶勬樉绀� PDF 鍐呭 -->
+					<iframe :src="pdfLink" width="100%" height="100%"></iframe>
+				</view>
+			</view>
+		</view>
+		
 		<u-button text="鎻愪氦" type="primary" style="margin-top: 10px;" @click="submit()"></u-button>
 		<u-toast ref="uToast" />
 	</view>
@@ -169,7 +174,7 @@
 		getInspectionInfo,
 		saveInspectionInfo,
 		getBadReason,
-		generateInfo
+		generateInfoc
 	} from '../../api/inspection';
 	import {
 		baseUrl
@@ -181,6 +186,8 @@
 				table: [],
 				name: '',
 				remeke: '',
+				pdfVisible: false, // 鍦ㄨ繖閲屽0鏄� pdfVisible
+				pdfLink: '', // 涔熷0鏄� pdfLink锛岀‘淇濆畠浠槸鍝嶅簲寮忕殑
 				//show: false
 				chooseValue: "",
 				list: []
@@ -208,7 +215,7 @@
 						name: 'file',
 						success: (uploadFileRes) => {
 							console.log(uploadFileRes.data);
-							
+
 						},
 						fail: (res) => {
 							console.log(res)
@@ -223,7 +230,7 @@
 					for (let item of res.data) {
 						// for (let i = 0; i < parseInt(item.CHECK_NUM); i++) {
 						// 	let insert = JSON.parse(JSON.stringify(item))
-							
+
 						// 	insert.CHECK_ITEM = insert.CHECK_ITEM + '-' + i
 						// 	if (!insert.UP_ALLOW) {
 						// 		insert.VALUE = '鍚堟牸'
@@ -237,7 +244,7 @@
 						} else {
 							item.VALUE = null
 						}
-						
+
 						this.table.push(item)
 					}
 					console.log(this.table)
@@ -251,7 +258,7 @@
 			// 	this.$refs.easySelect.hideOptions && this.$refs.easySelect.hideOptions()
 			// },
 			change(index) {
-				this.table[index].BAD_REASON=this.chooseValue;
+				this.table[index].BAD_REASON = this.chooseValue;
 			},
 			changeSwitch(item) {
 				console.log(item)
@@ -262,31 +269,31 @@
 				}
 			},
 			submit() {
-				if(this.table.length==0){
+				if (this.table.length == 0) {
 					this.$refs.uToast.show({
 						message: "鎻愪氦澶辫触锛岃缁存姢妫�楠岄」鐩�",
 						type: 'error'
 					})
 					return
-				}else{
-					if(this.check()) {
+				} else {
+					if (this.check()) {
 						saveInspectionInfo(this.item.CHECK_NO, this.table, this.remeke).then(res => {
-							if(!res.result) {
+							if (!res.result) {
 								this.$refs.uToast.show({
 									message: res.msg,
 									type: 'error'
 								})
 								return
-							}else{
+							} else {
 								// this.$refs.uToast.show({
 								// 	message: "鎻愪氦鎴愬姛",
 								// 	type: 'success'
 								// })
-								let pages=getCurrentPages();
-								let beforePage=pages[pages.length-2];
+								let pages = getCurrentPages();
+								let beforePage = pages[pages.length - 2];
 								uni.navigateBack({
-									delta: 1,  //杩斿洖鐨勯〉闈㈡暟锛屽鏋滀负1琛ㄧず杩斿洖涓婁竴椤�
-									success: (event)=> {
+									delta: 1, //杩斿洖鐨勯〉闈㈡暟锛屽鏋滀负1琛ㄧず杩斿洖涓婁竴椤�
+									success: (event) => {
 										console.log('鎻愪氦鎴愬姛');
 										beforePage.$vm.reload()
 									}
@@ -302,29 +309,29 @@
 					return
 				}
 			},
-			generate(){
-				generateInfo(this.item.CHECK_NO).then(res=>{
-					if(!res.result){
+			generate() {
+				generateInfo(this.item.CHECK_NO).then(res => {
+					if (!res.result) {
 						this.$refs.uToast.show({
-							message:res.msg,
-							type:'error'
+							message: res.msg,
+							type: 'error'
 						})
 						return
-					}else{
+					} else {
 						this.$refs.uToast.show({
 							message: "鏇存柊鎴愬姛",
 							type: 'success'
 						})
-						this.table.splice(0,this.table.length)
+						this.table.splice(0, this.table.length)
 						this.getInspection(this.item.CHECK_NO)
 					}
 				})
 			},
 			getBadReason() {
-				
+
 				getBadReason().then(res => {
 					console.log(res)
-					if(!res.result) {
+					if (!res.result) {
 						this.$refs.uToast.show({
 							message: res.msg,
 							type: 'error'
@@ -335,77 +342,56 @@
 				})
 			},
 			check() {
-				for(let item of this.table) {
-					if(item.VALUE === null) {
+				for (let item of this.table) {
+					if (item.VALUE === null) {
 						return false
 					}
 				}
 				return true
-			
+
+			},
+			fetchDrawingNumber() {
+				let lb = 0;
+				if (this.item.ITEM_NO.startsWith('A') || this.item.ITEM_NO.startsWith('B')) {
+					lb = 1;
+				} else if (this.item.ITEM_NO.startsWith('C')) {
+					lb = 2;
+				}
+				const id = this.item.ENGINEERING_NO;
+				// lb = 2;
+				// const id = 'A3-A010';
+				const url = "http://192.168.0.98:808/deviceMessage.ashx?lb='"+lb+"'&id='"+id+"'";
+				//const url = `/api/deviceMessage.ashx?lb=${lb}&id=${id}`; // 浣跨敤浠g悊璺緞
+
+				// 鎵撳嵃 URL 杩涜璋冭瘯
+				console.log("Request URL:", url);
+				uni.request({
+					url: url,
+					method: 'POST',
+					success: (response) => {
+						const respData = response.data;
+						if (respData != "") {
+							this.pdfLink = respData;
+							this.pdfVisible = true;
+						} else {
+							uni.showToast({
+								title: respData.msg,
+								icon: 'none'
+							});
+						}
+					},
+					fail: (error) => {
+						uni.showToast({
+							title: '璇锋眰鍥惧彿閾炬帴澶辫触',
+							icon: 'none'
+						});
+					}
+				});
+			},
+			closeModal() {
+				this.pdfVisible = false;
 			}
 		},
-		getMaterialInfo(checkNo) {
-		     return uni.request({
-		       url: '/check/getMaterialInfo?checkNo=' + checkNo,
-		       method: 'POST',
-		       header: {
-		         'Content-Type': 'application/json',
-		         'dataType': 'json',
-		         'Accept': 'application/json'
-		       }
-		     });
-		   },
-		    closeModal() {
-		           this.pdfVisible = false;
-		         },
-		fetchDrawingNumber() {
-						      // 鑾峰彇褰撳墠椤甸潰鐨勬楠屽崟鍙�
-						      const checkNo = this.item.CHECK_NO;
-						
-						      // 绗竴娆¤姹傦細鑾峰彇鐗╂枡淇℃伅
-						      this.getMaterialInfo(checkNo).then(res => {
-						        const data = res[1].data; // uni.request 杩斿洖鐨勬槸涓�涓暟缁勶紝res[1] 鎵嶆槸 response
-						        if (data.result) {
-						          const { materialId, drawingNumber } = data.data;
-						           const url = `http://192.168.0.98:808/deviceMessage.ashx?lb=${materialId}&id=${drawingNumber}`;
-		
-						          // 绗簩娆¤姹傦細鑾峰彇PDF閾炬帴
-						          uni.request({
-						            url: url,
-						            method: 'POST',
-						            success: (response) => {
-						              const respData = response.data;
-						              if (respData.result) {
-						                this.pdfLink = respData.link; // 璁剧疆PDF閾炬帴
-						                this.pdfVisible = true; // 鎵撳紑寮瑰嚭绐楀彛
-						              } else {
-						                uni.showToast({
-						                  title: respData.msg,
-						                  icon: 'none'
-						                });
-						              }
-						            },
-						            fail: (error) => {
-						              uni.showToast({
-						                title: '璇锋眰鍥惧彿閾炬帴澶辫触',
-						                icon: 'none'
-						              });
-						            }
-						          });
-						        } else {
-						          uni.showToast({
-						            title: data.msg,
-						            icon: 'none'
-						          });
-						        }
-						      }).catch(error => {
-						        uni.showToast({
-						          title: '鑾峰彇鐗╂枡淇℃伅澶辫触',
-						          icon: 'none'
-						        });
-						      });
-						    
-						}
 	}
 </script>
 
@@ -434,7 +420,52 @@
 	.text {
 		font-size: x-large;
 	}
-	.red{
+
+	.red {
 		color: red;
 	}
+
+
+	.modal {
+		display: flex;
+		justify-content: center;
+		align-items: center;
+		position: absolute;
+		top: 10%;
+		left: 0;
+		width: 100%;
+		height: 100%;
+		background-color: rgba(0, 0, 0, 0.5);
+		z-index: 1000;
+	}
+
+	.modal-content {
+		background-color: white;
+		padding: 20px;
+		border-radius: 10px;
+		width: 80%;
+		height: 80%;
+	}
+
+	.pdf-view {
+		width: 100%;
+		height: 100%;
+	}
+
+	button {
+		background-color: #4CAF50;
+		color: white;
+		border: none;
+		padding: 10px 20px;
+		text-align: center;
+		text-decoration: none;
+		display: inline-block;
+		font-size: 16px;
+		margin: 4px 2px;
+		cursor: pointer;
+	}
+
+	button:hover {
+		background-color: #45a049;
+	}
 </style>
\ No newline at end of file

--
Gitblit v1.9.3