<template>
  <div class="patient-container">
    <patient-sidebar :id="patientID" defaultActive="2-4"></patient-sidebar>
    <div class="patient-app-container app-container ">
      <!-- <table-title title="排班记录列表"></table-title> -->
      <div class="sum">
        <!-- <span>治疗频率 : 两周5次 </span> -->
      </div>

      <el-table
        :data="schedules"
        border
        :header-cell-style="{
          backgroundColor: 'rgb(245, 247, 250)',
          color: '#606266'
        }"
        :row-style="{ color: '#303133' }"
        style="width: 100%"
      >
        <el-table-column
          prop="schedule_date"
          label="日期"
          align="center"
          min-width="60"
        >
          <template slot-scope="scope">
            {{ scope.row.week }}周 ({{
              scope.row.schedule_date | parseTime("{y}-{m}-{d}")
            }})
          </template>
        </el-table-column>
        <el-table-column
          prop="schedule_type"
          label="星期"
          align="center"
          min-width="60"
        >
          <template slot-scope="scope">
             <span v-if="scope.row.schedule_week == 0">星期日</span>
             <span v-if="scope.row.schedule_week == 1">星期一</span>
             <span v-if="scope.row.schedule_week == 2">星期二</span>
             <span v-if="scope.row.schedule_week == 3">星期三</span>
             <span v-if="scope.row.schedule_week == 4">星期四</span>
             <span v-if="scope.row.schedule_week == 5">星期五</span>
             <span v-if="scope.row.schedule_week == 6">星期六</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="schedule_type"
          label="班次"
          align="center"
          min-width="60"
        >
          <template slot-scope="scope">{{
            scheduleType(scope.row.schedule_type)
          }}</template>
        </el-table-column>
        <el-table-column
          prop="zone.name"
          label="分区"
          align="center"
          min-width="60"
        >
        </el-table-column>
        <el-table-column
          prop="bed.number"
          label="机号"
          align="center"
          min-width="60"
        >
        </el-table-column>
        <el-table-column
          prop="mode_id"
          label="治疗模式"
          align="center"
          min-width="80"
        >
          <template slot-scope="scope">{{
            modeName(scope.row.mode_id)
          }}</template>
        </el-table-column>
        <!-- <el-table-column 
          prop="apply"
          label="申请调班日期"
          align="center"
          min-width="120">
          </el-table-column>
          <el-table-column
          prop="reason"
          label="申请理由"
          align="center"
          min-width="70">
          </el-table-column>  
          <el-table-column
          prop="status"
          label="申请状态"
          align="center"
          min-width="70">
          </el-table-column>
          <el-table-column
          prop="operation"
          label="操作"
          align="center"
          min-width="60">
          </el-table-column> -->
      </el-table>
    </div>
  </div>
</template>

<script>
import tableTitle from "./components/tableTitle";
import PatientSidebar from "./components/PatientSidebar";

import { GetPatientSchedules } from "@/api/schedule";
export default {
  name: "scheduling",
  data() {
    return {
      modeOptions: null,
      schedules: [],
      patientID: 0
    };
  },
  components: {
    tableTitle,
    PatientSidebar
  },
  methods: {
    GetPatientSchedules(id) {
      GetPatientSchedules(id).then(response => {
        if (response.data.state == 1) {
          this.schedules = response.data.data.schedules;
          
        }
      });
    },
    scheduleType(scheduleType) {
      var typeName = "";
      switch (scheduleType) {
        case 1:
          typeName = "上午";
          break;
        case 2:
          typeName = "下午";
          break;
        case 3:
          typeName = "晚上";
          break;

        default:
          break;
      }
      return typeName;
    },
    modeName(mode_id) {
      return typeof this.modeOptions[mode_id] != "undefined" &&
        typeof this.modeOptions[mode_id].name != "undefined"
        ? this.modeOptions[mode_id].name
        : "";
    }
  },
  created() {
    const id = this.$route.params && this.$route.params.id;
    this.patientID = parseInt(id);
    if (isNaN(this.patientID) || this.patientID <= 0) {
      this.$notify.error({
        title: "错误",
        message: "无效的id"
      });
      this.$router.push("/patients/patients");
    }

    this.modeOptions = this.$store.getters.treatment_mode;
    this.GetPatientSchedules(this.patientID);
  }
};
</script>

<style rel="stylesheet/css" lang="scss" scoped></style>
<style>
.el-table td,
.el-table th.is-leaf,
.el-table--border,
.el-table--group {
  border-color: #d0d3da;
}
.el-table--border::after,
.el-table--group::after,
.el-table::before {
  background-color: #d0d3da;
}
</style>
