<template>
  <view class="record-page">
    <view class="header-card">
      <text class="title">使用记录</text>
      <text class="sub">最近设备连接与控制行为</text>
    </view>

    <scroll-view class="record-list" scroll-y>
      <view v-if="records.length === 0" class="empty-card">
        <text class="empty-title">暂无使用记录</text>
        <text class="empty-sub">连接设备并执行操作后会自动生成记录</text>
      </view>

      <view v-for="item in records" :key="item.id" class="record-card">
        <view class="row top">
          <text class="device-name">{{ item.deviceName }}</text>
          <text class="time">{{ item.time }}</text>
        </view>

        <view class="row middle">
          <text class="device-id">{{ item.deviceId }}</text>
          <text class="status" :class="item.statusClass">{{ item.statusText }}</text>
        </view>

        <view class="event-wrap">
          <text class="event-tag">{{ item.eventType }}</text>
          <text class="event-desc">{{ item.desc }}</text>
        </view>
      </view>
    </scroll-view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      records: [
        {
          id: 1,
          deviceName: 'Attractor 主设备',
          deviceId: '8A:E5:FC:D4:C0:50',
          time: '2026-03-27 14:18',
          eventType: '连接',
          desc: '设备连接成功并进入参数页面',
          statusText: '成功',
          statusClass: 'ok'
        },
        {
          id: 2,
          deviceName: 'Attractor 主设备',
          deviceId: '8A:E5:FC:D4:C0:50',
          time: '2026-03-27 14:22',
          eventType: '快捷启动',
          desc: '首页快捷启动指令发送完成（0x30/0x01）',
          statusText: '成功',
          statusClass: 'ok'
        },
        {
          id: 3,
          deviceName: 'Attractor 主设备',
          deviceId: '8A:E5:FC:D4:C0:50',
          time: '2026-03-27 14:26',
          eventType: '快捷停止',
          desc: '首页快捷停止指令发送完成（0x30/0x00）',
          statusText: '成功',
          statusClass: 'ok'
        }
      ]
    }
  }
}
</script>

<style scoped>
.record-page {
  min-height: 100vh;
  background: #f4f7f8;
  padding: 20rpx;
  box-sizing: border-box;
}

.header-card {
  background: #ffffff;
  border: 1rpx solid #e7eeef;
  border-radius: 16rpx;
  padding: 20rpx;
  margin-bottom: 14rpx;
}

.title {
  display: block;
  font-size: 32rpx;
  font-weight: 700;
  color: #0f172a;
}

.sub {
  display: block;
  margin-top: 4rpx;
  font-size: 22rpx;
  color: #94a3b8;
}

.record-list {
  height: calc(100vh - 150rpx);
}

.record-card {
  background: #ffffff;
  border: 1rpx solid #e7eeef;
  border-radius: 16rpx;
  padding: 18rpx;
  margin-bottom: 12rpx;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.row.top {
  margin-bottom: 8rpx;
}

.row.middle {
  margin-bottom: 10rpx;
}

.device-name {
  font-size: 26rpx;
  font-weight: 600;
  color: #0f172a;
}

.time {
  font-size: 21rpx;
  color: #94a3b8;
}

.device-id {
  font-size: 22rpx;
  color: #64748b;
}

.status {
  font-size: 20rpx;
  border-radius: 999rpx;
  padding: 4rpx 12rpx;
}

.status.ok {
  color: #0f7f7a;
  background: #e6f5f4;
}

.event-wrap {
  display: flex;
  gap: 10rpx;
  align-items: flex-start;
}

.event-tag {
  font-size: 21rpx;
  color: #0f7f7a;
  background: #f0fdfa;
  border-radius: 8rpx;
  padding: 4rpx 10rpx;
  white-space: nowrap;
}

.event-desc {
  font-size: 23rpx;
  color: #334155;
  line-height: 1.55;
}

.empty-card {
  background: #ffffff;
  border: 1rpx dashed #d6dde3;
  border-radius: 16rpx;
  padding: 36rpx 20rpx;
  text-align: center;
}

.empty-title {
  display: block;
  font-size: 26rpx;
  color: #64748b;
}

.empty-sub {
  display: block;
  margin-top: 6rpx;
  font-size: 22rpx;
  color: #94a3b8;
}
</style>
