From cdc6decaadbc0abbe46167a0796fa7f701443d7f Mon Sep 17 00:00:00 2001 From: xwt <2740516069@qq.com> Date: 星期五, 05 九月 2025 13:14:35 +0800 Subject: [PATCH] llj优化 --- pages/QC/LLJ/Add.vue | 1768 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 1,523 insertions(+), 245 deletions(-) diff --git a/pages/QC/LLJ/Add.vue b/pages/QC/LLJ/Add.vue index 3d0778d..1b1d505 100644 --- a/pages/QC/LLJ/Add.vue +++ b/pages/QC/LLJ/Add.vue @@ -1,14 +1,14 @@ <template> <view class="inspection-sheet"> - <!-- 澶撮儴淇℃伅 --> - <view class="sheet-header"> - <h1>鏉ユ枡妫�楠屽崟</h1> - <view class="inspection-number">妫�楠屽崟鍙凤細{{formData.releaseNo}}</view> - <!--瀹為獙瀹ら�佹 --> - <view style="text-align: right;" class="action-buttons"> - <a class="sysLike" v-if="this.current" @click="toSysSubmitFrom(formData.releaseNo)">瀹為獙瀹ら�佹</a> + <!-- 澶撮儴淇℃伅 --> + <view class="sheet-header"> + <h1>鏉ユ枡妫�楠屽崟</h1> + <view class="inspection-number">妫�楠屽崟鍙凤細{{formData.releaseNo}}</view> + <!--瀹為獙瀹ら�佹 --> + <view style="text-align: right;" class="action-buttons"> + <a class="sysLike" v-if="this.current" @click="toSysSubmitFrom(formData.releaseNo)">瀹為獙瀹ら�佹</a> + </view> </view> - </view> <!-- 鍩烘湰淇℃伅鍖� --> <view class="basic-info"> @@ -56,57 +56,45 @@ <view class="info-label">涓嶈壇鎻忚堪锛�</view> <view class="info-value">{{formData.fngDesc}}</view> </view> - <view class="info-block" v-if="formData.newFngDesc!=null"> - <view class="info-label">涓婃涓嶈壇锛�</view> - <view class="info-value">{{formData.newFngDesc}}</view> - </view> </view> <view class="dropdown-row"> <view class="info-label">涓嶈壇鍘熷洜锛�</view> - <select id="defect-reason" v-model="badreason" v-if="current"> - <option value=""></option> - <option value="澶栬涓嶈壇">澶栬涓嶈壇</option> - <option value="鍔熻兘涓嶈壇">鍔熻兘涓嶈壇</option> - </select> + <picker v-if="current" :value="badreasonIndex" :range="badreasonOptions" @change="onBadreasonChange"> + <view class="picker-text" :class="{ 'selected': badreason }">{{ badreason || '' }}</view> + </picker> + <view v-else class="info-value">{{ badreason }}</view> </view> <view class="dropdown-row"> <view class="info-label">鎵�灞炶溅闂达細</view> - <select id="defect-reason" v-model="WORKSHOP" v-if="current"> - <option value=""></option> - <option value="鐢熶骇涓�閮�">鐢熶骇涓�閮�</option> - <option value="鐢熶骇浜岄儴">鐢熶骇浜岄儴</option> - <option value="娉ㄥ杞﹂棿">娉ㄥ杞﹂棿</option> - <option value="鍏朵粬">鍏朵粬</option> - </select> + <picker v-if="current" :value="workshopIndex" :range="workshopOptions" @change="onWorkshopChange"> + <view class="picker-text" :class="{ 'selected': WORKSHOP }">{{ WORKSHOP || '' }}</view> + </picker> + <view v-else class="info-value">{{ WORKSHOP }}</view> </view> <view class="dropdown-row"> <view class="info-label">璇勫鐘舵�侊細</view> - <select id="defect-reason" v-model="PSTYPE" v-if="current"> - <option value=""></option> - <option value="鐗归噰/璁╂浣跨敤">鐗归噰/璁╂浣跨敤</option> - <option value="鎸戦��/杩斿伐浣跨敤">鎸戦��/杩斿伐浣跨敤</option> - <option value="閫�璐�">閫�璐�</option> - - </select> + <picker v-if="current" :value="pstypeIndex" :range="pstypeOptions" @change="onPstypeChange"> + <view class="picker-text" :class="{ 'selected': PSTYPE }">{{ PSTYPE || '' }}</view> + </picker> + <view v-else class="info-value">{{ PSTYPE }}</view> </view> - <view class="info-block" style="margin-top: 10px;"> + <view class="info-block" style="margin-top: 10px;"> <view class="info-label">澶囨敞锛�</view> <input type="text" id="lotNo1" v-model="formData.lotNo1" placeholder="璇疯緭鍏ュ娉ㄤ俊鎭�" style="color: red; font-weight: bold;"/> </view> - - - - - <!-- 鎿嶄綔鎸夐挳鍖� --> - <view class="action-buttons" v-if="this.current"> - <button class="secondary-btn" @click="handleEmergencyRelease">绱ф�ユ斁琛�</button> - <button class="secondary-btn" @click="handleWithdraw">鎾ゅ洖</button> - <button class="secondary-btn" @click="getInspectionItems">鑾峰彇妫�楠岄」鐩�</button> + <view class="info-block" style="margin-top: 10px;"> + <view class="info-label">鐮村潖瀹為獙鏁伴噺锛�</view> + <view class="info-value highlight">{{formData.PHSY || formData.phsy || ''}}</view> </view> - + <!-- 琛ㄥ崟涓婃柟鎿嶄綔鎸夐挳鍖� --> + <view class="top-action-buttons"> + <button class="action-btn" @click="getInspectionItems" v-if="this.current">鑾峰彇妫�楠岄」鐩�</button> + <button class="action-btn" @click="handleEmergencyRelease" v-if="this.current">绱ф�ユ斁琛�</button> + <button class="action-btn" @click="handleWithdraw" v-if="this.current">鎾ゅ洖</button> + </view> <!-- 妫�楠岄」鐩〃鏍� --> <view class="inspection-table"> @@ -143,12 +131,14 @@ </table> </view> - <!-- 鎿嶄綔鎸夐挳鍖� --> - <view class="action-buttons"> - <button class="secondary-btn" @click="uploadImages">涓婁紶/鏌ョ湅鍥剧墖</button> - <button class="secondary-btn" @click="fetchDrawingNumber">璋冨彇PLM鍥剧焊</button> - <button class="secondary-btn" @click="addDefectDescription" v-if="this.current">娣诲姞涓嶈壇鎻忚堪</button> - <button class="primary-btn" @click="submitInspection" v-if="this.current">妫�楠屾彁浜�</button> + <!-- 琛ㄥ崟涓嬫柟鎿嶄綔鎸夐挳鍖� --> + <view class="bottom-action-buttons"> + <button class="action-btn small" @click="addDestruction" v-if="this.current">鐮村潖瀹為獙</button> + <button class="action-btn small" @click="uploadImages">涓婁紶/鏌ョ湅鍥剧墖</button> + <button class="action-btn small" @click="fetchDrawingNumber">璋冨彇PLM鍥剧焊</button> + <button class="action-btn small" @click="viewAttachmentInfo">鏌ョ湅闄勪欢淇℃伅</button> + <button class="action-btn small" @click="addDefectDescription" v-if="this.current">娣诲姞涓嶈壇鎻忚堪</button> + <button class="action-btn small primary" @click="submitInspection" v-if="this.current">妫�楠屾彁浜�</button> </view> <view v-if="remarksPopup" class="overlay"> <view class="popup"> @@ -165,18 +155,33 @@ </view> </view> + <view v-if="destructionPopup" class="overlay"> + <view class="popup"> + <h3>鐮村潖瀹為獙鏁伴噺</h3> + <form> + <view class="form-group"> + <label class="form-label">鐮村潖瀹為獙鏁伴噺:</label> + <input class="form-input" type="text" v-model="PHSY" placeholder="鐣欑┖琛ㄧず娓呴櫎鏁伴噺" /> + </view> + </form> + <div v-if="!isInteger" class="error-message">璇疯緭鍏ユ暣鏁板�兼垨鐣欑┖</div> + <button class="updateBut" @click="editDestruction">淇敼</button> + <button @click="clearDestruction">娓呴櫎</button> + <button @click="destructionPopup = !destructionPopup">鍙栨秷</button> + </view> + </view> <view class="barcode"> <u-modal :show="drawingShow" title="鍥剧焊鏄庣粏" @confirm="drawingConfirm" @cancel="drawingCancel" - showCancelButton> - <uni-table border stripe emptyText="鏆傛棤鏇村鏁版嵁" style="margin-left: 5px;margin-right: 5px;height: 500px;"> + showCancelButton :z-index="1000"> + <uni-table border stripe emptyText="鏆傛棤鏇村鏁版嵁" style="margin-left: 5px;margin-right: 5px;height: 400px;max-height: 60vh;overflow-y: auto;"> <uni-tr> <uni-th align="center">鐩稿叧鏂囨。</uni-th> <uni-th align="center" width="90">鏈夋棤鍏宠仈PDF鏂囦欢</uni-th> <uni-th align="center" width="90">鑳藉惁鎵撳紑鏂囦欢</uni-th> <uni-th align="center" width="150">鎿嶄綔锛堢偣鍑伙級</uni-th> </uni-tr> - <uni-tr v-for="(item,index) in drawing" style="height: 100px;"> + <uni-tr v-for="(item,index) in (drawing || [])" style="height: 100px;"> <uni-td align="center">{{item.fName}}</uni-td> <uni-td align="center" style="font-size:25px;"> <div v-if="item.fRelevantObject==' '" style="color: #E47470;">脳</div> @@ -192,6 +197,104 @@ </uni-tr> </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 class="attachment-actions-detail"> + <button class="attachment-action-btn preview-btn" + @click="previewFtpFile(selectedAttachment)" + v-if="isPreviewable(selectedAttachment.fattach)"> + 馃攳 鍦ㄧ嚎棰勮 + </button> + <button class="attachment-action-btn download-btn" + @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"> + <div class="attachment-info"> + <span class="attachment-name" @click="showAttachmentDetailDialog(item)"> + {{ item.fattach }} + </span> + <div class="attachment-meta"> + <span class="attachment-type">{{ item.ftype || '鏈煡绫诲瀷' }}</span> + </div> + </div> + <div class="attachment-actions"> + <button class="secondary-btn" @click="showAttachmentDetailDialog(item)">璇︽儏</button> + <button class="secondary-btn preview-btn" @click="previewFtpFile(item)" + v-if="isPreviewable(item.fattach)">棰勮</button> + <button class="secondary-btn" @click="downloadAttachment(item)">涓嬭浇</button> + </div> + </li> + </ul> + <button class="attachment-popup-close" @click="closeAttachmentPopup">鍏抽棴</button> + </view> + </view> + + <!-- 鏂囦欢棰勮寮圭獥 --> + <view v-if="showFilePreviewPopup" class="overlay"> + <view class="popup file-preview-popup"> + <h3 class="file-preview-title">{{ previewTitle }}</h3> + <div class="file-preview-divider"></div> + <div class="file-preview-content"> + <!-- 鏂囨湰鍐呭棰勮 --> + <pre v-if="previewType === 'text'">{{ previewContent }}</pre> + + <!-- 鍥剧墖鍐呭棰勮 --> + <view v-else-if="previewType === 'image'" class="image-preview-container"> + <image + :src="previewContent" + mode="aspectFit" + class="preview-image-clickable" + @click="previewImageInPopup" + style="width: 100%; max-height: 400px; cursor: pointer;" + /> + <div class="image-zoom-hint">鐐瑰嚮鍥剧墖鍙斁澶ф煡鐪�</div> + </view> + + <!-- Excel 绛� Office 鏂囦欢鎻愮ず --> + <view v-else-if="previewType === 'excel'" class="unsupported-preview"> + <view class="unsupported-icon">馃搳</view> + <view class="unsupported-text">Excel 鏂囦欢鏆備笉鏀寔鍦ㄧ嚎棰勮</view> + <view class="unsupported-hint">璇风偣鍑讳笅杞芥寜閽幏鍙栧畬鏁存枃浠�</view> + </view> + + <!-- 涓嶆敮鎸佺殑鏂囦欢绫诲瀷 --> + <view v-else class="unsupported-preview"> + <view class="unsupported-icon">馃搫</view> + <view class="unsupported-text">姝ゆ枃浠舵牸寮忔殏涓嶆敮鎸侀瑙�</view> + <view class="unsupported-hint">璇风偣鍑讳笅杞芥寜閽幏鍙栧畬鏁存枃浠�</view> + </view> + </div> + <div class="file-preview-actions"> + <button v-if="previewType !== 'text'" class="file-preview-btn download-btn" @click="downloadPreviewFile">馃摜 涓嬭浇鏂囦欢</button> + <button class="file-preview-btn close-btn" @click="closeFilePreview">鍏抽棴</button> + </div> + </view> </view> </view> @@ -225,6 +328,8 @@ permissionAccount: '', hasEmergencyPermission: false, showPopup: false, + PHSY:'', + EMERGENCY: '0', }, tableData: [], @@ -237,12 +342,45 @@ PSTYPE: '', WORKSHOP: '', REMARK: '', + // picker 閫夐」鍜岀储寮� + badreasonOptions: ['', '澶栬涓嶈壇', '灏哄涓嶈壇', '鍖呰涓嶈壇', '鎬ц兘涓嶈壇', '瑁呴厤涓嶈壇', '瀹夎涓嶈壇'], + badreasonIndex: 0, + workshopOptions: ['', '鐢熶骇涓�閮�', '鐢熶骇浜岄儴', '娉ㄥ杞﹂棿', '鍏朵粬'], + workshopIndex: 0, + pstypeOptions: ['', '鐗归噰/璁╂浣跨敤', '鎸戦��/杩斿伐浣跨敤', '閫�璐�', '寰呭垽'], + pstypeIndex: 0, checkState: false, writeStatu: true, fileName:'', originalRemarks: '', hasEmergencyPermission: false, + destructionPopup: false, + PHSY: '', + isInteger: true, + attachments: [], + showAttachmentPopup: false, + attachmentsLoading: false, + selectedAttachment: null, + showAttachmentDetail: false, + showFilePreviewPopup: false, + previewContent: '', + previewTitle: '', + previewItemNo: '', + previewType: '', // 'text', 'image', 'excel', 'unsupported' + } + }, + computed: { + isUnmaintainedAndNotEmergency() { + // 鍒ゆ柇琛ㄥ崟鏄惁鏈淮鎶や笖涓嶆槸绱ф�ユ斁琛� + // 鏈淮鎶ょ殑鏉′欢锛歵ableData涓虹┖鎴栨墍鏈夋楠岄」鐩兘鏈畬鎴� + const isUnmaintained = this.tableData.length === 0 || + this.tableData.every(item => item.fcheckResu === null || item.fcheckResu === ''); + + // 涓嶆槸绱ф�ユ斁琛岀殑鏉′欢锛歟mergencyStatus涓篺alse + const isNotEmergency = !this.formData.emergencyStatus; + + return isUnmaintained && isNotEmergency; } }, onLoad(options) { @@ -282,6 +420,10 @@ } if (this.$loginInfo.account === 'PL017') {this.hasEmergencyPermission = true;} + // 娴嬭瘯闄勪欢鏈嶅姟鍣ㄨ繛鎺� + + + }, methods: { getStatusText(status) { @@ -306,7 +448,8 @@ data: { itemNo: this.formData.itemId, quantity: this.formData.fcovertQty, - releaseNo: this.formData.releaseNo + releaseNo: this.formData.releaseNo, + PHSY: this.formData.PHSY } }).then(res => { if (res.status == 0) { @@ -350,18 +493,71 @@ addDefectDescription() { // 娣诲姞涓嶈壇鎻忚堪鐨勯�昏緫 this.remarksPopup = !this.remarksPopup; - this.remarks = this.formData.remarks; + this.remarks = this.formData.remarks || this.remarks || ''; + console.log('鎵撳紑寮圭獥鏃剁殑remarks鍊�:', this.remarks); + }, + // picker 浜嬩欢澶勭悊鏂规硶 + onBadreasonChange(e) { + const index = e.detail.value; + this.badreasonIndex = index; + this.badreason = this.badreasonOptions[index]; + this.saveRemarksGid('badreason'); + }, + onWorkshopChange(e) { + const index = e.detail.value; + this.workshopIndex = index; + this.WORKSHOP = this.workshopOptions[index]; + this.saveRemarksGid('WORKSHOP'); + }, + onPstypeChange(e) { + const index = e.detail.value; + this.pstypeIndex = index; + this.PSTYPE = this.pstypeOptions[index]; + this.saveRemarksGid('PSTYPE'); + }, + saveRemarksGid(fieldName) { + // 鐩存帴淇濆瓨鍒版暟鎹簱 + const requestData = { + gid: this.formData.id, + releaseNo: this.formData.releaseNo, + BLYY: this.badreason || '', + SSCJ: this.WORKSHOP || '', + PSZT: this.PSTYPE || '' + }; + console.log('鍙戦�佺殑鏁版嵁:', requestData); + console.log('badreason:', this.badreason); + console.log('WORKSHOP:', this.WORKSHOP); + console.log('PSTYPE:', this.PSTYPE); + console.log('閫夋嫨鐨勫瓧娈�:', fieldName); + this.$post({ + url: "/LLJ/saveDropdownFields", + data: requestData + }).then(res => { + if (res && res.data && res.data.data && res.data.data.tbBillList && res.data.data.tbBillList.length > 0) { + // 寤惰繜閲嶆柊鍔犺浇鏁版嵁锛岀‘淇濇暟鎹簱鏇存柊瀹屾垚 + setTimeout(() => { + this.init(); + }, 500); + } + }).catch(err => { + console.error('淇濆瓨澶辫触锛�', err); + }); }, submitInspection() { - if (this.PSTYPE == '') { - this.writeStatu = false - } - if (this.badreason == '') { - this.writeStatu = false - } - if (this.DEPARTMENT == '') { - this.writeStatu = false - } + + // 閲嶇疆楠岃瘉鐘舵�� + this.writeStatu = true; + + // if (this.PSTYPE == '') { + // this.writeStatu = false + // } + // if (this.badreason == '') { + // this.writeStatu = false + // } + // 绉婚櫎瀵规湭瀹氫箟鍙橀噺DEPARTMENT鐨勬鏌� + // if (this.DEPARTMENT == '') { + // this.writeStatu = false + // } console.log(this.tableData) this.checkState = false; @@ -372,9 +568,9 @@ }) if (this.checkState) { - if (this.formData.fngDesc == '' || this.writeStatu == false) { + if (this.formData.fngDesc == '') { uni.showToast({ - title: '鏈~鍐欎笉鑹弿杩版垨涓嶈壇鍘熷洜鎴栨墍灞炶溅闂存垨璇勫鐘舵��', + title: '鏈~鍐欎笉鑹弿杩�', icon: 'none' }); } else { @@ -388,45 +584,28 @@ }).then(res => { if (res.status == 0) { - 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 - }; - } + // 缁熶竴鎺ㄩ�佺粰HMCS锛屼笉绠″摢涓处鍙� + this.QcIssueResultDetailes = { + fbatchQty: this.formData.fcovertQty, + itemName: this.formData.itemName, + itemNo: this.formData.itemNo, + suppName: this.formData.suppName, + appicationReason: this.formData.fngDesc, + badReason: this.badreason, + remark: this.remarks || '', + workShop: this.WORKSHOP, + releaseNo: this.formData.releaseNo, + staffNo: 'HMCS', // 缁熶竴鎺ㄩ�佺粰HMCS + iqcStatus: this.PSTYPE, + department: this.WORKSHOP, // 浣跨敤WORKSHOP鏇夸唬鏈畾涔夌殑DEPARTMENT + EMERGENCY: this.formData.emergencyStatus ? "1" : "0" // 纭繚绱ф�ユ斁琛岀姸鎬佹纭紶閫� + }; - console.log(this.QcIssueResultDetailes) + console.log("鎻愪氦鐨勭揣鎬ユ斁琛岀姸鎬侊細", this.formData.emergencyStatus ? "1" : "0"); + console.log("瀹屾暣鐨勬彁浜ゆ暟鎹細", this.QcIssueResultDetailes); const url = this.$store.state.serverInfo.serverAPI+`/QcIssueResult/GetProcessNo`; - // 鍙戦�� POST 璇锋眰 + if (this.PSTYPE === '寰呭垽') {// 鍙戦�� POST 璇锋眰 uni.request({ url: url, // 璇锋眰鍦板潃 method: 'POST', // 璇锋眰鏂规硶 @@ -443,7 +622,10 @@ // 濡傛灉鏈夐〉闈㈣烦杞紝闇�瑕佺敤瀹氭椂鍣ㄥ欢杩� setTimeout(() => { - uni.navigateTo({ + // 璁剧疆涓�涓爣璁帮紝鍛婅瘔List椤甸潰闇�瑕佸埛鏂� + getApp().globalData = getApp().globalData || {}; + getApp().globalData.needRefreshList = true; + uni.redirectTo({ url: 'List' }); }, 2000); // 淇濇寔涓� duration 鐩稿悓鐨勬椂闀� @@ -458,7 +640,7 @@ }); } }); - + } uni.showToast({ title: res.message.toString(), icon: 'success', @@ -497,11 +679,11 @@ }) // 濡傛灉鏈夐〉闈㈣烦杞紝闇�瑕佺敤瀹氭椂鍣ㄥ欢杩� setTimeout(() => { - uni.navigateTo({ - url: 'List' - }); + // 璁剧疆涓�涓爣璁帮紝鍛婅瘔List椤甸潰闇�瑕佸埛鏂� + getApp().globalData = getApp().globalData || {}; + getApp().globalData.needRefreshList = true; + uni.navigateBack(); }, 2000); // 淇濇寔涓� duration 鐩稿悓鐨勬椂闀� - } else { uni.showModal({ title: "鎻愮ず", @@ -538,9 +720,25 @@ if (data) { this.formData = { ...data, - emergencyStatus: data.emergency + emergencyStatus: data.emergency === 1 || data.emergency === "1" || data.emergency === true }; + // 鍏抽敭锛氳祴鍊煎埌椤甸潰缁戝畾鍙橀噺 + this.badreason = data.blyy || ''; + this.PSTYPE = data.pszt || ''; + this.WORKSHOP = data.sscj || ''; + this.remarks = data.remarks || ''; // 璁剧疆remarks鍙橀噺 + + // 璁剧疆 picker 绱㈠紩 + this.badreasonIndex = this.badreasonOptions.indexOf(this.badreason); + this.workshopIndex = this.workshopOptions.indexOf(this.WORKSHOP); + this.pstypeIndex = this.pstypeOptions.indexOf(this.PSTYPE); + + // 纭繚PHSY瀛楁琚纭缃紙鍏煎澶у皬鍐欙級 + this.formData.PHSY = data.PHSY || data.phsy; + this.PHSY = (data.PHSY || data.phsy || '').toString(); // 鍚屾椂璁剧疆椤甸潰缁戝畾鐨凱HSY鍙橀噺 + + console.log("鍔犺浇鐨勭揣鎬ユ斁琛岀姸鎬�:", this.formData.emergencyStatus); this.$post({ url: "/LLJ/getJYItem", data: { @@ -551,6 +749,16 @@ let tableData = res1.data.tbBillList //褰撳凡妫�楠屼釜鏁伴兘涓嶄负绌烘椂鎸夌収妫�娴嬬粨鏋勬帓搴� tableData.sort((a, b) => { + // 棣栧厛鎸塅stand鎺掑簭锛欶stand涓嶄负绌虹殑鎺掑湪鍓嶉潰 + const aHasFstand = a.fstand !== null && a.fstand !== undefined; + const bHasFstand = b.fstand !== null && b.fstand !== undefined; + if (aHasFstand && !bHasFstand) { + return -1; + } else if (!aHasFstand && bHasFstand) { + return 1; + } + + // 鐒跺悗鎸夋楠岀粨鏋滄帓搴� if (a.result === '鍚堟牸' && b.result === '鏈畬鎴�') { return -1; } else if (a.result === '鏈畬鎴�' && b.result === '鍚堟牸') { @@ -592,60 +800,7 @@ url: 'SysSubmitFrom?releaseNo=' + releaseNo + '&userID=' + this.$loginInfo.account }); }, - editRemarks() { - if (this.remarks) { - //saveRemarksGid - this.$post({ - url: "/LLJ/saveRemarksGid", - data: { - gid: this.formData.id, - remarks: this.remarks, - releaseNo: this.formData.releaseNo, - } - }).then(res => { - if (res.data.tbBillList > 0) { - this.formData.remarks = this.remarks; - this.remarksPopup = !this.remarksPopup; - this.$showMessage("淇濆瓨鎴愬姛"); - setTimeout(() => { - let pages = getCurrentPages(); - let beforePage = pages[pages.length - 2]; - uni.navigateBack({ - delta: 1, //杩斿洖鐨勯〉闈㈡暟锛屽鏋滀负1琛ㄧず杩斿洖涓婁竴椤� - success: (event) => { - beforePage.$vm.reload() - } - }); - }, 2000); - } - }) - } else { - this.$post({ - url: "/LLJ/saveRemarksGid", - data: { - gid: this.formData.id, - remarks: '', - releaseNo: this.formData.releaseNo, - } - }).then(res => { - if (res.data.tbBillList > 0) { - this.formData.remarks = this.remarks; - this.remarksPopup = !this.remarksPopup; - this.$showMessage("淇濆瓨鎴愬姛"); - setTimeout(() => { - let pages = getCurrentPages(); - let beforePage = pages[pages.length - 2]; - uni.navigateBack({ - delta: 1, //杩斿洖鐨勯〉闈㈡暟锛屽鏋滀负1琛ㄧず杩斿洖涓婁竴椤� - success: (event) => { - beforePage.$vm.reload() - } - }); - }, 2000); - } - }) - } - }, + drawingConfirm() { this.drawingShow = false @@ -676,7 +831,7 @@ success: (response) => { console.log(response) if (response.data.data == '杩斿洖缁撴灉涓虹┖') { - _this.drawing = null + _this.drawing = [] } else { _this.drawing = response.data.data // 閬嶅巻鏁版嵁锛屽垽鏂枃浠跺悗缂�骞舵坊鍔犲瓧娈� @@ -1050,6 +1205,9 @@ this.formData.emergencyStatus = true; this.originalLotNo1 = lotNo1; this.formData.lotNo1 = lotNo1; + // 鏇存柊绱ф�ユ斁琛岀姸鎬侊紝纭繚鎻愪氦鏃惰兘姝g‘浼犻�� + this.formData.EMERGENCY = "1"; + uni.showToast({ title: message || '绱ф�ユ斁琛屾垚鍔�', icon: 'success', @@ -1096,6 +1254,9 @@ if (result === "0") { this.formData.emergencyStatus = false; + // 鏇存柊绱ф�ユ斁琛岀姸鎬侊紝纭繚鎻愪氦鏃惰兘姝g‘浼犻�� + this.formData.EMERGENCY = "0"; + uni.showToast({ title: message || '鎾ゅ洖鎴愬姛', icon: 'success', @@ -1122,64 +1283,704 @@ }); }, editRemarks() { - if (this.remarks) { - // 鍙繚瀛樹慨鏀圭殑閮ㄥ垎 - const modifiedRemarks = this.remarks !== this.originalRemarks ? this.remarks : ''; - - this.$post({ - url: "/LLJ/saveRemarksGid", - data: { - gid: this.formData.id, - remarks: modifiedRemarks, - releaseNo: this.formData.releaseNo, - } - }).then(res => { - if (res.data.tbBillList > 0) { - this.formData.remarks = this.remarks; - this.originalRemarks = this.remarks; // 鏇存柊鍘熷澶囨敞鍊� - this.remarksPopup = !this.remarksPopup; - this.$showMessage("淇濆瓨鎴愬姛"); - setTimeout(() => { - let pages = getCurrentPages(); - let beforePage = pages[pages.length - 2]; - uni.navigateBack({ - delta: 1, //杩斿洖鐨勯〉闈㈡暟锛屽鏋滀负1琛ㄧず杩斿洖涓婁竴椤� - success: (event) => { - beforePage.$vm.reload() - } - }); - }, 2000); - } - }) - } else { - this.$post({ - url: "/LLJ/saveRemarksGid", - data: { - gid: this.formData.id, - remarks: '', - releaseNo: this.formData.releaseNo, - } - }).then(res => { - if (res.data.tbBillList > 0) { - this.formData.remarks = this.remarks; - this.originalRemarks = this.remarks; // 鏇存柊鍘熷澶囨敞鍊� - this.remarksPopup = !this.remarksPopup; - this.$showMessage("淇濆瓨鎴愬姛"); - setTimeout(() => { - let pages = getCurrentPages(); - let beforePage = pages[pages.length - 2]; - uni.navigateBack({ - delta: 1, //杩斿洖鐨勯〉闈㈡暟锛屽鏋滀负1琛ㄧず杩斿洖涓婁竴椤� - success: (event) => { - beforePage.$vm.reload() - } - }); - }, 2000); - } - }) - } - }, + this.$post({ + url: "/LLJ/saveRemarksGid", + data: { + gid: this.formData.id, + remarks: this.remarks || '', + releaseNo: this.formData.releaseNo + } + }).then(res => { + if (res.data.tbBillList > 0) { + this.formData.remarks = this.remarks; + this.remarksPopup = !this.remarksPopup; + // 绔嬪嵆閲嶆柊鍔犺浇鏁版嵁纭繚鍚屾 + setTimeout(() => { + this.init(); + }, 500); + } + }).catch(err => { + console.error('淇濆瓨澶辫触锛�', err); + }) + }, + addDestruction() { + // 娣诲姞鐮村潖瀹為獙鐨勯�昏緫 + this.destructionPopup = !this.destructionPopup; + // 淇锛氱‘淇漃HSY鍙橀噺姝g‘鍒濆鍖� + this.PHSY = this.formData.PHSY || ''; + this.isInteger = true; + }, + editDestruction() { + // 楠岃瘉杈撳叆鏄惁涓烘暣鏁版垨绌哄瓧绗︿覆 + if(this.PHSY === '') { + this.isInteger = true; + } else { + const isInteger = /^-?\d+$/.test(this.PHSY); + this.isInteger = isInteger; + if (!isInteger) { + uni.showToast({ + title: '璇疯緭鍏ユ暣鏁板�兼垨鐣欑┖', + icon: 'none', + duration: 2000 + }); + return; + } + } + + // 鏄剧ず鍔犺浇鎻愮ず + uni.showLoading({ + title: '淇濆瓨涓�...' + }); + + this.$post({ + url: "/LLJ/savePhsyGid", + data: { + gid: this.formData.id, + releaseNo: this.formData.releaseNo, + PHSY: this.PHSY + } + }).then(res => { + uni.hideLoading(); + if (res.data && res.data.tbBillList > 0) { + this.formData.PHSY = this.PHSY === '' ? null : this.PHSY; + this.destructionPopup = false; + uni.showToast({ + title: '淇濆瓨鎴愬姛', + icon: 'success', + duration: 2000 + }); + // 绔嬪嵆閲嶆柊鍔犺浇鏁版嵁纭繚鍚屾 + setTimeout(() => { + this.init(); + }, 500); + } else { + uni.showToast({ + title: '淇濆瓨澶辫触', + icon: 'none', + duration: 2000 + }); + } + }).catch(err => { + uni.hideLoading(); + console.error('淇濆瓨澶辫触锛�', err); + uni.showToast({ + title: '淇濆瓨澶辫触锛岃閲嶈瘯', + icon: 'none', + duration: 2000 + }); + }) + }, + clearDestruction() { + // 鏄剧ず鍔犺浇鎻愮ず + uni.showLoading({ + title: '娓呴櫎涓�...' + }); + + this.$post({ + url: "/LLJ/savePhsyGid", + data: { + gid: this.formData.id, + releaseNo: this.formData.releaseNo, + PHSY: '' + } + }).then(res => { + uni.hideLoading(); + if (res.data && res.data.tbBillList > 0) { + this.formData.PHSY = null; + this.PHSY = ''; + this.destructionPopup = false; + uni.showToast({ + title: '娓呴櫎鎴愬姛', + icon: 'success', + duration: 2000 + }); + // 绔嬪嵆閲嶆柊鍔犺浇鏁版嵁纭繚鍚屾 + setTimeout(() => { + this.init(); + }, 500); + } else { + uni.showToast({ + title: '娓呴櫎澶辫触', + icon: 'none', + duration: 2000 + }); + } + }).catch(err => { + uni.hideLoading(); + console.error('娓呴櫎澶辫触锛�', err); + uni.showToast({ + title: '娓呴櫎澶辫触锛岃閲嶈瘯', + icon: 'none', + duration: 2000 + }); + }) + }, + viewAttachmentInfo() { + this.showAttachmentPopup = true; // 鍏堝脊绐� + this.attachmentsLoading = true; + this.attachments = []; + this.$post({ + url: "/LLJ/getAttachments", + data: { itemNo: this.formData.itemNo } + }).then(res => { + this.attachmentsLoading = false; + if (res.status === 0) { + this.attachments = res.data.tbBillList; + // 涓烘瘡涓檮浠惰缃粯璁ゅ彲鐢ㄧ姸鎬� + this.attachments.forEach((item, index) => { + this.$set(item, 'ftpAvailable', true); // 榛樿璁や负鏂囦欢鍙敤 + this.$set(item, 'checking', false); + }); + } 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) { + // 鍘婚櫎鎵�鏈夌┖鐧藉瓧绗︼紙鍖呮嫭涓嫳鏂囩┖鏍笺�佸埗琛ㄧ绛夛級 + let fileName = item.fattach.replace(/[\s\u3000\r\n]+/g, '').trim(); + // 缁熶竴浣跨敤FTP涓嬭浇鎺ュ彛锛屽寘鍚獸TP鏈嶅姟鍣ㄥ湴鍧� + return this.$store.state.serverInfo.serverAPI + "/LLJ/DownloadFtpFile?itemNo=" + encodeURIComponent(item.itemNo) + "&fileName=" + encodeURIComponent(fileName) + "&ftpServer=" + encodeURIComponent(this.$store.state.serverInfo.ftpServer); + }, + 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', // PDF鏂囦欢 + 'jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', // 鍥剧墖鏂囦欢 + 'txt', 'log', 'md', // 鏂囨湰鏂囦欢 + 'doc', 'docx', // Word鏂囨。 + 'xls', 'xlsx', // Excel琛ㄦ牸 + 'ppt', 'pptx', // PowerPoint婕旂ず鏂囩 + 'csv' // CSV鏂囦欢 + ].includes(ext); + }, + // 澶勭悊闄勪欢涓嬭浇閿欒 + handleAttachmentError(item) { + uni.showModal({ + title: '涓嬭浇澶辫触', + content: `鏃犳硶涓嬭浇闄勪欢锛�${item.fattach}\n璇锋鏌ョ綉缁滆繛鎺ユ垨鑱旂郴绠$悊鍛榒, + showCancel: false + }); + }, + // 棰勮FTP鏂囦欢 + previewFtpFile(item) { + const fileName = item.fattach.replace(/[\s\u3000\r\n]+/g, '').trim(); + const fileExt = fileName.split('.').pop().toLowerCase(); + + // 妫�鏌ユ枃浠剁被鍨嬫槸鍚︽敮鎸侀瑙� + if (!this.isPreviewable(fileName)) { + uni.showModal({ + title: '涓嶆敮鎸侀瑙�', + content: '璇ユ枃浠剁被鍨嬩笉鏀寔鍦ㄧ嚎棰勮锛岃涓嬭浇鍚庢煡鐪�', + showCancel: false + }); + return; + } + + const previewUrl = this.$store.state.serverInfo.serverAPI + "/LLJ/PreviewFtpFile?itemNo=" + encodeURIComponent(item.itemNo) + "&fileName=" + encodeURIComponent(fileName) + "&ftpServer=" + encodeURIComponent(this.$store.state.serverInfo.ftpServer); + + // 鏍规嵁鏂囦欢绫诲瀷杩涜涓嶅悓鐨勯瑙堝鐞� + if (['pdf'].includes(fileExt)) { + this.previewPdfFile(previewUrl, fileName); + } else if (['jpg', 'jpeg', 'png', 'gif', 'bmp'].includes(fileExt)) { + this.previewImageFile(previewUrl, fileName); + } else if (['txt'].includes(fileExt)) { + this.previewTextFile(previewUrl, fileName); + } else if (['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'].includes(fileExt)) { + this.previewOfficeFile(previewUrl, fileName); + } else { + // 灏濊瘯閫氱敤棰勮 + this.previewGenericFile(previewUrl, fileName); + } + }, + + // 棰勮PDF鏂囦欢 + previewPdfFile(url, fileName) { + // 鍏堜笅杞絇DF鏂囦欢锛岃浆涓篵ase64鍚庨瑙� + uni.request({ + url: url, + method: 'GET', + responseType: 'arraybuffer', + success: (res) => { + if (res.statusCode === 200) { + const base64Data = uni.arrayBufferToBase64(res.data); + // 瀛樺偍鍒板叏灞�鍙橀噺 + getApp().globalData.tempPDF = base64Data; + uni.navigateTo({ + url: `/pages/fileView/pdfView` + }); + } else { + this.handlePreviewError(res.statusCode, fileName); + } + }, + fail: (error) => { + this.handlePreviewError(0, fileName, error.errMsg); + } + }); + }, + + // 棰勮鍥剧墖鏂囦欢 + previewImageFile(url, fileName) { + // #ifdef APP-PLUS + // APP鐜锛氬厛涓嬭浇鍒版湰鍦板啀棰勮锛岄伩鍏嶇綉缁滃浘鐗囧姞杞介棶棰� + uni.showLoading({ title: '鍔犺浇鍥剧墖...' }); + uni.downloadFile({ + url: url, + success: (res) => { + uni.hideLoading(); + if (res.statusCode === 200) { + // 浣跨敤鏈湴涓存椂璺緞 + uni.navigateTo({ + url: `/pages/fileView/imageView?url=${encodeURIComponent(res.tempFilePath)}` + }); + } else { + this.handlePreviewError(res.statusCode, fileName); + } + }, + fail: (error) => { + uni.hideLoading(); + this.handlePreviewError(0, fileName, error.errMsg); + } + }); + // #endif + + // #ifdef H5 || MP + // H5鍜屽皬绋嬪簭锛氱洿鎺ヤ娇鐢ㄧ綉缁淯RL + uni.navigateTo({ + url: `/pages/fileView/imageView?url=${encodeURIComponent(url)}` + }); + // #endif + }, + + // 棰勮鏂囨湰鏂囦欢 + previewTextFile(url, fileName) { + // 鏂囨湰鏂囦欢鐩存帴鏄剧ず鍦ㄥ脊绐椾腑 + uni.showLoading({ title: '鍔犺浇鏂囦欢鍐呭...' }); + uni.request({ + url: url, + method: 'GET', + success: (res) => { + uni.hideLoading(); + if (res.statusCode === 200) { + const fileType = this.getFileType(fileName); + if (fileType === 'text') { + // 鏂囨湰鏂囦欢锛氭樉绀哄唴瀹� + this.showFilePreview(res.data, fileName); + } else if (fileType === 'image') { + // 鍥剧墖鏂囦欢锛氭樉绀哄浘鐗嘦RL + this.showFilePreview(url, fileName); + } else { + // 鍏朵粬鏂囦欢绫诲瀷锛氭樉绀烘彁绀轰俊鎭� + this.showFilePreview('', fileName); + } + } else { + this.handlePreviewError(res.statusCode, fileName); + } + }, + fail: (error) => { + uni.hideLoading(); + this.handlePreviewError(0, fileName, error.errMsg); + } + }); + }, + + // 妫�娴嬫枃浠剁被鍨� + getFileType(fileName) { + const fileExt = fileName.split('.').pop().toLowerCase(); + + if (['txt', 'log', 'md', 'csv', 'json', 'xml'].includes(fileExt)) { + return 'text'; + } else if (['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'].includes(fileExt)) { + return 'image'; + } else if (['xls', 'xlsx', 'doc', 'docx', 'ppt', 'pptx'].includes(fileExt)) { + return 'excel'; + } else { + return 'unsupported'; + } + }, + + // 鏄剧ず鏂囦欢棰勮寮圭獥 + showFilePreview(content, fileName) { + this.previewContent = content; + this.previewTitle = fileName; + this.previewItemNo = this.selectedAttachment?.itemNo || ''; + this.previewType = this.getFileType(fileName); + this.showFilePreviewPopup = true; + }, + + // 鍏抽棴鏂囦欢棰勮寮圭獥 + closeFilePreview() { + this.showFilePreviewPopup = false; + this.previewContent = ''; + this.previewTitle = ''; + this.previewItemNo = ''; + this.previewType = ''; + }, + + // 涓嬭浇棰勮鏂囦欢 + downloadPreviewFile() { + const item = { fattach: this.previewTitle, itemNo: this.previewItemNo }; + this.downloadAttachment(item); + this.closeFilePreview(); + }, + + // 鍦ㄥ脊绐椾腑棰勮鍥剧墖锛堟斁澶у姛鑳斤級 + previewImageInPopup() { + // 浣跨敤uni.previewImage API瀹炵幇鍥剧墖鏀惧ぇ棰勮 + uni.previewImage({ + current: this.previewContent, // 褰撳墠鏄剧ず鍥剧墖鐨勯摼鎺� + urls: [this.previewContent], // 闇�瑕侀瑙堢殑鍥剧墖閾炬帴鍒楄〃 + loop: false, // 鏄惁寮�鍚浘鐗囪疆鎾� + indicator: 'default', // 鍥剧墖鎸囩ず鍣ㄧ被鍨� + longPressActions: { + itemList: ['鍙戦�佺粰鏈嬪弸', '淇濆瓨鍥剧墖', '鏀惰棌'], + success: function (data) { + console.log('閫変腑浜嗙' + (data.tapIndex + 1) + '涓寜閽�'); + }, + fail: function (err) { + console.log(err.errMsg); + } + }, + success: () => { + console.log('鍥剧墖棰勮鎴愬姛'); + }, + fail: (err) => { + console.error('鍥剧墖棰勮澶辫触:', err); + uni.showToast({ + title: '鍥剧墖棰勮澶辫触', + icon: 'none' + }); + } + }); + }, + + // 棰勮Office鏂囦欢 + previewOfficeFile(url, fileName) { + // 鍏堟鏌xcel鏂囦欢锛屼娇鐢ㄤ笓闂ㄧ殑Excel棰勮椤甸潰 + const fileExt = fileName.split('.').pop().toLowerCase(); + if (['xls', 'xlsx'].includes(fileExt)) { + // Excel鏂囦欢棰勮 + uni.request({ + url: url, + method: 'GET', + responseType: 'arraybuffer', + success: (res) => { + if (res.statusCode === 200) { + const base64Data = uni.arrayBufferToBase64(res.data); + // 瀛樺偍 Base64 鏁版嵁鍒版湰鍦板瓨鍌� + uni.setStorageSync('excelBase64Data', base64Data); + uni.navigateTo({ + url: `/pages/fileView/excelView` + }); + } else { + this.handlePreviewError(res.statusCode, fileName); + } + }, + fail: (error) => { + this.handlePreviewError(0, fileName, error.errMsg); + } + }); + } else if (['doc', 'docx'].includes(fileExt)) { + // Word鏂囦欢锛屽皾璇曚娇鐢╓ord棰勮椤甸潰鎴栬�呭井杞湪绾块瑙� + try { + const officePreviewUrl = `https://view.officeapps.live.com/op/view.aspx?src=${encodeURIComponent(url)}`; + // 濡傛灉鏈墂ebView椤甸潰锛屼娇鐢╳ebView棰勮 + this.previewGenericFile(officePreviewUrl, fileName); + } catch (error) { + this.handlePreviewError(0, fileName, '涓嶆敮鎸佹Office鏂囦欢绫诲瀷鐨勯瑙�'); + } + } else { + // 鍏朵粬Office鏂囦欢锛屼娇鐢ㄥ井杞湪绾块瑙堟湇鍔� + const officePreviewUrl = `https://view.officeapps.live.com/op/view.aspx?src=${encodeURIComponent(url)}`; + this.previewGenericFile(officePreviewUrl, fileName); + } + }, + + // 閫氱敤鏂囦欢棰勮 + previewGenericFile(url, fileName) { + // 鐢变簬娌℃湁閫氱敤鐨剋ebView椤甸潰锛屾樉绀烘彁绀哄苟鎻愪緵涓嬭浇 + uni.showModal({ + title: '鏂囦欢棰勮', + content: `鏂囦欢 "${fileName}" 闇�瑕佷笅杞藉悗鏌ョ湅锛屾槸鍚︾珛鍗充笅杞斤紵`, + showCancel: true, + confirmText: '涓嬭浇', + cancelText: '鍙栨秷', + success: (res) => { + if (res.confirm) { + const item = { fattach: fileName, itemNo: this.selectedAttachment.itemNo }; + this.downloadAttachment(item); + } + } + }); + }, + + // 澶勭悊棰勮閿欒 + handlePreviewError(statusCode, fileName, errorMsg = '') { + let message = ''; + if (statusCode === 404) { + message = `鏂囦欢 ${fileName} 鍦‵TP鏈嶅姟鍣ㄤ笂涓嶅瓨鍦╜; + } else if (statusCode === 0) { + message = `棰勮澶辫触锛�${errorMsg}`; + } else { + message = `棰勮澶辫触锛岀姸鎬佺爜锛�${statusCode}`; + } + + uni.showModal({ + title: '棰勮澶辫触', + content: message, + showCancel: true, + confirmText: '涓嬭浇', + cancelText: '鍙栨秷', + success: (res) => { + if (res.confirm) { + // 鐢ㄦ埛閫夋嫨涓嬭浇鏂囦欢 + const item = { fattach: fileName, itemNo: this.selectedAttachment.itemNo }; + this.downloadAttachment(item); + } + } + }); + }, + + downloadAttachment(item) { + // 鍘婚櫎鎵�鏈夌┖鏍笺�佸叏瑙掔┖鏍笺�佸洖杞︺�佹崲琛� + const fileName = item.fattach.replace(/[\s\u3000\r\n]+/g, '').trim(); + // 浣跨敤閰嶇疆鐨勬湇鍔″櫒鍦板潃鍜孎TP鏈嶅姟鍣ㄥ湴鍧� + const url = this.$store.state.serverInfo.serverAPI + "/LLJ/DownloadFtpFile?itemNo=" + encodeURIComponent(item.itemNo) + "&fileName=" + encodeURIComponent(fileName) + "&ftpServer=" + encodeURIComponent(this.$store.state.serverInfo.ftpServer); + + // 妫�鏌ヨ繍琛岀幆澧� + // #ifdef H5 + // H5鐜锛氫娇鐢ㄦ祻瑙堝櫒涓嬭浇 + this.downloadFileInBrowser(url, fileName); + // #endif + + // #ifdef APP-PLUS + // APP鐜锛氫娇鐢╱ni.downloadFile + this.downloadFileInApp(url, fileName); + // #endif + + // #ifdef MP + // 灏忕▼搴忕幆澧冿細浣跨敤uni.downloadFile + this.downloadFileInApp(url, fileName); + // #endif + }, + + // 鍦ㄦ祻瑙堝櫒涓笅杞芥枃浠� + downloadFileInBrowser(url, fileName) { + uni.showLoading({ title: '姝e湪鍑嗗涓嬭浇...' }); + + // 鏂规硶1锛氬垱寤洪殣钘忕殑a鏍囩涓嬭浇 + try { + const link = document.createElement('a'); + link.href = url; + link.download = fileName; + link.style.display = 'none'; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + + uni.hideLoading(); + uni.showToast({ + title: '涓嬭浇宸插紑濮�', + icon: 'success', + duration: 2000 + }); + } catch (error) { + console.log('a鏍囩涓嬭浇澶辫触锛屽皾璇晈indow.open鏂瑰紡:', error); + // 鏂规硶2锛氫娇鐢╳indow.open + try { + window.open(url, '_blank'); + uni.hideLoading(); + uni.showToast({ + title: '涓嬭浇宸插紑濮�', + icon: 'success', + duration: 2000 + }); + } catch (error2) { + console.log('window.open涓嬭浇澶辫触锛屽皾璇昮etch鏂瑰紡:', error2); + // 鏂规硶3锛氫娇鐢╢etch涓嬭浇 + this.downloadFileWithFetch(url, fileName); + } + } + }, + + // 浣跨敤fetch涓嬭浇鏂囦欢 + downloadFileWithFetch(url, fileName) { + fetch(url) + .then(response => { + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + return response.blob(); + }) + .then(blob => { + // 鍒涘缓blob URL + const blobUrl = window.URL.createObjectURL(blob); + + // 鍒涘缓涓嬭浇閾炬帴 + const link = document.createElement('a'); + link.href = blobUrl; + link.download = fileName; + link.style.display = 'none'; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + + // 閲婃斁blob URL + window.URL.revokeObjectURL(blobUrl); + + uni.hideLoading(); + uni.showToast({ + title: '涓嬭浇鎴愬姛', + icon: 'success', + duration: 2000 + }); + }) + .catch(error => { + console.error('Fetch涓嬭浇澶辫触:', error); + uni.hideLoading(); + if (error.message.includes('404')) { + uni.showModal({ + title: '鏂囦欢涓嶅瓨鍦�', + content: `璇ラ檮浠跺湪FTP鏈嶅姟鍣ㄤ笂涓嶅瓨鍦╜, + showCancel: false + }); + } else { + uni.showModal({ + title: '涓嬭浇澶辫触', + content: `涓嬭浇澶辫触: ${error.message}`, + showCancel: false + }); + } + }); + }, + + // 鍦ˋPP涓笅杞芥枃浠� + downloadFileInApp(url, fileName) { + // #ifdef APP-PLUS + uni.showLoading({ title: '浠嶧TP鏈嶅姟鍣ㄤ笅杞戒腑...' }); + + // Android 鑾峰彇瀛樺偍璺緞 + const saveDir = plus.os.name === 'Android' ? plus.io.convertLocalFileSystemURL('_downloads/') : plus.io.convertLocalFileSystemURL('_documents/'); + const filePath = `${saveDir}${fileName}`; + + const downloadTask = uni.downloadFile({ + url: url, + filePath: filePath, // 鎸囧畾淇濆瓨璺緞 + success: (res) => { + uni.hideLoading(); + if (res.statusCode === 200) { + const fileInfo = { + name: fileName, + path: res.filePath || filePath, + tempPath: res.tempFilePath + }; + + uni.showModal({ + title: '涓嬭浇鎴愬姛', + content: `鏂囦欢宸蹭繚瀛樺埌锛�${fileInfo.path}`, + showCancel: true, + confirmText: '鎵撳紑鏂囦欢', + cancelText: '纭畾', + success: (modalRes) => { + if (modalRes.confirm) { + // 鐢ㄦ埛閫夋嫨鎵撳紑鏂囦欢 + this.openFileInApp(fileInfo); + } + } + }); + } else if (res.statusCode === 404) { + uni.showModal({ + title: '鏂囦欢涓嶅瓨鍦�', + content: `璇ラ檮浠跺湪FTP鏈嶅姟鍣ㄤ笂涓嶅瓨鍦╜, + showCancel: false + }); + } else { + uni.showModal({ + title: '涓嬭浇澶辫触', + content: `鐘舵�佺爜锛�${res.statusCode}`, + showCancel: false + }); + } + }, + fail: (error) => { + uni.hideLoading(); + console.error('涓嬭浇澶辫触:', error); + uni.showModal({ + title: '涓嬭浇澶辫触', + content: `缃戠粶閿欒锛�${error.errMsg}`, + showCancel: false + }); + } + }); + + // 鐩戝惉涓嬭浇杩涘害 + downloadTask.onProgressUpdate((res) => { + const progress = Math.round(res.progress); + uni.showLoading({ + title: `涓嬭浇涓� ${progress}%`, + mask: true + }); + }); + // #endif + + // #ifdef MP + // 灏忕▼搴忕幆澧冪殑绠�鍖栧疄鐜� + uni.showLoading({ title: '涓嬭浇涓�...' }); + uni.downloadFile({ + url: url, + success: (res) => { + uni.hideLoading(); + if (res.statusCode === 200) { + uni.showToast({ title: '涓嬭浇瀹屾垚', icon: 'success' }); + } + }, + fail: (error) => { + uni.hideLoading(); + uni.showModal({ title: '涓嬭浇澶辫触', content: error.errMsg, showCancel: false }); + } + }); + // #endif + }, + + // APP涓墦寮�鏂囦欢 + openFileInApp(fileInfo) { + // #ifdef APP-PLUS + if (typeof plus !== 'undefined') { + const filePath = fileInfo.path || fileInfo.tempPath; + + // 灏濊瘯鎵撳紑鏂囦欢 + plus.runtime.openFile(filePath, {}, (error) => { + console.error('鎵撳紑鏂囦欢澶辫触:', error); + uni.showModal({ + title: '鏃犳硶鎵撳紑', + content: '绯荤粺涓病鏈夋壘鍒拌兘鎵撳紑姝ゆ枃浠剁殑搴旂敤绋嬪簭', + showCancel: false + }); + }); + } + // #endif + }, + } } </script> @@ -1190,9 +1991,44 @@ font-family: 'Microsoft YaHei', 'Segoe UI', sans-serif; max-width: 1000px; margin: 0 auto; - padding: 20px; + padding: 20px 20px 100px 20px; /* 搴曢儴澧炲姞鍐呰竟璺濅负鍥哄畾鎸夐挳鐣欑┖闂� */ background-color: #fff; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); + min-height: 100vh; + position: relative; + transition: all 0.3s ease; + } + + /* 鏈淮鎶や笖闈炵揣鎬ユ斁琛岃〃鍗曠殑绱壊鏍峰紡 */ + .inspection-sheet.unmaintained-form { + background: linear-gradient(135deg, #f8f4ff 0%, #f0e6ff 100%); + border: 2px solid #9c27b0; + box-shadow: 0 0 20px rgba(156, 39, 176, 0.2); + } + + .inspection-sheet.unmaintained-form .sheet-header { + border-bottom: 2px solid #9c27b0; + } + + .inspection-sheet.unmaintained-form .sheet-header h1 { + color: #6a1b9a; + } + + .inspection-sheet.unmaintained-form .inspection-number { + color: #9c27b0; + } + + .inspection-sheet.unmaintained-form .material-info { + border: 1px solid #e1bee7; + background-color: rgba(156, 39, 176, 0.05); + } + + .inspection-sheet.unmaintained-form .info-label { + color: #6a1b9a; + } + + .inspection-sheet.unmaintained-form .info-value { + color: #4a148c; } /* 澶撮儴鏍峰紡 */ @@ -1237,6 +2073,24 @@ .info-value { color: #2c3e50; margin-right: 20px; + } + + .picker-text { + padding: 6px 10px; + border: 1px solid #ddd; + border-radius: 4px; + background-color: white; + color: #999; + font-size: 14px; + min-height: 32px; + display: flex; + align-items: center; + max-width: 150px; + } + + .picker-text.selected { + color: #e74c3c; + font-weight: 500; } .highlight { @@ -1313,7 +2167,80 @@ background-color: #f1f5f9; } - /* 鎸夐挳鏍峰紡 */ + /* 琛ㄥ崟涓婃柟鎿嶄綔鎸夐挳鍖烘牱寮� */ + .top-action-buttons { + display: flex; + justify-content: flex-end; + gap: 10px; + margin: 20px 0; + padding: 15px; + background-color: #f8f9fa; + border-radius: 8px; + border: 1px solid #e9ecef; + } + + /* 琛ㄥ崟涓嬫柟鎿嶄綔鎸夐挳鍖烘牱寮� */ +.bottom-action-buttons { + display: flex; + justify-content: center; + gap: 8px; + padding: 12px; + flex-wrap: wrap; + align-items: center; + position: fixed; /* 鍥哄畾鍦ㄥ睆骞曞簳閮� */ + bottom: 0; /* 璺濈搴曢儴0px */ + left: 0; /* 璺濈宸﹁竟0px */ + right: 0; /* 璺濈鍙宠竟0px */ + background-color: #fff; /* 鑳屾櫙鑹� */ + border-top: 1px solid #e9ecef; /* 椤堕儴杈规 */ + z-index: 1000; /* 纭繚鍦ㄦ渶涓婂眰 */ + box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1); /* 椤堕儴闃村奖 */ +} + + .action-btn { + background-color: #ecf0f1; + color: #34495e; + padding: 12px 15px; + border: none; + border-radius: 6px; + cursor: pointer; + font-size: 14px; + font-weight: 500; + transition: all 0.3s ease; + text-align: center; + min-height: 44px; + display: flex; + align-items: center; + justify-content: center; + } + + .action-btn:hover { + background-color: #d5dbdb; + transform: translateY(-1px); + } + + .action-btn.primary { + background-color: #3498db; + color: #fff; + } + + .action-btn.primary:hover { + background-color: #2980b9; + } + + /* 灏忓昂瀵告寜閽牱寮� */ + .action-btn.small { + padding: 10px 12px; + font-size: 14px; + min-height: 44px; + white-space: nowrap; + flex-shrink: 0; + min-width: 80px; + max-width: 120px; + flex: 1; + } + + /* 鍘熸湁鎸夐挳鏍峰紡淇濇寔鍏煎 */ .action-buttons { display: flex; gap: 10px; @@ -1422,29 +2349,335 @@ display: flex; justify-content: center; align-items: center; - z-index: 10; + z-index: 1000; /* 鎻愰珮灞傜骇锛岀‘淇濆湪鍥哄畾鎸夐挳涓婃柟 */ } - .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; + z-index: 1001; /* 纭繚寮圭獥鍐呭鍦ㄦ渶涓婂眰 */ + max-height: 80vh; /* 闄愬埗鏈�澶ч珮搴︼紝閬垮厤琚簳閮ㄦ寜閽伄鎸� */ + overflow-y: auto; /* 鍐呭杩囧鏃跺彲婊氬姩 */ } - - .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; + .attachment-label { + min-width: 80px; + color: #1976d2; + font-weight: 500; + margin-right: 8px; + } + .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); + } + .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-actions-detail { + margin: 20px 0; + display: flex; + gap: 12px; + justify-content: center; + flex-wrap: wrap; + } + .attachment-action-btn { + padding: 10px 20px; + border: none; + border-radius: 8px; + font-size: 14px; + font-weight: 600; + cursor: pointer; + transition: all 0.3s ease; + display: flex; + align-items: center; + justify-content: center; + min-width: 120px; + box-shadow: 0 2px 4px rgba(0,0,0,0.1); + } + .attachment-action-btn.preview-btn { + background: linear-gradient(135deg, #4CAF50, #45a049); color: white; + } + .attachment-action-btn.preview-btn:hover { + background: linear-gradient(135deg, #45a049, #3d8b40); + transform: translateY(-1px); + box-shadow: 0 4px 8px rgba(0,0,0,0.15); + } + .attachment-action-btn.download-btn { + background: linear-gradient(135deg, #2196F3, #1976D2); + color: white; + } + .attachment-action-btn.download-btn:hover { + background: linear-gradient(135deg, #1976D2, #1565C0); + transform: translateY(-1px); + box-shadow: 0 4px 8px rgba(0,0,0,0.15); + } + + /* 鏂囦欢棰勮寮圭獥鏍峰紡 */ + .file-preview-popup { + width: 80vw; + max-width: 600px; + max-height: 70vh; + display: flex; + flex-direction: column; + } + + /* APP鐜閫傞厤 */ + /* #ifdef APP-PLUS */ + .file-preview-popup { + width: 85vw; + max-height: 75vh; + } + .file-preview-content { + max-height: 350px; + } + /* #endif */ + .file-preview-title { + font-size: 18px; + font-weight: 700; + color: #222; + margin-bottom: 8px; + text-align: center; + word-break: break-all; + } + .file-preview-divider { + height: 1px; + background: linear-gradient(90deg,#e0e7ef 0%,#f5f7fa 100%); + margin-bottom: 16px; + } + .file-preview-content { + flex: 1; + max-height: 400px; + overflow-y: auto; + background: #f8fafc; + border-radius: 8px; + padding: 16px; + margin-bottom: 16px; + border: 1px solid #e2e8f0; + } + .file-preview-content pre { + font-family: 'Consolas', 'Monaco', 'Courier New', monospace; + font-size: 12px; + line-height: 1.5; + color: #2d3748; + white-space: pre-wrap; + word-wrap: break-word; + margin: 0; + } + + /* 鍥剧墖棰勮鏍峰紡 */ + .image-preview-container { + display: flex; + justify-content: center; + align-items: center; + min-height: 200px; + } + + /* 涓嶆敮鎸佹枃浠剁被鍨嬬殑鎻愮ず鏍峰紡 */ + .unsupported-preview { + text-align: center; + padding: 40px 20px; + color: #666; + } + .unsupported-icon { + font-size: 48px; + margin-bottom: 16px; + } + .unsupported-text { + font-size: 16px; + font-weight: 600; + color: #333; + margin-bottom: 8px; + } + .unsupported-hint { + font-size: 14px; + color: #999; + line-height: 1.4; + } + + .file-preview-actions { + display: flex; + gap: 12px; + justify-content: center; + } + .file-preview-btn { + padding: 8px 20px; + border: none; + border-radius: 6px; + font-size: 14px; + font-weight: 600; + cursor: pointer; + transition: all 0.3s ease; + display: flex; + align-items: center; + justify-content: center; + min-width: 120px; + } + .file-preview-btn.download-btn { + background: linear-gradient(135deg, #2196F3, #1976D2); + color: white; + } + .file-preview-btn.download-btn:hover { + background: linear-gradient(135deg, #1976D2, #1565C0); + transform: translateY(-1px); + } + .file-preview-btn.close-btn { + background: linear-gradient(135deg, #e0e0e0, #bdbdbd); + color: #444; + } + .file-preview-btn.close-btn:hover { + background: linear-gradient(135deg, #bdbdbd, #9e9e9e); + transform: translateY(-1px); + } + /* 鍒楄〃寮圭獥缇庡寲锛堜繚鐣欏師鏈夛級 */ + .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: 12px 0; + border-bottom: 1px solid #f0f0f0; + } + .attachment-info { + flex: 1; + margin-right: 10px; + } + .attachment-name { + color: #3498db; + cursor: pointer; + font-weight: 500; + transition: color 0.2s; + display: block; + margin-bottom: 4px; + } + .attachment-name:hover { + color: #217dbb; + text-decoration: underline; + } + .attachment-meta { + font-size: 12px; + } + .attachment-type { + color: #7f8c8d; + font-style: italic; + } + .attachment-actions { + display: flex; + gap: 8px; + flex-shrink: 0; + } + .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; + } + .preview-btn { + background: #e8f5e8 !important; + color: #2e7d2e !important; + border-color: #a5d6a5 !important; + } + .preview-btn:hover { + background: #d4eecc !important; + color: #1e5f1e !important; + } + .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; } /* 鍝嶅簲寮忚璁� */ @@ -1461,20 +2694,65 @@ margin-top: 10px; } - .action-buttons { + .top-action-buttons { flex-direction: column; + align-items: stretch; + } + + .bottom-action-buttons { + flex-direction: row; + align-items: center; + justify-content: center; + padding: 8px; + gap: 6px; + position: fixed; /* 淇濇寔鍥哄畾鍦ㄥ睆骞曞簳閮� */ + bottom: 0; + left: 0; + right: 0; + background-color: #fff; + border-top: 1px solid #e9ecef; + z-index: 1000; + box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1); + } + + .action-btn.small { + min-width: 70px; + max-width: 100px; + padding: 8px 10px; + font-size: 13px; + min-height: 40px; } .inspection-table table { display: block; overflow-x: auto; } - - .click-wd { - color: #056cba; - font-size: 1.25rem; - text-decoration: underline; - } - + } + + /* 鍥剧墖鏀惧ぇ棰勮鐩稿叧鏍峰紡 */ + .preview-image-clickable { + transition: transform 0.2s ease; + border-radius: 8px; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); + } + + .preview-image-clickable:hover { + transform: scale(1.02); + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); + } + + .image-zoom-hint { + text-align: center; + margin-top: 8px; + font-size: 12px; + color: #666; + font-style: italic; + } + + .image-preview-container { + position: relative; + display: flex; + flex-direction: column; + align-items: center; } </style> \ No newline at end of file -- Gitblit v1.9.3