xwt
2025-08-21 bfffb0306f8e37ea39624499c55306837bf23ecf
pages/QC/LLJ/Add.vue
@@ -63,31 +63,24 @@
      </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-label">备注:</view>
@@ -99,12 +92,13 @@
          <view class="info-label">破坏实验数量:</view>
          <view class="info-value highlight">{{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">
@@ -141,22 +135,14 @@
         </table>
      </view>
      <!-- 页面内容区域 -->
      <view class="content-wrapper">
         <!-- 为底部按钮留出空间 -->
      </view>
      <!-- 固定在底部的操作按钮区 -->
      <view class="fixed-action-buttons">
         <button class="action-btn" @click="handleEmergencyRelease" v-if="this.current">紧急放行</button>
         <button class="action-btn" @click="handleWithdraw" v-if="this.current">撤回</button>
         <button class="action-btn" @click="getInspectionItems" v-if="this.current">获取检验项目</button>
         <button class="action-btn" @click="addDestruction" v-if="this.current">破坏实验</button>
         <button class="action-btn" @click="uploadImages">上传/查看图片</button>
         <button class="action-btn" @click="fetchDrawingNumber">调取PLM图纸</button>
         <button class="action-btn" @click="viewAttachmentInfo">查看附件信息</button>
         <button class="action-btn" @click="addDefectDescription" v-if="this.current">添加不良描述</button>
         <button class="action-btn primary" @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">
@@ -199,7 +185,7 @@
                  <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>
@@ -284,7 +270,14 @@
               
               <!-- 图片内容预览 -->
               <view v-else-if="previewType === 'image'" class="image-preview-container">
                  <image :src="previewContent" mode="widthFix" style="width: 100%; max-height: 400px;"></image>
                  <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 文件提示 -->
@@ -353,6 +346,13 @@
            PSTYPE: '',
            WORKSHOP: '',
            REMARK: '',
            // picker 选项和索引
            badreasonOptions: ['', '外观不良', '尺寸不良', '包装不良', '性能不良', '装配不良', '安规不良'],
            badreasonIndex: 0,
            workshopOptions: ['', '生产一部', '生产二部', '注塑车间', '其他'],
            workshopIndex: 0,
            pstypeOptions: ['', '特采/让步使用', '挑选/返工使用', '退货', '待判'],
            pstypeIndex: 0,
            checkState: false,
            writeStatu: true,
            fileName:'',
@@ -484,18 +484,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;
@@ -506,9 +559,9 @@
            })
            if (this.checkState) {
               if (this.formData.fngDesc == '' || this.writeStatu == false) {
               if (this.formData.fngDesc == '') {
                  uni.showToast({
                     title: '未填写不良描述或不良原因或所属车间或评审状态',
                     title: '未填写不良描述',
                     icon: 'none'
                  });
               } else {
@@ -522,48 +575,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,
                              EMERGENCY: this.formData.emergencyStatus ? "1" : "0" // 确保紧急放行状态正确传递
                           };
                        }
                        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,
                              EMERGENCY: this.formData.emergencyStatus ? "1" : "0" // 确保紧急放行状态正确传递
                           };
                        }
                        // 统一推送给HMCS,不管哪个账号
                        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.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.formData.emergencyStatus ? "1" : "0");
                        console.log("完整的提交数据:", this.QcIssueResultDetailes);
                        const url = this.$store.state.serverInfo.serverAPI+`/QcIssueResult/GetProcessNo`;
                        if (this.PSTYPE === '特采/让步使用') {// 发送 POST 请求
                        if (this.PSTYPE === '待判') {// 发送 POST 请求
                        uni.request({
                           url: url, // 请求地址
                           method: 'POST', // 请求方法
@@ -680,12 +713,23 @@
                     ...data,
                     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;
                  this.PHSY = data.PHSY || ''; // 同时设置页面绑定的PHSY变量
                  
                  console.log("加载的紧急放行状态:", this.formData.emergencyStatus);
                  this.$post({
                     url: "/LLJ/getJYItem",
                     data: {
@@ -737,27 +781,7 @@
               url: 'SysSubmitFrom?releaseNo=' + releaseNo + '&userID=' + this.$loginInfo.account
            });
         },
         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);
               }
            })
         },
         drawingConfirm() {
            this.drawingShow = false
@@ -788,7 +812,7 @@
               success: (response) => {
                  console.log(response)
                  if (response.data.data == '返回结果为空') {
                     _this.drawing = null
                     _this.drawing = []
                  } else {
                     _this.drawing = response.data.data
                     // 遍历数据,判断文件后缀并添加字段
@@ -1240,24 +1264,24 @@
                     });
                 },
               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);
                        }, 500);
                     }
                  }).catch(err => {
                     console.error('保存失败:', err);
                  })
               },
         addDestruction() {
@@ -1267,10 +1291,8 @@
            this.isInteger = true;
         },
         editDestruction() {
            // 验证输入是否为整数
            if(this.PHSY === '') {
               this.isInteger = true;
               // 如果为空,传递空字符串,后端会处理为null
            } else {
               const isInteger = /^-?\d+$/.test(this.PHSY);
               this.isInteger = isInteger;
@@ -1278,47 +1300,47 @@
                  return;
               }
            }
            // 保存破坏实验数量
            this.$post({
               url: "/LLJ/saveRemarksGid",
               url: "/LLJ/savePhsyGid",
               data: {
                  gid: this.formData.id,
                  releaseNo: this.formData.releaseNo,
                  PHSY: this.PHSY // 可以是空字符串或有效整数
                  // 不再包含remarks字段
                  PHSY: this.PHSY
               }
            }).then(res => {
               if (res.data.tbBillList > 0) {
                  // 如果输入为空,设置为null以便不显示
                  this.formData.PHSY = this.PHSY === '' ? null : this.PHSY;
                  this.destructionPopup = false;
                  this.$showMessage("保存成功");
                  // 立即重新加载数据确保同步
                  setTimeout(() => {
                     this.init();
                  }, 2000);
                  }, 500);
               }
            }).catch(err => {
               console.error('保存失败:', err);
            })
         },
         clearDestruction() {
            // 清除破坏实验数量
            this.PHSY = '';
            this.$post({
               url: "/LLJ/saveRemarksGid",
               url: "/LLJ/savePhsyGid",
               data: {
                  gid: this.formData.id,
                  releaseNo: this.formData.releaseNo,
                  PHSY: '' // 空字符串,后端会处理为null
                  PHSY: ''
               }
            }).then(res => {
               if (res.data.tbBillList > 0) {
                  this.formData.PHSY = null; // 确保前端也为null,不显示
                  this.formData.PHSY = null;
                  this.destructionPopup = false;
                  this.$showMessage("清除成功");
                  // 立即重新加载数据确保同步
                  setTimeout(() => {
                     this.init();
                  }, 2000);
                  }, 500);
               }
            }).catch(err => {
               console.error('清除失败:', err);
            })
         },
         viewAttachmentInfo() {
@@ -1327,7 +1349,7 @@
            this.attachments = [];
            this.$post({
               url: "/LLJ/getAttachments",
               data: { releaseNo: this.formData.releaseNo }
               data: { itemNo: this.formData.itemNo }
            }).then(res => {
               this.attachmentsLoading = false;
               if (res.status === 0) {
@@ -1548,6 +1570,36 @@
            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文件
@@ -1856,7 +1908,7 @@
            }
            // #endif
         },
      }
   }
</script>
@@ -1867,7 +1919,7 @@
      font-family: 'Microsoft YaHei', 'Segoe UI', sans-serif;
      max-width: 1000px;
      margin: 0 auto;
      padding: 20px 20px 160px 20px; /* 底部增加padding为固定按钮留空间 */
      padding: 20px 20px 100px 20px; /* 底部增加内边距为固定按钮留空间 */
      background-color: #fff;
      box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
      min-height: 100vh;
@@ -1916,6 +1968,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 {
@@ -1992,22 +2062,35 @@
      background-color: #f1f5f9;
   }
   /* 固定底部按钮样式 */
   .fixed-action-buttons {
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
      background-color: #fff;
      box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
      padding: 10px 15px 20px 15px;
      z-index: 100;
   /* 表单上方操作按钮区样式 */
   .top-action-buttons {
      display: flex;
      flex-direction: column;
      gap: 8px;
      max-height: 150px;
      overflow-y: auto;
      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;
@@ -2040,9 +2123,16 @@
      background-color: #2980b9;
   }
   /* 内容包装器,为底部按钮留出空间 */
   .content-wrapper {
      height: 20px; /* 额外的空白区域 */
   /* 小尺寸按钮样式 */
   .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;
   }
   /* 原有按钮样式保持兼容 */
@@ -2484,4 +2574,80 @@
   .attachment-popup-close:hover {
      background: #bdbdbd;
   }
   /* 响应式设计 */
   @media (max-width: 500px) {
      .info-row,
      .info-block {
         flex-direction: column;
         align-items: flex-start;
      }
      .doc-links {
         margin-left: 0;
         margin-top: 10px;
      }
      .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;
      }
   }
   /* 图片放大预览相关样式 */
   .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>