xwt
2025-06-10 676db89a661ba8af8da04f4503c39b1bc0d2c25e
pages/QC/LLJ/detail.vue
@@ -97,9 +97,13 @@
                  <view class="info-value">{{formData.result}}</view>
               </view>
               <view v-if="formData.remarks!=null" class="result-ng">
               <view v-if="formData.funit!=null" class="result-ng">
                  <view class="info-label">不良描述</view>
                  <view class="info-value danger">{{formData.remarks}}</view>
                  <view class="info-value danger">{{formData.funit}}</view>
               </view>
               <view class="result-ng">
                   <view class="info-label">备注</view>
                   <view class="info-value danger">{{formData.meom}}</view>
               </view>
            </view>
         </view>
@@ -108,6 +112,17 @@
         <view class="section">
            <view class="section-header">检验结果录入</view>
            <view class="section-body">
               <view class="input-group" v-if="tableData.length >= formData.checkQyt">
                  <view class="input-wrapper">
                     <input v-model="batchInput" type="text" class="result-input"
                        placeholder="格式:OK-3 或 NG-3(请勿修改结果为数字的值)" placeholder-class="placeholder"
                        @input="validateBatchInput" @blur="validateBatchInput" />
                     <button :disabled="!isBatchInputValid" :class="{ 'btn-disabled': !isBatchInputValid }"
                        style="margin: 0px;background-color: #3498db;color:#ffffff ;" class="btn primary-btn"
                        @tap="batchUpdateResults">批量修改</button>
                  </view>
                  <view v-if="batchInputError" class="error-message">{{ batchInputError }}</view>
               </view>
               <view class="input-group input1">
                  <view class="input-wrapper">
@@ -119,6 +134,10 @@
                        <uni-icons type="compose" size="16" color="#fff"></uni-icons>
                        不良描述
                     </button>
                     <button v-if="this.current" class="btn upload-btn" @tap="upMeom">
                        <uni-icons type="compose" size="16" color="#fff"></uni-icons>
                        备注
                     </button>
                     <input v-if="(tableData.length < formData.checkQyt)" @input="search($event)"
                        v-model="inputTxt" type="text" class="result-input" placeholder="请输入检验结果..."
                        placeholder-class="placeholder" />
@@ -127,10 +146,10 @@
                        @tap="saveResult">保存结果</button>
                  </view>
               </view>
               <view class="input-group input2">
                  <view class="input-wrapper">
                     <button class="btn upload-btn" @tap="chooseImage">
                        <uni-icons type="upload" size="16" color="#fff"></uni-icons>
                        上传/查看图片
@@ -139,9 +158,15 @@
                        <uni-icons type="compose" size="16" color="#fff"></uni-icons>
                        不良描述
                     </button>
                     <button v-if="this.current" class="btn upload-btn" @tap="upMeom">
                                 <uni-icons type="compose" size="16" color="#fff"></uni-icons>
                                 备注
                             </button>
                  </view>
                  <view class="input-wrapper" style="margin-top: 15px;">
                     <input v-if="(tableData.length < formData.checkQyt)" @input="search($event)"
                        v-model="inputTxt" type="text" class="result-input" placeholder="请输入检验结果..."
                        placeholder-class="placeholder" />
@@ -157,7 +182,8 @@
         <view v-if="tableData.length>0" class="table-container">
            <view class="table-header">
               <view class="th">编号</view>
               <view class="th">检验结果<i style="color: rgb(0 212 68);" v-if="!(tableData.length < formData.checkQyt)">(输入已完成)</i></view>
               <view class="th">检验结果<i style="color: rgb(0 212 68);"
                     v-if="!(tableData.length < formData.checkQyt)">(输入已完成)</i></view>
               <view class="th" v-if="current">操作</view>
            </view>
@@ -168,7 +194,7 @@
                     {{ item.fcheckResu }}
                  </view>
               </view>
               <view class="td" v-if="current" >
               <view class="td" v-if="current">
                  <button v-if="!isNumber" class="btn danger-btn" @tap="toggleResult(item)">
                     {{ editResult(item.fcheckResu) }}
                  </button>
@@ -191,7 +217,20 @@
               </form>
            </view>
         </view>
         <view v-if="showPopup" class="overlay">
         <view v-if="meomPopup" 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="meom" />
                     </view>
                     <button class="updateBut" type="warn" @click="editMeom">修改</button>
                     <button @click="meomPopup = !meomPopup">取消</button>
                 </form>
             </view>
         </view>
         <view v-if="showMeom" class="overlay">
            <view class="popup">
               <h3>修改检验结果</h3>
               <form :modelValue="editData">
@@ -200,7 +239,7 @@
                     <input class="form-input" type="text" v-model="editData.fcheckResu" />
                  </view>
                  <button type="warn" @click="eidt">修改</button>
                  <button @click="showPopup = !showPopup">取消</button>
                  <button @click="showMeom = !showMeom">取消</button>
               </form>
            </view>
         </view>
@@ -228,16 +267,99 @@
            showPopup: false,
            editData: {},
            inputTxt: '',
            formID:'',
            releaseNo:'',
            current:false
            formID: '',
            releaseNo: '',
            current: false,
            batchInput: '',
            batchInputError: '',
            isBatchInputValid: false,
            funit:'',
            meomPopup: false,
            showMeom:false,
            meom: '',
         }
      },
      methods: {
         switchTab(index,mainIds) {
         switchTab(index, mainIds) {
            this.currentTab = index
            this.mainId = mainIds;
            this.refreshResult();
         },
         validateBatchInput() {
            const input = this.batchInput.trim();
            if (!input) {
               this.batchInputError = '';
               this.isBatchInputValid = false;
               return;
            }
            // 验证格式:OK-数字 或 NG-数字
            const match = input.match(/^(OK|NG)-(\d+)$/);
            if (!match) {
               this.batchInputError = '格式错误,请输入:OK-数字 或 NG-数字';
               this.isBatchInputValid = false;
               return;
            }
            const count = parseInt(match[2]);
            if (count <= 0 || count > this.tableData.length) {
               this.batchInputError = `数量必须在 1-${this.tableData.length} 之间`;
               this.isBatchInputValid = false;
               return;
            }
            this.batchInputError = '';
            this.isBatchInputValid = true;
         },
         // 批量更新检验结果
         batchUpdateResults() {
            if (!this.isBatchInputValid) return;
            const [status, countStr] = this.batchInput.split('-');
            const count = parseInt(countStr);
            if (this.tableData.length > 0) {
               const firstItem = this.tableData[0];
               const isNumber = /^-?\d+(\.\d+)?$/.test(firstItem.fcheckResu);
               if (isNumber) {
                  this.$showMessage("不能批量修改数字类型的结果");
                  return;
               }
            }
            let updatedCount = 0;
            const requests = [];
            for (let i = 0; i < count; i++) {
               const item = this.tableData[i];
               const fstand = status === 'OK' ? '√' : '×';
               const fcheckResu = status;
               requests.push(this.$post({
                  url: "/LLJ/UpdateQSItemDetail",
                  data: {
                     id: item.id,
                     mainId: this.formData.id,
                     releaseNo: this.formData.releaseNo,
                     fstand: fstand,
                     fcheckResu: fcheckResu,
                     updateBy: this.$loginInfo.account,
                  }
               }));
            }
            Promise.all(requests)
               .then(() => {
                  this.$showMessage(`成功将前${count}个结果修改为${status}`);
                  this.batchInput = '';
                  this.batchInputError = '';
                  this.isBatchInputValid = false;
                  this.refreshResult(); // 刷新结果
               })
               .catch(error => {
                  this.$showMessage(`批量修改失败: ${error.message}`);
               });
         },
         //检测输入框的输入,并给变量赋值
         search(event) {
@@ -359,9 +481,10 @@
               //fupAllow  fdownAllow  standardValue
               if (this.formData.fupAllow && this.formData.fdownAllow && this.formData.fstand) {
                  this.isNumber = true;
               }else{
               } else {
                  this.isNumber = false;
               }
            })
         },
         editResult(fcheckResu) {
@@ -373,11 +496,50 @@
         },
         toDetail(item) {
            this.showPopup = !this.showPopup;
            this.showMeom = !this.showMeom;
            this.editData = item;
         },
         upMeom() {
             this.meomPopup = true;
         },
         editMeom() {
             // 保存备注信息
             if (this.meom) {
                 this.$post({
                     url: "/LLJ/saveRemarksPid",
                     data: {
                         pid: this.formData.id,
                         meom: this.meom,
                     }
                 }).then(res => {
                     if (res.data.tbBillList > 0) {
                         this.formData.meom = this.meom;
                         this.meomPopup = !this.meomPopup;
                         this.$showMessage("保存成功");
                     }
                 })
             } else {
                 this.$post({
                     url: "/LLJ/saveRemarksPid",
                     data: {
                         pid: this.formData.id,
                         meom: ''
                     }
                 }).then(res => {
                     if (res.data.tbBillList > 0) {
                         this.formData.meom = this.meom;
                         this.meomPopup = !this.meomPopup;
                         this.$showMessage("保存成功");
                     }
                 })
             }
         },
         editRemarks() {
            if (this.remarks) {
               //saveRemarksGid
               this.$post({
                  url: "/LLJ/saveRemarksPid",
                  data: {
@@ -475,15 +637,16 @@
         let params = options;
         this.mainId = params["mainId"];
         this.refreshResult();
         this.formID= params["formID"];
         this.releaseNo= params["releaseNo"];
            this.currentTab=parseInt(params["index"]);
         this.current=params["current"] === 'true' ? true : false;
         this.formID = params["formID"];
         this.releaseNo = params["releaseNo"];
         this.currentTab = parseInt(params["index"]);
         this.current = params["current"] === 'true' ? true : false;
         this.$post({
            url: "/LLJ/getJYItem",
            data: {
               id: this.formID,
               releaseNo: this.releaseNo
               releaseNo: this.releaseNo,
            }
         }).then(res1 => {
            let tableData = res1.data.tbBillList
@@ -497,7 +660,7 @@
                  return 0;
               }
            });
             this.tabs = tableData;
            this.tabs = tableData;
            // if (this.tableData.length === 0) {
            //    this.isShowTable = true;
            // }
@@ -505,7 +668,12 @@
               this.set(item, 'current', this.current);
            });
            console.log(this.tableData);
         })
         this.$nextTick(() => {
            this.validateBatchInput();
         });
      }
   }
</script>
@@ -745,20 +913,41 @@
      background-color: #3498db;
      color: white;
   }
 .input1{
          display: block;
 }
 .input2{
          display: none;
 }
   .input1 {
      display: block;
   }
   .input2 {
      display: none;
   }
   /* 响应式设计 */
   @media (max-width: 500px) {
      .input1{
         display: none;
      }
      .input2{
         display: block;
      }
      .input1 {
         display: none;
      }
      .input2 {
         display: block;
      }
   }
   .error-message {
      color: $danger-color;
      font-size: 12px;
      margin-top: 4px;
   }
   .input-group:first-child {
      .result-input {
         border-color: $primary-color;
         box-shadow: 0 0 0 2px rgba($primary-color, 0.2);
      }
   }
   .btn-disabled {
      opacity: 0.6;
      cursor: not-allowed;
   }
</style>