1
lkk
2025-06-09 c733f15292736ea539378226af0639f4ff04fe5b
src/views/doctor/check/index.vue
@@ -280,10 +280,16 @@
                      ></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column prop="exceptionDesc" label="异常" width="55px" align="center">
                  <!-- <el-table-column prop="exceptionDesc" label="异常" width="55px" align="center">
                    <template slot-scope="scope">
                      <el-checkbox v-model="scope.row.exceptionDesc" @change="changDesc(scope.row)"
                        :disabled="scope.row.project.sfcyyc === 1"></el-checkbox>
                    </template>
                  </el-table-column> -->
                   <el-table-column prop="exceptionDesc" label="异常" width="55px" align="center">
                    <template slot-scope="scope">
                      <el-checkbox v-model="scope.row.exceptionDesc" @change="changDesc(scope.row)"
                        :disabled="scope.row.project.sfcyyc === 1 || scope.row.project.proName === 'BMI'"></el-checkbox>
                    </template>
                  </el-table-column>
                  <el-table-column label="规则" width="70">
@@ -293,7 +299,12 @@
                  </el-table-column>
                  <el-table-column prop="project.proMetering" label="单位" width="55">
                  </el-table-column>
                  <el-table-column prop="project.proScope" label="参考范围" width="70">
                  <el-table-column label="参考范围" width="70">
                     <template slot-scope="scope">
                      {{ scope.row.project.proScope }}
                    </template>
                  </el-table-column>
                  <el-table-column prop="conclusion" label="结果结论" width="200">
                    <template slot-scope="scope">
@@ -880,16 +891,28 @@
      return '';
    },
    // 实时更新 BMI 并验证输入
    vale(value, row) {
      if (row.project.proName === '身高' || row.project.proName === '体重') {
        // 输入验证
        if (!/^\d*\.?\d*$/.test(value) || parseFloat(value) <= 0) {
          this.$message.error('请输入有效的正数');
          row.proResult = ''; // 清空无效输入
          return;
        }
    getBMIStatus(row) {
      const bmi = parseFloat(row.proResult);
      if (isNaN(bmi) || !row.proResult) return ''; // 处理无效或空的BMI值
      if (bmi > 28) {
        row.exceptionDesc = true; // 自动勾选异常复选框
        row.conclusion = '偏高'; // 设置结论
        return '偏高';
      }
      if (bmi < 12) {
        row.exceptionDesc = true; // 自动勾选异常复选框
        row.conclusion = '偏低'; // 设置结论
        return '偏低';
      }
      row.exceptionDesc = false; // 正常范围内取消勾选
      row.conclusion = '正常'; // 设置结论
      return '正常';
    },
    // 实时更新 BMI 并验证输入
     vale(value, row) {
      console.log(3333)
      if (row.project.proName === '身高' || row.project.proName === '体重') {
        const heightRow = this.proParentList.sons.find(
          item => item.project.proName === '身高'
        );
@@ -900,27 +923,156 @@
          item => item.project.proName === 'BMI'
        );
        if (!heightRow || !weightRow || !bmiRow) {
          return;
        if (heightRow && weightRow && bmiRow) {
          const height = row.project.proName === '身高' ? value : heightRow.proResult;
          const weight = row.project.proName === '体重' ? value : weightRow.proResult;
          const bmi = this.calculateBMI(height, weight);
          bmiRow.proResult = bmi || ''; // 实时更新BMI值
          this.getBMIStatus(bmiRow); // 检查BMI状态并更新异常复选框
        }
      }
        const height = row.project.proName === '身高' ? value : heightRow.proResult;
        const weight = row.project.proName === '体重' ? value : weightRow.proResult;
        if (!height || !weight) {
          this.$message.warning('请填写身高和体重以计算 BMI');
          bmiRow.proResult = '';
          return;
        }
        const bmi = this.calculateBMI(height, weight);
        bmiRow.proResult = bmi || ''; // 实时更新 BMI
      // 现有的规则检查逻辑保持不变
      this.focusrow = row;
      this.proResult = row;
      const pattern3 = new RegExp("[0-9]+");
      if (row.proResult) { }
      if (pattern3.test(row.proResult)) {
        let data = {
          proId: this.focusrow.proId,
          cusId: this.tableAll.cusId,
          tjNum: this.tableAll.tjNumber,
          keyNum: this.proResult.proResult,
        };
        AutoGetRule(data).then((res) => {
          this.focusrow.conclusion = "";
          if (res.data) {
            this.autorule = res.data;
            this.focusrow.rulesList = res.data;
            if (row.project.sfcyyc == 1) {
              return;
            } else {
              if (res.data.length > 0) {
                const conditions = ["正常", "未见异常", "阴性", "未见明显异常"];
                this.focusrow.exceptionDesc = !conditions.some((condition) =>
                  this.autorule[0].bz.includes(condition)
                );
              } else {
                this.focusrow.exceptionDesc = false;
              }
            }
            if (this.autorule.length !== 0 && (this.autorule[0] || this.autorule[0].nr)) {
              this.focusrow.proAdvice = this.autorule[0].nr;
            }
            this.autorule.forEach((item) => {
              this.focusrow.conclusion += this.focusrow.conclusion ? item.bz : item.bz;
            });
          }
        });
      }
    },
    /*  vale(value, row) {
        if (row.project.proName === '身高' || row.project.proName === '体重') {
          // 输入验证
          if (!/^\d*\.?\d*$/.test(value) || parseFloat(value) <= 0) {
            this.$message.error('请输入有效的正数');
            row.proResult = ''; // 清空无效输入
            return;
          }
          const heightRow = this.proParentList.sons.find(
            item => item.project.proName === '身高'
          );
          const weightRow = this.proParentList.sons.find(
            item => item.project.proName === '体重'
          );
          const bmiRow = this.proParentList.sons.find(
            item => item.project.proName === 'BMI'
          );
          if (!heightRow || !weightRow || !bmiRow) {
            return;
          }
          const height = row.project.proName === '身高' ? value : heightRow.proResult;
          const weight = row.project.proName === '体重' ? value : weightRow.proResult;
          if (!height || !weight) {
            this.$message.warning('请填写身高和体重以计算 BMI');
            bmiRow.proResult = '';
            return;
          }
          const bmi = this.calculateBMI(height, weight);
          bmiRow.proResult = bmi || ''; // 实时更新 BMI
        }
      },
 */
    // 输入确认时更新 BMI
    handleInputConfirm(row, params) {
    handleInputConfirm(row) {
      if (row.proResult) {
        if (row.project.proName === '身高' || row.project.proName === '体重') {
          const heightRow = this.proParentList.sons.find(
            item => item.project.proName === '身高'
          );
          const weightRow = this.proParentList.sons.find(
            item => item.project.proName === '体重'
          );
          const bmiRow = this.proParentList.sons.find(
            item => item.project.proName === 'BMI'
          );
          if (heightRow && weightRow && bmiRow) {
            const height = heightRow.proResult;
            const weight = weightRow.proResult;
            const bmi = this.calculateBMI(height, weight);
            bmiRow.proResult = bmi || '';
            this.getBMIStatus(bmiRow); // 检查BMI状态并更新异常复选框
          }
        }
      }
      // 现有的规则检查逻辑保持不变
      this.focusrow = row;
      this.proResult = row;
      const pattern3 = new RegExp("[0-9]+");
      if (pattern3.test(row.proResult)) {
        let data = {
          proId: this.focusrow.proId,
          cusId: this.tableAll.cusId,
          tjNum: this.tableAll.tjNumber,
          keyNum: this.proResult.proResult,
        };
        AutoGetRule(data).then((res) => {
          this.focusrow.conclusion = "";
          if (res.data) {
            this.autorule = res.data;
            this.focusrow.rulesList = res.data;
            if (row.project.sfcyyc == 1) {
              return;
            } else {
              if (res.data.length > 0) {
                const conditions = ["正常", "未见异常", "阴性", "未见明显异常"];
                this.focusrow.exceptionDesc = !conditions.some((condition) =>
                  this.autorule[0].bz.includes(condition)
                );
              } else {
                this.focusrow.exceptionDesc = false;
              }
            }
            if (this.autorule.length !== 0 && (this.autorule[0] || this.autorule[0].nr)) {
              this.focusrow.proAdvice = this.autorule[0].nr;
            }
            this.autorule.forEach((item) => {
              this.focusrow.conclusion += this.focusrow.conclusion ? item.bz : item.bz;
            });
          }
        });
      }
      this.rows.push(row);
    },
    /* handleInputConfirm(row, params) {
      console.log(row, params, 55555);
      // 如果有 params 且为空,取消异常状态并清空相关字段
      if (params && params.length === 0) {
@@ -945,21 +1097,13 @@
            item => item.project.proName === 'BMI'
          );
          if (!heightRow || !weightRow || !bmiRow) {
            return;
           if (heightRow && weightRow && bmiRow) {
            const height = heightRow.proResult;
            const weight = weightRow.proResult;
            const bmi = this.calculateBMI(height, weight);
            bmiRow.proResult = bmi || '';
            this.getBMIStatus(bmiRow); // 检查BMI状态并更新异常复选框
          }
          const height = heightRow.proResult;
          const weight = weightRow.proResult;
          if (!height || !weight) {
            this.$message.warning('请填写身高和体重以计算 BMI');
            bmiRow.proResult = '';
            return;
          }
          const bmi = this.calculateBMI(height, weight);
          bmiRow.proResult = bmi || '';
        }
        this.focusrow = row;
@@ -1037,7 +1181,7 @@
        this.rows.push(row);
        console.log(this.rows, row);
      }
    },
    }, */
    // 初始化数据时计算 BMI
    getParentIdsss() {