<template>
  <view class="finance-balance-record">
    <!-- 筛选卡片 -->
    <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 class="filter-item">
          <text class="filter-label">交易类型:</text>
          <view class="select-box">
            <text class="select-txt">请选择</text>
            <text class="arrow-down">▼</text>
          </view>
        </view>
      </view>
    </view>

    <!-- 列表表格 -->
    <view class="table-container border-shadow">
      <view class="table-header">
        <view class="th col-id"><text class="th-txt">ID</text></view>
        <view class="th col-order"><text class="th-txt">关联订单</text></view>
        <view class="th col-time"><text class="th-txt">交易时间</text></view>
        <view class="th col-amount"><text class="th-txt">交易金额</text></view>
        <view class="th col-user"><text class="th-txt">用户</text></view>
        <view class="th col-type"><text class="th-txt">交易类型</text></view>
        <view class="th col-remark"><text class="th-txt">备注</text></view>
        <view class="th col-op"><text class="th-txt">操作</text></view>
      </view>

      <scroll-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-order text-left"><text class="td-txt">{{ item.order }}</text></view>
          <view class="td col-time"><text class="td-txt">{{ item.time }}</text></view>
          <view class="td col-amount">
            <text :class="['td-txt', item.amount.startsWith('+') ? 'red-txt' : 'green-txt']">{{ item.amount }}</text>
          </view>
          <view class="td col-user"><text class="td-txt">{{ item.user }}</text></view>
          <view class="td col-type"><text class="td-txt">{{ item.type }}</text></view>
          <view class="td col-remark text-left"><text class="td-txt">{{ item.remark }}</text></view>
          <view class="td col-op">
            <text class="btn-link">备注</text>
          </view>
        </view>
      </scroll-view>
    </view>
  </view>
</template>

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

interface BalanceRecord {
  id: string
  order: string
  time: string
  amount: string
  user: string
  type: string
  remark: string
}

const tableData = ref<BalanceRecord[]>([
  {
    id: '31216',
    order: '新用户注册赠送余额',
    time: '2026-02-03 10:30:11',
    amount: '+ 88888.00',
    user: '1',
    type: '新用户注册赠送余额',
    remark: '新用户注册赠送88888余额'
  },
  {
    id: '31215',
    order: '新用户注册赠送余额',
    time: '2026-02-03 10:19:52',
    amount: '+ 88888.00',
    user: 'circus',
    type: '新用户注册赠送余额',
    remark: '新用户注册赠送88888余额'
  },
  {
    id: '31214',
    order: 'cp541560738494283776',
    time: '2026-02-03 10:09:07',
    amount: '- 999.00',
    user: '1岁上班22岁退休',
    type: '余额支付购买商品',
    remark: '余额支付999.00元购买商品'
  },
  {
    id: '31213',
    order: '新用户注册赠送余额',
    time: '2026-02-03 10:07:59',
    amount: '+ 88888.00',
    user: '1岁上班22岁退休',
    type: '新用户注册赠送余额',
    remark: '新用户注册赠送88888余额'
  },
  {
    id: '31212',
    order: '新用户注册赠送余额',
    time: '2026-02-03 02:17:24',
    amount: '+ 88888.00',
    user: '136****0434',
    type: '新用户注册赠送余额',
    remark: '新用户注册赠送88888余额'
  },
  {
    id: '31211',
    order: '新用户注册赠送余额',
    time: '2026-02-03 02:04:17',
    amount: '+ 88888.00',
    user: '灵境',
    type: '新用户注册赠送余额',
    remark: '新用户注册赠送88888余额'
  },
  {
    id: '31210',
    order: '新用户注册赠送余额',
    time: '2026-02-03 00:58:21',
    amount: '+ 88888.00',
    user: 'J.',
    type: '新用户注册赠送余额',
    remark: '新用户注册赠送88888余额'
  }
])
</script>

<style scoped lang="scss">
.finance-balance-record {
  padding: 20px;
  background-color: #f5f7fa;
  min-height: 100vh;
}

.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; margin-right: 40px; }
.filter-label { font-size: 14px; color: #333; margin-right: 15px; }

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

.select-box {
  width: 200px;
  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: 10px; color: #c0c4cc; }
.date-placeholder, .select-txt { font-size: 14px; color: #c0c4cc; }
.arrow-down { margin-left: auto; font-size: 10px; color: #c0c4cc; }

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

.table-header { 
  background-color: #e6f0ff; 
  display: flex; 
  flex-direction: row; 
  border-bottom: 1px solid #f0f0f0; 
  padding: 4px 0;
}

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

.th-txt { 
  font-size: 13px; 
  font-weight: 500; 
  color: #606266; 
}

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

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

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

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

/* 列宽分配 (参考截图比例) */
.col-id { width: 70px; }
.col-order { flex: 1.5; min-width: 180px; justify-content: flex-start; }
.col-time { width: 160px; }
.col-amount { width: 120px; }
.col-user { width: 120px; }
.col-type { width: 150px; }
.col-remark { flex: 1.8; min-width: 200px; justify-content: flex-start; }
.col-op { width: 80px; }

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

/* 颜色 */
.red-txt { color: #f56c6c; font-weight: 500; }
.green-txt { color: #67c23a; font-weight: 500; }
.btn-link { color: #1890ff; font-size: 13px; cursor: pointer; }
</style>
