<template>
  <el-dialog
    v-model="visible"
    title="房间入住成员"
    width="600px"
  >
    <el-table :data="students" border>
      <el-table-column prop="bedNo" label="床位号" width="100" />
      <el-table-column prop="name" label="姓名" width="100" />
      <el-table-column prop="studentId" label="学号" width="120" />
      <el-table-column prop="college" label="学院" />
      <el-table-column prop="checkInDate" label="入住时间" width="120" />
    </el-table>
  </el-dialog>
</template>

<script setup>
import { ref } from 'vue'

const visible = ref(false)
const students = ref([])

const open = (room) => {
  if (room) {
    // Generate mock students based on room data
    const list = []
    const count = room.occupied || 0
    for (let i = 1; i <= count; i++) {
      list.push({
        bedNo: `${i}号床`,
        name: `学生${room.id}-${i}`,
        studentId: `319010${room.id}${i}`,
        college: 'ZJUI学院',
        checkInDate: '2025-09-01'
      })
    }
    students.value = list
    visible.value = true
  }
}

defineExpose({
  open
})
</script>
