<template>
  <div>
    <div>
      <div class="contenttitle">
        体检 /<span class="contenttitleBold">总检医生诊台</span>
      </div>
      <div style="display: flex">
        <div :style="'width:' + (window.pageWidth - 110 - 15) + 'px;'">
          <div>
            <PatientRegisterBase />
          </div>
          <div :style="`height: ${window.pageHeight < 600 ? 436 : window.pageHeight - 164}px;`">
            <el-tabs v-model="tabChoosed">
              <el-tab-pane label="综述建议" name="1">
                <div style="display: flex;">
                  <!-- 综述建议 -->
                  <div :style="'width:' + (window.pageWidth - 110 - 15) + 'px;'">
                    <SumSug :patientRegisterId="dataTransOpts.tableS.patient_register.id" :tabChoosed="tabChoosed"/>
                  </div>
                  <!-- 诊断 width:200px; 
                  <div v-if="false" style="width:200px;">
                    <SumDiagnosis :patientRegisterId="dataTransOpts.tableS.patient_register.id" />
                  </div>
                  -->
                </div>
                <div>
                  <!-- 总检状态 -->
                  <SumPREdit />
                  <!-- 检查情况 -->
                  <div style="margin-top: -6px;">
                    <SumAsbItemStatus :patientRegisterId="dataTransOpts.tableS.patient_register.id" :tabChoosed="tabChoosed"/>
                  </div>                  
                </div>
              </el-tab-pane>
              
              <el-tab-pane label="明细结果" name="2">                
                <CheckDetails :patientRegisterId="dataTransOpts.tableS.patient_register.id" :tabChoosed="tabChoosed"/>
              </el-tab-pane>
              <!--
              <el-tab-pane label="危急值" name="3"> </el-tab-pane>              
              <el-tab-pane label="项目对比" name="4">
                <SumItemsType :patientId="dataTransOpts.tableS.patient_register.patientId" />
              </el-tab-pane>
               -->
              <el-tab-pane label="历次结果" name="5">
                <SumItems :patientId="dataTransOpts.tableS.patient_register.patientId" :tabChoosed="tabChoosed"/>
              </el-tab-pane>
              <el-tab-pane label="历次综述" name="6">
                <SumHistory :patientId="dataTransOpts.tableS.patient_register.patientId" :tabChoosed="tabChoosed"/>
              </el-tab-pane>
             
            </el-tabs>
          </div>
        </div>
        <div style="width: 110px">
          <ButtonList/>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { mapState } from "vuex";
import { getapi, postapi, putapi, deletapi } from "@/api/api";
import { tcdate } from "../../utlis/proFunc";

import PatientRegisterBase from "../../components/doctorCheck/PatientRegisterBase.vue";
import ButtonList from "../../components/sumDoctorCheck/ButtonList.vue";
import SumSug from "../../components/sumDoctorCheck/SumSug.vue";
import SumDiagnosis from "../../components/sumDoctorCheck/SumDiagnosis.vue";
import SumPREdit from "../../components/sumDoctorCheck/SumPREdit.vue";
import SumAsbItemStatus from "../../components/sumDoctorCheck/SumAsbItemStatus.vue";
import CheckDetails from "../../components/sumDoctorCheck/CheckDetails.vue";
import SumItemsType from "../../components/sumDoctorCheck/SumItemsType.vue";
import SumItems from "../../components/sumDoctorCheck/SumItems.vue";
import SumHistory from "../../components/sumDoctorCheck/SumHistory.vue";
export default {
  components: {
    PatientRegisterBase,
    ButtonList,
    SumSug,
    SumDiagnosis,
    SumPREdit,
    SumAsbItemStatus,
    CheckDetails,
    SumItemsType,
    SumItems,
    SumHistory,
  },
  data() {
    return {
      tabChoosed: "1",
    };
  },

  created() { 
    if(this.$route.query.patient_register){
      this.dataTransOpts.tableS.patient_register = this.$route.query.patient_register
    }else{
      this.dataTransOpts.tableS.patient_register = { id: '', patientRegisterNo: ''}
    }
  },

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

  computed: {
    ...mapState([
      "window",
      "dict",
      "dataTransOpts",
      "patientRegister",
      "customerOrg",
      "sumDoctorCheck",
    ]),
  },

  methods: {

    //数据初始化
    dictInit() {
      //性别
      getapi("/api/app/sex").then((res) => {
        if (res.code == 1) {
          this.dict.sex = res.data;
        }
      });

      //体检中心
      getapi("/api/app/organization-units/organization-unit-by-is-peis").then(
        (res) => {
          if (res.code == 1) {
            this.dict.organization = res.data;
          }
        }
      );

      //体检单位
      // getapi("/api/app/customer-org/in-filter").then((res) => {
      //   if (res.code == 1) {
      //     this.dict.customerOrg = res.data;
      //   }
      // });

      //体检类别
      getapi("/api/app/medical-type/in-filter").then((res) => {
        if (res.code == 1) {
          this.dict.medicalType = res.data;
        }
      });

      //人员类别
      getapi("/api/app/personnel-type/in-filter").then((res) => {
        if (res.code == 1) {
          this.dict.personnelType = res.data;
        }
      });

      //婚姻状况
      getapi("/api/app/MaritalStatus/GetMaritalStatusList").then((res) => {
        if (res.code == 1) {
          this.dict.maritalStatus = res.data;
        }
      });

      //性激素期
      getapi("/api/app/sex-hormone-term/in-filter").then((res) => {
        if (res.code == 1) {
          this.dict.sexHormoneTerm = res.data;
        }
      });

      //民族
      getapi("/api/app/nation/in-filter").then((res) => {
        if (res.code == 1) {
          this.dict.nation = res.data;
        }
      });

      //籍惯 ，出生地
      getapi("/api/app/birth-place/in-filter").then((res) => {
        if (res.code == 1) {
          this.dict.birthPlace = res.data;
        }
      });

      //套餐
      postapi("/api/app/medicalpackage/GetBasicList", {}).then((res) => {
        if (res.code == 1) {
          this.dict.medicalPackage = res.data;
        }
      });

      //分组，所有分组，不限单位，不限次数
      // getapi("/api/app/customer-org-group").then((res) => {
      //   if (res.code == 1) {
      //     this.dict.customerOrgGroupAll = res.data.items;
      //   }
      // });

      //支付方式
      // getapi("/api/app/pay-mode").then((res) => {
      //   if (res.code == 1) {
      //     this.dict.payMode = res.data;
      //   }
      // });

      //体检类别 树结构
      getapi("/api/app/item-type/by-code-all").then((res) => {
        if (res.code == 1) {
          this.dict.itemTypeTree = res.data;
          tcdate(this.dict.itemTypeTree);
        }
      });

      postapi("/api/app/asbitem/GetBasicList", { isFilterActive: 'Y' }).then((res) => {
        if (res.code == 1) {
          this.dict.asbItemAll = res.data;
        }
      });

      console.log("dict", this.dict);
    },

    
  },

  //监听事件()
  watch: {
    "tabChoosed":{
      // immediate:true,
      handler(newVal, oldVal) {
        console.log(`watch 总检--历次综述建议 newVal: ${newVal}, oldVal: ${oldVal} `);        
        if(newVal != oldVal && newVal != '1') this.dataTransOpts.refresh.sumDoctor.M++
      }
    },

  },
};
</script>
<style scoped>
@import '../../assets/css/global_card.css';
@import '../../assets/css/global_input.css';
@import '../../assets/css/global_table.css';
@import '../../assets/css/global.css';
</style>
