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>
@@ -266,8 +269,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("请输入检验值");
@@ -277,6 +280,19 @@
        let checkValue = Number(this.formData.fcheckResu);
        let minValue = Number(this.formData.minValue);
        let maxValue = Number(this.formData.maxValue);
        let standardValue = Number(this.formData.standardValue);
        // 添加新的验证:检查上限值和下限值与标准值的关系
        if (this.formData.standardValue != null) {
          if (maxValue < standardValue) {
            this.$showMessage("上限值过小,应大于等于标准值");
            return;
          }
          if (minValue > standardValue) {
            this.$showMessage("下限值过大,应小于等于标准值");
            return;
          }
        }
        if (isNaN(checkValue) || isNaN(minValue) || isNaN(maxValue)) {
          this.$showMessage("检验值或范围值格式不正确,请检查输入");
@@ -338,7 +354,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 +387,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("请输入检验值");
@@ -380,6 +398,19 @@
        let checkValue = Number(this.editData.fcheckResu);
        let minValue = Number(this.formData.minValue);
        let maxValue = Number(this.formData.maxValue);
        let standardValue = Number(this.formData.standardValue);
        // 添加新的验证:检查上限值和下限值与标准值的关系
        if (this.formData.standardValue != null) {
          if (maxValue < standardValue) {
            this.$showMessage("上限值过小,应大于等于标准值");
            return;
          }
          if (minValue > standardValue) {
            this.$showMessage("下限值过大,应小于等于标准值");
            return;
          }
        }
        if (isNaN(checkValue) || isNaN(minValue) || isNaN(maxValue)) {
          this.$showMessage("检验值或范围值格式不正确,请检查输入");
@@ -398,9 +429,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!");
@@ -458,7 +493,7 @@
    // 上传图片
    chooseImage() {
      uni.navigateTo({
        url: 'ImageItem?id=' + this.formData.id + '&gid=' + this.gid
        url: 'ImageItem?id=777' + this.formData.id + '&gid=' + this.gid
      });
    },
    saveRemarks() {
@@ -487,14 +522,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 +690,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 +767,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 {