<template>
  <view class="admin-kefu-feedback">
    <view class="content-body">
      <!-- 顶部搜索栏 -->
      <view class="filter-card border-shadow">
        <view class="filter-item">
          <text class="label-txt">留言时间:</text>
          <view class="date-picker-mock">
            <text class="placeholder">开始日期</text>
            <text class="sep">-</text>
            <text class="placeholder">结束日期</text>
            <text class="calendar-icon">📅</text>
          </view>
        </view>
        
        <view class="filter-item">
          <text class="label-txt">留言信息:</text>
          <input class="search-input" placeholder="请输入用户昵称/电话/留言内容搜索" v-model="searchQuery" />
        </view>

        <view class="btn-query" @click="handleQuery">
          <text class="query-txt">查询</text>
        </view>
      </view>

      <!-- 数据表格 -->
      <view class="table-card border-shadow">
        <view class="table-header">
          <view class="th col-id"><text class="th-txt">ID</text></view>
          <view class="th col-nick"><text class="th-txt">昵称</text></view>
          <view class="th col-phone"><text class="th-txt">电话</text></view>
          <view class="th col-content"><text class="th-txt">内容</text></view>
          <view class="th col-status"><text class="th-txt">状态</text></view>
          <view class="th col-time"><text class="th-txt">时间</text></view>
          <view class="th col-op"><text class="th-txt">操作</text></view>
        </view>

        <view class="table-body">
          <view class="table-row" v-for="item in feedbackList" :key="item.id">
            <view class="td col-id"><text class="td-txt">{{ item.id }}</text></view>
            <view class="td col-nick"><text class="td-txt">{{ item.nickname }}</text></view>
            <view class="td col-phone"><text class="td-txt">{{ item.phone }}</text></view>
            <view class="td col-content"><text class="td-txt ellipsis">{{ item.content }}</text></view>
            <view class="td col-status">
              <text class="status-tag">{{ item.status }}</text>
            </view>
            <view class="td col-time"><text class="td-txt">{{ item.time }}</text></view>
            <view class="td col-op">
              <text class="btn-link" @click="handleProcess(item)">处理</text>
              <view class="divider"></view>
              <text class="btn-link danger" @click="handleDelete(item)">删除</text>
            </view>
          </view>
        </view>

        <!-- 分页 -->
        <view class="pagination-bar">
          <text class="page-total">共 {{ feedbackList.length }} 条</text>
          <view class="page-nav">
            <view class="nav-btn"><text class="nav-icon"> < </text></view>
            <view class="nav-item active"><text class="nav-num">1</text></view>
            <view class="nav-btn"><text class="nav-icon"> > </text></view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

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

interface FeedbackItem {
  id: string
  nickname: string
  phone: string
  content: string
  status: string
  time: string
}

const searchQuery = ref('')

const feedbackList = ref<FeedbackItem[]>([
  { id: '37', nickname: 'hhh', phone: '14779580008', content: 'hhh', status: '未处理', time: '2025-12-20 03:22:10' },
  { id: '36', nickname: 'hhh', phone: '14779580008', content: 'hhh', status: '未处理', time: '2025-12-20 03:22:05' },
  { id: '35', nickname: '发给大哥他', phone: '13212324567', content: '回复挂号费', status: '未处理', time: '2025-12-17 22:11:35' },
  { id: '34', nickname: '郑立民', phone: '15604580931', content: '我提现为啥不到账', status: '未处理', time: '2025-11-24 12:29:02' },
  { id: '33', nickname: '11', phone: '15012760793', content: '22222', status: '未处理', time: '2025-10-16 17:55:31' },
  { id: '32', nickname: '玉兔', phone: '13133164548', content: '我去会吐', status: '未处理', time: '2025-09-09 15:31:45' },
  { id: '31', nickname: '哟', phone: '15151424728', content: '玩意', status: '未处理', time: '2025-09-04 15:40:28' },
  { id: '30', nickname: '哟', phone: '15151424728', content: '玩意', status: '未处理', time: '2025-09-04 15:40:27' },
  { id: '29', nickname: 'pww', phone: '15274289992', content: '我们的', status: '未处理', time: '2025-08-13 18:21:35' },
  { id: '28', nickname: '1', phone: '18888888888', content: '1', status: '未处理', time: '2024-12-12 11:56:48' }
])

const handleQuery = () => {
  console.log('查询:', searchQuery.value)
}

const handleProcess = (item: FeedbackItem) => {
  console.log('处理留言:', item.id)
}

const handleDelete = (item: FeedbackItem) => {
  console.log('删除留言:', item.id)
}
</script>

<style scoped lang="scss">
.admin-kefu-feedback {
  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: 20px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 30px;
}

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

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

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

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

.sep {
  margin: 0 8px;
  color: #c0c4cc;
}

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

.search-input {
  width: 320px;
  height: 38px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  padding: 0 12px;
  font-size: 13px;
}

.btn-query {
  width: 76px;
  height: 34px;
  background-color: #2d8cf0;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.query-txt {
  color: #fff;
  font-size: 14px;
}

/* 表格卡片 */
.table-card {
  display: flex;
  flex-direction: column;
}

.table-header {
  height: 50px;
  background-color: #eaf2ff;
  display: flex;
  flex-direction: row;
  align-items: center;
  border-bottom: 1px solid #f0f0f0;
}

.th {
  display: flex;
  align-items: center;
  padding: 0 15px;
}

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

.table-row {
  height: 60px;
  display: flex;
  flex-direction: row;
  align-items: center;
  border-bottom: 1px solid #f0f0f0;
}

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

.td {
  display: flex;
  align-items: center;
  padding: 0 15px;
}

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

.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 列宽定义 */
.col-id { width: 80px; justify-content: center; }
.col-nick { width: 140px; }
.col-phone { width: 180px; }
.col-content { flex: 1; justify-content: flex-start; }
.col-status { width: 120px; justify-content: center; }
.col-time { width: 220px; justify-content: center; }
.col-op { 
  display: flex;
  flex-direction: row;
  align-items: center;
  width: 150px; 
  justify-content: center; 
}

.status-tag {
  font-size: 12px;
  color: #606266;
}

.btn-link {
  font-size: 13px;
  color: #2d8cf0;
  cursor: pointer;
}

.btn-link.danger {
  color: #2d8cf0; /* 根据截图，删除也是蓝色的链接感，但通常后台会区分，这里按截图感肉眼识别为蓝色 */
}

.divider {
  width: 1px;
  height: 12px;
  background-color: #e8eaec;
  margin: 0 10px;
}

/* 分页栏 */
.pagination-bar {
  padding: 20px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
}

.page-total {
  font-size: 13px;
  color: #606266;
  margin-right: 15px;
}

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

.nav-btn {
  width: 30px;
  height: 30px;
  border: 1px solid #dcdee2;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  margin: 0 4px;
}

.nav-item {
  width: 30px;
  height: 30px;
  border: 1px solid #dcdee2;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  margin: 0 4px;
}

.nav-item.active {
  background-color: #2d8cf0;
  border-color: #2d8cf0;
}

.nav-item.active .nav-num {
  color: #fff;
}

.nav-num, .nav-icon {
  font-size: 13px;
  color: #606266;
}
</style>
