<template>
  <div style="display: flex;background-color: #fff;margin-top: 10px;border-radius: 8px;padding: 10px;">
    <div class="asbitemListClass">
      <div class="asbTitle">未检组合项目：</div>
      <div style="overflow-y:auto; height:68px;width:100%; margin-top:2px;border: 1px solid;">
        <el-tag style="color:red;background-color: white;margin-left: 5px;" v-for="item in data.unCheckedAsbitem" :key="item" size="mini">{{
          item }}</el-tag>
      </div>
    </div>
    <div class="asbitemListClass">
      <div class="asbTitle">弃检组合项目：</div>
      <div style="overflow-y:auto; height:68px;width:100%; margin-top:2px;border: 1px solid;">
        <el-tag style="color:#303133;background-color: white;margin-left: 5px;" v-for="item in data.giveUpAsbitem" :key="item" size="mini">{{ item
        }}</el-tag>
      </div>
    </div>
    <div class="asbitemListClass">
      <div class="asbTitle">组合项目已检但无值的明细项目：</div>
      <div style="overflow-y:auto; height:68px;width:100%; margin-top:2px;border: 1px solid;">
        <el-tag style="color:#303133;background-color: white;margin-left: 5px;" v-for="item in data.checkedNullValueItem" :key="item" size="mini">{{ item
        }}</el-tag>
      </div>
    </div>
    <div class="asbitemListClass">
      <div class="asbTitle">组合项目已检但弃检的明细项目：</div>
      <div style="overflow-y:auto; height:68px;width:100%; margin-top:2px;border: 1px solid;">
        <el-tag style="color: #303133;background-color: white;margin-left: 5px;" v-for="item in data.checkedGiveUpItem" :key="item" size="mini">{{
          item }}</el-tag>
      </div>
    </div>
  </div>
</template>
<script>
import moment from "moment";
import { mapState } from "vuex";
import { getapi, postapi, putapi, deletapi } from "@/api/api";

export default {
  components: {},
  props: ['patientRegisterId','tabChoosed','brushSummary'],
  data() {
    return {
      data: {
        unCheckedAsbitem: [],//['未检项目1','未检项目2','未检项目3','未检项目4','未检项目5','未检项目6','未检项目7','未检项目8'],
        giveUpAsbitem: [],//['弃检1','弃检2'],
        checkedNullValueItem: [],//['无果1','无果2'],
        checkedGiveUpItem: [],//['弃检明细1','弃检明细2'],
      }
    };
  },

  created() { 
    
  },

  //挂载完成
  mounted() {
    this.getSumAsbItemStatus(this.patientRegisterId);
  },

  computed: {
    ...mapState(["window", "dict", "dataTransOpts", "doctorCheck", "sumDoctorCheck"]),
    sumHeight() {
      let tempHeight = this.window.pageHeight < 600 ? 600 : this.window.pageHeight
      return tempHeight - 320
    },
  },
  methods: {
    getSumAsbItemStatus(PatientRegisterId) {
      this.data.unCheckedAsbitem = [];
      this.data.giveUpAsbitem = [];
      this.data.checkedNullValueItem = [];
      this.data.checkedGiveUpItem = [];
      if (!PatientRegisterId) return

      getapi(`/api/app/patientregister/getpatientregisteritemstatus?PatientRegisterId=${PatientRegisterId}`).then(res => {
        if (res.code > -1) {
          this.data.unCheckedAsbitem = res.data.unCheckedAsbitem;
          this.data.giveUpAsbitem = res.data.giveUpAsbitem;
          this.data.checkedNullValueItem = res.data.checkedNullValueItem;
          this.data.checkedGiveUpItem = res.data.checkedGiveUpItem;
        }
      });
    }
  },

  //监听事件
  watch: {
    //人员ID切换
    // "patientRegisterId":{
    //   immediate:true,
    //   handler(newVal, oldVal) {
    //     console.log("watch patientRegisterId newVal：", newVal, " oldVal：", oldVal);      
    //     this.getSumAsbItemStatus(newVal);
    //   }
    // },
    // 虚拟表 触发强制刷新 （sumDoctor.M 合并包含：综述、建议、对比、历史等，不包含总检诊断）
    // "dataTransOpts.refresh.sumDoctor.M": {
    //   // immediate:true,
    //   handler(newVal, oldVal) {
    //     console.log(`watch 总检--检查状态汇总 newVal: ${newVal}, oldVal: ${oldVal} patientRegisterId: ${this.patientRegisterId}`);
    //     if(newVal != oldVal && this.tabChoosed == '1') this.getSumAsbItemStatus(this.patientRegisterId);
    //   }
    // },

    // 传入参数控制
    "brushSummary": {
      // immediate:true,
      handler(newVal, oldVal) {
        console.log(`watch 总检--检查状态汇总 newVal: ${newVal}, oldVal: ${oldVal} patientRegisterId: ${this.patientRegisterId}`);
        // && this.tabChoosed == '1'
        if(newVal && newVal != oldVal) this.getSumAsbItemStatus(this.patientRegisterId);
      }
    },


  },

};
</script>
<style scoped>
.asbitemListClass {
  display: block;
  width: v-bind("Math.floor((window.pageWidth - 110 - 15 - 15) / 4) + 'px'");
  margin-left: 3px;
}

.labelClass {
  margin-top: 2px;
  font-size: 8x;
}

.asbTitle {
  margin-top: -5px; 
  font-size:12px;
  color: #303133;
}
.contentClass {
  display: flex;
  height: 52px;
  margin-top: 2px;
  font-size: 8x;
}
</style>
