<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="content" label="护理内容" />
      <el-table-column prop="attachmentUrl" label="附件" />
    </el-table>
  </div>
</template>

<script>
import { familyElders, familyCareList } 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 familyCareList(this.elderId);
        this.items = res.data.data;
      } catch (e) {
        this.$message.error(e.message || "加载失败");
      }
    }
  }
};
</script>

