fcx
5 天以前 dbfb045ad92072e880104e13fddb4dc7574499a1
pages/QC/SJ/detail.vue
@@ -40,15 +40,16 @@
              <view class="info-label">检验数</view>
              <view class="info-value">{{ formData.levelNum }}</view>
            </view>
            <view v-if="formData.minValue" class="info-item">
            <!-- 修复:使用更准确的判断条件,避免0被误判为falsy -->
            <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" class="info-item">
            <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" class="info-item">
            <view v-if="formData.maxValue != null" class="info-item">
              <view class="info-label">上限</view>
              <view class="info-value">{{ formData.maxValue }}</view>
            </view>
@@ -69,11 +70,11 @@
        <view class="section-header">检验结果</view>
        <view class="section-body">
          <view class="info-grid">
            <view v-if="formData.result" class="info-item">
            <view v-if="formData.result != null" class="info-item">
              <view class="info-label">预览结果</view>
              <view class="info-value">{{ formData.result }}</view>
            </view>
            <view v-if="formData.remarks" class="info-item">
            <view v-if="formData.remarks != null" class="info-item">
              <view class="info-label">备注</view>
              <view class="info-value danger">{{ formData.remarks }}</view>
            </view>
@@ -85,7 +86,8 @@
      <view class="section">
        <view class="section-header">检验结果录入</view>
        <view class="section-body">
          <view v-if="!formData.maxValue && !formData.minValue" class="info-item edit">
          <!-- 修复:使用更准确的判断条件,避免0被误判为falsy -->
          <view v-if="formData.maxValue == null && formData.minValue == null" class="info-item edit">
            <view class="info-label" style="color: #F56C6C">提示</view>
            <view class="info-value" style="color: #F56C6C">没有最大值和最小值时填写0(未通过检验)或1(通过检验)</view>
          </view>
@@ -102,7 +104,7 @@
              </button>
              <input v-if="(tableData.length < formData.levelNum)" v-model="formData.fcheckResu" class="result-input"
                     placeholder="请输入检验结果..." type="number"/>
              <button v-if="(tableData.length < formData.levelNum)" class="btn primary-btn" @click="submit">保存结果
              <button v-if="(tableData.length < formData.levelNum)" class="btn primary-btn" @click="submit" style="margin: 0px;">保存结果
              </button>
            </view>
          </view>
@@ -110,20 +112,21 @@
          <!-- 响应式设计的第二个输入组 -->
          <view class="input-group input2">
            <view class="input-wrapper">
              <button class="btn upload-btn" @click="chooseImage">
              <button class="btn upload-btn" @click="chooseImage ">
                <uni-icons type="upload" size="16" color="#fff"></uni-icons>
                上传/查看图片
              </button>
              <button v-if="current" class="btn upload-btn" @click="saveRemarks">
              <button v-if="current" class="btn upload-btn" @click="saveRemarks  ">
                <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.levelNum)" v-model="formData.fcheckResu" class="result-input"
              <input v-if="(tableData.length < formData.levelNum)" v-model="formData.fcheckResu" class="result-input"
                     placeholder="请输入检验结果..." type="number"/>
              <button v-if="(tableData.length < formData.levelNum) && current" class="btn primary-btn" @click="submit">保存结果
              </button>
              <button v-if="tableData.length < formData.levelNum" class="btn primary-btn" @click="submit" style="margin: 0px;" >保存结果
           </button>
            </view>
          </view>
        </view>
@@ -215,6 +218,42 @@
    }
  },
  methods: {
    // 检查所有检验项目是否已完成
    checkAllItemsCompleted() {
      this.$post({
        url: "/SJ/getQSItems",
        data: {
          pid: this.gid,
        }
      }).then(res => {
        if (res.data && res.data.tbBillList) {
          const allItems = res.data.tbBillList;
          // 检查是否所有项目都不是"未完成"状态
          const allCompleted = allItems.every(item => item.result !== '未完成');
          if (allCompleted) {
            // 所有项目已完成,不自动跳转,用户手动返回
            // const pages = getCurrentPages();
            // if (pages.length >= 2) {
            //   const prevPage = pages[pages.length - 2];
            //   const route = '/' + prevPage.route;
            //   const options = prevPage.options;
            //   let query = '';
            //   for (let key in options) {
            //     query += `${key}=${options[key]}&`;
            //   }
            //   query = query.slice(0, -1);
            //   setTimeout(() => {
            //     uni.redirectTo({
            //       url: query ? `${route}?${query}` : route
            //     });
            //   }, 1000);
            // }
          }
        }
      });
    },
    // 切换标签页
    switchTab(index, id) {
      this.currentTab = index;
@@ -242,6 +281,15 @@
              return 0;
            }
          });
          // 根据当前id查找对应的标签索引(参考LLJ实现)
          const foundIndex = this.tabs.findIndex(tab => tab.id == this.id); // 使用==而非===,避免类型不匹配
          if (foundIndex !== -1) {
            this.currentTab = foundIndex;
          } else {
            // 如果没找到,默认跳转到第一个标签
            this.currentTab = 0;
          }
        } else {
          // 没有项目时至少添加当前项目到标签
          this.tabs = [{id: this.id, projName: this.formData.projName || '当前项目'}];
@@ -266,8 +314,8 @@
      let count = this.formData.levelNum;
      let fstand = "√";
      //有最大值和最小值就根据是否符合标准值更新判定结果,没有最大值和最小值就根据是否通过检验判定结果
      if (this.formData.maxValue && this.formData.minValue) {
      // 修复:使用更准确的判断条件,避免0被误判为falsy
      if (this.formData.maxValue != null && this.formData.minValue != null) {
        if (!this.formData.fcheckResu) {
          this.$showMessage("请输入检验值");
@@ -319,9 +367,38 @@
      }).then(res => {
        this.formData.fcheckResu = null;
        this.$showMessage("保存成功");
        this.refreshResult();
        // 重新加载标签项以更新状态
        this.loadTabItems();
        // 等待tabs更新后,查找下一个未完成的项目
        this.$nextTick(() => {
          // 查找下一个未完成的项目
          const nextUnfinishedIndex = this.tabs.findIndex((tab, index) =>
            index > this.currentTab && tab.result === '未完成'
          );
          if (nextUnfinishedIndex !== -1) {
            // 找到了下一个未完成的项目,跳转过去
            this.currentTab = nextUnfinishedIndex;
            this.id = this.tabs[nextUnfinishedIndex].id;
            this.refreshResult();
          } else {
            // 没有下一个未完成的,从头查找第一个未完成的
            const firstUnfinishedIndex = this.tabs.findIndex(tab => tab.result === '未完成');
            if (firstUnfinishedIndex !== -1) {
              this.currentTab = firstUnfinishedIndex;
              this.id = this.tabs[firstUnfinishedIndex].id;
              this.refreshResult();
            } else {
              // 所有项目都已完成,刷新当前项目
              this.refreshResult();
            }
          }
        });
        // 检查是否所有检验项目都已完成
        this.checkAllItemsCompleted();
      })
    },
@@ -338,7 +415,8 @@
          this.isShowImg = true;
          this.base64Image = 'data:image/jpeg;base64,' + this.formData.imageData;
        }
        if (this.formData.maxValue && this.formData.minValue && this.formData.standardValue) {
        // 修复:使用更准确的判断条件,避免0被误判为falsy
        if (this.formData.maxValue != null && this.formData.minValue != null && this.formData.standardValue != null) {
          this.isNumber = true;
        }
      })
@@ -370,7 +448,8 @@
      let fstand = "√";
      if (this.formData.maxValue && this.formData.minValue) {
      // 修复:使用更准确的判断条件,避免0被误判为falsy
      if (this.formData.maxValue != null && this.formData.minValue != null) {
        if (!this.editData.fcheckResu) {
          this.$showMessage("请输入检验值");
@@ -398,9 +477,13 @@
          this.editData.fcheckResu = 1
        }
        // 改进后的逻辑:根据检验结果值来判断合格与否
        if (this.editData.fcheckResu == 0 || this.editData.fcheckResu == 1) {
          // 0表示不合格,1表示合格
          if (this.editData.fcheckResu == 0) {
            fstand = "×";
          } else {
            fstand = "√";
          }
        } else {
          this.$showMessage("无标准值时,检验结果只能为0或1!");
@@ -426,6 +509,9 @@
        this.refreshResult();//刷新页面
        // 重新加载标签项以更新状态
        this.loadTabItems();
        // 检查是否所有检验项目都已完成
        this.checkAllItemsCompleted();
      })
    },
    numberEdit(item) {
@@ -453,6 +539,9 @@
        this.refreshResult(); //刷新页面
        // 重新加载标签项以更新状态
        this.loadTabItems();
        // 检查是否所有检验项目都已完成
        this.checkAllItemsCompleted();
      })
    },
    // 上传图片
@@ -466,7 +555,8 @@
      this.remarks = this.formData.remarks;
    },
    editRemarks() {
      if (this.remarks) {
      // 允许保存空字符串或空格,只检查是否为null或undefined
      if (this.remarks !== null && this.remarks !== undefined) {
        //saveRemarksGid
        this.$post({
          url: "/SJ/saveRemarksPid",
@@ -487,14 +577,16 @@
    },
    // 判断数字是否在范围内
    isInRange(value) {
      if (!this.formData.maxValue || !this.formData.minValue) return true;
      // 修复:使用更准确的判断条件,避免0被误判为falsy
      if (this.formData.maxValue == null || this.formData.minValue == null) return true;
      const numValue = parseFloat(value);
      return numValue >= parseFloat(this.formData.minValue) &&
          numValue <= parseFloat(this.formData.maxValue);
    },
    // 获取数字结果的样式类
    getNumberResultClass(value) {
      if (!this.formData.maxValue || !this.formData.minValue) return 'number-normal';
      // 修复:使用更准确的判断条件,避免0被误判为falsy
      if (this.formData.maxValue == null || this.formData.minValue == null) return 'number-normal';
      return this.isInRange(value) ? 'number-pass' : 'number-fail';
    },
    // 获取状态结果的样式类
@@ -653,6 +745,15 @@
      border: none;
      border-radius: 4px;
    }
    .primary-btn {
      height: 45px;
      display: flex;
      align-items: center;
      justify-content: center;
      border: none;
      border-radius: 4px;
    }
  }
}
@@ -721,6 +822,13 @@
    &.primary-btn {
      background-color: $primary-color;
      color: #fff;
      height: 45px;
      display: flex;
      align-items: center;
      justify-content: center;
      border: none;
      border-radius: 4px;
      padding: 0 20px;
    }
    &.cancel-btn {