cnf
2025-09-16 1dfbf152be9db7bc8c589a4d0bfba5df8d240585
pages/QC/SJ/detail.vue
@@ -1,751 +1,1028 @@
<template>
   <view class="container">
      <!-- 头部 -->
      <view class="header">
         <view class="title">首检检验项目明细</view>
         <view class="order-number">当前检验单号: {{releaseNo}}</view>
      </view>
  <view class="container">
    <!-- 头部 -->
    <view class="header">
      <view class="title">首检项目明细</view>
      <view class="order-number">首检单号: {{formData.billNo}}</view>
    </view>
      <!-- 标签栏 -->
      <view class="tabs">
         <view v-for="(tab, index) in tabs" :key="index" class="tab" :class="{active: currentTab === index}"
            @tap="switchTab(index,tab.id)">
            {{ tab.projName }}
         </view>
      </view>
      <view class="tab-content">
         <!-- 基本信息 -->
         <view class="section">
            <view class="section-header">基本信息</view>
            <view class="section-body">
               <view class="info-grid">
                  <view class="info-item">
                     <view class="info-label">项目名称</view>
                     <view class="info-value">{{ formData.projName }}</view>
                  </view>
                  <view class="info-item">
                     <view class="info-label">使用仪表</view>
                     <view class="info-value">{{ formData.usingInstruments }}</view>
                  </view>
                  <view class="info-item">
                     <view class="info-label">检验数量</view>
                     <view class="info-value">{{ formData.levelNum }}</view>
                  </view>
    <!-- 标签栏 - 如果有多个检验项目可以切换 -->
    <view class="tabs" v-if="tabs && tabs.length > 1">
      <view v-for="(tab, index) in tabs" :key="index" class="tab" :class="{active: currentTab === index}"
        @tap="switchTab(index, tab.id)">
        {{ tab.projName }}
      </view>
    </view>
    <view class="tab-content">
      <!-- 基本信息 -->
      <view class="section">
        <view class="section-header">基本信息</view>
        <view class="section-body">
          <view class="info-grid">
            <view class="info-item">
              <view class="info-label">项目名称</view>
              <view class="info-value">{{ formData.projName }}</view>
            </view>
            <view class="info-item" v-if="formData.itemMod">
              <view class="info-label">质量要求</view>
              <view class="info-value">{{ formData.itemMod }}</view>
            </view>
            <view class="info-item" v-if="formData.inspectionMethod">
              <view class="info-label">检验方法</view>
              <view class="info-value">{{ formData.inspectionMethod }}</view>
            </view>
            <view class="info-item" v-if="formData.usingInstruments">
              <view class="info-label">使用仪表</view>
              <view class="info-value">{{ formData.usingInstruments }}</view>
            </view>
            <view class="info-item">
              <view class="info-label">检验数</view>
              <view class="info-value">{{ formData.levelNum }}</view>
            </view>
            <view class="info-item" v-if="formData.minValue">
              <view class="info-label">下限</view>
              <view class="info-value">{{ formData.minValue }}</view>
            </view>
            <view class="info-item" v-if="formData.standardValue">
              <view class="info-label">标准值</view>
              <view class="info-value">{{ formData.standardValue }}</view>
            </view>
            <view class="info-item" v-if="formData.maxValue">
              <view class="info-label">上限</view>
              <view class="info-value">{{ formData.maxValue }}</view>
            </view>
            <view class="info-item" v-if="formData.mnum">
              <view class="info-label">开穴总数</view>
              <view class="info-value">{{ formData.mnum }}</view>
            </view>
            <view class="info-item" v-if="formData.dnum">
              <view class="info-label">堵穴号</view>
              <view class="info-value">{{ formData.dnum }}</view>
            </view>
            <view class="info-item" v-if="formData.updater">
              <view class="info-label">更新人</view>
              <view class="info-value">{{ formData.updater }}</view>
            </view>
            <view class="info-item" v-if="formData.updateTime">
              <view class="info-label">更新时间</view>
              <view class="info-value">{{ formData.updateTime }}</view>
            </view>
          </view>
        </view>
      </view>
                  <view v-if="formData.minValue!=null" class="info-item">
                     <view class="info-label">下限</view>
                     <view class="info-value">{{ formData.minValue }}</view>
                  </view>
                  <view v-if="formData.standardValue!=null" class="info-item">
                     <view class="info-label">标准值</view>
                     <view class="info-value">{{ formData.standardValue }}</view>
                  </view>
                  <view v-if="formData.maxValue!=null" class="info-item">
                     <view class="info-label">上限</view>
                     <view class="info-value">{{ formData.maxValue }}</view>
                  </view>
               </view>
            </view>
         </view>
      <!-- 规格要求 -->
      <view class="section" v-if="formData.specRequ">
        <view class="section-header">规格要求</view>
        <view class="section-body">
          <text class="spec-text">{{ formData.specRequ }}</text>
        </view>
      </view>
         <!-- 规格要求 -->
         <view class="section">
            <view class="section-header">质量要求</view>
            <view class="section-body">
               <text class="spec-text">{{ formData.itemMod }}</text>
            </view>
         </view>
         <!-- 规格要求 -->
         <view class="section">
            <view class="section-header">检验描述</view>
            <view class="section-body">
               <text class="spec-text">{{ formData.inspectionMethod }}</text>
            </view>
         </view>
         <!-- 检验结果 -->
         <view class="section">
            <view class="section-header">检验结果</view>
            <view class="section-body">
               <view v-if="formData.result!=null" class="result-preview">
                  <view class="info-label">预览结果</view>
                  <view class="info-value"><b>{{formData.result}}</b></view>
               </view>
      <!-- 检验描述 -->
      <view class="section" v-if="formData.itemMod">
        <view class="section-header">检验描述</view>
        <view class="section-body">
          <text class="spec-text">{{ formData.itemMod }}</text>
        </view>
      </view>
               <view v-if="formData.remarks!=null" class="result-ng">
                  <view class="info-label">不良描述</view>
                  <view class="info-value danger">{{formData.remarks}}</view>
               </view>
            </view>
         </view>
      <!-- 检验结果 -->
      <view class="section">
        <view class="section-header">检验结果</view>
        <view class="section-body">
          <view class="info-grid">
            <view class="info-item" v-if="formData.result">
              <view class="info-label">预览结果</view>
              <view class="info-value">{{formData.result}}</view>
            </view>
          </view>
         <!-- 结果录入 -->
         <view class="section">
            <view class="section-header">检验结果录入</view>
            <view class="section-body">
               <view class="input-group input1">
                  <view class="input-wrapper">
          <view v-if="formData.result != null" class="result-preview">
            <view class="info-label">预览结果</view>
            <view class="info-value">{{formData.result}}</view>
          </view>
                     <button class="btn upload-btn" @tap="chooseImage">
                        <uni-icons type="upload" size="16" color="#fff"></uni-icons>
                        上传/查看图片
                     </button>
                     <button v-if="this.current" class="btn upload-btn" @tap="upRemarks">
                        <uni-icons type="compose" size="16" color="#fff"></uni-icons>
                        不良描述
                     </button>
                     <input v-if="(tableData.length < formData.levelNum)" @input="search($event)"
                        v-model="inputTxt" type="text" class="result-input" placeholder="请输入检验结果..."
                        placeholder-class="placeholder" />
                     <button v-if="(tableData.length < formData.levelNum)"
                        style="margin: 0px;background-color: #3498db;color:#ffffff ;" class="btn primary-btn"
                        @tap="saveResult">保存结果</button>
                  </view>
               </view>
          <view v-if="formData.remarks != null" class="result-ng">
            <view class="info-label">不合格描述</view>
            <view class="info-value danger">{{formData.remarks}}</view>
          </view>
        </view>
      </view>
               <view class="input-group input2">
                  <view class="input-wrapper">
      <!-- 结果录入 -->
      <view class="section">
        <view class="section-header">检验结果录入</view>
        <view class="section-body">
          <view class="input-group">
            <view class="input-wrapper">
              <button class="btn upload-btn" @tap="saveRemarks">
                <uni-icons type="compose" size="16" color="#fff"></uni-icons>
                不合格描述
              </button>
              <input v-if="!isAllCompleted"
                v-model="formData.fcheckResu"
                type="text"
                class="result-input"
                placeholder="没有最大值和最小值时填写0(未通过检验)或1(通过检验)"
                placeholder-class="placeholder" />
              <button v-if="!isAllCompleted"
                style="margin: 0px;background-color: #3498db;color:#ffffff ;" class="btn primary-btn"
                @tap="submit">保存结果</button>
            </view>
          </view>
        </view>
      </view>
                     <button class="btn upload-btn" @tap="chooseImage">
                        <uni-icons type="upload" size="16" color="#fff"></uni-icons>
                        上传/查看图片
                     </button>
                     <button v-if="this.current" class="btn upload-btn" @tap="upRemarks">
                        <uni-icons type="compose" size="16" color="#fff"></uni-icons>
                        不良描述
                     </button>
                  </view>
                  <view class="input-wrapper" style="margin-top: 15px;">
      <!-- 结果表格 -->
      <view v-if="formData.levelNum > 0" class="table-container">
        <view class="table-header">
          <view class="th">编号</view>
          <view class="th">穴号</view>
          <view class="th">记录值</view>
          <view class="th">检验结果<i style="color: rgb(0 212 68);"
              v-if="isAllCompleted">(输入已完成)</i></view>
          <view class="th">操作</view>
        </view>
                     <input v-if="(tableData.length < formData.checkQyt)" @input="search($event)"
                        v-model="inputTxt" type="text" class="result-input" placeholder="请输入检验结果..."
                        placeholder-class="placeholder" />
                     <button v-if="(tableData.length < formData.checkQyt)"
                        style="margin: 0px;background-color: #3498db;color:#ffffff ;" class="btn primary-btn"
                        @tap="saveResult">保存结果</button>
                  </view>
               </view>
            </view>
         </view>
        <view v-for="(item, index) in displayTableData" :key="index" class="table-row">
          <view class="td">{{ index + 1 }}</view>
          <view class="td">{{ getHoleNumber(index) }}</view>
          <view class="td">
            <view class="record-value">{{ getRecordValue(item, index) }}</view>
          </view>
          <view class="td">
            <view :class="['result-badge', getResultClass(item.fcheckResu, item.fstand, index)]">
              {{ getResultText(item.fcheckResu, item.fstand, index) }}
            </view>
          </view>
          <view class="td">
            <button v-if="!isHoleBlocked(index) && item.fcheckResu && !isNumber" class="btn danger-btn" @tap="numberEdit(item)">
              {{ editResult(item.fcheckResu) }}
            </button>
            <button v-if="!isHoleBlocked(index) && item.fcheckResu && isNumber" class="btn danger-btn" @tap="toDetail(item)">
              修改
            </button>
            <span v-if="isHoleBlocked(index)" class="blocked-text">已堵穴</span>
            <span v-else-if="!item.fcheckResu" class="no-data-text">待填写</span>
          </view>
        </view>
      </view>
         <!-- 结果表格 -->
         <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.levelNum)">(输入已完成)</i></view>
               <view class="th" v-if="current">操作</view>
            </view>
      <!-- 图片预览 -->
      <view v-if="isShowImg" class="section">
        <view class="section-header">相关图片</view>
        <view class="section-body">
          <view class="image-preview" @click="previewImage">
            <image :src="base64Image" mode="aspectFit" class="preview-image"/>
          </view>
        </view>
      </view>
    </view>
            <view v-for="(item, index) in tableData" :key="index" class="table-row">
               <view class="td">{{ index + 1 }}</view>
               <view v-if="!isNumber" class="td">
                  <view :class="['result-badge', 'OK']" v-if="item.fcheckResu==1">
                     OK
                  </view>
                  <view :class="['result-badge', 'NG']" v-if="item.fcheckResu==0">
                     NG
                  </view>
               </view>
               <view v-if="isNumber" class="td">
                  <view :class="['result-badge', item.fcheckResu]">
                     {{ item.fcheckResu }}
                  </view>
               </view>
               <view class="td" v-if="current">
                  <button v-if="!isNumber" class="btn danger-btn" @tap="toggleResult(item)">
                     {{ editResult(item.fcheckResu) }}
                  </button>
                  <button v-if="isNumber" class="btn danger-btn" @tap="toDetail(item)">
                     修改
                  </button>
               </view>
            </view>
         </view>
         <view v-if="remarksPopup" 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="remarks" />
                  </view>
                  <button class="updateBut" type="warn" @click="editRemarks">修改</button>
                  <button @click="remarksPopup = !remarksPopup">取消</button>
               </form>
            </view>
         </view>
         <view v-if="showPopup" class="overlay">
            <view class="popup">
               <h3>修改检验结果</h3>
               <form :modelValue="editData">
                  <view class="form-group">
                     <label class="form-label">检验结果:</label>
                     <input class="form-input" type="text" v-model="editData.fcheckResu" />
                  </view>
                  <button type="warn" @click="eidt">修改</button>
                  <button @click="showPopup = !showPopup">取消</button>
               </form>
            </view>
         </view>
    <!-- 修改不合格描述弹出框 -->
    <view v-if="remarksPopup" class="overlay">
      <view class="popup">
        <view class="popup-header">
          <h3>修改不合格描述</h3>
        </view>
        <view class="popup-content">
          <view class="input-group">
            <view class="input-label">不合格描述:</view>
            <input class="input-field" type="text" v-model="remarks" placeholder="请输入不合格描述"/>
          </view>
        </view>
        <view class="popup-actions">
          <button class="action-btn primary" @click="editRemarks">修改</button>
          <button class="action-btn secondary" @click="remarksPopup = !remarksPopup">取消</button>
        </view>
      </view>
    </view>
      </view>
   </view>
    <!-- 修改检验结果弹出框 -->
    <view v-if="showPopup" class="overlay">
      <view class="popup">
        <view class="popup-header">
          <h3>修改检验结果</h3>
        </view>
        <view class="popup-content">
          <view class="input-group">
            <view class="input-label">检验结果:</view>
            <input class="input-field" type="text" v-model="editData.fcheckResu" placeholder="请输入检验结果"/>
          </view>
        </view>
        <view class="popup-actions">
          <button class="action-btn primary" @click="eidt">修改</button>
          <button class="action-btn secondary" @click="showPopup = !showPopup">取消</button>
        </view>
      </view>
    </view>
  </view>
</template>
<script>
   import {
      compile
   } from "vue";
export default {
  data() {
    return {
      formData: {},
      isNumber: false,
      checkItem: "",
      id: 0,
      gid: 0,
      billNo: "",
      showPopup: false,
      editData: {},
      tableData: [],
      base64Image: "",
      isShowImg: false,
      remarks: "",
      remarksPopup: false,
      // ===== 新增LLJ样式相关数据 =====
      currentTab: 0,
      tabs: []
    }
  },
  computed: {
    // 根据穴号信息生成完整的显示数据
    displayTableData() {
      const result = [];
      // 如果有穴号信息,使用穴号信息生成数据
      if (this.formData.holeNumbers && this.formData.holeNumbers.length > 0) {
        this.formData.holeNumbers.forEach((holeInfo, index) => {
          // 查找是否有对应的实际数据
          const actualData = this.tableData.find(item => {
            return this.tableData.indexOf(item) === index;
          });
          if (actualData) {
            // 如果有实际数据,使用实际数据
            result.push({
              ...actualData,
              index: index,
              holeInfo: holeInfo
            });
          } else {
            // 如果没有实际数据,创建空记录
            result.push({
              id: null,
              fcheckResu: holeInfo.isBlocked ? "/" : null,
              fstand: holeInfo.isBlocked ? "/" : null,
              index: index,
              pid: this.id,
              gid: this.gid,
              holeInfo: holeInfo
            });
          }
        });
      } else {
        // 如果没有穴号信息,使用原来的逻辑
        const levelNum = this.formData.levelNum || 0;
        for (let i = 0; i < levelNum; i++) {
          const actualData = this.tableData.find(item => {
            return this.tableData.indexOf(item) === i;
          });
          if (actualData) {
            result.push({
              ...actualData,
              index: i
            });
          } else {
            result.push({
              id: null,
              fcheckResu: null,
              fstand: null,
              index: i,
              pid: this.id,
              gid: this.gid
            });
          }
        }
      }
      return result;
    },
    // 判断是否所有检验都已完成
    isAllCompleted() {
      return this.displayTableData.every(item => item.fcheckResu !== null && item.fcheckResu !== undefined);
    }
  },
  methods: {
    getResultClass(fcheckResu, fstand, index) {
      // 检查是否被堵穴
      if (this.isHoleBlocked(index)) {
        return 'BLOCKED';
      }
      // 如果没有记录值,显示未检验样式
      if (!fcheckResu) {
        return 'PENDING';
      }
      // 根据检验结果和判定标识确定样式类
      if (fstand === '√' || fcheckResu === 'OK') {
        return 'OK';
      } else if (fstand === '×' || fcheckResu === 'NG') {
        return 'NG';
      } else {
        // 对于数字结果,根据fstand判断
        return fstand === '√' ? 'OK' : 'NG';
      }
    },
    getResultText(fcheckResu, fstand, index) {
      // 检查是否被堵穴
      if (this.isHoleBlocked(index)) {
        return '/';
      }
      // 如果没有记录值,显示未检验
      if (!fcheckResu) {
        return '未检验';
      }
      // 根据记录值判断检验结果是否OK
      if (fstand === '√') {
        return 'OK';
      } else if (fstand === '×') {
        return 'NG';
      } else {
        // 如果没有fstand,根据fcheckResu的值判断
        if (fcheckResu === '1' || fcheckResu === 1) {
          return 'OK';
        } else if (fcheckResu === '0' || fcheckResu === 0) {
          return 'NG';
        } else {
          // 对于有上下限的数值检验,根据fcheckResu是否在范围内判断
          if (this.formData.maxValue && this.formData.minValue) {
            const value = parseFloat(fcheckResu);
            if (!isNaN(value)) {
              if (value >= this.formData.minValue && value <= this.formData.maxValue) {
                return 'OK';
              } else {
                return 'NG';
              }
            }
          }
          return fcheckResu || '未检测';
        }
      }
    },
    // ===== 新增标签切换方法 =====
    switchTab(index, id) {
      this.currentTab = index;
      // 如果需要切换检验项目,可以在这里添加逻辑
      // this.gid = id;
      // this.refreshResult();
    },
   export default {
      data() {
         return {
            formData: {},
            tableData: {},
            mainId: '',
            isNumber: false,
            currentTab: 0,
            tabs: [],
            inputResult: '',
            remarksPopup: false,
            showPopup: false,
            editData: {},
            inputTxt: '',
            formID: '',
            releaseNo: '',
            current: false
         }
      },
      methods: {
         switchTab(index, mainIds) {
            this.currentTab = index
            this.mainId = mainIds;
            this.refreshResult();
         },
         //检测输入框的输入,并给变量赋值
         search(event) {
            this.formData.fcheckResu = event.detail.value;
         },
         toggleResult(item) {
            let fstand = "√";
            let fcheckResu = 1;
    // ===== 穴号相关方法 =====
    getHoleNumber(index) {
      const item = this.displayTableData[index];
      if (item && item.holeInfo) {
        return item.holeInfo.holeNumber;
      }
      return index + 1;
    },
            if (item.fcheckResu == '1') {
               fstand = "×";
               fcheckResu = 0;
            }
    getRecordValue(item, index) {
      if (this.isHoleBlocked(index)) {
        return '/';
      }
      return item.fcheckResu || '无';
    },
            this.$post({
               url: "/SJ/UpdateQSItemDetail",
               data: {
                  id: item.id,
                  pid: item.pid,
                  gid: item.gid,
                  fstand: fstand,
                  fcheckResu: fcheckResu,
                  updateBy: this.$loginInfo.account,
               }
            }).then(res => {
               this.$showMessage("修改成功");
               this.refreshResult(); //刷新页面
            })
         },
         chooseImage() {
            uni.navigateTo({
               url: 'ImageItem?id=' + this.formData.id
            });
         },
         upRemarks() {
            this.remarksPopup = true;
         },
         saveResult() {
            let count = this.formData.levelNum;
            let fstand = "√";
    isHoleBlocked(index) {
      const item = this.displayTableData[index];
      if (item && item.holeInfo) {
        return item.holeInfo.isBlocked;
      }
      return false;
    },
            //有最大值和最小值就根据是否符合标准值更新判定结果,没有最大值和最小值就根据是否通过检验判定结果
            if (this.formData.maxValue && this.formData.minValue) {
    previewImage() {
      uni.previewImage({
        urls: [this.base64Image],
      });
    },
    editResult(fcheckResu) {
      if (fcheckResu == '1') {
        return "改为不合格";
      } else {
        return "改为合格";
      }
    },
    submit() {
               if (!this.formData.fcheckResu) {
                  this.$showMessage("请输入检验值");
                  return;
               }
      let count = this.formData.levelNum;
      let fstand = "√";
               if (this.formData.fcheckResu >= this.formData.minValue && this.formData.fcheckResu <= this.formData
                  .maxValue) {
                  fstand = "√"
               } else {
                  fstand = "×";
               }
               count = 1;
            } else {
      //有最大值和最小值就根据是否符合标准值更新判定结果,没有最大值和最小值就根据是否通过检验判定结果
      if (this.formData.maxValue && this.formData.minValue) {
               if (!this.formData.fcheckResu) {
                  this.formData.fcheckResu = 1
               }
        if (!this.formData.fcheckResu) {
          this.$showMessage("请输入检验值");
          return;
        }
               if (this.formData.fcheckResu == 0 || this.formData.fcheckResu == 1) {
                  this.formData.isPass = this.formData.fcheckResu
               } else {
                  this.$showMessage("无标准值时,检验结果只能为0或1!");
                  return;
               }
               count = count - this.tableData.length;
            }
        if (this.formData.fcheckResu >= this.formData.minValue && this.formData.fcheckResu <= this.formData.maxValue) {
          fstand = "√"
        } else {
          fstand = "×";
        }
        count = 1;
      } else {
            this.formData.updater = this.$loginInfo.account;
        if (!this.formData.fcheckResu) {
          this.formData.fcheckResu = 1
        }
            this.$post({
               url: "/SJ/SetQSItemDetail",
               data: {
                  pid: this.mainId,
                  gid: this.formID,
                  fstand: fstand,
                  fcheckResu: this.formData.fcheckResu,
                  updateBy: this.formData.updater,
                  count: count
               }
            }).then(res => {
               this.formData.fcheckResu = null;
               this.$showMessage("保存成功");
               this.refreshResult();
            })
        if (this.formData.fcheckResu == 0 || this.formData.fcheckResu == 1) {
          this.formData.isPass = this.formData.fcheckResu
        } else {
          this.$showMessage("无标准值时,检验结果只能为0或1!");
          return;
        }
        count = 1; // 每次只填写一个记录
      }
      this.formData.updater = this.$loginInfo.account;
         },
         goBack() {
            uni.navigateBack()
         },
         //获取检验单详情
         refreshResult() {
            this.$post({
               url: "/SJ/getQSItems",
               data: {
                  id: this.mainId
               }
            }).then(res => {
      this.$post({
        url: "/SJ/SetQSItemDetail",
        data: {
          pid: this.id,
          gid: this.gid,
          fstand: fstand,
          fcheckResu: this.formData.fcheckResu,
          updateBy: this.formData.updater,
          count: count
        }
      }).then(res => {
        this.formData.fcheckResu = null;
        this.$showMessage("保存成功");
        this.refreshResult();
      })
               this.formData = res.data.tbBillList[0];
               this.$post({
                  url: "/SJ/getQSItemDetail",
                  data: {
                     pid: this.mainId,
                     gid: this.formID
                  }
               }).then(res => {
                  this.tableData = res.data.tbBillList;
               })
               // this.tableData = res.data.tbBillList.itemXj02s;
    },
    refreshResult() {
      this.$post({
        url: "/SJ/getQSItems",
        data: {
          id: this.id
        }
      }).then(res => {
        this.formData = res.data.tbBillList[0];
        this.formData.billNo = this.billNo;
        if (this.formData.imageData) {
          this.isShowImg = true;
          this.base64Image = 'data:image/jpeg;base64,' + this.formData.imageData;
        }
        if (this.formData.maxValue && this.formData.minValue && this.formData.standardValue) {
          this.isNumber = true;
        }
      })
               if (this.formData.imageData) {
                  this.isShowImg = true;
                  this.base64Image = 'data:image/jpeg;base64,' + this.formData.imageData;
               }
      this.$post({
        url: "/SJ/getQSItemDetail",
        data: {
          pid: this.id,
          gid: this.gid
        }
      }).then(res => {
        this.tableData = res.data.tbBillList;
      })
    },
    toDetail(item) {
      this.showPopup = !this.showPopup;
      this.editData = item;
    },
    eidt() {
               //fupAllow  fdownAllow  standardValue
               if (this.formData.maxValue && this.formData.minValue && this.formData.standardValue) {
                  this.isNumber = true;
               } else {
                  this.isNumber = false;
               }
            })
         },
         editResult(fcheckResu) {
            if (fcheckResu == '1') {
               return "改为不合格";
            } else {
               return "改为合格";
            }
         },
         toDetail(item) {
            this.showPopup = !this.showPopup;
            this.editData = item;
         },
         editRemarks() {
            if (this.remarks) {
               //saveRemarksGid
               this.$post({
                  url: "/SJ/saveRemarksPid",
                  data: {
                     pid: this.formData.id,
                     remarks: this.remarks
                  }
               }).then(res => {
                  if (res.data.tbBillList > 0) {
                     this.formData.remarks = this.remarks;
                     this.remarksPopup = !this.remarksPopup;
                     this.$showMessage("保存成功");
                  }
               })
            } else {
               this.$post({
                  url: "/SJ/saveRemarksPid",
                  data: {
                     pid: this.formData.id,
                     remarks: ''
                  }
               }).then(res => {
                  if (res.data.tbBillList > 0) {
                     this.formData.remarks = this.remarks;
                     this.remarksPopup = !this.remarksPopup;
                     this.$showMessage("保存成功");
                  }
               })
            }
         },
         eidt() {
      if (!this.editData.fcheckResu) {
        this.$showMessage("请输入检验结果");
      }
            if (!this.editData.fcheckResu) {
               this.$showMessage("请输入检验结果");
            }
      if (this.formData.fcheckResu == this.editData.fcheckResu) {
        this.$showMessage("修改成功");
        return;
      }
            if (this.formData.fcheckResu == this.editData.fcheckResu) {
               this.$showMessage("修改成功");
               return;
            }
      let fstand = "√";
            let fstand = "√";
      if (this.formData.maxValue && this.formData.minValue) {
            if (this.formData.maxValue && this.formData.minValue) {
        if (!this.editData.fcheckResu) {
          this.$showMessage("请输入检验值");
          return;
        }
               if (!this.editData.fcheckResu) {
                  this.$showMessage("请输入检验值");
                  return;
               }
        if (this.editData.fcheckResu >= this.formData.minValue && this.editData.fcheckResu <= this.formData.maxValue) {
          this.editData.isPass = 1
        } else {
          this.editData.isPass = 0
          fstand = "×";
        }
      } else {
               if (parseFloat(this.editData.fcheckResu) >= parseFloat(this.formData.fdownAllow) && parseFloat(this
                     .editData
                     .fcheckResu) <= parseFloat(this.formData.fupAllow)) {
                  this.editData.isPass = 1
               } else {
                  this.editData.isPass = 0
                  fstand = "×";
               }
            } else {
        if (!this.editData.fcheckResu) {
          this.editData.fcheckResu = 1
        }
               if (!this.editData.fcheckResu) {
                  this.editData.fcheckResu = 1
               }
        if (this.editData.fcheckResu == 0 || this.editData.fcheckResu == 1) {
          if (this.editData.fcheckResu == 0) {
            fstand = "×";
          }
        } else {
          this.$showMessage("无标准值时,检验结果只能为0或1!");
          return;
        }
      }
               if (this.editData.fcheckResu == 0 || this.editData.fcheckResu == 1) {
                  if (this.editData.fcheckResu == 0) {
                     fstand = "×";
                  }
               } else {
                  this.$showMessage("无标准值时,检验结果只能为0或1!");
                  return;
               }
            }
      this.editData.updater = this.$loginInfo.account;
            this.editData.updater = this.$loginInfo.account;
      this.$post({
        url: "/SJ/UpdateQSItemDetail",
        data: {
          id: this.editData.id,
          pid: this.id,
          gid: this.gid,
          fstand: fstand,
          fcheckResu: this.editData.fcheckResu,
          updateBy: this.editData.updater,
        }
      }).then(res => {
        this.showPopup = !this.showPopup;
        this.$showMessage("修改成功");
        this.refreshResult();//刷新页面
      })
    },
    numberEdit(item) {
            this.$post({
               url: "/SJ/UpdateQSItemDetail",
               data: {
                  id: this.editData.id,
                  pid: this.mainId,
                  gid: this.formID,
                  fstand: fstand,
                  fcheckResu: this.editData.fcheckResu,
                  updateBy: this.editData.updater,
               }
            }).then(res => {
               this.showPopup = !this.showPopup;
               this.$showMessage("修改成功");
               this.refreshResult(); //刷新页面
            })
         },
      },
      onLoad(options) {
         //options中包含了url附带的参数
         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.$post({
         url: "/SJ/getQSItems",
         data: {
            pid: this.formID
         }
         }).then(res1 => {
            let tableData = res1.data.tbBillList
            //当已检验个数都不为空时按照检测结构排序
            tableData.sort((a, b) => {
               if (a.result === '未完成' && b.result === '合格') {
                  return -1;
               } else if (a.result === '合格' && b.result === '未完成') {
                  return 1;
               } else {
                  return 0;
               }
            });
            this.tabs = tableData;
            // if (this.tableData.length === 0) {
            //    this.isShowTable = true;
            // }
            this.tableData.forEach((item, index) => {
               this.set(item, 'current', this.current);
            });
            console.log(this.tableData);
         })
      }
   }
      let fstand = "√";
      let fcheckResu = 1;
      if (item.fcheckResu == '1') {
        fstand = "×";
        fcheckResu = 0;
      }
      this.$post({
        url: "/SJ/UpdateQSItemDetail",
        data: {
          id: item.id,
          pid: item.pid,
          gid: item.gid,
          fstand: fstand,
          fcheckResu: fcheckResu,
          updateBy: this.$loginInfo.account,
        }
      }).then(res => {
        this.$showMessage("修改成功");
        this.refreshResult(); //刷新页面
      })
    },
    saveRemarks() {
      this.remarksPopup = !this.remarksPopup;
      this.remarks = this.formData.remarks;
    },
    editRemarks() {
      if (this.remarks) {
        //saveRemarksGid
        this.$post({
          url: "/SJ/saveRemarksPid",
          data: {
            pid: this.formData.id,
            remarks: this.remarks
          }
        }).then(res => {
          if (res.data.tbBillList > 0) {
            this.formData.remarks = this.remarks;
            this.remarksPopup = !this.remarksPopup;
            this.$showMessage("保存成功");
          }
        })
      }
    }
  },
  onLoad(options) {
//options中包含了url附带的参数
    let params = options;
    this.id = params["id"];
    this.billNo = params["billNo"];
    this.gid = params["gid"];
    this.refreshResult();
  }
}
</script>
<style lang="scss">
   $primary-color: #409EFF;
   $success-color: #67C23A;
   $danger-color: #F56C6C;
   $border-color: #DCDFE6;
   $bg-color: #f5f7fa;
$primary-color: #409EFF;
$success-color: #67C23A;
$danger-color: #F56C6C;
$border-color: #DCDFE6;
$bg-color: #f5f7fa;
   .container {
      padding: 20px;
      background-color: #fff;
   }
.container {
  padding: 20px;
  background-color: #fff;
}
   .header {
      padding: 20px;
      border-bottom: 1px solid $border-color;
      background: linear-gradient(90deg, #f0f7ff, #e1f0ff);
.header {
  padding: 20px;
  border-bottom: 1px solid $border-color;
  background: linear-gradient(90deg, #f0f7ff, #e1f0ff);
      .title {
         font-size: 24px;
         color: #333;
         margin-bottom: 10px;
      }
  .title {
    font-size: 24px;
    color: #333;
    margin-bottom: 10px;
  }
      .order-number {
         color: #666;
         font-size: 14px;
      }
   }
  .order-number {
    color: #666;
    font-size: 14px;
  }
}
   .tabs {
      display: flex;
      background-color: $bg-color;
      border-bottom: 1px solid $border-color;
.tabs {
  display: flex;
  background-color: $bg-color;
  border-bottom: 1px solid $border-color;
      .tab {
         flex: 1;
         text-align: center;
         padding: 12px 0;
         border-right: 1px solid $border-color;
         color: #666;
         transition: all 0.3s;
  .tab {
    flex: 1;
    text-align: center;
    padding: 12px 0;
    border-right: 1px solid $border-color;
    color: #666;
    transition: all 0.3s;
         &:last-child {
            border-right: none;
         }
    &:last-child {
      border-right: none;
    }
         &.active {
            background-color: #fff;
            color: $primary-color;
            font-weight: bold;
            position: relative;
    &.active {
      background-color: #fff;
      color: $primary-color;
      font-weight: bold;
      position: relative;
            &::after {
               content: '';
               position: absolute;
               bottom: 0;
               left: 0;
               right: 0;
               height: 2px;
               background-color: $primary-color;
            }
         }
      }
   }
      &::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 2px;
        background-color: $primary-color;
      }
    }
  }
}
   .section {
      margin: 20px 0;
      border: 1px solid $border-color;
      border-radius: 4px;
.section {
  margin: 20px 0;
  border: 1px solid $border-color;
  border-radius: 4px;
      &-header {
         padding: 12px 16px;
         background-color: $bg-color;
         border-bottom: 1px solid $border-color;
         font-weight: bold;
      }
  &-header {
    padding: 12px 16px;
    background-color: $bg-color;
    border-bottom: 1px solid $border-color;
    font-weight: bold;
  }
      &-body {
         padding: 16px;
      }
   }
  &-body {
    padding: 16px;
  }
}
   .info-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 16px;
.info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
      .info-item {
         margin-bottom: 12px;
  .info-item {
    margin-bottom: 12px;
         .info-label {
            color: #909399;
            font-size: 14px;
            margin-bottom: 4px;
         }
    .info-label {
      color: #909399;
      font-size: 14px;
      margin-bottom: 4px;
    }
         .info-value {
            color: #333;
            font-weight: 500;
         }
      }
   }
    .info-value {
      color: #333;
      font-weight: 500;
    }
  }
}
   .input-group {
      margin: 16px 0;
.input-group {
  margin: 16px 0;
      .input-wrapper {
         display: flex;
         gap: 12px;
  .input-wrapper {
    display: flex;
    gap: 12px;
         .result-input {
            flex: 1;
            height: 45px;
            padding: 0 12px;
            border: 1px solid $border-color;
            border-radius: 4px;
            font-size: 14px;
         }
    .result-input {
      flex: 1;
      height: 45px;
      padding: 0 12px;
      border: 1px solid $border-color;
      border-radius: 4px;
      font-size: 14px;
    }
         .upload-btn {
            background-color: #909399;
            color: #fff;
            padding: 0 10px;
            margin: 0;
            //height: 40rpx;
         }
      }
   }
    .upload-btn {
      background-color: #909399;
      color: #fff;
      padding: 0 10px;
      margin: 0;
    }
  }
}
   .table-container {
      border: 1px solid $border-color;
      border-radius: 4px;
      margin-top: 20px;
.table-container {
  border: 1px solid $border-color;
  border-radius: 4px;
  margin-top: 20px;
      .table-header {
         display: flex;
         background-color: $bg-color;
         border-bottom: 1px solid $border-color;
  .table-header {
    display: flex;
    background-color: $bg-color;
    border-bottom: 1px solid $border-color;
         .th {
            flex: 1;
            padding: 12px;
            font-weight: bold;
         }
      }
    .th {
      flex: 1;
      padding: 12px;
      font-weight: bold;
    }
  }
      .table-row {
         display: flex;
         border-bottom: 1px solid $border-color;
         padding: 12px;
  .table-row {
    display: flex;
    border-bottom: 1px solid $border-color;
    padding: 12px;
         &:last-child {
            border-bottom: none;
         }
    &:last-child {
      border-bottom: none;
    }
         .td {
            flex: 1;
            display: flex;
            align-items: center;
         }
      }
   }
    .td {
      flex: 1;
      display: flex;
      align-items: center;
    }
  }
}
   .result-badge {
      display: inline-block;
      padding: 4px 8px;
      border-radius: 4px;
      font-size: 12px;
      font-weight: bold;
.result-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
      &.OK {
         background-color: rgba($success-color, 0.1);
         color: $success-color;
      }
  &.OK {
    background-color: rgba($success-color, 0.1);
    color: $success-color;
  }
      &.NG {
         background-color: rgba($danger-color, 0.1);
         color: $danger-color;
      }
   }
  &.NG {
    background-color: rgba($danger-color, 0.1);
    color: $danger-color;
  }
   .action-buttons {
      margin-top: 20px;
      display: flex;
      justify-content: flex-end;
      gap: 12px;
  &.PENDING {
    background-color: rgba(#E6A23C, 0.1);
    color: #E6A23C;
  }
      .btn {
         padding: 8px 20px;
         border-radius: 4px;
  &.BLOCKED {
    background-color: rgba(#909399, 0.1);
    color: #909399;
  }
}
         &.primary-btn {
            background-color: $primary-color;
            color: #fff;
.record-value {
  font-family: 'Courier New', monospace;
  font-weight: 500;
  color: #333;
  padding: 2px 4px;
  background-color: #f8f9fa;
  border-radius: 3px;
  border: 1px solid #e9ecef;
}
         }
.no-data-text {
  color: #E6A23C;
  font-size: 12px;
  font-style: italic;
}
         &.cancel-btn {
            background-color: #909399;
            color: #fff;
         }
      }
   }
.blocked-text {
  color: #909399;
  font-size: 12px;
  font-style: italic;
}
   .danger {
      color: $danger-color;
   }
.spec-text {
  font-size: 14px;
  color: #333;
  line-height: 1.5;
}
   .overlay {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background-color: rgba(0, 0, 0, 0.5);
      display: flex;
      justify-content: center;
      align-items: center;
   }
.result-preview {
  margin: 16px 0;
  padding: 12px;
  background-color: #f8f9fa;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 12px;
   .popup {
      background-color: #fff;
      padding: 20px;
      border: 1px solid #ccc;
      box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
      width: 68vw;
      /* 设置宽度为视口宽度的80% */
      height: 25vh;
      /* 设置高度为视口高度的80% */
   }
  .info-label {
    color: #909399;
    font-size: 14px;
    min-width: 80px;
  }
   .updateBut {
      background-color: #3498db;
      color: white;
   }
  .info-value {
    color: #333;
    font-weight: 500;
  }
}
   .input1 {
      display: block;
   }
.result-ng {
  margin: 16px 0;
  padding: 12px;
  background-color: rgba($danger-color, 0.1);
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 12px;
   .input2 {
      display: none;
   }
  .info-label {
    color: $danger-color;
    font-size: 14px;
    min-width: 80px;
  }
   /* 响应式设计 */
   @media (max-width: 500px) {
      .input1 {
         display: none;
      }
  .info-value {
    color: $danger-color;
    font-weight: 500;
  }
}
      .input2 {
         display: block;
      }
   }
.action-buttons {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  .btn {
    padding: 8px 20px;
    border-radius: 4px;
    &.primary-btn {
      background-color: $primary-color;
      color: #fff;
    }
    &.cancel-btn {
      background-color: #909399;
      color: #fff;
    }
  }
}
.danger {
  color: $danger-color;
}
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}
.popup {
  background-color: #fff;
  padding: 20px;
  border: 1px solid #ccc;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  width: 68vw;
  height: 25vh;
  border-radius: 8px;
}
.popup-header {
  padding: 20px;
  border-bottom: 1px solid #eee;
  h3 {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
  }
}
.popup-content {
  padding: 20px;
  .input-group {
    margin-bottom: 15px;
    .input-label {
      font-size: 14px;
      color: #7f8c8d;
      margin-right: 10px;
      min-width: 80px;
    }
    .input-field {
      flex: 1;
      padding: 8px 12px;
      border: 1px solid #ddd;
      border-radius: 4px;
      font-size: 14px;
      background-color: white;
    }
  }
}
.popup-actions {
  padding: 20px;
  border-top: 1px solid #eee;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  .action-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    &.primary {
      background-color: #3498db;
      color: white;
    }
    &.secondary {
      background-color: #95a5a6;
      color: white;
    }
  }
}
/* 图片预览 */
.image-preview {
  text-align: center;
  cursor: pointer;
}
.preview-image {
  max-width: 100%;
  max-height: 300px;
  border-radius: 4px;
  border: 1px solid #ddd;
}
/* 响应式设计 */
@media (max-width: 768px) {
  .info-grid {
    grid-template-columns: 1fr;
  }
  .input-group {
    flex-direction: column;
    align-items: flex-start;
  }
  .input-label {
    margin-bottom: 5px;
  }
}
</style>