<template>
  <view class="admin-page-container">
    <view class="page-card">
      <!-- 搜索栏 -->
      <view class="search-wrap">
        <view class="search-item">
          <text class="label">状态：</text>
          <picker mode="selector" :range="statusRange" @change="onStatusChange">
            <view class="picker-input">{{ statusText }}</view>
          </picker>
        </view>
        <view class="search-item">
          <text class="label">身份昵称：</text>
          <input class="input" placeholder="请输入身份昵称" v-model="searchKey" />
        </view>
        <button class="btn btn-primary" @click="onSearch">查询</button>
      </view>

      <view class="action-wrap">
        <button class="btn btn-primary" @click="onAdd">添加身份</button>
      </view>

      <!-- 表格区域 -->
      <view class="table-wrap">
        <view class="table-header">
          <view class="th" style="flex: 1;">ID</view>
          <view class="th" style="flex: 3;">身份昵称</view>
          <view class="th" style="flex: 2;">状态</view>
          <view class="th" style="flex: 2;">操作</view>
        </view>
        <view class="table-body">
          <view class="no-data">
            <text class="no-data-text">暂无数据</text>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

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

const searchKey = ref('')
const statusRange = ['所有', '启用', '禁用']
const statusIndex = ref(0)
const statusText = ref('请选择')

function onStatusChange(e: any) {
  statusIndex.value = parseInt(e.detail.value.toString())
  statusText.value = statusRange[statusIndex.value]
}

function onSearch() {
  console.log('Search:', searchKey.value, statusText.value)
}

function onAdd() {
  console.log('Add role')
}
</script>

<style scoped>
.admin-page-container {
  /* 使用 Layout 的背景和内边距 */
  padding: 0;
  background-color: transparent;
  min-height: auto;
}

.page-card {
  background-color: #fff;
  border-radius: 4px;
  padding: 20px;
}

.search-wrap {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  padding-bottom: 20px;
  border-bottom: 1px solid #f0f0f0;
  margin-bottom: 20px;
}

.search-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  margin-right: 20px;
  margin-bottom: 10px;
}

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

.picker-input {
  width: 150px;
  height: 32px;
  line-height: 32px;
  padding: 0 10px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  font-size: 14px;
  color: #606266;
  background-color: #fff;
}

.input {
  width: 180px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  font-size: 14px;
  color: #606266;
}

.btn {
  height: 32px;
  line-height: 30px;
  padding: 0 15px;
  font-size: 14px;
  border-radius: 4px;
  border: none;
  margin-bottom: 10px;
}

.btn-primary {
  background-color: #1890ff;
  color: #fff;
}

.action-wrap {
  margin-bottom: 20px;
}

.table-wrap {
  width: 100%;
  border: 1px solid #f0f0f0;
}

.table-header {
  display: flex;
  flex-direction: row;
  background-color: #f8f8f9;
}

.th {
  padding: 12px 10px;
  font-size: 14px;
  font-weight: bold;
  color: #515a6e;
  border-bottom: 1px solid #f0f0f0;
  text-align: center;
}

.table-body {
  min-height: 100px;
}

.no-data {
  padding: 40px 0;
  text-align: center;
}

.no-data-text {
  font-size: 14px;
  color: #c5c8ce;
}
</style>
