yhj
4 天以前 ea5c60a0ac52216b22d6096d2d0394c2480f5bc3
ÏÄÃÉ×¢Ëܱ¨¹¤/pages/scbg/scbg.vue
@@ -178,6 +178,8 @@
            <view class="history-record">
               <button @click="viewHistory" class="lsjl">历史记录</button <!-- å¼¹å‡ºçª—口显示历史记录 -->
               <button @click="fetchDrawingNumber" class="lsjl">调取PLM图纸</button <!-- å¼¹å‡ºçª—口显示plm图纸记录 -->
               <view v-if="showHistoryPopup" class="history-popup">
                  <!-- å¼¹çª—头部 -->
                  <view class="popup-header">
@@ -206,10 +208,61 @@
                        </view>
                     </scroll-view>
                  </view>
               </view>
               <view v-if="drawingShow" class="history-popup">
                  <!-- å¼¹çª—容器 -->
                  <view class="popup-container">
                     <!-- å†…容区域 -->
                     <view class="popup-content">
                        <!-- è¡¨å¤´ -->
                        <view class="history-header">
                           <view class="header-item" id="tm">相关文档</view>
                           <view class="header-item" id="sl">有无关联PDF文件</view>
                           <view class="header-item" id="sj">能否打开文件</view>
                           <view class="header-item" id="ry">操作(点击)</view>
                        </view>
                        <!-- è¡¨æ ¼å†…容区域 -->
                        <scroll-view scroll-y="true" class="history-scroll">
                           <!-- æ•°æ®ä¸ºç©ºæ—¶çš„æç¤º -->
                           <view v-if="(!drawing || drawing.length === 0)" class="empty-text">
                              æš‚无更多数据
                           </view>
                           <!-- æœ‰æ•°æ®æ—¶æ˜¾ç¤ºçš„列表 -->
                           <view v-for="(item, index) in (drawing || [])" :key="index" class="history-record">
                              <view class="record-item">{{ item.fName }}</view>
                              <view class="record-item" style="font-size:25px;">
                                 <div v-if="item.fRelevantObject==' '" style="color: #E47470;">×</div>
                                 <div style="color: #90BA87;" v-else>√</div>
                              </view>
                              <view class="record-item" style="font-size:25px;">
                                 <div v-if="item.isSupported || item.fRelevantObject!=' '"
                                    style="color: #90BA87;">√</div>
                                 <div style="color: #E47470;" v-else>×</div>
                              </view>
                              <view class="record-item click-wd" @click="openDrawings(item)">
                                 æ‰“开文档
                              </view>
                           </view>
                        </scroll-view>
                     </view>
                     <!-- å›ºå®šåœ¨æœ€åº•部的按钮区域 -->
                     <view class="popup-footer">
                        <view class="popup-buttons">
                           <button class="popup-button cancel-button" @click="drawingCancel">取消</button>
                           <button class="popup-button confirm-button" @click="drawingConfirm">确定</button>
                        </view>
                     </view>
                  </view>
               </view>
            <!--    <button @click="reprintLast" :disabled="isButtonDisabled2" class="uni-btn">{{ isButtonDisabled2 ? '请稍后...' : '补打上一张' }}</button>
             --></view>
             -->
            </view>
         </view>
      </view>
@@ -230,7 +283,8 @@
                     {{ deviceState }}
                  </view>
               </view>
   <button @click="reprintLast" :disabled="isButtonDisabled2" class="uni-btn">{{ isButtonDisabled2 ? '请稍后...' : '补打上一张' }}</button>
               <button @click="reprintLast" :disabled="isButtonDisabled2"
                  class="uni-btn">{{ isButtonDisabled2 ? '请稍后...' : '补打上一张' }}</button>
            
               <!-- æŒ‰é’®æ”¾åœ¨çŠ¶æ€æ–‡æœ¬çš„ä¸‹æ–¹ -->
               <!-- <button @click="manualCheck" class="check-button">手动检测</button> -->
@@ -267,6 +321,9 @@
      data() {
         return {
            showHistoryPopup: false, // æŽ§åˆ¶å¼¹å‡ºæ¡†æ˜¾ç¤º
            drawing: [],
            drawingShow: false,
            itemShow: false,
            selectedPerson: '',
            selectedLine: '',
            selectedOrder: '',
@@ -1245,7 +1302,7 @@
         // æäº¤æŠ¥å·¥ä¿¡æ¯çš„æ–¹æ³•
         printBarcode() {
            // **先检查 USB è¿žæŽ¥çŠ¶æ€**
            if (!UsbModule || !UsbModule.isUsbConnect || !UsbModule.isUsbConnect()) {
            /*   if (!UsbModule || !UsbModule.isUsbConnect || !UsbModule.isUsbConnect()) {
               uni.showModal({
                  title: ` ${this.networkState}`,
                  content: "请检查打印机连接",
@@ -1256,7 +1313,7 @@
                  }
               });
               return; // **USB è¿žæŽ¥å¤±è´¥ï¼Œç›´æŽ¥è¿”回,防止执行打印**
            }
               }*/
            
            uni.request({
               url: `http://192.168.0.107:44380/api/persons/${encodeURIComponent(this.personCode)}`, // ä¿®æ”¹åŽçš„请求路径
@@ -1487,6 +1544,175 @@
         //   return lines;
         // },
         
         drawingConfirm() {
            this.drawingShow = false
            // this.imageShow = false
            // this.productionShow = false
            // this.itemShow = false
         },
         drawingCancel() {
            this.drawingShow = false
            // this.imageShow = false
            // this.productionShow = false
            // this.itemShow = false
         },
         fetchDrawingNumber() {
            // const item = 'BC.XM.001.006.009.0002'
            const item = this.orderDetails.itemNo;
            console.log(this.orderDetails.itemNo)
            // console.log(item)
            // const url = this.$store.state.serverInfo.serverAPI +"/PLM/RetrieveDrawings?ItemNo=" + item
            // const item = '5.06.04.4002';
            const url = "http://192.168.0.107:10054/api/PLM/RetrieveDrawings?ItemNo=" + item
            let _this = this;
            uni.request({
               url: url,
               method: 'POST',
               success: (response) => {
                  console.log(response)
                  if (response.data.data == '返回结果为空') {
                     _this.drawing = []
                  } else {
                     _this.drawing = response.data.data
                     // éåŽ†æ•°æ®ï¼Œåˆ¤æ–­æ–‡ä»¶åŽç¼€å¹¶æ·»åŠ å­—æ®µ
                     _this.drawing.forEach((file) => {
                        // èŽ·å–æ–‡ä»¶åçš„åŽç¼€
                        const fileExtension = file.fName.split('.').pop()
                           .toLowerCase();
                        // å®šä¹‰æ”¯æŒçš„æ–‡ä»¶ç±»åž‹
                        const supportedExtensions = ['jpg', 'pdf', 'xlsx', 'doc',
                           'docx',
                           'xls'
                        ];
                        // åˆ¤æ–­æ˜¯å¦æ”¯æŒè¯¥æ–‡ä»¶ç±»åž‹
                        file.isSupported = supportedExtensions.includes(fileExtension);
                     });
                  }
               },
               fail: (error) => {
                  uni.showToast({
                     title: '请求图纸链接失败',
                     icon: 'none'
                  });
               }
            });
            this.drawingShow = true
         },
         //图纸相关文档
         openDrawings(item) {
            console.log("jkjoi", item.fRelevantObject)
            if (item.fRelevantObject.length > 2) {
               // ç”Ÿæˆè¯·æ±‚URL(简化编码逻辑)
               const encodedName = encodeURIComponent(item.fName);
               const url = `http://192.168.0.107: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.request({
                  url: url,
                  method: 'POST',
                  responseType: 'arraybuffer',
                  success: (response) => {
                     console.log(response.data)
                     if (!response) {
                        uni.showToast({
                           title: "协议预览失败",
                           duration: 2000
                        });
                     }
                  },
                  fail: (error) => {
                     console.log(error)
                     uni.showToast({
                        title: '请求预览链接失败',
                        icon: 'none'
                     });
                  }
               });
            }
         },
         // è¡¥æ‰“上一张记录
         reprintLast() {
            
@@ -1641,8 +1867,7 @@
            this.senUSBData();
          // **记录 "补打后" äº‹ä»¶**
        
         }
      ,
         },
   logPrintEvent(eventType, printType, barcodeValue) {
        
          
@@ -2369,4 +2594,204 @@
      box-sizing: border-box;
      /* ç¡®ä¿å†…边距和边框包含在宽度内 */
   }
   /* å¦‚果需要按钮等宽并靠边 */
   .popup-buttons {
      display: flex;
      justify-content: space-between;
      /* å·¦å³åˆ†å¸ƒ */
      gap: 20px;
      /* æŒ‰é’®ä¹‹é—´çš„间距 */
   }
   .popup-button {
      flex: 1;
      /* è®©ä¸¤ä¸ªæŒ‰é’®ç­‰å®½ */
      min-width: 100px;
      padding: 12px 0;
      border-radius: 6px;
      font-size: 8px;
      font-weight: 500;
   }
   /* æˆ–者保持原宽度但固定在两边 */
   .popup-buttons.fixed-sides {
      display: flex;
      justify-content: space-between;
   }
   .popup-buttons.fixed-sides .popup-button {
      flex: 0 0 auto;
      /* ä¸ä¼¸ç¼©ï¼Œä¿æŒåŽŸå¤§å° */
   }
   /* å¼¹çª—整体样式保持不变,增加高度控制 */
   .history-popup {
      position: fixed;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      width: 80%;
      height: 70%;
      background-color: #fff;
      border-radius: 8px;
      box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
      z-index: 1000;
      display: flex;
      flex-direction: column;
   }
   /* å¼¹çª—头部 */
   .popup-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 10px;
      border-bottom: 1px solid #ccc;
      flex-shrink: 0;
      /* é˜²æ­¢å¤´éƒ¨è¢«åŽ‹ç¼© */
   }
   .popup-title {
      font-size: 18px;
      font-weight: bold;
   }
   /* å†…容包装器 - å›ºå®šé«˜åº¦ï¼Œå¯æ»šåЍ */
   .popup-content-wrapper {
      flex: 1;
      /* å æ®å‰©ä½™ç©ºé—´ */
      display: flex;
      flex-direction: column;
      overflow: hidden;
      /* éšè—æº¢å‡ºå†…容 */
   }
   /* è¡¨å¤´å›ºå®š */
   .history-header {
      display: flex;
      justify-content: space-between;
      font-weight: bold;
      border-bottom: 1px solid #ccc;
      padding: 10px 5px;
      background-color: #fff;
      flex-shrink: 0;
      /* é˜²æ­¢è¡¨å¤´è¢«åŽ‹ç¼© */
      z-index: 1;
      /* ç¡®ä¿è¡¨å¤´åœ¨æœ€ä¸Šå±‚ */
   }
   /* æ»šåŠ¨åŒºåŸŸ - è‡ªé€‚应高度 */
   .history-scroll {
      flex: 1;
      /* å æ®å‰©ä½™ç©ºé—´ */
      overflow-y: auto;
      padding: 0 5px;
   }
   /* ç©ºæ•°æ®æç¤º */
   .empty-text {
      text-align: center;
      padding: 40px 0;
      color: #999;
      font-size: 16px;
   }
   /* å›ºå®šåœ¨å¼¹çª—底部的按钮区域 */
   .popup-footer {
      padding: 15px 20px;
      border-top: 1px solid #eee;
      background-color: #fff;
      flex-shrink: 0;
      /* é˜²æ­¢åº•部被压缩 */
      box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.05);
   }
   /* æŒ‰é’®åŒºåŸŸ */
   .popup-buttons {
      display: flex;
      justify-content: space-between;
      gap: 20px;
   }
   .popup-button {
      flex: 1;
      min-width: 100px;
      padding: 12px 0;
      border-radius: 6px;
      font-size: 16px;
      font-weight: 500;
      border: none;
      outline: none;
      cursor: pointer;
   }
   .cancel-button {
      background-color: #f8f9fa;
      color: #6c757d;
      border: 1px solid #dee2e6;
   }
   .cancel-button:hover {
      background-color: #e9ecef;
      color: #495057;
   }
   .confirm-button {
      background-color: #1890ff;
      color: white;
   }
   .confirm-button:hover {
      background-color: #40a9ff;
   }
   /* è¡¨æ ¼å†…容行样式 */
   .history-record {
      display: flex;
      justify-content: space-between;
      border-bottom: 1px solid #eee;
      padding: 10px 0;
      font-size: 14px;
   }
   /* è¡¨å¤´å’Œè¡¨æ ¼å†…容的每列样式 */
   .header-item,
   .record-item {
      flex: 1;
      text-align: center;
      padding: 0 5px;
      word-wrap: break-word;
      overflow: hidden;
      text-overflow: ellipsis;
   }
   /* æ‰“开文档样式 */
   .click-wd {
      color: #1890ff;
      cursor: pointer;
      text-decoration: underline;
   }
   .click-wd:hover {
      color: #40a9ff;
   }
   /* ç§»åŠ¨ç«¯é€‚é… */
   @media (max-width: 768px) {
      .history-popup {
         width: 95%;
         height: 85%;
      }
      .popup-button {
         min-width: 80px;
         padding: 10px 0;
         font-size: 14px;
      }
      .popup-buttons {
         gap: 10px;
      }
   }
</style>