xwt
2025-06-27 0d3eadb50310ca60b8871e967e64da01aa25a9ad
pages/QC/LLJ/Add.vue
@@ -4,9 +4,10 @@
      <view class="sheet-header">
         <h1>来料检验单</h1>
         <view class="inspection-number">检验单号:{{formData.releaseNo}}</view>
         <!-- 造梦者特殊功能 -->
         <view style="text-align: right;" v-if="this.current"><a class="sysLike"
               @click="toSysSubmitFrom(formData.releaseNo)">实验室送检</a></view>
         <!--实验室送检 -->
         <view style="text-align: right;" class="action-buttons">
            <a class="sysLike" v-if="this.current" @click="toSysSubmitFrom(formData.releaseNo)">实验室送检</a>
         </view>
      </view>
      <!-- 基本信息区 -->
@@ -88,26 +89,37 @@
         </select>
      </view>
      <view class="dropdown-row">
         <view class="info-label">备注:</view>
         <input type="text" id="remark" v-model="REMARK" placeholder="请输入备注信息" />
               <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="info-block" style="margin-top: 10px;">
          <view class="info-label">破坏实验数量:</view>
          <view class="info-value highlight">{{formData.phsy}}</view>
      </view>
      <!-- 操作按钮区 -->
      <view class="action-buttons" v-if="this.current">
         <button class="secondary-btn" @click="getInspectionItems">获取检验项目</button>
                  <button class="secondary-btn" @click="handleEmergencyRelease">紧急放行</button>
                  <button class="secondary-btn" @click="handleWithdraw">撤回</button>
                  <button class="secondary-btn" @click="getInspectionItems">获取检验项目</button>
      </view>
      <!-- 检验项目表格 -->
      <view class="inspection-table">
         <table>
            <thead>
               <tr>
                  <th width="15%" style="text-align: center;">检验项目</th>
                  <th width="20%" style="text-align: center;">检验项目</th>
                  <th width="50%" style="text-align: center;">检验描述</th>
                  <th width="20%" style="text-align: center;">记录(点击)</th>
                  <th width="15%" style="text-align: center;">记录(点击)</th>
               </tr>
            </thead>
            <tbody>
@@ -129,6 +141,7 @@
                     <button v-if="item.current" class="record-btn" @click="fillRecord(item,index)">填写</button>
                     <button v-if="!item.current" class="record-btn" @click="fillRecord(item,index)">查看</button>
                  </td>
               </tr>
            </tbody>
         </table>
@@ -136,6 +149,7 @@
      <!-- 操作按钮区 -->
      <view class="action-buttons">
         <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="addDefectDescription" v-if="this.current">添加不良描述</button>
@@ -155,7 +169,23 @@
            <button @click="remarksPopup = !remarksPopup">取消</button>
         </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>
@@ -183,8 +213,8 @@
            </uni-table>
         </u-modal>
      </view>
   </view>
</template>
<script>
@@ -207,10 +237,20 @@
               planQty: "",
               mocode: "",
               boardStyle: "",
               itemId: ""
               itemId: "",
               emergencyStatus: false,
               lotNo1: '',
               emergency:'',
               permissionModalVisible: false,
               permissionAccount: '',
               hasEmergencyPermission: false,
               showPopup: false,
               PHSY:'',
            },
            tableData: [],
            remarksPopup: false,
            meomPopup: false,
            current: true,
            drawing: [],
            drawingShow: false,
@@ -220,18 +260,28 @@
            REMARK: '',
            checkState: false,
            writeStatu: true,
            fileName:''
            fileName:'',
            originalRemarks: '',
            hasEmergencyPermission: false,
            destructionPopup: false,
            PHSY: '',
            isInteger: true,
         }
      },
      onLoad(options) {
         //options中包含了url附带的参数
         let params = options;
         if (params["id"]) {
            this.formData.id = params["id"];
            this.formData.releaseNo = params["releaseNo"];
            this.formData.lotNo = params["lotNo"];
            this.msgId = params["msgId"];
            this.emergency = params["emergency"]
            this.meom = params["meom"]
            if (params["current"] === 'A') {
               this.current = true;
@@ -254,6 +304,7 @@
            });
         }
          if (this.$loginInfo.account === 'PL017') {this.hasEmergencyPermission = true;}
      },
      methods: {
@@ -279,7 +330,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) {
@@ -306,6 +358,7 @@
               }
            });
         },
         fillRecord(item, index) {
            // 填写记录的逻辑
            uni.navigateTo({
@@ -397,7 +450,7 @@
                        console.log(this.QcIssueResultDetailes)
                        const url = `http://192.168.1.22:10054/api/QcIssueResult/GetProcessNo`;
                        const url = this.$store.state.serverInfo.serverAPI+`/QcIssueResult/GetProcessNo`;
                        // 发送 POST 请求
                        uni.request({
                           url: url, // 请求地址
@@ -508,7 +561,13 @@
            }).then(res => {
               let data = res.data.tbBillList[0];
               if (data) {
                  this.formData = data;
                  this.formData = {
                     ...data,
                     emergencyStatus: data.emergency
                  };
                  // 确保PHSY字段被正确设置
                  this.formData.PHSY = data.PHSY;
                  this.$post({
                     url: "/LLJ/getJYItem",
@@ -520,9 +579,9 @@
                     let tableData = res1.data.tbBillList
                     //当已检验个数都不为空时按照检测结构排序
                     tableData.sort((a, b) => {
                        if (a.result === '未完成' && b.result === '合格') {
                        if (a.result === '合格' && b.result === '未完成') {
                           return -1;
                        } else if (a.result === '合格' && b.result === '未完成') {
                        } else if (a.result === '未完成' && b.result === '合格') {
                           return 1;
                        } else {
                           return 0;
@@ -562,58 +621,25 @@
            });
         },
         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);
                  }
               })
            }
            // 保存不良描述
            this.$post({
               url: "/LLJ/saveRemarksGid",
               data: {
                  gid: this.formData.id,
                  remarks: this.remarks || '',
                  releaseNo: this.formData.releaseNo
                  // 不再包含PHSY字段
               }
            }).then(res => {
               if (res.data.tbBillList > 0) {
                  this.formData.remarks = this.remarks;
                  this.remarksPopup = !this.remarksPopup;
                  this.$showMessage("保存成功");
                  setTimeout(() => {
                     this.init();
                  }, 2000);
               }
            })
         },
         drawingConfirm() {
@@ -632,22 +658,24 @@
            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
            const url = this.$store.state.serverInfo.serverAPI +"/PLM/RetrieveDrawings?ItemNo=" + item
            // const item = '5.06.04.4002';
            // const url = "http://192.168.0.100: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 = null
                     _this.drawing = null
                  } else {
                     this.drawing = response.data.data
                     _this.drawing = response.data.data
                     // 遍历数据,判断文件后缀并添加字段
                     this.drawing.forEach((file) => {
                     _this.drawing.forEach((file) => {
                        // 获取文件名的后缀
                        const fileExtension = file.fName.split('.').pop()
                           .toLowerCase();
@@ -680,7 +708,7 @@
            if (item.fRelevantObject.length > 2) {
               // 生成请求URL(简化编码逻辑)
               const encodedName = encodeURIComponent(item.fName); 
               const url = `http://192.168.1.22:10054/api/PLM/OpenDrawingsGet?fileId=${item.fRelevantObject}&fName=${encodedName}`;
               const url = this.$store.state.serverInfo.serverAPI+`/PLM/OpenDrawingsGet?fileId=${item.fRelevantObject}&fName=${encodedName}`;
               console.log('请求URL:', url);
               
               const now = new Date();
@@ -984,7 +1012,198 @@
            //       title: '无对应PDF文件,打开失败',
            //       icon: 'none'
            //    });            // }
         }
         },
         // 处理紧急放行
         handleEmergencyRelease() {
                     if (this.formData.emergencyStatus) {
                         uni.showModal({
                             title: "提示",
                             content: '该单已紧急放行,请勿重复操作',
                             showCancel: false
                         });
                         return;
                     }
                     uni.showModal({
                         title: '确认',
                         content: '确定要执行紧急放行吗?',
                         success: (res) => {
                             if (res.confirm) {
                                 // 调用新的后端接口
                                 this.$post({
                                     url: "/LLJ/EmergencyRelease",
                                     data: {
                                         id: this.formData.id
                                     }
                                 }).then(res => {
                                     if (res.data && res.status === 0) {
                                         const result = res.data.tbBillList[0];
                                         const message = res.data.tbBillList[1];
                                 const lotNo1 = res.data.tbBillList[2] || "";
                                         if (result === "0") {
                                             this.formData.emergencyStatus = true;
                                    this.originalLotNo1 = lotNo1;
                                    this.formData.lotNo1 = lotNo1;
                                             uni.showToast({
                                                 title: message || '紧急放行成功',
                                                 icon: 'success',
                                                 duration: 2000
                                             });
                                             this.init();
                                         } else {
                                             uni.showModal({
                                                 title: "提示",
                                                 content: message || '操作失败',
                                                 showCancel: false
                                             });
                                         }
                                     }
                                 }).catch(error => {
                                     uni.showModal({
                                         title: "错误",
                                         content: '网络错误,请检查网络连接',
                                         showCancel: false
                                     });
                                 });
                             }
                         }
                     });
                 },
                 // 处理撤回
                 handleWithdraw() {
                     uni.showModal({
                         title: '确认',
                         content: '确定要撤回紧急放行吗?',
                         success: (res) => {
                             if (res.confirm) {
                                 // 调用新的后端接口
                                 this.$post({
                                     url: "/LLJ/WithdrawEmergencyRelease",
                                     data: {
                                         id: this.formData.id
                                     }
                                 }).then(res => {
                                     if (res.data && res.status === 0) {
                                         const result = res.data.tbBillList[0];
                                         const message = res.data.tbBillList[1];
                                         if (result === "0") {
                                             this.formData.emergencyStatus = false;
                                             uni.showToast({
                                                 title: message || '撤回成功',
                                                 icon: 'success',
                                                 duration: 2000
                                             });
                                             this.init();
                                         } else {
                                             uni.showModal({
                                                 title: "提示",
                                                 content: message || '操作失败',
                                                 showCancel: false
                                             });
                                         }
                                     }
                                 }).catch(error => {
                                     uni.showModal({
                                         title: "错误",
                                         content: '网络错误,请检查网络连接',
                                         showCancel: false
                                     });
                                 });
                             }
                         }
                     });
                 },
               editRemarks() {
                  // 保存不良描述
                  this.$post({
                     url: "/LLJ/saveRemarksGid",
                     data: {
                        gid: this.formData.id,
                        remarks: this.remarks || '',
                        releaseNo: this.formData.releaseNo
                        // 不再包含PHSY字段
                     }
                  }).then(res => {
                     if (res.data.tbBillList > 0) {
                        this.formData.remarks = this.remarks;
                        this.remarksPopup = !this.remarksPopup;
                        this.$showMessage("保存成功");
                        setTimeout(() => {
                           this.init();
                        }, 2000);
                     }
                  })
               },
         addDestruction() {
            // 添加破坏实验的逻辑
            this.destructionPopup = !this.destructionPopup;
            this.PHSY = this.formData.PHSY || '';
            this.isInteger = true;
         },
         editDestruction() {
            // 验证输入是否为整数
            if(this.PHSY === '') {
               this.isInteger = true;
               // 如果为空,传递空字符串,后端会处理为null
            } else {
               const isInteger = /^-?\d+$/.test(this.PHSY);
               this.isInteger = isInteger;
               if (!isInteger) {
                  return;
               }
            }
            // 保存破坏实验数量
            this.$post({
               url: "/LLJ/saveRemarksGid",
               data: {
                  gid: this.formData.id,
                  releaseNo: this.formData.releaseNo,
                  PHSY: this.PHSY // 可以是空字符串或有效整数
                  // 不再包含remarks字段
               }
            }).then(res => {
               if (res.data.tbBillList > 0) {
                  // 如果输入为空,设置为null以便不显示
                  this.formData.PHSY = this.PHSY === '' ? null : this.PHSY;
                  this.destructionPopup = false;
                  this.$showMessage("保存成功");
                  setTimeout(() => {
                     // 跳转到列表页面
                     uni.navigateTo({
                        url: 'List'
                     });
                  }, 2000);
               }
            })
         },
         clearDestruction() {
            // 清除破坏实验数量
            this.PHSY = '';
            this.$post({
               url: "/LLJ/saveRemarksGid",
               data: {
                  gid: this.formData.id,
                  releaseNo: this.formData.releaseNo,
                  PHSY: '' // 空字符串,后端会处理为null
               }
            }).then(res => {
               if (res.data.tbBillList > 0) {
                  this.formData.PHSY = null; // 确保前端也为null,不显示
                  this.destructionPopup = false;
                  this.$showMessage("清除成功");
                  setTimeout(() => {
                     // 跳转到列表页面
                     uni.navigateTo({
                        url: 'List'
                     });
                  }, 2000);
               }
            })
         },
      }
   }
</script>
@@ -1078,12 +1297,9 @@
   }
   .sysLike {
      color: #3498db;
      color: #1890ff;
      text-decoration: none;
      margin-left: 15px;
      padding: 3px 8px;
      border-radius: 3px;
      font-size: 12px;
      cursor: pointer;
   }
   .doc-link:hover {
@@ -1124,13 +1340,31 @@
   /* 按钮样式 */
   .action-buttons {
      display: flex;
      justify-content: flex-end;
      gap: 10px;
      margin-top: 20px;
      margin: 15px 0;
      justify-content: flex-end;
   }
   .primary-btn,
   .secondary-btn {
      background-color: #ecf0f1;
      color: #7f8c8d;
      padding: 8px 15px;
      border: none;
      border-radius: 4px;
      cursor: pointer;
   }
   .secondary-btn:hover {
      background-color: #d5dbdb;
   }
   .secondary-btn:disabled {
      background-color: #d9d9d9;
      cursor: not-allowed;
      opacity: 0.7;
   }
   .primary-btn {
      padding: 10px 20px;
      border: none;
      border-radius: 4px;
@@ -1139,22 +1373,8 @@
      transition: all 0.3s;
   }
   .primary-btn {
      background-color: #3498db;
      color: white;
   }
   .primary-btn:hover {
      background-color: #2980b9;
   }
   .secondary-btn {
      background-color: #ecf0f1;
      color: #7f8c8d;
   }
   .secondary-btn:hover {
      background-color: #d5dbdb;
   }
   .record-btn {
@@ -1281,4 +1501,11 @@
      }
   }
   .error-message {
      color: #e74c3c;
      font-size: 14px;
      margin-top: 5px;
      margin-bottom: 10px;
   }
</style>