xwt
2 天以前 7c2192a2f000d94add173b77b6bd4c8c4fc6a5e4
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,44 +56,26 @@
            <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" @change="saveRemarksGid">
            <option value=""></option>
            <option value="外观不良">外观不良</option>
            <option value="尺寸不良">尺寸不良</option>
            <option value="包装不良">包装不良</option>
            <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" @change="saveRemarksGid">
            <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" @change="saveRemarksGid">
            <option value=""></option>
            <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;">   
@@ -104,7 +86,7 @@
      </view>
      <view class="info-block" style="margin-top: 10px;">   
          <view class="info-label">破坏实验数量:</view>
          <view class="info-value highlight">{{formData.phsy}}</view>
          <view class="info-value highlight">{{formData.PHSY || formData.phsy || ''}}</view>
      </view>
      <!-- 表单上方操作按钮区 -->
@@ -154,6 +136,7 @@
         <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="getBom">Bom用料清单</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>
@@ -190,6 +173,32 @@
      </view>
      
      <view class="barcode">
         <u-modal :show="itemShow" title="物料明细" @confirm="drawingConfirm" @cancel="drawingCancel"
            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">名称</uni-th>
                  <uni-th align="center" width="90">规格型号</uni-th>
                  <uni-th align="center" width="150">调取PLM图纸</uni-th>
               </uni-tr>
               <uni-tr v-for="(item,index) in (drawing || [])" style="height: 100px;">
                  <uni-td align="center">{{item.itemNo}}</uni-td>
                  <uni-td align="center" style="font-size:25px;">
                     <div >{{item.itemName}}</div>
                  </uni-td>
                  <uni-td align="center" style="font-size:25px;">
                     <div>{{item.itemModel}}</div>
                  </uni-td>
                  <uni-td align="center" class="click-wd">
                     <div @click="fetchDrawingNumber">调取图纸</div>
                  </uni-td>
               </uni-tr>
            </uni-table>
         </u-modal>
      </view>
      <view class="barcode">
         <u-modal :show="drawingShow" title="图纸明细" @confirm="drawingConfirm" @cancel="drawingCancel"
            showCancelButton :z-index="1000">
            <uni-table border stripe emptyText="暂无更多数据" style="margin-left: 5px;margin-right: 5px;height: 400px;max-height: 60vh;overflow-y: auto;">
@@ -199,7 +208,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>
@@ -356,10 +365,18 @@
            current: true,
            drawing: [],
            drawingShow: false,
            itemShow: false,
            badreason: '',
            PSTYPE: '',
            WORKSHOP: '',
            REMARK: '',
            // picker 选项和索引
            badreasonOptions: ['', '外观不良', '尺寸不良', '包装不良', '性能不良', '装配不良', '安规不良'],
            badreasonIndex: 0,
            workshopOptions: ['', '生产一部', '生产二部', '注塑车间', '其他'],
            workshopIndex: 0,
            pstypeOptions: ['', '特采/让步使用', '挑选/返工使用', '退货', '待判'],
            pstypeIndex: 0,
            checkState: false,
            writeStatu: true,
            fileName:'',
@@ -379,6 +396,19 @@
            previewItemNo: '',
            previewType: '', // 'text', 'image', 'excel', 'unsupported'
            
         }
      },
      computed: {
         isUnmaintainedAndNotEmergency() {
            // 判断表单是否未维护且不是紧急放行
            // 未维护的条件:tableData为空或所有检验项目都未完成
            const isUnmaintained = this.tableData.length === 0 ||
               this.tableData.every(item => item.fcheckResu === null || item.fcheckResu === '');
            // 不是紧急放行的条件:emergencyStatus为false
            const isNotEmergency = !this.formData.emergencyStatus;
            return isUnmaintained && isNotEmergency;
         }
      },
      onLoad(options) {
@@ -494,16 +524,68 @@
            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;
@@ -514,9 +596,9 @@
            })
            if (this.checkState) {
               if (this.formData.fngDesc == '' || this.writeStatu == false) {
               if (this.formData.fngDesc == '') {
                  uni.showToast({
                     title: '未填写不良描述或不良原因或所属车间或评审状态',
                     title: '未填写不良描述',
                     icon: 'none'
                  });
               } else {
@@ -530,42 +612,22 @@
                  }).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.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.formData.emergencyStatus ? "1" : "0");
                        console.log("完整的提交数据:", this.QcIssueResultDetailes);
@@ -693,11 +755,16 @@
                  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变量
                  // 确保PHSY字段被正确设置(兼容大小写)
                  this.formData.PHSY = data.PHSY || data.phsy;
                  this.PHSY = (data.PHSY || data.phsy || '').toString(); // 同时设置页面绑定的PHSY变量
                  
                  console.log("加载的紧急放行状态:", this.formData.emergencyStatus);
                  this.$post({
@@ -710,6 +777,16 @@
                     let tableData = res1.data.tbBillList
                     //当已检验个数都不为空时按照检测结构排序
                     tableData.sort((a, b) => {
                        // 首先按Fstand排序:Fstand不为空的排在前面
                        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 === '合格') {
@@ -757,11 +834,13 @@
            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() {
@@ -782,7 +861,7 @@
               success: (response) => {
                  console.log(response)
                  if (response.data.data == '返回结果为空') {
                     _this.drawing = null
                     _this.drawing = []
                  } else {
                     _this.drawing = response.data.data
                     // 遍历数据,判断文件后缀并添加字段
@@ -811,7 +890,7 @@
            });
            this.drawingShow = true
         },
         //图纸相关文档
         openDrawings(item) {
@@ -1245,29 +1324,43 @@
                     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() {
            // 添加破坏实验的逻辑
            this.destructionPopup = !this.destructionPopup;
            // 修复:确保PHSY变量正确初始化
            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",
@@ -1277,18 +1370,42 @@
                  PHSY: this.PHSY
               }
            }).then(res => {
               if (res.data.tbBillList > 0) {
               uni.hideLoading();
               if (res.data && res.data.tbBillList > 0) {
                  this.formData.PHSY = this.PHSY === '' ? null : this.PHSY;
                  this.destructionPopup = false;
                  this.$showMessage("保存成功");
                  uni.showToast({
                     title: '保存成功',
                     icon: 'success',
                     duration: 2000
                  });
                  // 立即重新加载数据确保同步
                  setTimeout(() => {
                     this.init();
                  }, 2000);
                  }, 500);
               } else {
                  uni.showToast({
                     title: '保存失败',
                     icon: 'none',
                     duration: 2000
                  });
               }
            }).catch(err => {
               uni.hideLoading();
               console.error('保存失败:', err);
               uni.showToast({
                  title: '保存失败,请重试',
                  icon: 'none',
                  duration: 2000
               });
            })
         },
         clearDestruction() {
            this.PHSY = '';
            // 显示加载提示
            uni.showLoading({
               title: '清除中...'
            });
            this.$post({
               url: "/LLJ/savePhsyGid",
               data: {
@@ -1297,14 +1414,35 @@
                  PHSY: ''
               }
            }).then(res => {
               if (res.data.tbBillList > 0) {
               uni.hideLoading();
               if (res.data && res.data.tbBillList > 0) {
                  this.formData.PHSY = null;
                  this.PHSY = '';
                  this.destructionPopup = false;
                  this.$showMessage("清除成功");
                  uni.showToast({
                     title: '清除成功',
                     icon: 'success',
                     duration: 2000
                  });
                  // 立即重新加载数据确保同步
                  setTimeout(() => {
                     this.init();
                  }, 2000);
                  }, 500);
               } else {
                  uni.showToast({
                     title: '清除失败',
                     icon: 'none',
                     duration: 2000
                  });
               }
            }).catch(err => {
               uni.hideLoading();
               console.error('清除失败:', err);
               uni.showToast({
                  title: '清除失败,请重试',
                  icon: 'none',
                  duration: 2000
               });
            })
         },
         viewAttachmentInfo() {
@@ -1872,22 +2010,7 @@
            }
            // #endif
         },
         saveRemarksGid() {
           this.$post({
            url: "/LLJ/saveDropdownFields",
            data: {
              gid: this.formData.id,
              releaseNo: this.formData.releaseNo,
              BLYY: this.badreason || '',
              SSCJ: this.WORKSHOP || '',
              PSZT: this.PSTYPE || ''
            }
           }).then(res => {
            if (res.data.tbBillList > 0) {
              this.$showMessage("自动保存成功");
            }
           });
         },
      }
   }
</script>
@@ -1903,6 +2026,39 @@
      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;
   }
   /* 头部样式 */
@@ -1948,6 +2104,24 @@
      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 {
      font-weight: bold;