<template>
  <view class="finance-bill">
    <!-- 头部筛选 -->
    <view class="filter-card border-shadow">
      <view class="filter-row">
        <view class="filter-item">
          <text class="filter-label">创建时间:</text>
          <view class="date-picker-wrap">
            <text class="calendar-icon">📅</text>
            <text class="date-placeholder">开始日期 - 结束日期</text>
          </view>
        </view>
      </view>
    </view>

    <!-- 内容区域 -->
    <view class="content-card border-shadow">
      <!-- 汇总选项卡 -->
      <view class="tab-header">
        <view class="tab-item active"><text class="tab-txt active-txt">日账单</text></view>
        <view class="tab-item"><text class="tab-txt">周账单</text></view>
        <view class="tab-item"><text class="tab-txt">月账单</text></view>
      </view>

      <!-- 表格区域 -->
      <view class="table-container">
        <view class="table-header">
          <view class="th col-id"><text class="th-txt">ID</text></view>
          <view class="th col-title"><text class="th-txt">标题</text></view>
          <view class="th col-date"><text class="th-txt">日期</text></view>
          <view class="th col-income"><text class="th-txt">收入金额</text></view>
          <view class="th col-expense"><text class="th-txt">支出金额</text></view>
          <view class="th col-entry"><text class="th-txt">入账金额</text></view>
          <view class="th col-ops"><text class="th-txt">操作</text></view>
        </view>

        <view class="table-body">
          <view class="table-row" v-for="item in tableData" :key="item.id">
            <view class="td col-id"><text class="td-txt">{{ item.id }}</text></view>
            <view class="td col-title text-left"><text class="td-txt">{{ item.title }}</text></view>
            <view class="td col-date"><text class="td-txt">{{ item.date }}</text></view>
            <view class="td col-income"><text class="td-txt red-txt">￥{{ item.income }}</text></view>
            <view class="td col-expense"><text class="td-txt green-txt">￥{{ item.expense }}</text></view>
            <view class="td col-entry"><text class="td-txt">￥{{ item.entry }}</text></view>
            <view class="td col-ops">
              <view class="ops-wrap">
                <text class="op-link">账单详情</text>
                <text class="op-divider">|</text>
                <text class="op-link">下载</text>
              </view>
            </view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

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

interface BillSumRecord {
  id: number
  title: string
  date: string
  income: string
  expense: string
  entry: string
}

const tableData = ref<BillSumRecord[]>([
  { id: 1, title: '日账单', date: '2026-02-03', income: '0.00', expense: '0.00', entry: '0.00' },
  { id: 2, title: '日账单', date: '2026-02-01', income: '0.00', expense: '0.00', entry: '0.00' },
  { id: 3, title: '日账单', date: '2026-01-30', income: '0.00', expense: '0.00', entry: '0.00' },
  { id: 4, title: '日账单', date: '2026-01-29', income: '0.00', expense: '0.00', entry: '0.00' },
  { id: 5, title: '日账单', date: '2026-01-28', income: '0.00', expense: '0.00', entry: '0.00' },
  { id: 6, title: '日账单', date: '2026-01-27', income: '0.00', expense: '0.00', entry: '0.00' },
  { id: 7, title: '日账单', date: '2026-01-26', income: '0.00', expense: '0.00', entry: '0.00' },
  { id: 8, title: '日账单', date: '2026-01-25', income: '0.00', expense: '0.00', entry: '0.00' },
  { id: 9, title: '日账单', date: '2026-01-23', income: '0.00', expense: '0.00', entry: '0.00' },
  { id: 10, title: '日账单', date: '2026-01-22', income: '0.00', expense: '0.00', entry: '0.00' }
])
</script>

<style scoped lang="scss">
.finance-bill {
  padding: 0;
  background-color: transparent;
  min-height: auto;
}

.border-shadow {
  background-color: #fff;
  border-radius: 4px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
}

/* 筛选 */
.filter-card {
  padding: 24px;
  margin-bottom: 20px;
}

.filter-row {
  display: flex;
  flex-direction: row;
  align-items: center;
}

.filter-item {
  display: flex;
  flex-direction: row;
  align-items: center;
}

.filter-label {
  font-size: 14px;
  color: #333;
  margin-right: 12px;
}

.date-picker-wrap {
  width: 280px;
  height: 36px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 0 12px;
}

.calendar-icon {
  font-size: 14px;
  margin-right: 8px;
  color: #c0c4cc;
}

.date-placeholder {
  font-size: 14px;
  color: #c0c4cc;
}

/* 内容卡片 */
.content-card {
  padding: 0;
  overflow: hidden;
}

.tab-header {
  display: flex;
  flex-direction: row;
  padding: 0 20px;
  border-bottom: 1px solid #f0f0f0;
}

.tab-item {
  padding: 16px 20px;
  cursor: pointer;
  position: relative;
}

.tab-item.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background-color: #1890ff;
}

.tab-txt {
  font-size: 14px;
  color: #666;
}

.active-txt {
  color: #1890ff;
  font-weight: 500;
}

/* 表格样式 */
.table-container {
  display: flex;
  flex-direction: column;
}

.table-header {
  background-color: #e6f0ff; /* 对应截图的淡蓝色背景 */
  display: flex;
  flex-direction: row;
}

.th {
  padding: 14px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.th-txt {
  font-size: 14px;
  font-weight: 600;
  color: #303133;
}

.table-row {
  display: flex;
  flex-direction: row;
  border-bottom: 1px solid #f0f0f0;
}

.table-row:hover {
  background-color: #fafafa;
}

.td {
  padding: 16px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.td-txt {
  font-size: 14px;
  color: #606266;
}

/* 列宽分配 */
.col-id { width: 80px; }
.col-title { width: 150px; }
.col-date { width: 220px; }
.col-income { width: 180px; }
.col-expense { width: 180px; }
.col-entry { width: 180px; }
.col-ops { flex: 1; min-width: 150px; }

.text-left {
  justify-content: flex-start;
}

/* 颜色 */
.red-txt {
  color: #f5222d; /* 收入红色 */
}

.green-txt {
  color: #52c41a; /* 支出绿色 */
}

/* 操作项 */
.ops-wrap {
  display: flex;
  flex-direction: row;
  align-items: center;
}

.op-link {
  font-size: 14px;
  color: #1890ff;
  cursor: pointer;
}

.op-divider {
  margin: 0 8px;
  color: #e8e8e8;
  font-size: 12px;
}
</style>
