<template>
  <div class="page-card">
    <h3>亲人档案</h3>
    <el-table :data="elders" stripe>
      <el-table-column prop="name" label="姓名" />
      <el-table-column label="性别" width="80">
        <template slot-scope="scope">
          {{ genderLabel(scope.row.gender) }}
        </template>
      </el-table-column>
      <el-table-column prop="roomNo" label="房间号" width="100" />
      <el-table-column prop="careLevel" label="护理等级" />
    </el-table>
  </div>
</template>

<script>
import { familyElders } from "../../api";

export default {
  data() {
    return { elders: [] };
  },
  async created() {
    try {
      const res = await familyElders();
      this.elders = res.data.data;
    } catch (e) {
      this.$message.error(e.message || "加载失败");
    }
  },
  methods: {
    genderLabel(value) {
      if (value === "M") return "男";
      if (value === "F") return "女";
      return value || "-";
    }
  }
};
</script>

