<template>
  <div class="page-card">
    <h3>健康记录</h3>
    <div style="margin-bottom: 12px;">
      <el-select v-model="elderId" placeholder="选择亲人" @change="load">
        <el-option v-for="elder in elders" :key="elder.id" :label="elder.name" :value="elder.id" />
      </el-select>
    </div>
    <el-table :data="items" stripe>
      <el-table-column prop="recordTime" label="时间" />
      <el-table-column prop="temperature" label="体温" />
      <el-table-column prop="bpSystolic" label="收缩压" />
      <el-table-column prop="bpDiastolic" label="舒张压" />
      <el-table-column prop="heartRate" label="心率" />
    </el-table>
  </div>
</template>

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

export default {
  data() {
    return { elders: [], elderId: "", items: [] };
  },
  async created() {
    try {
      const res = await familyElders();
      this.elders = res.data.data;
    } catch (e) {
      this.$message.error(e.message || "加载失败");
    }
  },
  methods: {
    async load() {
      if (!this.elderId) return;
      try {
        const res = await familyHealthList(this.elderId);
        this.items = res.data.data;
      } catch (e) {
        this.$message.error(e.message || "加载失败");
      }
    }
  }
};
</script>

