<template>
  <div>
    <el-table :data="doctorCheck.RegisterCheckList" style="width: 100%" height="750" border
      :row-class-name="tableRowClassName" @row-click="rowClick">
      <el-table-column prop="asbitemName" label="组合项目" width="180" />    
    </el-table>
  </div>
</template>
<script>
import { mapState } from 'vuex';
import { getapi, postapi, putapi, deletapi } from "@/api/api";

export default {
  components: {},
  data() {
    return {

    };
  },

  created() {},

  //挂载完成
  mounted() {},

  computed:{
      ...mapState(['dict','doctorCheck']),
  },

  methods: {
    tableRowClassName({row, rowIndex}) {
      //console.log('tableRowClassName',rowIndex,row)
      if (row.completeFlag === '0') {
        return 'warning-row'; //未检
      } else if (row.completeFlag === '2') {
        return 'refuse-row'; //弃检
      }
      return '';
          
    },
    
    //选择组合项目
    rowClick(row){
      //registerCheckId 具体动作写在相应组件监听事件中
      this.doctorCheck.RegisterCheckId = row.id
      this.doctorCheck.RegisterCheckEdit = row
    },

    //获取检查组合项目
    registerCheckList(patientRegisterId){
      console.log(`/api/app/register-check/register-check-or-asbitem/${patientRegisterId}`)
      getapi(`/api/app/register-check/register-check-or-asbitem/${patientRegisterId}`)
      .then((res) => {
          console.log("registerCheckList", res.data);
          if (res.code != -1) {
            this.doctorCheck.RegisterCheckList = res.data;
            //查询出来 默认显示第1条记录明细、小结等
            if(res.data.length > 0) this.doctorCheck.RegisterCheckId = res.data[0].id
          }
      })
      .catch((err) => {
          this.$message({type: "error",message: `操作失败，原因：${err}`});
      });
    },


  },

  

  //监听事件
  watch: {
    //体检人员切换
    "doctorCheck.prBase.id"(newVal, oldVal) {
      console.log("watch doctorCheck.prBase.id newVal：", newVal, " oldVal：", oldVal);
      if (newVal != oldVal && newVal != '') {
        this.registerCheckList(newVal)
      }
    },
  }
};
</script>
<style>
  .el-table .warning-row {
    background: rgb(240,125,125);
  }

  .el-table .refuse-row {
    background: rgb(192,192,192);
  }

</style>
  