<template>
  <el-dialog v-model="visible" title="历史记录详情" width="500px">
    <el-descriptions border :column="1" v-if="currentOrder">
      <el-descriptions-item label="记录编号">{{ currentOrder.orderNo }}</el-descriptions-item>
      <el-descriptions-item label="学生姓名">{{ currentOrder.studentName }} ({{ currentOrder.studentId }})</el-descriptions-item>
      <el-descriptions-item label="住宿房间">{{ currentOrder.room }}</el-descriptions-item>
      <el-descriptions-item label="住宿时段">{{ currentOrder.period }}</el-descriptions-item>
      <el-descriptions-item label="办理类型">{{ getTypeLabel(currentOrder.type) }}</el-descriptions-item>
      <el-descriptions-item label="经办人">{{ currentOrder.operator }}</el-descriptions-item>
      <el-descriptions-item label="备注">{{ currentOrder.remark || '无' }}</el-descriptions-item>
    </el-descriptions>
  </el-dialog>
</template>

<script setup lang="ts">
import { ref } from 'vue'

const visible = ref(false)
const currentOrder = ref<any>(null)

const open = (order: any) => {
  currentOrder.value = order
  visible.value = true
}

const getTypeLabel = (type: string) => {
  const map: any = { check_in: '入住办理', check_out: '退宿结算', adjust: '调宿变更' }
  return map[type] || type
}

defineExpose({
  open
})
</script>
