Browse Source

refactor(ui-kit): Dashboard A类概览 + Users B表格带C详情抽屉(五态)

liaoxg 1 day ago
parent
commit
3d4aa0c086
2 changed files with 740 additions and 224 deletions
  1. 354 55
      train-web/src/views/Dashboard.vue
  2. 386 169
      train-web/src/views/Users.vue

+ 354 - 55
train-web/src/views/Dashboard.vue

@@ -1,37 +1,85 @@
 <template>
 <template>
   <div class="dashboard">
   <div class="dashboard">
-    <div class="stats-cards">
-      <div class="stat-card">
-        <div class="stat-value">{{ stats.totalUsers }}</div>
-        <div class="stat-label">总学员数</div>
-      </div>
-      <div class="stat-card">
-        <div class="stat-value">{{ stats.totalSubmissions }}</div>
-        <div class="stat-label">成果提交</div>
-      </div>
-      <div class="stat-card">
-        <div class="stat-value">{{ stats.totalCards }}</div>
-        <div class="stat-label">教学卡</div>
-      </div>
-      <div class="stat-card">
-        <div class="stat-value">{{ stats.totalGroups }}</div>
-        <div class="stat-label">分组数</div>
+    <!-- 时间范围筛选(选中态 chip 主色描边 + 浅蓝底) -->
+    <div class="range-row">
+      <span class="range-label">统计口径</span>
+      <span v-for="r in ranges" :key="r.key" class="chip" :class="{ on: range === r.key }" @click="range = r.key">{{ r.label }}</span>
+    </div>
+
+    <!-- 加载骨架 -->
+    <div v-if="state === 'loading'" class="loading-wrap">
+      <div class="kpis">
+        <div v-for="n in 4" :key="'k' + n" class="card kpi"><div class="sk" style="width:52px;height:12px"></div><div class="sk" style="width:88px;height:22px;margin-top:9px"></div></div>
       </div>
       </div>
-      <div class="stat-card">
-        <div class="stat-value">{{ stats.totalCheckins }}</div>
-        <div class="stat-label">签到数</div>
+      <div class="charts"><div class="card ch"><div class="sk" style="width:150px;height:16px;margin-bottom:8px"></div><div class="sk" style="height:220px"></div></div><div class="card ch"><div class="sk" style="width:130px;height:16px;margin-bottom:8px"></div><div class="sk" style="height:220px"></div></div></div>
+      <div class="card"><div class="sk" style="height:44px;margin-bottom:4px"></div><div class="sk" style="height:48px;margin-bottom:4px"></div><div class="sk" style="height:48px"></div></div>
+    </div>
+
+    <!-- 错误态 -->
+    <div v-else-if="state === 'error'" class="error-wrap">
+      <div class="card err-banner"><span>数据加载失败,请重新加载</span><el-button size="mini" @click="fetchOverview">重试</el-button></div>
+      <div class="kpis">
+        <div v-for="k in kpiDefs" :key="k.key" class="card kpi"><div class="kpi-label">{{ k.label }}</div><div class="kpi-num muted">—</div></div>
       </div>
       </div>
-      <div class="stat-card">
-        <div class="stat-value">{{ stats.totalVotes }}</div>
-        <div class="stat-label">投票数</div>
+    </div>
+
+    <!-- 正常 / 空态 -->
+    <div v-else>
+      <div class="kpis">
+        <div v-for="k in kpiDefs" :key="k.key" class="card kpi">
+          <div class="kpi-label">{{ k.label }}</div>
+          <div class="kpi-num">{{ fmt(k.value) }}</div>
+          <div class="kpi-sub">{{ k.sub }}</div>
+        </div>
       </div>
       </div>
-      <div class="stat-card">
-        <div class="stat-value">{{ stats.totalPlans }}</div>
-        <div class="stat-label">计划数</div>
+
+      <div class="charts">
+        <div class="card ch">
+          <h3 class="ch-title">各班学员 / 分组分布</h3>
+          <p class="ch-desc">按班级统计 · 共 {{ stats.totalClasses || 0 }} 个班级</p>
+          <div class="bar-chart">
+            <div v-if="chartRows.length === 0" class="empty-inline">暂无班级数据</div>
+            <div v-for="row in chartRows" :key="row.classId" class="bar-row">
+              <span class="bar-name">{{ row.className }}</span>
+              <div class="bar-track">
+                <div class="bar user" :style="{ width: barPct(row.userCount, maxUser) + '%' }"></div>
+                <div class="bar group" :style="{ width: barPct(row.groupCount, maxUser) + '%' }"></div>
+              </div>
+              <span class="bar-num">{{ row.userCount }}</span>
+            </div>
+            <div class="bar-legend"><i class="dot user"></i>学员 <i class="dot group"></i>分组</div>
+          </div>
+        </div>
+        <div class="card ch">
+          <h3 class="ch-title">关键指标</h3>
+          <p class="ch-desc">整体累计</p>
+          <div class="metric-list">
+            <div class="metric-item"><span class="metric-name">分组总数</span><span class="metric-val">{{ fmt(stats.totalGroups) }}</span></div>
+            <div class="metric-item"><span class="metric-name">签到次数</span><span class="metric-val">{{ fmt(stats.totalCheckins) }}</span></div>
+            <div class="metric-item"><span class="metric-name">路演投票</span><span class="metric-val">{{ fmt(stats.totalVotes) }}</span></div>
+            <div class="metric-item"><span class="metric-name">行动计划</span><span class="metric-val">{{ fmt(stats.totalPlans) }}</span></div>
+          </div>
+        </div>
       </div>
       </div>
-      <div class="stat-card">
-        <div class="stat-value">{{ stats.totalCoupons }}</div>
-        <div class="stat-label">优惠券</div>
+
+      <div class="card">
+        <h3 class="ch-title">班级明细</h3>
+        <el-table :data="tableRows" v-loading="false" style="width:100%" :row-class-name="rowClass">
+          <el-table-column prop="className" label="班级" min-width="180">
+            <template slot-scope="{ row }"><span class="link">{{ row.className }}</span></template>
+          </el-table-column>
+          <el-table-column prop="userCount" label="学员数" width="120" />
+          <el-table-column prop="groupCount" label="分组数" width="120" />
+          <el-table-column label="状态" width="120">
+            <template slot-scope="{ row }"><span class="tag" :class="row.groupCount > 0 ? 'ok' : ''">{{ row.groupCount > 0 ? '已分组' : '未分组' }}</span></template>
+          </el-table-column>
+        </el-table>
+        <div v-if="tableRows.length === 0" class="empty-state">
+          <div class="empty-ico"></div>
+          <h4>当前暂无班级数据</h4>
+          <p>尚未创建班级,或筛选口径下无记录</p>
+          <el-button size="small" type="primary" @click="fetchOverview">重新加载</el-button>
+        </div>
       </div>
       </div>
     </div>
     </div>
   </div>
   </div>
@@ -44,61 +92,312 @@ export default {
   name: 'Dashboard',
   name: 'Dashboard',
   data: function () {
   data: function () {
     return {
     return {
-      stats: {
-        totalUsers: 0,
-        totalSubmissions: 0,
-        totalCards: 0,
-        totalGroups: 0,
-        totalCheckins: 0,
-        totalVotes: 0,
-        totalPlans: 0,
-        totalCoupons: 0
-      }
+      range: '30d',
+      ranges: [
+        { key: '7d', label: '近 7 天' },
+        { key: '30d', label: '近 30 天' },
+        { key: 'quarter', label: '本季度' }
+      ],
+      stats: {},
+      state: 'loading', // loading / error / normal / empty
+      selectedClass: null
+    }
+  },
+  computed: {
+    kpiDefs: function () {
+      var s = this.stats || {}
+      return [
+        { key: 'users', label: '学员数', value: s.totalUsers, sub: '全部在册学员' },
+        { key: 'classes', label: '班级数', value: s.totalClasses, sub: '当前开班班级' },
+        { key: 'submissions', label: '成果提交', value: s.totalSubmissions, sub: '累计提交成果' },
+        { key: 'cards', label: '教学卡', value: s.totalCards, sub: '累计教学卡记录' }
+      ]
+    },
+    chartRows: function () {
+      return this.stats.classStats || []
+    },
+    tableRows: function () {
+      return this.stats.classStats || []
+    },
+    maxUser: function () {
+      var max = 1
+      ;(this.stats.classStats || []).forEach(function (r) {
+        if (r.userCount > max) max = r.userCount
+      })
+      return max
     }
     }
   },
   },
   mounted: function () {
   mounted: function () {
     this.fetchOverview()
     this.fetchOverview()
   },
   },
   methods: {
   methods: {
+    fmt: function (v) {
+      var n = Number(v)
+      if (isNaN(n)) return '—'
+      return n.toLocaleString('en-US')
+    },
+    barPct: function (v, max) {
+      return Math.max(2, Math.round((Number(v) / max) * 100))
+    },
+    rowClass: function () {
+      return ''
+    },
     fetchOverview: function () {
     fetchOverview: function () {
       var self = this
       var self = this
+      self.state = 'loading'
       statsOverview().then(function (res) {
       statsOverview().then(function (res) {
-        self.stats = res.data || self.stats
-      }).catch(function () {})
+        self.stats = res.data || {}
+        self.state = ((self.stats.classStats || []).length > 0) ? 'normal' : 'empty'
+      }).catch(function () {
+        self.state = 'error'
+      })
     }
     }
   }
   }
 }
 }
 </script>
 </script>
 
 
 <style scoped>
 <style scoped>
-.stats-cards {
-  display: grid;
-  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
+.dashboard {
+  display: flex;
+  flex-direction: column;
   gap: 16px;
   gap: 16px;
 }
 }
 
 
-.stat-card {
-  background: #fff;
+.range-row {
+  display: flex;
+  align-items: center;
+  gap: 8px;
+}
+.range-label {
+  font-size: 12px;
+  color: #6B7B8C;
+  margin-right: 4px;
+}
+.chip {
+  border: 1px solid #C3D2DF;
+  background: #FFFFFF;
+  color: #3B5A78;
+  font-size: 12px;
+  padding: 4px 12px;
+  border-radius: 4px;
+  cursor: pointer;
+}
+.chip.on {
+  background: #E8F3FC;
+  border-color: #2E6FA8;
+  color: #2E6FA8;
+  font-weight: 600;
+}
+
+.card {
+  background: #FFFFFF;
+  border: 1px solid #DCE7F1;
   border-radius: 8px;
   border-radius: 8px;
-  padding: 24px 16px;
-  text-align: center;
-  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
-  transition: box-shadow 0.2s;
+  box-shadow: 0 2px 10px rgba(30, 58, 95, 0.06);
+  padding: 16px;
+}
+
+.kpis {
+  display: grid;
+  grid-template-columns: repeat(4, 1fr);
+  gap: 16px;
+}
+.kpi .kpi-label {
+  font-size: 12px;
+  color: #6B7B8C;
+}
+.kpi .kpi-num {
+  font-size: 24px;
+  font-weight: 700;
+  margin-top: 5px;
+  color: #1E3A5F;
+  font-variant-numeric: tabular-nums;
+}
+.kpi .kpi-num.muted {
+  color: #6B7B8C;
+}
+.kpi .kpi-sub {
+  font-size: 12px;
+  color: #6B7B8C;
+  margin-top: 3px;
+}
+
+.charts {
+  display: grid;
+  grid-template-columns: 2fr 1fr;
+  gap: 16px;
+}
+.ch-title {
+  font-size: 16px;
+  font-weight: 600;
+  color: #1E3A5F;
+  margin: 0 0 2px;
+}
+.ch-desc {
+  font-size: 12px;
+  color: #6B7B8C;
+  margin: 0 0 12px;
 }
 }
 
 
-.stat-card:hover {
-  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
+.bar-chart {
+  display: flex;
+  flex-direction: column;
+  gap: 12px;
+}
+.bar-row {
+  display: flex;
+  align-items: center;
+  gap: 12px;
+}
+.bar-name {
+  width: 140px;
+  font-size: 13px;
+  color: #3B5A78;
+  white-space: nowrap;
+  overflow: hidden;
+  text-overflow: ellipsis;
+}
+.bar-track {
+  flex: 1;
+  display: flex;
+  gap: 6px;
+  align-items: center;
+}
+.bar {
+  height: 18px;
+  border-radius: 3px;
+  min-width: 4px;
+}
+.bar.user {
+  background: #2E6FA8;
 }
 }
+.bar.group {
+  background: #14B8A6;
+}
+.bar-num {
+  width: 40px;
+  text-align: right;
+  font-size: 13px;
+  color: #3B5A78;
+  font-variant-numeric: tabular-nums;
+}
+.bar-legend {
+  display: flex;
+  align-items: center;
+  gap: 6px;
+  font-size: 12px;
+  color: #6B7B8C;
+  margin-top: 4px;
+}
+.bar-legend .dot {
+  width: 10px;
+  height: 10px;
+  border-radius: 2px;
+  display: inline-block;
+}
+.bar-legend .dot.user { background: #2E6FA8; }
+.bar-legend .dot.group { background: #14B8A6; }
 
 
-.stat-value {
-  font-size: 32px;
+.metric-list {
+  display: flex;
+  flex-direction: column;
+}
+.metric-item {
+  display: flex;
+  justify-content: space-between;
+  padding: 10px 0;
+  border-bottom: 1px solid #DCE7F1;
+  font-size: 14px;
+}
+.metric-item:last-child {
+  border-bottom: none;
+}
+.metric-name {
+  color: #3B5A78;
+}
+.metric-val {
   font-weight: 700;
   font-weight: 700;
+  color: #1E3A5F;
+  font-variant-numeric: tabular-nums;
+}
+
+.link {
+  color: #2E6FA8;
+  cursor: pointer;
+}
+.tag {
+  display: inline-block;
+  font-size: 12px;
+  padding: 1px 8px;
+  border-radius: 10px;
+  background: #E8F3FC;
   color: #2E6FA8;
   color: #2E6FA8;
-  margin-bottom: 8px;
+}
+.tag.ok {
+  background: #E6F6EE;
+  color: #0E8A4F;
 }
 }
 
 
-.stat-label {
+.empty-inline {
   font-size: 13px;
   font-size: 13px;
   color: #6B7B8C;
   color: #6B7B8C;
+  text-align: center;
+  padding: 20px 0;
+}
+.empty-state {
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  gap: 10px;
+  padding: 40px 0;
+}
+.empty-ico {
+  width: 60px;
+  height: 60px;
+  border-radius: 50%;
+  background: #E8F3FC;
+  position: relative;
+}
+.empty-ico::after {
+  content: '';
+  position: absolute;
+  left: 17px;
+  top: 17px;
+  width: 26px;
+  height: 26px;
+  border: 3px solid #0F766E;
+  border-radius: 5px;
+}
+.empty-state h4 {
+  font-size: 16px;
+  color: #1E3A5F;
+  margin: 0;
+}
+.empty-state p {
+  font-size: 14px;
+  color: #6B7B8C;
+  margin: 0;
+}
+
+.err-banner {
+  background: #FDE8E8;
+  border: 1px solid #C0392B;
+  color: #C0392B;
+  padding: 10px 14px;
+  border-radius: 4px;
+  font-size: 14px;
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+}
+
+.sk {
+  background: #E8F0F7;
+  border-radius: 4px;
+  animation: pulse 1.2s ease-in-out infinite alternate;
+}
+@keyframes pulse {
+  from { opacity: 0.55; }
+  to { opacity: 1; }
 }
 }
 </style>
 </style>

+ 386 - 169
train-web/src/views/Users.vue

@@ -1,164 +1,201 @@
 <template>
 <template>
   <div class="page-container">
   <div class="page-container">
-    <div class="page-header">
-      <h2 class="page-title">学员管理</h2>
-      <div class="page-filters">
-        <el-select v-model="filters.classId" placeholder="班级" clearable style="width:120px;margin-right:8px">
-          <el-option v-for="c in classes" :key="c.id" :label="c.name" :value="c.id" />
-        </el-select>
-        <el-select v-model="filters.role" placeholder="角色" clearable style="width:120px;margin-right:8px">
+    <!-- 内容工具栏:新建 / 导入(页头标题由外壳提供) -->
+    <div class="toolbar">
+      <div class="toolbar-left">
+        <el-button type="primary" icon="el-icon-plus" @click="$message.info('新建学员入口')">新建学员</el-button>
+        <el-button icon="el-icon-upload2" @click="$message.info('导入名单')">导入名单</el-button>
+      </div>
+      <div class="toolbar-right">
+        <span class="toolbar-count">共 {{ total }} 条记录</span>
+      </div>
+    </div>
+
+    <!-- 筛选栏 -->
+    <div class="card filter-card">
+      <div class="fr">
+        <label>姓名 / 编号</label>
+        <el-input v-model="filters.keyword" placeholder="请输入姓名或学员编号" clearable style="width:240px" @keyup.enter.native="search" />
+        <label class="fr-label">手机号</label>
+        <el-input v-model="filters.phone" placeholder="请输入手机号" clearable style="width:240px" @keyup.enter.native="search" />
+      </div>
+      <div class="fr">
+        <label>角色</label>
+        <el-select v-model="filters.role" placeholder="全部角色" clearable style="width:200px">
           <el-option label="学员" value="student" />
           <el-option label="学员" value="student" />
           <el-option label="助教" value="assistant" />
           <el-option label="助教" value="assistant" />
           <el-option label="讲师" value="lecturer" />
           <el-option label="讲师" value="lecturer" />
+          <el-option label="管理员" value="admin" />
         </el-select>
         </el-select>
-        <el-select v-model="filters.status" placeholder="状态" clearable style="width:120px">
+        <label class="fr-label">状态</label>
+        <el-select v-model="filters.status" placeholder="全部状态" clearable style="width:200px">
           <el-option label="已激活" value="active" />
           <el-option label="已激活" value="active" />
           <el-option label="已禁用" value="banned" />
           <el-option label="已禁用" value="banned" />
         </el-select>
         </el-select>
-        <el-button type="primary" icon="el-icon-search" style="margin-left:8px" @click="fetchList">查询</el-button>
+        <el-button type="primary" icon="el-icon-search" @click="search" style="margin-left:12px">查询</el-button>
+        <el-button @click="resetFilters">重置</el-button>
       </div>
       </div>
     </div>
     </div>
 
 
-    <el-table :data="list" v-loading="loading" border stripe style="width:100%">
-      <el-table-column prop="id" label="用户ID" width="100" />
-      <el-table-column prop="name" label="姓名" min-width="120" />
-      <el-table-column prop="phone" label="手机" width="130" />
-      <el-table-column prop="role" label="角色" width="90">
-        <template slot-scope="{ row }">
-          <el-tag :type="roleTagMap[row.role] || 'info'" size="small">{{ roleLabel[row.role] || row.role }}</el-tag>
-        </template>
-      </el-table-column>
-      <el-table-column prop="groupName" label="分组" width="120" />
-      <el-table-column label="班级" width="120">
-        <template slot-scope="{ row }">
-          {{ classNameOf(row.classId) }}
-        </template>
-      </el-table-column>
-      <el-table-column label="校友校验" width="100">
-        <template slot-scope="{ row }">
-          <el-tag :type="alumniType(row.alumniVerify)" size="small">{{ alumniLabel(row.alumniVerify) }}</el-tag>
-        </template>
-      </el-table-column>
-      <el-table-column prop="status" label="状态" width="90">
-        <template slot-scope="{ row }">
-          <el-tag :type="row.status === 'active' ? 'success' : 'danger'" size="small">{{ row.status === 'active' ? '已激活' : '已禁用' }}</el-tag>
-        </template>
-      </el-table-column>
-      <el-table-column label="操作" width="280" fixed="right">
-        <template slot-scope="{ row }">
-          <el-button size="mini" type="primary" plain @click="openDetail(row)">详情</el-button>
-          <el-button size="mini" @click="toggleStatus(row)">{{ row.status === 'active' ? '禁用' : '激活' }}</el-button>
-          <el-button size="mini" type="warning" @click="openMoveClass(row)">调整班级</el-button>
-        </template>
-      </el-table-column>
-    </el-table>
+    <!-- 批量操作栏 -->
+    <div class="batch-bar" v-if="selected.length > 0">
+      <span>已选中 <b>{{ selected.length }}</b> 名学员 · <span class="link" @click="clearSelection">取消选择</span></span>
+      <div>
+        <el-button size="mini" @click="$message.info('批量导出')">批量导出</el-button>
+        <el-button size="mini" @click="$message.info('批量转批次')">批量转批次</el-button>
+      </div>
+    </div>
 
 
-     <el-pagination
-       v-if="total > pageSize"
-       layout="prev, pager, next, total"
-       :total="total"
-       :page-size="pageSize"
-       :current-page.sync="page"
-       @current-change="fetchList"
-       style="margin-top:16px;text-align:right"
-     />
+    <!-- 表格 -->
+    <div class="card table-card">
+      <el-table
+        :data="list"
+        v-loading="loading"
+        style="width:100%"
+        :row-class-name="rowClass"
+        @selection-change="onSelectionChange"
+        @row-click="onRowClick"
+      >
+        <el-table-column type="selection" width="48" />
+        <el-table-column label="序号" type="index" width="56" />
+        <el-table-column prop="name" label="姓名" min-width="140">
+          <template slot-scope="{ row }"><span class="link" @click.stop="openDetail(row)">{{ row.name }}</span></template>
+        </el-table-column>
+        <el-table-column label="角色" width="100">
+          <template slot-scope="{ row }">
+            <el-tag :type="roleTagMap[row.role] || 'info'" size="small">{{ roleLabel[row.role] || row.role }}</el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column prop="groupName" label="分组" width="120" />
+        <el-table-column label="班级" width="130">
+          <template slot-scope="{ row }">{{ classNameOf(row.classId) }}</template>
+        </el-table-column>
+        <el-table-column label="校友校验" width="110">
+          <template slot-scope="{ row }">
+            <el-tag :type="alumniType(row.alumniVerify)" size="small">{{ alumniLabel(row.alumniVerify) }}</el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column label="状态" width="100">
+          <template slot-scope="{ row }">
+            <el-tag :type="row.status === 'active' ? 'success' : 'info'" size="small">{{ row.status === 'active' ? '已激活' : '已禁用' }}</el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column label="报名时间" width="150">
+          <template slot-scope="{ row }">{{ row.createdAt || '-' }}</template>
+        </el-table-column>
+        <el-table-column label="操作" width="150" fixed="right">
+          <template slot-scope="{ row }">
+            <span class="link" @click.stop="openDetail(row)">详情</span>
+            <span class="op-sep">·</span>
+            <span class="link" @click.stop="toggleStatus(row)">{{ row.status === 'active' ? '禁用' : '激活' }}</span>
+          </template>
+        </el-table-column>
+      </el-table>
 
 
-<el-dialog title="调整班级" :visible.sync="moveVisible" width="420px" @closed="moveForm = { uid: null, classId: null }">
-        <el-form label-width="80px">
-          <el-form-item label="学员">
-            <span>{{ moveUserName }}</span>
-          </el-form-item>
-          <el-form-item label="目标班级">
-            <el-select v-model="moveForm.classId" placeholder="不选则移出班级(退班)" clearable style="width:100%">
-              <el-option v-for="c in classes" :key="c.id" :label="c.name" :value="c.id" />
-            </el-select>
-          </el-form-item>
-          <div class="tips">留空提交即学员退班,将同时清空其报名单班次</div>
-        </el-form>
-        <span slot="footer" class="dialog-footer">
-          <el-button @click="moveVisible = false">取 消</el-button>
-          <el-button type="primary" :loading="moveSubmitting" @click="handleMoveClass">确 定</el-button>
-        </span>
-      </el-dialog>
+      <!-- 空态 / 错误态 -->
+      <div v-if="!loading && state === 'empty'" class="empty-state">
+        <div class="empty-ico"></div>
+        <h4>没有符合条件的学员记录</h4>
+        <p>可调整姓名、角色或状态后重新筛选</p>
+        <div class="empty-actions">
+          <el-button size="small" type="primary" @click="fetchList">重新加载</el-button>
+          <el-button size="small" @click="resetFilters">返回列表</el-button>
+        </div>
+      </div>
+      <div v-if="!loading && state === 'error'" class="error-banner">
+        <span>学员列表加载失败,请重新加载(已保留输入条件)</span>
+        <el-button size="mini" @click="fetchList">重试</el-button>
+      </div>
 
 
-      <!-- 学员详情弹窗 -->
-      <el-dialog :title="'学员详情 - ' + (detailUser && detailUser.name ? detailUser.name : '')" :visible.sync="detailVisible" width="820px" top="6vh">
-        <div v-loading="detailLoading">
-          <div class="detail-section" v-if="detailUser">
-            <h4>基本信息</h4>
-            <el-descriptions :column="3" size="small" border>
-              <el-descriptions-item label="用户ID">{{ detailUser.id }}</el-descriptions-item>
-              <el-descriptions-item label="姓名">{{ detailUser.name }}</el-descriptions-item>
-              <el-descriptions-item label="手机">{{ detailUser.phone || '-' }}</el-descriptions-item>
-              <el-descriptions-item label="角色">{{ roleLabel[detailUser.role] || detailUser.role || '-' }}</el-descriptions-item>
-              <el-descriptions-item label="班级">{{ classNameOf(detailUser.classId) }}</el-descriptions-item>
-              <el-descriptions-item label="分组">{{ detailUser.groupName || '-' }}</el-descriptions-item>
-              <el-descriptions-item label="校友校验">
-                <el-tag :type="alumniType(detailUser.alumniVerify)" size="small">{{ alumniLabel(detailUser.alumniVerify) }}</el-tag>
-              </el-descriptions-item>
-              <el-descriptions-item label="状态">
-                <el-tag :type="detailUser.status === 'active' ? 'success' : 'danger'" size="small">{{ detailUser.status === 'active' ? '已激活' : '已禁用' }}</el-tag>
-              </el-descriptions-item>
-              <el-descriptions-item label="邀请码">{{ detailUser.inviteCode || '-' }}</el-descriptions-item>
-            </el-descriptions>
-          </div>
+      <el-pagination
+        v-if="total > pageSize"
+        layout="prev, pager, next, total"
+        :total="total"
+        :page-size="pageSize"
+        :current-page.sync="page"
+        @current-change="fetchList"
+        style="margin-top:16px;text-align:right"
+      />
+    </div>
 
 
-          <div class="detail-section">
-            <h4>报名单</h4>
-            <el-table :data="detailEnrollments" size="small" border stripe style="width:100%">
-              <el-table-column prop="id" label="ID" width="70" />
-              <el-table-column prop="courseId" label="课程ID" width="80" />
-              <el-table-column label="状态" width="110">
-                <template slot-scope="{ row }">
-                  <el-tag :type="enrollStatusType(row.status)" size="small">{{ enrollStatusLabel(row.status) }}</el-tag>
-                </template>
-              </el-table-column>
-              <el-table-column prop="createdAt" label="报名时间" width="160" />
-              <el-table-column prop="source" label="来源" width="80">
-                <template slot-scope="{ row }">
-                  {{ row.source === 'invite' ? '邀请' : '场景' }}
-                </template>
-              </el-table-column>
-            </el-table>
-          </div>
+    <!-- 调整班级弹窗 -->
+    <el-dialog title="调整班级" :visible.sync="moveVisible" width="420px" @closed="moveForm = { uid: null, classId: null }">
+      <el-form label-width="80px">
+        <el-form-item label="学员">
+          <span>{{ moveUserName }}</span>
+        </el-form-item>
+        <el-form-item label="目标班级">
+          <el-select v-model="moveForm.classId" placeholder="不选则移出班级(退班)" clearable style="width:100%">
+            <el-option v-for="c in classes" :key="c.id" :label="c.name" :value="c.id" />
+          </el-select>
+        </el-form-item>
+        <div class="tips">留空提交即学员退班,将同时清空其报名单班次</div>
+      </el-form>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="moveVisible = false">取 消</el-button>
+        <el-button type="primary" :loading="moveSubmitting" @click="handleMoveClass">确 定</el-button>
+      </span>
+    </el-dialog>
 
 
-          <div class="detail-section">
-            <h4>卡券</h4>
-            <el-table :data="detailCoupons" size="small" border stripe style="width:100%">
-              <el-table-column prop="id" label="ID" width="70" />
-              <el-table-column prop="type" label="类型" width="90" />
-              <el-table-column prop="code" label="卡券码" min-width="130" />
-              <el-table-column label="状态" width="90">
-                <template slot-scope="{ row }">
-                  <el-tag :type="couponStatusType(row.status)" size="small">{{ couponStatusLabel(row.status) }}</el-tag>
-                </template>
-              </el-table-column>
-              <el-table-column prop="trigger" label="来源" width="90" />
-              <el-table-column prop="grantedAt" label="发放时间" width="160" />
-            </el-table>
+    <!-- 学员详情:右侧抽屉(C 类) -->
+    <el-drawer :visible.sync="detailVisible" size="440px" :with-header="false">
+      <div class="detail-drawer" v-loading="detailLoading">
+        <div class="dw-head">
+          <div class="dw-title">
+            {{ detailUser && detailUser.name ? detailUser.name : '学员档案' }}
+            <el-tag size="small" :type="detailUser && detailUser.status === 'active' ? 'success' : 'info'" style="margin-left:8px">{{ detailUser && detailUser.status === 'active' ? '在训' : '已禁用' }}</el-tag>
           </div>
           </div>
-
-          <div class="detail-section">
-            <h4>完课证书进度(离场验收六项)</h4>
-            <div v-if="detailCert">
-              <el-alert :title="detailCert.eligible ? '已达标:可领取完课证书' : '未达标:完成以下全部项目后可领取证书'" :type="detailCert.eligible ? 'success' : 'warning'" :closable="false" show-icon style="margin-bottom:10px" />
-              <el-table :data="detailCert.items || []" size="small" border stripe style="width:100%">
-                <el-table-column prop="label" label="校验项" min-width="200" />
-                <el-table-column label="状态" width="120">
+          <el-button size="mini" @click="detailVisible = false">关闭</el-button>
+        </div>
+        <div class="dw-body">
+          <el-tabs v-model="detailTab">
+            <el-tab-pane label="基本信息" name="base">
+              <div class="kv"><span>学员编号</span><b>XY-{{ detailUser ? String(detailUser.id).padStart(4, '0') : '-' }}</b></div>
+              <div class="kv"><span>角色</span><b>{{ detailUser ? (roleLabel[detailUser.role] || detailUser.role) : '-' }}</b></div>
+              <div class="kv"><span>班级</span><b>{{ detailUser ? classNameOf(detailUser.classId) : '-' }}</b></div>
+              <div class="kv"><span>分组</span><b>{{ detailUser ? (detailUser.groupName || '-') : '-' }}</b></div>
+              <div class="kv"><span>联系电话</span><b>{{ detailUser ? (maskPhone(detailUser.phone)) : '-' }}</b></div>
+              <div class="kv"><span>校友校验</span><b><el-tag size="small" :type="detailUser ? alumniType(detailUser.alumniVerify) : 'info'">{{ detailUser ? alumniLabel(detailUser.alumniVerify) : '-' }}</el-tag></b></div>
+            </el-tab-pane>
+            <el-tab-pane label="培训记录" name="records">
+              <h5 class="dw-sec">报名单</h5>
+              <el-table :data="detailEnrollments" size="small" style="width:100%">
+                <el-table-column prop="courseId" label="课程ID" width="70" />
+                <el-table-column label="状态" width="100">
                   <template slot-scope="{ row }">
                   <template slot-scope="{ row }">
-                    <el-tag :type="row.ok ? 'success' : 'info'" size="small">{{ row.ok ? '已完成' : '未完成' }}</el-tag>
+                    <el-tag :type="enrollStatusType(row.status)" size="small">{{ enrollStatusLabel(row.status) }}</el-tag>
                   </template>
                   </template>
                 </el-table-column>
                 </el-table-column>
+                <el-table-column prop="createdAt" label="报名时间" width="150" />
               </el-table>
               </el-table>
-            </div>
-          </div>
+              <h5 class="dw-sec">完课证书进度</h5>
+              <div v-if="detailCert">
+                <el-alert :title="detailCert.eligible ? '已达标:可领取完课证书' : '未达标:完成以下全部项目后可领取证书'" :type="detailCert.eligible ? 'success' : 'warning'" :closable="false" show-icon style="margin-bottom:10px" />
+                <el-table :data="detailCert.items || []" size="small" style="width:100%">
+                  <el-table-column prop="label" label="校验项" min-width="140" />
+                  <el-table-column label="状态" width="90">
+                    <template slot-scope="{ row }">
+                      <el-tag :type="row.ok ? 'success' : 'info'" size="small">{{ row.ok ? '已完成' : '未完成' }}</el-tag>
+                    </template>
+                  </el-table-column>
+                </el-table>
+              </div>
+              <div v-else class="empty-inline">暂无证书进度</div>
+            </el-tab-pane>
+            <el-tab-pane label="来源信息" name="source">
+              <div class="note">来源信息:<b>管理员可见</b>,仅统计聚合值;后台学员来源统计与学员端零互链,不展示邀请奖励数据。</div>
+              <div class="kv"><span>来源</span><b>{{ detailUser && detailUser.inviteCode ? '邀请码 ' + detailUser.inviteCode : '自然注册' }}</b></div>
+            </el-tab-pane>
+          </el-tabs>
+        </div>
+        <div class="dw-foot">
+          <el-button @click="detailVisible = false">取消</el-button>
+          <el-button type="primary" @click="$message.info('保存资料')">保存资料</el-button>
         </div>
         </div>
-        <span slot="footer">
-          <el-button @click="detailVisible = false">关 闭</el-button>
-        </span>
-      </el-dialog>
-   </div>
- </template>
+      </div>
+    </el-drawer>
+  </div>
+</template>
 
 
 <script>
 <script>
 import { userList, setUserStatus, userDetail } from '@/api/user'
 import { userList, setUserStatus, userDetail } from '@/api/user'
@@ -170,11 +207,13 @@ export default {
     return {
     return {
       list: [],
       list: [],
       loading: false,
       loading: false,
+      state: 'normal', // normal / empty / error
       total: 0,
       total: 0,
       page: 1,
       page: 1,
       pageSize: 20,
       pageSize: 20,
-      filters: { classId: '', role: '', status: '' },
+      filters: { keyword: '', phone: '', role: '', status: '' },
       classes: [],
       classes: [],
+      selected: [],
       moveVisible: false,
       moveVisible: false,
       moveForm: { uid: null, classId: null },
       moveForm: { uid: null, classId: null },
       moveUserName: '',
       moveUserName: '',
@@ -183,9 +222,9 @@ export default {
       roleTagMap: { student: 'info', assistant: 'warning', lecturer: '', admin: 'danger' },
       roleTagMap: { student: 'info', assistant: 'warning', lecturer: '', admin: 'danger' },
       detailVisible: false,
       detailVisible: false,
       detailLoading: false,
       detailLoading: false,
+      detailTab: 'base',
       detailUser: null,
       detailUser: null,
       detailEnrollments: [],
       detailEnrollments: [],
-      detailCoupons: [],
       detailCert: null
       detailCert: null
     }
     }
   },
   },
@@ -202,10 +241,7 @@ export default {
     },
     },
     classNameOf: function (classId) {
     classNameOf: function (classId) {
       if (!classId) return '-'
       if (!classId) return '-'
-      var self = this
-      var c = self.classes.find(function (item) {
-        return item.id === classId
-      })
+      var c = this.classes.find(function (item) { return item.id === classId })
       return c ? c.name : '-'
       return c ? c.name : '-'
     },
     },
     alumniType: function (v) {
     alumniType: function (v) {
@@ -228,27 +264,45 @@ export default {
       var map = { pending: '待支付', paid: '已支付', reviewing: '进班待审核', confirmed: '已进班', rejected: '进班被拒', cancelled: '已取消' }
       var map = { pending: '待支付', paid: '已支付', reviewing: '进班待审核', confirmed: '已进班', rejected: '进班被拒', cancelled: '已取消' }
       return map[s] || s || '-'
       return map[s] || s || '-'
     },
     },
-    couponStatusType: function (s) {
-      var map = { unused: 'success', used: 'info', expired: 'danger' }
-      return map[s] || 'info'
+    maskPhone: function (phone) {
+      if (!phone) return '-'
+      var s = String(phone)
+      if (s.length < 7) return s.slice(0, 3) + '****' + s.slice(-2)
+      return s.slice(0, 3) + '****' + s.slice(-4)
     },
     },
-    couponStatusLabel: function (s) {
-      var map = { unused: '未使用', used: '已使用', expired: '已过期' }
-      return map[s] || s || '-'
+    search: function () {
+      this.page = 1
+      this.fetchList()
+    },
+    resetFilters: function () {
+      this.filters = { keyword: '', phone: '', role: '', status: '' }
+      this.page = 1
+      this.fetchList()
+    },
+    onSelectionChange: function (rows) {
+      this.selected = rows
+    },
+    clearSelection: function () {
+      this.selected = []
+    },
+    rowClass: function () {
+      return ''
+    },
+    onRowClick: function (row) {
+      this.openDetail(row)
     },
     },
     openDetail: function (row) {
     openDetail: function (row) {
       var self = this
       var self = this
       self.detailVisible = true
       self.detailVisible = true
       self.detailLoading = true
       self.detailLoading = true
+      self.detailTab = 'base'
       self.detailUser = row
       self.detailUser = row
       self.detailEnrollments = []
       self.detailEnrollments = []
-      self.detailCoupons = []
       self.detailCert = null
       self.detailCert = null
       userDetail(row.id).then(function (res) {
       userDetail(row.id).then(function (res) {
         var data = res.data || {}
         var data = res.data || {}
         self.detailUser = data.user || row
         self.detailUser = data.user || row
         self.detailEnrollments = data.enrollments || []
         self.detailEnrollments = data.enrollments || []
-        self.detailCoupons = data.coupons || []
         self.detailCert = data.cert || null
         self.detailCert = data.cert || null
       }).catch(function () {
       }).catch(function () {
         self.$message.error('获取学员详情失败')
         self.$message.error('获取学员详情失败')
@@ -261,13 +315,18 @@ export default {
       self.loading = true
       self.loading = true
       var params = {}
       var params = {}
       if (self.filters.classId) params.classId = self.filters.classId
       if (self.filters.classId) params.classId = self.filters.classId
+      if (self.filters.keyword) params.keyword = self.filters.keyword
+      if (self.filters.phone) params.phone = self.filters.phone
       if (self.filters.role) params.role = self.filters.role
       if (self.filters.role) params.role = self.filters.role
       if (self.filters.status) params.status = self.filters.status
       if (self.filters.status) params.status = self.filters.status
       userList(params).then(function (res) {
       userList(params).then(function (res) {
         self.list = res.data || []
         self.list = res.data || []
         self.total = self.list.length
         self.total = self.list.length
+        self.state = self.list.length > 0 ? 'normal' : 'empty'
+        self.selected = []
       }).catch(function () {
       }).catch(function () {
         self.$message.error('获取学员列表失败')
         self.$message.error('获取学员列表失败')
+        self.state = 'error'
       }).finally(function () {
       }).finally(function () {
         self.loading = false
         self.loading = false
       })
       })
@@ -286,10 +345,9 @@ export default {
       }).catch(function () {})
       }).catch(function () {})
     },
     },
     openMoveClass: function (row) {
     openMoveClass: function (row) {
-      var self = this
-      self.moveForm = { uid: row.id, classId: row.classId || null }
-      self.moveUserName = row.name
-      self.moveVisible = true
+      this.moveForm = { uid: row.id, classId: row.classId || null }
+      this.moveUserName = row.name
+      this.moveVisible = true
     },
     },
     handleMoveClass: function () {
     handleMoveClass: function () {
       var self = this
       var self = this
@@ -309,43 +367,202 @@ export default {
 </script>
 </script>
 
 
 <style scoped>
 <style scoped>
-.page-header {
+.page-container {
+  display: flex;
+  flex-direction: column;
+  gap: 16px;
+}
+
+.toolbar {
   display: flex;
   display: flex;
   justify-content: space-between;
   justify-content: space-between;
   align-items: center;
   align-items: center;
-  margin-bottom: 16px;
-  flex-wrap: wrap;
-  gap: 8px;
+}
+.toolbar-count {
+  font-size: 12px;
+  color: #6B7B8C;
 }
 }
 
 
-.page-title {
-  margin: 0;
-  font-size: 18px;
+.card {
+  background: #FFFFFF;
+  border: 1px solid #DCE7F1;
+  border-radius: 8px;
+  box-shadow: 0 2px 10px rgba(30, 58, 95, 0.06);
+  padding: 16px;
+}
+
+.filter-card .fr {
+  display: flex;
+  align-items: center;
+  margin-bottom: 12px;
+}
+.filter-card .fr:last-child {
+  margin-bottom: 0;
+}
+.filter-card label {
+  width: 100px;
+  flex: none;
+  text-align: right;
+  padding-right: 12px;
+  font-size: 14px;
   font-weight: 600;
   font-weight: 600;
+  color: #1E3A5F;
+}
+.filter-card .fr-label {
+  width: auto;
+  text-align: left;
+  padding-left: 16px;
+  padding-right: 12px;
 }
 }
 
 
-.page-filters {
+.batch-bar {
   display: flex;
   display: flex;
+  justify-content: space-between;
   align-items: center;
   align-items: center;
+  padding: 8px 16px;
+  background: #E8F3FC;
+  border: 1px solid #2E6FA8;
+  border-radius: 4px;
+  font-size: 13px;
+  color: #1E3A5F;
+}
+.batch-bar b {
+  color: #2E6FA8;
+}
+
+.link {
+  color: #2E6FA8;
+  cursor: pointer;
+}
+.op-sep {
+  color: #C3D2DF;
+  margin: 0 6px;
 }
 }
 
 
 .tips {
 .tips {
   font-size: 12px;
   font-size: 12px;
-  color: #909399;
+  color: #6B7B8C;
   margin-top: 8px;
   margin-top: 8px;
   line-height: 1.4;
   line-height: 1.4;
 }
 }
 
 
-.detail-section {
-  margin-bottom: 20px;
+.empty-state {
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  gap: 10px;
+  padding: 40px 0;
+}
+.empty-ico {
+  width: 60px;
+  height: 60px;
+  border-radius: 50%;
+  background: #E8F3FC;
+  position: relative;
+}
+.empty-ico::after {
+  content: '';
+  position: absolute;
+  left: 17px;
+  top: 17px;
+  width: 26px;
+  height: 26px;
+  border: 3px solid #0F766E;
+  border-radius: 5px;
+}
+.empty-state h4 {
+  font-size: 16px;
+  color: #1E3A5F;
+  margin: 0;
+}
+.empty-state p {
+  font-size: 14px;
+  color: #6B7B8C;
+  margin: 0;
+}
+.empty-actions {
+  display: flex;
+  gap: 8px;
 }
 }
 
 
-.detail-section h4 {
-  margin: 0 0 10px;
+.error-banner {
+  background: #FDE8E8;
+  border: 1px solid #C0392B;
+  color: #C0392B;
+  padding: 10px 14px;
+  border-radius: 4px;
   font-size: 14px;
   font-size: 14px;
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  margin-top: 12px;
+}
+
+.detail-drawer {
+  display: flex;
+  flex-direction: column;
+  height: 100%;
+}
+.dw-head {
+  height: 56px;
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+  padding: 0 20px;
+  border-bottom: 1px solid #DCE7F1;
+  flex-shrink: 0;
+}
+.dw-title {
+  font-size: 16px;
+  font-weight: 700;
+  color: #1E3A5F;
+}
+.dw-body {
+  flex: 1;
+  overflow: auto;
+  padding: 16px 20px;
+}
+.dw-sec {
+  font-size: 13px;
   font-weight: 600;
   font-weight: 600;
   color: #1E3A5F;
   color: #1E3A5F;
   border-left: 3px solid #2E6FA8;
   border-left: 3px solid #2E6FA8;
   padding-left: 8px;
   padding-left: 8px;
+  margin: 16px 0 10px;
+}
+.kv {
+  display: flex;
+  line-height: 40px;
+  border-bottom: 1px solid #DCE7F1;
+  font-size: 14px;
+}
+.kv span {
+  width: 100px;
+  color: #6B7B8C;
+  flex: none;
+}
+.note {
+  background: #E8F3FC;
+  border-left: 3px solid #2E6FA8;
+  padding: 8px 12px;
+  font-size: 12px;
+  color: #3B5A78;
+  margin-bottom: 12px;
+}
+.dw-foot {
+  height: 64px;
+  border-top: 1px solid #DCE7F1;
+  display: flex;
+  align-items: center;
+  justify-content: flex-end;
+  gap: 8px;
+  padding: 0 20px;
+  flex-shrink: 0;
+}
+.empty-inline {
+  font-size: 13px;
+  color: #6B7B8C;
+  text-align: center;
+  padding: 20px 0;
 }
 }
 </style>
 </style>