<!-- 设备历史数据弹窗 -->
<template>
  <Dialog
    v-model="dialogVisible"
    :title="`设备历史数据 - ${device?.deviceName || ''}`"
    width="80%"
    max-height="80vh"
    destroy-on-close
  >
    <DeviceDetailsData v-if="dialogVisible && device" :device="device" />
  </Dialog>
</template>

<script setup lang="ts">
import { DeviceVO } from '@/api/iot/device/device'
import DeviceDetailsData from './detail/DeviceDetailsData.vue'

defineOptions({ name: 'DeviceDataDialog' })

const dialogVisible = ref(false)
const device = ref<DeviceVO | null>(null)

/** 打开弹窗 */
const open = (deviceData: DeviceVO) => {
  device.value = deviceData
  dialogVisible.value = true
}

/** 关闭弹窗 */
const close = () => {
  dialogVisible.value = false
  device.value = null
}

defineExpose({
  open,
  close
})
</script>
