xwt
2025-06-27 0d3eadb50310ca60b8871e967e64da01aa25a9ad
pages/QC/LLJ/Add.vue
@@ -89,11 +89,15 @@
         </select>
      </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="info-block" style="margin-top: 10px;">
          <view class="info-label">破坏实验数量:</view>
          <view class="info-value highlight">{{formData.phsy}}</view>
      </view>
      
@@ -145,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>
@@ -165,6 +170,21 @@
         </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"
@@ -225,6 +245,7 @@
               permissionAccount: '',
               hasEmergencyPermission: false,
               showPopup: false,
               PHSY:'',
               
            },
            tableData: [],
@@ -242,6 +263,9 @@
            fileName:'',
            originalRemarks: '',
            hasEmergencyPermission: false,
            destructionPopup: false,
            PHSY: '',
            isInteger: true,
            
         }
      },
@@ -306,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) {
@@ -540,6 +565,9 @@
                     ...data,
                     emergencyStatus: data.emergency
                  };
                  // 确保PHSY字段被正确设置
                  this.formData.PHSY = data.PHSY;
                  this.$post({
                     url: "/LLJ/getJYItem",
@@ -593,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() {
@@ -1122,64 +1117,93 @@
                     });
                 },
               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
                        // 不再包含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>
@@ -1477,4 +1501,11 @@
      }
   }
   .error-message {
      color: #e74c3c;
      font-size: 14px;
      margin-top: 5px;
      margin-bottom: 10px;
   }
</style>