From 5f0b94e9c252e507b4c09badf923796151be0d03 Mon Sep 17 00:00:00 2001 From: cnf <3200815559@qq.com> Date: 星期四, 15 五月 2025 11:17:49 +0800 Subject: [PATCH] 最新 --- pages/QC/LLJ/Add.vue | 228 ++++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 184 insertions(+), 44 deletions(-) diff --git a/pages/QC/LLJ/Add.vue b/pages/QC/LLJ/Add.vue index d4a9f86..1b1a998 100644 --- a/pages/QC/LLJ/Add.vue +++ b/pages/QC/LLJ/Add.vue @@ -30,11 +30,6 @@ <view class="info-block"> <view class="info-label">鐗╂枡缂栫爜锛�</view> <view class="info-value">{{formData.itemNo}}</view> - <!-- 閫犳ⅵ鑰呯壒娈婂姛鑳� --> - <view class="doc-links"> - <a class="doc-link" @click="toFileUrlByU9List(1,formData.itemNo)">鍥剧焊瑙勬牸涔�</a> - <a class="doc-link" @click="toFileUrlByU9List(2,formData.itemNo)">杩涙枡妫�楠屾枃浠�</a> - </view> </view> <view class="info-block"> @@ -50,11 +45,11 @@ <view class="info-label" v-if="formData.extendNo1!=null">鎶�鏀圭姸鎬侊細</view> <view class="info-value" v-if="formData.extendNo1!=null">{{formData.extendNo1}}</view> - <view class="info-label">椤圭洰锛�</view> - <view class="info-value">{{formData.projectCodes}}</view> + <view class="info-label">鏁伴噺锛�</view> <view class="info-value highlight">{{formData.fcovertQty}}</view> + </view> <view class="info-block" v-if="formData.fngDesc!=null"> <view class="info-label">涓嶈壇鎻忚堪锛�</view> @@ -223,7 +218,8 @@ WORKSHOP: '', REMARK: '', checkState: false, - writeStatu: true + writeStatu: true, + fileName:'' } }, onLoad(options) { @@ -363,20 +359,40 @@ }).then(res => { if (res.status == 0) { - this.QcIssueResultDetailes = { - fbatchQty: this.formData.fbatchQty, - itemName: this.formData.itemName, - itemNo: this.formData.itemNo, - suppName: this.formData.suppName, - appicationReason: this.formData.fngDesc, - badReason: this.badreason, - remark: this.REMARK, - releaseNo: this.formData.releaseNo, - staffNo: 'HMCS', - // staffNo: this.formData.userNo, - iqcStatus: this.PSTYPE, - department: this.DEPARTMENT - }; + if(this.$loginInfo.account == 'PL017'){ + this.QcIssueResultDetailes = { + fbatchQty: this.formData.fbatchQty, + itemName: this.formData.itemName, + itemNo: this.formData.itemNo, + suppName: this.formData.suppName, + appicationReason: this.formData.fngDesc, + badReason: this.badreason, + remark: this.REMARK, + workShop: this.WORKSHOP, + releaseNo: this.formData.releaseNo, + staffNo: 'HMCS', + // staffNo: this.$loginInfo.account, + iqcStatus: this.PSTYPE, + department: this.DEPARTMENT + }; + } + else{ + this.QcIssueResultDetailes = { + fbatchQty: this.formData.fbatchQty, + itemName: this.formData.itemName, + itemNo: this.formData.itemNo, + suppName: this.formData.suppName, + appicationReason: this.formData.fngDesc, + badReason: this.badreason, + remark: this.REMARK, + workShop: this.WORKSHOP, + releaseNo: this.formData.releaseNo, + // staffNo: 'HMCS', + staffNo: this.$loginInfo.account, + iqcStatus: this.PSTYPE, + department: this.DEPARTMENT + }; + } console.log(this.QcIssueResultDetailes) @@ -611,9 +627,9 @@ }, fetchDrawingNumber() { - const item = '83070100066' - // const item = this.formData.itemNo; - // console.log(this.formData.itemNo) + // const item = '83040700101' + const item = this.formData.itemNo; + console.log(this.formData.itemNo) // console.log(item) const url = "http://192.168.1.22:10054/api/PLM/RetrieveDrawings?ItemNo=" + item @@ -661,14 +677,123 @@ openDrawings(item) { console.log("jkjoi", item) if (item.fRelevantObject.length > 2) { - const url = "http://192.168.1.22:10054/api/PLM/OpenDrawings?fileId=" + item.fRelevantObject + - '&fName=' + encodeURIComponent(item.fName.replace(/\%/g, '%25').replace(/\ /g, '%20') - .replace( - /\#/g, '%23').replace(/\?/g, '%3F').replace(/\+/g, '%2B').replace(/\//g, '%2F') - .replace( - /\&/g, '%26')) - console.log('jpgurl锛� ' + url); + // 鐢熸垚璇锋眰URL锛堢畝鍖栫紪鐮侀�昏緫锛� + const encodedName = encodeURIComponent(item.fName); + const url = `http://192.168.1.22:10054/api/PLM/OpenDrawingsGet?fileId=${item.fRelevantObject}&fName=${encodedName}`; + console.log('璇锋眰URL:', url); + + const now = new Date(); + const timestamp = [ + now.getFullYear(), + String(now.getMonth() + 1).padStart(2, '0'), + String(now.getDate()).padStart(2, '0'), + String(now.getHours()).padStart(2, '0'), + String(now.getMinutes()).padStart(2, '0'), + String(now.getSeconds()).padStart(2, '0') + ].join(''); + + // 鐢熸垚鏂版枃浠跺悕锛堝熀纭�鍚峗鏃堕棿鎴�.鍚庣紑锛� + this.fileName = `${item.fName}_${timestamp}.pdf`; + console.log('鏂版枃浠跺悕:', this.fileName); + + uni.downloadFile({ + url: url, + success: (res) => { + console.log(res); + let fileName = this.fileName; + let fileExt = fileName.split('.').pop(); + // let newFilePath = "_doc/uniapp_temp_1742877118745/download" + "/" + fileName; + // console.log('newFilePath', newFilePath) + if (fileExt === 'xls' || fileExt === 'xlsx' || fileExt === 'pdf'|| fileExt === 'jpg'|| fileExt === 'png') { + plus.io.resolveLocalFileSystemURL(res.tempFilePath, (entry) => { + // 鑾峰彇鏂囦欢鎵�鍦ㄧ殑鐩綍 + entry.getParent((parentEntry) => { + let newFileName = this.fileName; // 鏂扮殑鏂囦欢鍚� + + // 绉诲姩骞堕噸鍛藉悕鏂囦欢 + entry.moveTo( + parentEntry, + newFileName, + (newEntry) => { + console.log('閲嶅懡鍚嶆垚鍔�:', newEntry.fullPath); + + // 鎵撳紑 Excel 鏂囦欢 + plus.runtime.openFile(newEntry.fullPath, {}, (e) => { + console.error('鏃犳硶鎵撳紑 Excel 鏂囦欢:', e); + }); + + // let pages = getCurrentPages(); + // let beforePage = pages[pages.length - 2]; + // uni.navigateBack({ + // delta: 1, //杩斿洖鐨勯〉闈㈡暟锛屽鏋滀负1琛ㄧず杩斿洖涓婁竴椤� + // success: (event) => { + // beforePage.$vm.reload() + // } + // }); + + }, + (err) => { + console.error('閲嶅懡鍚嶅け璐�:', err); + } + ); + }, (err) => { + console.error('鑾峰彇鐖剁洰褰曞け璐�:', err); + }); + }, (err) => { + console.error('鑾峰彇鏂囦欢澶辫触:', err); + }); + } else { + console.error('鏂囦欢鏍煎紡涓嶅尮閰�:', fileExt); + uni.showToast({ + title: '鏂囦欢鏍煎紡涓嶆敮鎸�', + icon: 'none' + }); + } + } + }) + + + // uni.downloadFile({ + // url: url, + // responseType: 'arraybuffer', // 鍏抽敭锛氭寚瀹氬搷搴旀暟鎹被鍨嬩负 ArrayBuffer + // success: (res) => { + // console.log(res) + // if (res.statusCode === 200) { + // // 鑾峰彇 ArrayBuffer 鏁版嵁 + // const arrayBuffer = res.data; + // // 鍙�夛細楠岃瘉鏂囦欢绫诲瀷锛堜緥濡傛鏌� PDF 鏂囦欢澶达級 + // const header = new Uint8Array(arrayBuffer).subarray(0, 4); + // const headerStr = Array.from(header).map(byte => byte.toString(16).padStart(2, + // '0')).join('').toUpperCase(); + // if (headerStr !== '25504446') { // PDF 鏂囦欢澶翠负 "%PDF" 鐨勫崄鍏繘鍒惰〃绀� + // console.error('鏂囦欢鏍煎紡鏃犳晥锛岄潪 PDF 鏂囦欢'); + // return; + // } + + // // 淇濆瓨涓轰复鏃舵枃浠讹紙纭繚鎵╁睍鍚嶄负 .pdf锛� + // const tempPath = `${wx.env.USER_DATA_PATH}/${Date.now()}.pdf`; // 寰俊灏忕▼搴忚矾寰� + // uni.saveFile({ + // tempFilePath: arrayBuffer, // 娉ㄦ剰锛氶儴鍒嗗钩鍙板彲鑳介渶瑕佽浆鎹� ArrayBuffer 涓� Base64 + // filePath: tempPath, + // success: () => { + // uni.openDocument({ + // filePath: tempPath, + // fileType: 'pdf', + // success: () => console.log('鏂囨。鎵撳紑鎴愬姛'), + // fail: (err) => console.error('鎵撳紑澶辫触:', err) + // }); + // }, + // fail: (saveErr) => console.error('淇濆瓨鏂囦欢澶辫触:', saveErr) + // }); + // } else { + // console.error('涓嬭浇澶辫触锛岀姸鎬佺爜:', res.statusCode); + // } + // }, + // fail: (error) => { + // console.error('涓嬭浇璇锋眰澶辫触:', error.errMsg); + // } + // }); uni.request({ url: url, method: 'POST', @@ -681,19 +806,32 @@ duration: 2000 }); } - const base64Data = uni.arrayBufferToBase64(response.data); + + + + // const base64Data = uni.arrayBufferToBase64(response.data); - // 鏋勯�犱竴涓彲浠ョ敤浜庨瑙堢殑 Data URL - const pdfUrl = `data:application/pdf;base64,${base64Data}`; + // // 鏋勯�犱竴涓彲浠ョ敤浜庨瑙堢殑 Data URL + // const pdfUrl = `data:application/pdf;base64,${base64Data}`; - // 浣跨敤 pdfUrl 浣滀负棰勮璺緞 - console.log("PDF 棰勮璺緞锛�", pdfUrl); + // // 浣跨敤 pdfUrl 浣滀负棰勮璺緞 + // console.log("PDF 棰勮璺緞锛�", pdfUrl); - // 灏� Base64 鏁版嵁浼犻�掔粰鍙︿竴涓〉闈㈣繘琛岄瑙� - // 娉ㄦ剰锛氱洿鎺ヤ紶閫� pdfUrl 鍙兘浼氬鑷� URL 杩囬暱锛屽缓璁娇鐢ㄥ叾浠栨柟寮忎紶閫� - uni.navigateTo({ - url: `/pages/fileView/pdfView?url=${encodeURIComponent(pdfUrl)}` - }); + // // 灏� Base64 鏁版嵁浼犻�掔粰鍙︿竴涓〉闈㈣繘琛岄瑙� + // // 娉ㄦ剰锛氱洿鎺ヤ紶閫� pdfUrl 鍙兘浼氬鑷� URL 杩囬暱锛屽缓璁娇鐢ㄥ叾浠栨柟寮忎紶閫� + // uni.navigateTo({ + // url: `/pages/fileView/pdfView?url=${encodeURIComponent(pdfUrl)}` + // }); + + // const base64Data = uni.arrayBufferToBase64(response.data); + + // // 瀛樺偍鍒板叏灞�鍙橀噺锛堝湪App.vue涓畾涔夛級 + // getApp().globalData.tempPDF = base64Data; + + // uni.navigateTo({ + // url: '/pages/fileView/pdfView' + // }); + }, fail: (error) => { console.log(error) @@ -706,7 +844,8 @@ } else if (item.fName && item.fName.toLowerCase().endsWith('.jpg')) { const url = "http://192.168.1.22:10054/api/PLM/OpenDrawings?fileId=" + item.fFileId + '&fName=' + - encodeURIComponent(item.fName.replace(/\%/g, '%25').replace(/\ /g, '%20').replace(/\#/g, + encodeURIComponent(item.fName.replace(/\%/g, '%25').replace(/\ /g, '%20').replace( + /\#/g, '%23') .replace(/\?/g, '%3F').replace(/\+/g, '%2B').replace(/\//g, '%2F').replace(/\&/g, '%26')) @@ -749,7 +888,8 @@ console.log(item); const url = "http://192.168.1.22:10054/api/PLM/OpenDrawings?fileId=" + item.fFileId + '&fName=' + - encodeURIComponent(item.fName.replace(/\%/g, '%25').replace(/\ /g, '%20').replace(/\#/g, + encodeURIComponent(item.fName.replace(/\%/g, '%25').replace(/\ /g, '%20').replace( + /\#/g, '%23') .replace(/\?/g, '%3F').replace(/\+/g, '%2B').replace(/\//g, '%2F').replace(/\&/g, '%26')) -- Gitblit v1.9.3