<template>
  <div class="patient-container">
    <fast-patients-sidebar :id="patientID"></fast-patients-sidebar>
    <!-- <fast-upload-detail  :id="patientID"  :is-edit='true' :class='panelClass'></fast-upload-detail> -->
    <!-- <one></one> -->
  </div>
</template>

<script>
import FastUploadDetail from "./FastUploadDetail";
import { fetchAllList } from "@/api/patient";
import FastPatientsSidebar from "./FastPatientsSidebar";
// import One from "./One";

export default {
  name: "FastPatientsDetail",
  components: { FastPatientsSidebar, FastUploadDetail, One },
  data() {
    return {
      patientID: 1,
      panelClass: "patient-app-container",
      patientInfo: {
        id: 0
      }
    };
  },
  created() {
    const id = this.$route.query && this.$route.query.id;
    this.patientID = parseInt(id);

    if (isNaN(this.patientID) || this.patientID <= 0) {
      this.getList(1);
    } else {
      this.getList(2);
    }
  },
  methods: {
    getList(type) {
      fetchAllList().then(response => {
        if (response.data.state == 1) {
          this.patientsList = response.data.data.patients;
          if (type == 1) {
            this.patientID = this.patientsList[0].id;
          } else {
            this.patientID = this.$route.query.id;
          }
        }
      });
    }
  }
};
</script>
