完成代码路径重构
This commit is contained in:
@@ -1,157 +0,0 @@
|
||||
<template>
|
||||
<view class="admin-page">
|
||||
<view class="filter-card">
|
||||
<view class="filter-row">
|
||||
<view class="filter-item">
|
||||
<text class="label">代理商查询:</text>
|
||||
<input class="filter-input" placeholder="请输入姓名、手机号或UID" />
|
||||
</view>
|
||||
<view class="filter-btns">
|
||||
<button class="btn primary" @click="onSearch">查询</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="content-card">
|
||||
<view class="action-bar">
|
||||
<button class="btn primary small" @click="onAdd">添加代理商</button>
|
||||
</view>
|
||||
<view class="table-container">
|
||||
<view class="table-header">
|
||||
<view class="col col-uid"><text>用户UID</text></view>
|
||||
<view class="col col-avatar"><text>头像</text></view>
|
||||
<view class="col col-name"><text>名称</text></view>
|
||||
<view class="col col-ratio"><text>分佣比例</text></view>
|
||||
<view class="col col-count"><text>员工数量</text></view>
|
||||
<view class="col col-time"><text>过期时间</text></view>
|
||||
<view class="col col-status"><text>状态</text></view>
|
||||
<view class="col col-ops"><text>操作</text></view>
|
||||
</view>
|
||||
<view class="table-body">
|
||||
<view v-for="item in pagedList" :key="item.uid" class="table-row">
|
||||
<view class="col col-uid"><text>{{ item.uid }}</text></view>
|
||||
<view class="col col-avatar">
|
||||
<image class="avatar-img" src="/static/logo.png" mode="aspectFill" />
|
||||
</view>
|
||||
<view class="col col-name"><text>{{ item.name }}</text></view>
|
||||
<view class="col col-ratio"><text>{{ item.ratio }}%</text></view>
|
||||
<view class="col col-count"><text>{{ item.staffCount }}</text></view>
|
||||
<view class="col col-time"><text>{{ item.endTime }}</text></view>
|
||||
<view class="col col-status">
|
||||
<switch :checked="item.status" color="#1890ff" scale="0.8" />
|
||||
</view>
|
||||
<view class="col col-ops">
|
||||
<text class="op-link">编辑</text>
|
||||
<text class="op-divider">|</text>
|
||||
<text class="op-link">查看</text>
|
||||
<text class="op-divider">|</text>
|
||||
<text class="op-link">员工</text>
|
||||
<text class="op-divider">|</text>
|
||||
<text class="op-link">删除</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<CommonPagination
|
||||
v-if="total > 0"
|
||||
:total="total"
|
||||
:loading="false"
|
||||
:currentPage="currentPage"
|
||||
:pageSize="pageSize"
|
||||
:pageSizeOptionLabels="pageSizeOptionLabels"
|
||||
:pageSizeIndex="pageSizeIndex"
|
||||
:visiblePages="visiblePages"
|
||||
:totalPage="totalPage"
|
||||
:jumpPageInput="jumpPageInput"
|
||||
@page-size-change="handlePageSizeChange"
|
||||
@page-change="handlePageChange"
|
||||
@update:jumpPageInput="(val: string) => { jumpPageInput.value = val }"
|
||||
@jump-page="handleJumpPage"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script setup lang="uts">
|
||||
import { ref, computed } from 'vue'
|
||||
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||
|
||||
// ========== MOCK DATA START ==========
|
||||
// TODO: 接真实接口时替换此处 agentList 为 fetchAgentList() 调用
|
||||
const agentList = ref([
|
||||
{ uid: '60569', name: 'cs2020', ratio: 50, staffCount: 1, endTime: '2026-01-01', status: true },
|
||||
{ uid: '60570', name: '张伟', ratio: 45, staffCount: 3, endTime: '2026-06-30', status: true },
|
||||
{ uid: '60571', name: '李华', ratio: 40, staffCount: 5, endTime: '2026-12-31', status: true },
|
||||
{ uid: '60572', name: '王芳', ratio: 38, staffCount: 2, endTime: '2027-03-01', status: false },
|
||||
{ uid: '60573', name: '赵磊', ratio: 42, staffCount: 7, endTime: '2026-09-30', status: true },
|
||||
{ uid: '60574', name: '陈浩', ratio: 35, staffCount: 0, endTime: '2026-04-15', status: true },
|
||||
{ uid: '60575', name: '刘娜', ratio: 48, staffCount: 4, endTime: '2026-08-01', status: true },
|
||||
{ uid: '60576', name: '黄明', ratio: 33, staffCount: 6, endTime: '2027-01-31', status: false },
|
||||
{ uid: '60577', name: '周静', ratio: 52, staffCount: 1, endTime: '2026-11-30', status: true },
|
||||
{ uid: '60578', name: '吴强', ratio: 30, staffCount: 9, endTime: '2026-07-15', status: true },
|
||||
{ uid: '60579', name: '郑丽', ratio: 55, staffCount: 2, endTime: '2026-03-31', status: true },
|
||||
{ uid: '60580', name: '孙勇', ratio: 28, staffCount: 11, endTime: '2027-06-30', status: true },
|
||||
{ uid: '60581', name: '朱婷', ratio: 46, staffCount: 3, endTime: '2026-10-31', status: false },
|
||||
{ uid: '60582', name: '马林', ratio: 37, staffCount: 0, endTime: '2026-05-01', status: true },
|
||||
{ uid: '60583', name: '胡倩', ratio: 41, staffCount: 8, endTime: '2026-02-28', status: true },
|
||||
{ uid: '60584', name: '高峰', ratio: 36, staffCount: 4, endTime: '2027-09-30', status: true },
|
||||
{ uid: '60585', name: '梁雪', ratio: 49, staffCount: 2, endTime: '2026-06-15', status: false },
|
||||
{ uid: '60586', name: '邓超', ratio: 32, staffCount: 6, endTime: '2027-02-01', status: true },
|
||||
{ uid: '60587', name: '彭宇', ratio: 44, staffCount: 5, endTime: '2026-08-30', status: true },
|
||||
{ uid: '60588', name: '曹芸', ratio: 39, staffCount: 1, endTime: '2026-12-01', status: true },
|
||||
])
|
||||
// ========== MOCK DATA END ==========
|
||||
|
||||
// ========== PAGINATION STATE ==========
|
||||
const currentPage = ref(1)
|
||||
const pageSize = ref(15)
|
||||
const jumpPageInput = ref('')
|
||||
const pageSizeOptions = [10, 15, 20, 30, 50]
|
||||
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
|
||||
const pageSizeIndex = computed(() => { const idx = pageSizeOptions.indexOf(pageSize.value); return idx >= 0 ? idx : 0 })
|
||||
const total = computed(() => agentList.value.length)
|
||||
const totalPage = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
||||
const pagedList = computed(() => {
|
||||
const start = (currentPage.value - 1) * pageSize.value
|
||||
return agentList.value.slice(start, start + pageSize.value)
|
||||
})
|
||||
const visiblePages = computed((): number[] => {
|
||||
const t = totalPage.value; const cur = currentPage.value
|
||||
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
|
||||
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
|
||||
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
|
||||
return [1, -1, cur - 1, cur, cur + 1, -1, t]
|
||||
})
|
||||
const handlePageChange = (p: number) => { currentPage.value = p }
|
||||
const handlePageSizeChange = (e: any) => {
|
||||
const idx = Number(e.detail.value)
|
||||
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
|
||||
currentPage.value = 1
|
||||
}
|
||||
const handleJumpPage = () => {
|
||||
const p = parseInt(jumpPageInput.value)
|
||||
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
|
||||
}
|
||||
// ========== END PAGINATION STATE ==========
|
||||
|
||||
function onSearch() { uni.showToast({ title: '查询中...', icon: 'none' }) }
|
||||
function onAdd() { uni.showToast({ title: '添加中...', icon: 'none' }) }
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.admin-page { padding: 0; }
|
||||
.filter-card { background: #fff; padding: 24px; margin-bottom: 16px; border-radius: 4px; }
|
||||
.filter-row { display: flex; flex-direction: row; align-items: center; gap: 24px; }
|
||||
.label { font-size: 14px; color: #333; }
|
||||
.filter-input { border: 1px solid #d9d9d9; height: 32px; width: 220px; padding: 0 12px; font-size: 14px; }
|
||||
.btn { height: 32px; padding: 0 16px; font-size: 14px; border: 1px solid #d9d9d9; background: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
|
||||
.btn.primary { background: #1890ff; border-color: #1890ff; color: #fff; }
|
||||
.content-card { background: #fff; border-radius: 4px; }
|
||||
.action-bar { padding: 16px 24px; }
|
||||
.table-container { padding: 0 24px 24px; }
|
||||
.table-header { display: flex; flex-direction: row; background: #f8faff; border-bottom: 1px solid #f0f0f0; padding: 12px 0; }
|
||||
.table-row { display: flex; flex-direction: row; border-bottom: 1px solid #f0f0f0; padding: 12px 0; align-items: center; &:hover { background: #fafafa; } }
|
||||
.col { padding: 0 8px; font-size: 14px; color: #333; display: flex; align-items: center; }
|
||||
.col-uid { width: 80px; } .col-avatar { width: 80px; justify-content: center; } .col-name { width: 120px; } .col-ratio { width: 100px; justify-content: center; } .col-count { width: 100px; justify-content: center; } .col-time { width: 120px; justify-content: center; } .col-status { width: 80px; justify-content: center; }
|
||||
.col-ops { flex: 1; justify-content: flex-end; display: flex; flex-direction: row; }
|
||||
.avatar-img { width: 32px; height: 32px; border-radius: 2px; }
|
||||
.op-link { color: #1890ff; cursor: pointer; }
|
||||
.op-divider { color: #e8e8e8; margin: 0 8px; }
|
||||
</style>
|
||||
@@ -1,164 +0,0 @@
|
||||
<template>
|
||||
<view class="admin-page">
|
||||
<view class="filter-card">
|
||||
<view class="filter-row">
|
||||
<view class="filter-item">
|
||||
<text class="label">搜索:</text>
|
||||
<input class="filter-input" placeholder="请输入姓名、UID" />
|
||||
</view>
|
||||
<view class="filter-btns">
|
||||
<button class="btn primary" @click="onSearch">查询</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="content-card">
|
||||
<view class="tabs-row">
|
||||
<view v-for="(tab, index) in tabs" :key="index" class="tab-item" :class="{ active: activeTab === index }" @click="activeTab = index">
|
||||
<text>{{ tab }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="table-container">
|
||||
<view class="table-header">
|
||||
<view class="col col-uid"><text>用户UID</text></view>
|
||||
<view class="col col-name"><text>代理商名称</text></view>
|
||||
<view class="col col-phone"><text>代理商电话</text></view>
|
||||
<view class="col col-dept"><text>事业部名称</text></view>
|
||||
<view class="col col-img"><text>申请图片</text></view>
|
||||
<view class="col col-time"><text>申请时间</text></view>
|
||||
<view class="col col-status"><text>申请状态</text></view>
|
||||
<view class="col col-code"><text>邀请码</text></view>
|
||||
<view class="col col-ops"><text>操作</text></view>
|
||||
</view>
|
||||
<view class="table-body">
|
||||
<view v-for="item in pagedList" :key="item.uid" class="table-row">
|
||||
<view class="col col-uid"><text>{{ item.uid }}</text></view>
|
||||
<view class="col col-name"><text>{{ item.name }}</text></view>
|
||||
<view class="col col-phone"><text>{{ item.phone }}</text></view>
|
||||
<view class="col col-dept"><text>{{ item.deptName }}</text></view>
|
||||
<view class="col col-img">
|
||||
<image class="table-img" src="/static/logo.png" mode="aspectFill" />
|
||||
</view>
|
||||
<view class="col col-time"><text>{{ item.time }}</text></view>
|
||||
<view class="col col-status">
|
||||
<view class="status-tag"><text>{{ item.statusText }}</text></view>
|
||||
</view>
|
||||
<view class="col col-code"><view class="code-box"><text>{{ item.code }}</text></view></view>
|
||||
<view class="col col-ops">
|
||||
<text class="op-link">同意</text>
|
||||
<text class="op-divider">|</text>
|
||||
<text class="op-link">拒绝</text>
|
||||
<text class="op-divider">|</text>
|
||||
<text class="op-link">删除</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<CommonPagination
|
||||
v-if="total > 0"
|
||||
:total="total"
|
||||
:loading="false"
|
||||
:currentPage="currentPage"
|
||||
:pageSize="pageSize"
|
||||
:pageSizeOptionLabels="pageSizeOptionLabels"
|
||||
:pageSizeIndex="pageSizeIndex"
|
||||
:visiblePages="visiblePages"
|
||||
:totalPage="totalPage"
|
||||
:jumpPageInput="jumpPageInput"
|
||||
@page-size-change="handlePageSizeChange"
|
||||
@page-change="handlePageChange"
|
||||
@update:jumpPageInput="(val: string) => { jumpPageInput.value = val }"
|
||||
@jump-page="handleJumpPage"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script setup lang="uts">
|
||||
import { ref, computed } from 'vue'
|
||||
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||
|
||||
const activeTab = ref(0)
|
||||
const tabs = ['全部', '申请中', '已同意', '已拒绝']
|
||||
|
||||
// ========== MOCK DATA START ==========
|
||||
// TODO: 接真实接口时替换此处 applyList 为 fetchApplyList() 调用
|
||||
const applyList = ref([
|
||||
{ uid: '81806', name: '测试测试', phone: '19910205954', deptName: '26991', time: '2026-01-08 15:30:39', statusText: '申请中', code: '70623142' },
|
||||
{ uid: '81807', name: '张三', phone: '13812345678', deptName: '北京事业部', time: '2026-01-10 09:20:15', statusText: '已同意', code: '80731253' },
|
||||
{ uid: '81808', name: '李四', phone: '13987654321', deptName: '上海事业部', time: '2026-01-12 14:05:33', statusText: '已拒绝', code: '90842364' },
|
||||
{ uid: '81809', name: '王五', phone: '15012341234', deptName: '广州事业部', time: '2026-01-15 11:45:20', statusText: '申请中', code: '10953475' },
|
||||
{ uid: '81810', name: '赵六', phone: '18600001111', deptName: '深圳事业部', time: '2026-01-18 08:30:00', statusText: '已同意', code: '21064586' },
|
||||
{ uid: '81811', name: '孙七', phone: '17712349876', deptName: '成都事业部', time: '2026-01-20 16:15:44', statusText: '已同意', code: '32175697' },
|
||||
{ uid: '81812', name: '周八', phone: '13300002222', deptName: '杭州事业部', time: '2026-01-22 10:55:30', statusText: '申请中', code: '43286708' },
|
||||
{ uid: '81813', name: '吴九', phone: '15566667777', deptName: '武汉事业部', time: '2026-01-25 13:40:18', statusText: '已拒绝', code: '54397819' },
|
||||
{ uid: '81814', name: '郑十', phone: '18899998888', deptName: '南京事业部', time: '2026-01-28 09:00:05', statusText: '申请中', code: '65408920' },
|
||||
{ uid: '81815', name: '冯云', phone: '13712348765', deptName: '西安事业部', time: '2026-02-01 15:20:33', statusText: '已同意', code: '76519031' },
|
||||
{ uid: '81816', name: '陈霞', phone: '15087651234', deptName: '重庆事业部', time: '2026-02-05 11:10:22', statusText: '申请中', code: '87620142' },
|
||||
{ uid: '81817', name: '蒋峰', phone: '13500004444', deptName: '郑州事业部', time: '2026-02-08 14:35:49', statusText: '已同意', code: '98731253' },
|
||||
{ uid: '81818', name: '卫林', phone: '17656785678', deptName: '长沙事业部', time: '2026-02-10 08:45:11', statusText: '已拒绝', code: '09842364' },
|
||||
{ uid: '81819', name: '蒋彪', phone: '18211112222', deptName: '合肥事业部', time: '2026-02-12 17:00:00', statusText: '申请中', code: '10953476' },
|
||||
{ uid: '81820', name: '沈辉', phone: '13655554444', deptName: '天津事业部', time: '2026-02-15 12:30:40', statusText: '已同意', code: '21064587' },
|
||||
{ uid: '81821', name: '韩磊', phone: '15999990000', deptName: '苏州事业部', time: '2026-02-18 09:55:28', statusText: '已同意', code: '32175698' },
|
||||
{ uid: '81822', name: '杨红', phone: '17811122233', deptName: '宁波事业部', time: '2026-02-20 16:40:15', statusText: '申请中', code: '43286709' },
|
||||
{ uid: '81823', name: '秦波', phone: '13234561234', deptName: '厦门事业部', time: '2026-02-22 11:20:06', statusText: '已拒绝', code: '54397820' },
|
||||
{ uid: '81824', name: '许丹', phone: '18777776666', deptName: '青岛事业部', time: '2026-02-25 14:05:50', statusText: '已同意', code: '65408921' },
|
||||
{ uid: '81825', name: '何强', phone: '15344443333', deptName: '福州事业部', time: '2026-02-28 08:15:38', statusText: '申请中', code: '76519032' },
|
||||
])
|
||||
// ========== MOCK DATA END ==========
|
||||
|
||||
// ========== PAGINATION STATE ==========
|
||||
const currentPage = ref(1)
|
||||
const pageSize = ref(15)
|
||||
const jumpPageInput = ref('')
|
||||
const pageSizeOptions = [10, 15, 20, 30, 50]
|
||||
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
|
||||
const pageSizeIndex = computed(() => { const idx = pageSizeOptions.indexOf(pageSize.value); return idx >= 0 ? idx : 0 })
|
||||
const total = computed(() => applyList.value.length)
|
||||
const totalPage = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
||||
const pagedList = computed(() => {
|
||||
const start = (currentPage.value - 1) * pageSize.value
|
||||
return applyList.value.slice(start, start + pageSize.value)
|
||||
})
|
||||
const visiblePages = computed((): number[] => {
|
||||
const t = totalPage.value; const cur = currentPage.value
|
||||
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
|
||||
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
|
||||
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
|
||||
return [1, -1, cur - 1, cur, cur + 1, -1, t]
|
||||
})
|
||||
const handlePageChange = (p: number) => { currentPage.value = p }
|
||||
const handlePageSizeChange = (e: any) => {
|
||||
const idx = Number(e.detail.value)
|
||||
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
|
||||
currentPage.value = 1
|
||||
}
|
||||
const handleJumpPage = () => {
|
||||
const p = parseInt(jumpPageInput.value)
|
||||
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
|
||||
}
|
||||
// ========== END PAGINATION STATE ==========
|
||||
|
||||
function onSearch() { uni.showToast({ title: '查询中...', icon: 'none' }) }
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.admin-page { padding: 0; }
|
||||
.filter-card { background: #fff; padding: 24px; margin-bottom: 16px; border-radius: 4px; }
|
||||
.filter-row { display: flex; flex-direction: row; align-items: center; gap: 24px; }
|
||||
.label { font-size: 14px; color: #333; }
|
||||
.filter-input { border: 1px solid #d9d9d9; height: 32px; width: 220px; padding: 0 12px; font-size: 14px; }
|
||||
.btn { height: 32px; padding: 0 16px; font-size: 14px; border: 1px solid #d9d9d9; background: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
|
||||
.btn.primary { background: #1890ff; border-color: #1890ff; color: #fff; }
|
||||
.content-card { background: #fff; border-radius: 4px; }
|
||||
.tabs-row { display: flex; flex-direction: row; padding: 0 24px; border-bottom: 1px solid #f0f0f0; }
|
||||
.tab-item { padding: 16px 20px; cursor: pointer; position: relative; text { font-size: 15px; color: #666; } &.active { text { color: #1890ff; font-weight: 500; } &::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 2px; background: #1890ff; } } }
|
||||
.table-container { padding: 24px; }
|
||||
.table-header { display: flex; flex-direction: row; background: #f8faff; border-bottom: 1px solid #f0f0f0; padding: 12px 0; }
|
||||
.table-row { display: flex; flex-direction: row; border-bottom: 1px solid #f0f0f0; padding: 12px 0; align-items: center; &:hover { background: #fafafa; } }
|
||||
.col { padding: 0 8px; font-size: 14px; color: #333; display: flex; align-items: center; }
|
||||
.col-uid { width: 80px; } .col-name { width: 120px; } .col-phone { width: 120px; } .col-dept { width: 120px; } .col-img { width: 80px; justify-content: center; } .col-time { width: 160px; justify-content: center; } .col-status { width: 100px; justify-content: center; } .col-code { width: 100px; justify-content: center; }
|
||||
.col-ops { flex: 1; justify-content: flex-end; display: flex; flex-direction: row; }
|
||||
.table-img { width: 32px; height: 32px; border-radius: 2px; }
|
||||
.status-tag { border: 1px solid #1890ff; color: #1890ff; padding: 2px 8px; border-radius: 4px; font-size: 12px; }
|
||||
.code-box { border: 1px solid #d9d9d9; padding: 2px 8px; border-radius: 4px; font-size: 12px; background: #fafafa; }
|
||||
.op-link { color: #1890ff; cursor: pointer; }
|
||||
.op-divider { color: #e8e8e8; margin: 0 8px; }
|
||||
</style>
|
||||
@@ -1,157 +0,0 @@
|
||||
<template>
|
||||
<view class="admin-page">
|
||||
<view class="filter-card">
|
||||
<view class="filter-row">
|
||||
<view class="filter-item">
|
||||
<text class="label">搜索:</text>
|
||||
<input class="filter-input" placeholder="请输入姓名、UID" />
|
||||
</view>
|
||||
<view class="filter-btns">
|
||||
<button class="btn primary" @click="onSearch">查询</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="content-card">
|
||||
<view class="action-bar">
|
||||
<button class="btn primary small" @click="onAdd">添加事业部</button>
|
||||
</view>
|
||||
<view class="table-container">
|
||||
<view class="table-header">
|
||||
<view class="col col-uid"><text>用户UID</text></view>
|
||||
<view class="col col-avatar"><text>头像</text></view>
|
||||
<view class="col col-name"><text>名称</text></view>
|
||||
<view class="col col-code"><text>邀请码</text></view>
|
||||
<view class="col col-ratio"><text>分销比例</text></view>
|
||||
<view class="col col-count"><text>代理商数量</text></view>
|
||||
<view class="col col-time"><text>截止时间</text></view>
|
||||
<view class="col col-status"><text>状态</text></view>
|
||||
<view class="col col-ops"><text>操作</text></view>
|
||||
</view>
|
||||
<view class="table-body">
|
||||
<view v-for="item in pagedList" :key="item.uid" class="table-row">
|
||||
<view class="col col-uid"><text>{{ item.uid }}</text></view>
|
||||
<view class="col col-avatar">
|
||||
<image class="avatar-img" src="/static/logo.png" mode="aspectFill" />
|
||||
</view>
|
||||
<view class="col col-name"><text>{{ item.name }}</text></view>
|
||||
<view class="col col-code"><text>{{ item.code }}</text></view>
|
||||
<view class="col col-ratio"><text>{{ item.ratio }}%</text></view>
|
||||
<view class="col col-count"><text>{{ item.agentCount }}</text></view>
|
||||
<view class="col col-time"><text>{{ item.endTime }}</text></view>
|
||||
<view class="col col-status">
|
||||
<switch :checked="item.status" color="#1890ff" scale="0.8" />
|
||||
</view>
|
||||
<view class="col col-ops">
|
||||
<text class="op-link">查看代理商</text>
|
||||
<text class="op-divider">|</text>
|
||||
<text class="op-link">编辑</text>
|
||||
<text class="op-divider">|</text>
|
||||
<text class="op-link">删除</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<CommonPagination
|
||||
v-if="total > 0"
|
||||
:total="total"
|
||||
:loading="false"
|
||||
:currentPage="currentPage"
|
||||
:pageSize="pageSize"
|
||||
:pageSizeOptionLabels="pageSizeOptionLabels"
|
||||
:pageSizeIndex="pageSizeIndex"
|
||||
:visiblePages="visiblePages"
|
||||
:totalPage="totalPage"
|
||||
:jumpPageInput="jumpPageInput"
|
||||
@page-size-change="handlePageSizeChange"
|
||||
@page-change="handlePageChange"
|
||||
@update:jumpPageInput="(val: string) => { jumpPageInput.value = val }"
|
||||
@jump-page="handleJumpPage"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script setup lang="uts">
|
||||
import { ref, computed } from 'vue'
|
||||
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||
|
||||
// ========== MOCK DATA START ==========
|
||||
// TODO: 接真实接口时替换此处 divisionList 为 fetchDivisionList() 调用
|
||||
const divisionList = ref([
|
||||
{ uid: '26991', name: '北京事业部', code: '70623142', ratio: 40, agentCount: 5, endTime: '2026-12-31', status: true },
|
||||
{ uid: '26992', name: '上海事业部', code: '80731253', ratio: 35, agentCount: 8, endTime: '2026-06-30', status: true },
|
||||
{ uid: '26993', name: '广州事业部', code: '90842364', ratio: 38, agentCount: 3, endTime: '2027-03-01', status: true },
|
||||
{ uid: '26994', name: '深圳事业部', code: '10953475', ratio: 42, agentCount: 12, endTime: '2026-09-30', status: false },
|
||||
{ uid: '26995', name: '成都事业部', code: '21064586', ratio: 30, agentCount: 2, endTime: '2026-08-15', status: true },
|
||||
{ uid: '26996', name: '杭州事业部', code: '32175697', ratio: 45, agentCount: 7, endTime: '2026-12-01', status: true },
|
||||
{ uid: '26997', name: '武汉事业部', code: '43286708', ratio: 33, agentCount: 4, endTime: '2027-01-01', status: true },
|
||||
{ uid: '26998', name: '南京事业部', code: '54397819', ratio: 36, agentCount: 6, endTime: '2026-11-30', status: false },
|
||||
{ uid: '26999', name: '西安事业部', code: '65408920', ratio: 40, agentCount: 1, endTime: '2026-07-31', status: true },
|
||||
{ uid: '27000', name: '重庆事业部', code: '76519031', ratio: 28, agentCount: 9, endTime: '2026-10-01', status: true },
|
||||
{ uid: '27001', name: '郑州事业部', code: '87620142', ratio: 32, agentCount: 3, endTime: '2026-05-31', status: true },
|
||||
{ uid: '27002', name: '长沙事业部', code: '98731253', ratio: 37, agentCount: 5, endTime: '2027-02-28', status: false },
|
||||
{ uid: '27003', name: '合肥事业部', code: '09842364', ratio: 41, agentCount: 2, endTime: '2026-04-30', status: true },
|
||||
{ uid: '27004', name: '天津事业部', code: '10953476', ratio: 39, agentCount: 10, endTime: '2026-12-31', status: true },
|
||||
{ uid: '27005', name: '苏州事业部', code: '21064587', ratio: 34, agentCount: 4, endTime: '2026-03-31', status: true },
|
||||
{ uid: '27006', name: '宁波事业部', code: '32175698', ratio: 43, agentCount: 6, endTime: '2027-06-30', status: true },
|
||||
{ uid: '27007', name: '厦门事业部', code: '43286709', ratio: 31, agentCount: 1, endTime: '2026-08-31', status: false },
|
||||
{ uid: '27008', name: '青岛事业部', code: '54397820', ratio: 44, agentCount: 7, endTime: '2026-02-28', status: true },
|
||||
{ uid: '27009', name: '福州事业部', code: '65408921', ratio: 29, agentCount: 3, endTime: '2027-04-30', status: true },
|
||||
{ uid: '27010', name: '昆明事业部', code: '76519032', ratio: 46, agentCount: 8, endTime: '2026-01-31', status: true },
|
||||
])
|
||||
// ========== MOCK DATA END ==========
|
||||
|
||||
// ========== PAGINATION STATE ==========
|
||||
const currentPage = ref(1)
|
||||
const pageSize = ref(15)
|
||||
const jumpPageInput = ref('')
|
||||
const pageSizeOptions = [10, 15, 20, 30, 50]
|
||||
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
|
||||
const pageSizeIndex = computed(() => { const idx = pageSizeOptions.indexOf(pageSize.value); return idx >= 0 ? idx : 0 })
|
||||
const total = computed(() => divisionList.value.length)
|
||||
const totalPage = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
||||
const pagedList = computed(() => {
|
||||
const start = (currentPage.value - 1) * pageSize.value
|
||||
return divisionList.value.slice(start, start + pageSize.value)
|
||||
})
|
||||
const visiblePages = computed((): number[] => {
|
||||
const t = totalPage.value; const cur = currentPage.value
|
||||
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
|
||||
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
|
||||
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
|
||||
return [1, -1, cur - 1, cur, cur + 1, -1, t]
|
||||
})
|
||||
const handlePageChange = (p: number) => { currentPage.value = p }
|
||||
const handlePageSizeChange = (e: any) => {
|
||||
const idx = Number(e.detail.value)
|
||||
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
|
||||
currentPage.value = 1
|
||||
}
|
||||
const handleJumpPage = () => {
|
||||
const p = parseInt(jumpPageInput.value)
|
||||
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
|
||||
}
|
||||
// ========== END PAGINATION STATE ==========
|
||||
|
||||
function onSearch() { uni.showToast({ title: '查询中...', icon: 'none' }) }
|
||||
function onAdd() { uni.showToast({ title: '添加中...', icon: 'none' }) }
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.admin-page { padding: 0; }
|
||||
.filter-card { background: #fff; padding: 24px; margin-bottom: 16px; border-radius: 4px; }
|
||||
.filter-row { display: flex; flex-direction: row; align-items: center; gap: 24px; }
|
||||
.label { font-size: 14px; color: #333; }
|
||||
.filter-input { border: 1px solid #d9d9d9; height: 32px; width: 220px; padding: 0 12px; font-size: 14px; }
|
||||
.btn { height: 32px; padding: 0 16px; font-size: 14px; border: 1px solid #d9d9d9; background: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
|
||||
.btn.primary { background: #1890ff; border-color: #1890ff; color: #fff; }
|
||||
.content-card { background: #fff; border-radius: 4px; }
|
||||
.action-bar { padding: 16px 24px; }
|
||||
.table-container { padding: 0 24px 24px; }
|
||||
.table-header { display: flex; flex-direction: row; background: #f8faff; border-bottom: 1px solid #f0f0f0; padding: 12px 0; }
|
||||
.table-row { display: flex; flex-direction: row; border-bottom: 1px solid #f0f0f0; padding: 12px 0; align-items: center; &:hover { background: #fafafa; } }
|
||||
.col { padding: 0 8px; font-size: 14px; color: #333; display: flex; align-items: center; }
|
||||
.col-uid { width: 80px; } .col-avatar { width: 80px; justify-content: center; } .col-name { width: 120px; } .col-code { width: 100px; justify-content: center; } .col-ratio { width: 100px; justify-content: center; } .col-count { width: 100px; justify-content: center; } .col-time { width: 120px; justify-content: center; } .col-status { width: 80px; justify-content: center; }
|
||||
.col-ops { flex: 1; justify-content: flex-end; display: flex; flex-direction: row; }
|
||||
.avatar-img { width: 32px; height: 32px; border-radius: 2px; }
|
||||
.op-link { color: #1890ff; cursor: pointer; }
|
||||
.op-divider { color: #e8e8e8; margin: 0 8px; }
|
||||
</style>
|
||||
Reference in New Issue
Block a user