完成90%页面分页组件的抽取

This commit is contained in:
2026-03-17 09:01:11 +08:00
parent 7e814d349e
commit 7211fcdfea
29 changed files with 2331 additions and 539 deletions

View File

@@ -1,21 +1,154 @@
<template>
<AdminLayout currentPage="data-logistics-company">
<view class="page">
<view class="header">
<text class="title">物流公司</text>
</view>
<view class="content">
<text class="tip">TODO: 物流公司</text>
<view class="admin-page-container">
<view class="page-card">
<view class="search-wrap">
<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: 0 0 60px;">ID</view>
<view class="th" style="flex: 2;">公司名称</view>
<view class="th" style="flex: 2;">编码</view>
<view class="th" style="flex: 1;">是否显示</view>
<view class="th" style="flex: 1;">排序</view>
<view class="th" style="flex: 2;">操作</view>
</view>
<view class="table-body">
<view v-for="item in pagedList" :key="item.id" class="tr">
<view class="td" style="flex: 0 0 60px;">{{ item.id }}</view>
<view class="td" style="flex: 2;">{{ item.name }}</view>
<view class="td" style="flex: 2;">{{ item.code }}</view>
<view class="td" style="flex: 1;">
<switch :checked="item.isshow" color="#1890ff" style="transform: scale(0.7);" />
</view>
<view class="td" style="flex: 1;">{{ item.sort }}</view>
<view class="td" style="flex: 2;">
<text class="action-btn" @click="onEdit(item)">编辑</text>
<text class="action-btn-del" @click="onDel(item)">删除</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>
</AdminLayout>
</template>
<script setup lang="uts">
import AdminLayout from '@/layouts/admin/AdminLayout.uvue'
</script>
<style scoped>
.page { padding: 0; }
.title { font-size: 18px; font-weight: 600; }
.tip { color: #999; margin-top: 8px; display: block; }
</style>
<script setup lang="uts">
import { ref, computed } from 'vue'
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
const searchKey = ref('')
type LogisticsItem = { id: number; name: string; code: string; isshow: boolean; sort: number }
// ========== MOCK DATA START ==========
// TODO: 接真实接口时替换此处 logisticsList 为 fetchLogisticsList() 调用
const logisticsList = ref<LogisticsItem[]>([
{ id: 20, name: '顺丰速递', code: 'SF', isshow: true, sort: 1 },
{ id: 19, name: '圆通速递', code: 'YTO', isshow: true, sort: 2 },
{ id: 18, name: '申通快递', code: 'STO', isshow: true, sort: 3 },
{ id: 17, name: '中通快递', code: 'ZTO', isshow: true, sort: 4 },
{ id: 16, name: '韵达速递', code: 'YUNDA', isshow: true, sort: 5 },
{ id: 15, name: '百世快递', code: 'BEST', isshow: true, sort: 6 },
{ id: 14, name: '极兔速递', code: 'JTEX', isshow: true, sort: 7 },
{ id: 13, name: '菜鸟快递', code: 'CAINIAO', isshow: true, sort: 8 },
{ id: 12, name: '京东快递', code: 'JD', isshow: true, sort: 9 },
{ id: 11, name: '丰网速运', code: 'FENGWANG', isshow: false, sort: 10 },
{ id: 10, name: '邮政快递包裹', code: 'YZPY', isshow: true, sort: 11 },
{ id: 9, name: 'EMS', code: 'EMS', isshow: true, sort: 12 },
{ id: 8, name: '德邦快递', code: 'DEPPON', isshow: true, sort: 13 },
{ id: 7, name: '壹米滴答', code: 'YMDD', isshow: false, sort: 14 },
{ id: 6, name: '安能快运', code: 'ANE', isshow: true, sort: 15 },
{ id: 5, name: '中远快运', code: 'COSCO', isshow: false, sort: 16 },
{ id: 4, name: '宅急送', code: 'ZJS', isshow: true, sort: 17 },
{ id: 3, name: '国通快递', code: 'GTO', isshow: true, sort: 18 },
{ id: 2, name: '明亮(品骏)', code: 'PINJUN', isshow: false, sort: 19 },
{ id: 1, name: '速尔快递', code: 'SURE', isshow: true, sort: 20 }
])
// ========== 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(() => logisticsList.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 logisticsList.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() { console.log('Search:', searchKey.value) }
function onAdd() { uni.showToast({ title: '添加物流公司', icon: 'none' }) }
function onEdit(item: LogisticsItem) { uni.showToast({ title: '编辑: ' + item.name, icon: 'none' }) }
function onDel(item: LogisticsItem) {
uni.showModal({ title: '提示', content: '确定删除该物流公司吗?', success: (res) => {
if (res.confirm) uni.showToast({ title: '已删除', icon: 'success' })
}})
}
</script>
<style scoped>
.admin-page-container { 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; padding-bottom: 20px; border-bottom: 1px solid #f0f0f0; margin-bottom: 20px; }
.search-item { display: flex; flex-direction: row; align-items: center; margin-right: 20px; }
.label { font-size: 14px; color: #606266; margin-right: 8px; }
.input { width: 220px; height: 32px; padding: 0 10px; border: 1px solid #dcdfe6; border-radius: 4px; font-size: 14px; }
.btn { height: 32px; padding: 0 15px; font-size: 14px; border-radius: 4px; border: none; }
.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: 13px; font-weight: bold; color: #515a6e; border-bottom: 1px solid #f0f0f0; text-align: center; }
.tr { display: flex; flex-direction: row; align-items: center; border-bottom: 1px solid #f0f0f0; min-height: 50px; }
.td { padding: 10px; font-size: 13px; color: #515a6e; text-align: center; }
.action-btn { font-size: 13px; color: #1890ff; margin-right: 8px; cursor: pointer; }
.action-btn-del { font-size: 13px; color: #ed4014; cursor: pointer; }
</style>

View File

@@ -30,7 +30,7 @@
</view>
<view class="table-body">
<view v-for="item in dataList" :key="item.id" class="table-row">
<view v-for="item in pagedList" :key="item.id" class="table-row">
<view class="col col-id"><text>{{ item.id }}</text></view>
<view class="col col-key"><text>{{ item.key }}</text></view>
<view class="col col-name"><text>{{ item.name }}</text></view>
@@ -45,13 +45,30 @@
</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>
</view>
</template>
<script setup lang="uts">
import { ref } from 'vue'
import { ref, computed } from 'vue'
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
const dataList = ref([
{ id: 49, key: 'routine_seckill_time', name: '秒杀时间段', desc: '秒杀时间段' },
@@ -66,8 +83,48 @@ const dataList = ref([
{ id: 65, key: 'admin_login_slide', name: '后台登录页面幻灯片', desc: '后台登录页面幻灯片' },
{ id: 66, key: 'uni_app_link', name: '前端页面链接', desc: '前端页面链接' },
{ id: 67, key: 'combination_banner', name: '拼团列表轮播图', desc: '拼团列表轮播图' },
{ id: 68, key: 'integral_shop_banner', name: '积分商城轮播图', desc: '积分商城轮播图' }
{ id: 68, key: 'integral_shop_banner', name: '积分商城轮播图', desc: '积分商城轮播图' },
{ id: 70, key: 'live_share_img', name: '直播分享图片', desc: '直播分享图片' },
{ id: 71, key: 'live_home_banner', name: '直播首页轮播图', desc: '直播首页轮播图' },
{ id: 72, key: 'user_welfare', name: '会员权益配置', desc: '会员权益配置' },
{ id: 73, key: 'presale_banner', name: '预售轮播图配置', desc: '预售轮播图配置' },
{ id: 74, key: 'share_image', name: '分享海报图片', desc: '分享海报图片' },
{ id: 75, key: 'coupon_banner', name: '优惠券列表轮播图', desc: '优惠券列表轮播图' },
{ id: 76, key: 'vip_privilege', name: 'VIP特权配置', desc: 'VIP特权配置' }
])
// ========== 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(() => dataList.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 dataList.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' })
@@ -203,7 +260,7 @@ function onDelete(item: any) {
.col-key { flex: 2; }
.col-name { flex: 2; }
.col-desc { flex: 2; }
.col-ops { flex: 2; justify-content: flex-end; }
.col-ops { flex: 2; justify-content: flex-end; flex-direction: row;}
.op-link {
color: #1890ff;

View File

@@ -28,7 +28,7 @@
</view>
<view class="table-body">
<view v-for="item in dataList" :key="item.id" class="table-row">
<view v-for="item in pagedList" :key="item.id" class="table-row">
<view class="col col-title"><text>{{ item.title }}</text></view>
<view class="col col-desc"><text>{{ item.desc }}</text></view>
<view class="col col-cycle"><text>{{ item.cycle }}</text></view>
@@ -42,17 +42,30 @@
</view>
</view>
<!-- 分页 -->
<view class="pagination">
<text class="page-info">共 10 条 15条/页</text>
</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>
</view>
</template>
<script setup lang="uts">
import { ref } from 'vue'
import { ref, computed } from 'vue'
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
const dataList = ref([
{ id: 1, title: '自动开具/冲红电子发票', desc: '每隔10分钟执行自动开具/冲红电子发票', cycle: '每隔10分钟执行一次', status: true },
@@ -64,8 +77,51 @@ const dataList = ref([
{ id: 7, title: '自动更新直播商品状态', desc: '每隔3分钟执行更新直播商品状态', cycle: '每隔3分钟执行一次', status: true },
{ id: 8, title: '到期自动解绑上级', desc: '每隔1分钟执行到期的绑定关系的解除', cycle: '每隔1分钟执行一次', status: true },
{ id: 9, title: '拼团到期订单处理', desc: '每隔1分钟拼团到期后的操作', cycle: '每隔1分钟执行一次', status: true },
{ id: 10, title: '未支付自动取消订单', desc: '每30秒执行自动取消到期未支付的订单', cycle: '每30秒执行一次', status: true }
{ id: 10, title: '未支付自动取消订单', desc: '每30秒执行自动取消到期未支付的订单', cycle: '每30秒执行一次', status: true },
{ id: 11, title: '积分过期处理', desc: '每天凅晑59分0秒执行清除已过期积分', cycle: '每天凅晑59分执行一次', status: true },
{ id: 12, title: '余额到期处理', desc: '每天中午1时执行一次余额到期检查', cycle: '每天中午1时执行一次', status: false },
{ id: 13, title: '优惠券过期处理', desc: '每隔1小时检查并更新过期优惠券状态', cycle: '每隔1小时执行一次', status: true },
{ id: 14, title: '会员等级更新', desc: '每天凅昹3时执行会员等级自动更新', cycle: '每天凅昹3时执行一次', status: true },
{ id: 15, title: '统计数据更新', desc: '每天凅昹4时执行一次经营数据汇总', cycle: '每天凅昹4时执行一次', status: true },
{ id: 16, title: '清理缓存数据', desc: '每天凅晑30分执行一次过期缓存清除', cycle: '每天凅晑30分执行一次', status: true },
{ id: 17, title: '商品库存预警', desc: '每隆15分钟检查库存不足预警商品', cycle: '每隆15分钟执行一次', status: false },
{ id: 18, title: '短信队列发送', desc: '每隔1分钟处理短信队列', cycle: '每隔1分钟执行一次', status: true },
{ id: 19, title: '邮件队列发送', desc: '每隔2分钟处理邮件发送队列', cycle: '每隔2分钟执行一次', status: true },
{ id: 20, title: '每日对账任务', desc: '每天凅晑22时执行一次财务对账', cycle: '每天凅晑22时执行一次', 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(() => dataList.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 dataList.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 onEdit(item: any) {
uni.showToast({ title: '编辑: ' + item.title, icon: 'none' })

View File

@@ -23,7 +23,7 @@
<view class="table-cell action-cell" style="flex: 2;">操作</view>
</view>
<view class="table-body">
<view class="table-row" v-for="(item, index) in dictionaryList" :key="index">
<view class="table-row" v-for="(item, index) in pagedList" :key="index">
<view class="table-cell" style="flex: 0 0 60px;">{{ item.id }}</view>
<view class="table-cell" style="flex: 2;">{{ item.name }}</view>
<view class="table-cell" style="flex: 2;">{{ item.tag }}</view>
@@ -38,10 +38,27 @@
</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 } from 'vue'
import { ref, computed } from 'vue'
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
const searchQuery = ref('')
const dictionaryList = ref([
@@ -54,8 +71,50 @@ const dictionaryList = ref([
{ id: 16, name: '用户管理模块', tag: '123', type: '多级', add_time: '2024-10-22 09:30:46' },
{ id: 18, name: '类型', tag: '1', type: '多级', add_time: '2024-12-11 13:48:01' },
{ id: 19, name: '店铺', tag: 'shop', type: '多级', add_time: '2024-12-11 22:23:07' },
{ id: 20, name: 'ce', tag: 'zzz', type: '一级', add_time: '2024-12-14 12:19:17' }
{ id: 20, name: 'ce', tag: 'zzz', type: '一级', add_time: '2024-12-14 12:19:17' },
{ id: 21, name: '语言', tag: 'language', type: '多级', add_time: '2025-01-05 10:00:00' },
{ id: 22, name: '地区', tag: 'region', type: '多级', add_time: '2025-01-10 11:30:00' },
{ id: 23, name: '货币类型', tag: 'currency', type: '一级', add_time: '2025-01-15 09:00:00' },
{ id: 24, name: '支付方式', tag: 'payment_type', type: '一级', add_time: '2025-01-20 14:00:00' },
{ id: 25, name: '订单状态', tag: 'order_status', type: '一级', add_time: '2025-01-25 10:30:00' },
{ id: 26, name: '物流公司', tag: 'express_company', type: '一级', add_time: '2025-02-01 08:00:00' },
{ id: 27, name: '售后类型', tag: 'after_sale_type', type: '多级', add_time: '2025-02-05 15:00:00' },
{ id: 28, name: '套餐类型', tag: 'package_type', type: '多级', add_time: '2025-02-10 09:30:00' },
{ id: 29, name: '签到规则', tag: 'sign_rule', type: '一级', add_time: '2025-02-15 11:00:00' }
])
// ========== 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(() => dictionaryList.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 dictionaryList.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 handleSearch() {
uni.showToast({ title: '搜索: ' + searchQuery.value, icon: 'none' })

View File

@@ -1,13 +1,154 @@
<template>
<AdminLayout currentPage="external-account">
<view class="page">
<view class="header">
<text class="title">账号管理</text>
</view>
<view class="content">
<text class="tip">TODO: 账号管理</text>
</view>
</view>
</AdminLayout>
<view class="admin-page-container">
<view class="page-card">
<view class="search-wrap">
<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: 0 0 60px;">ID</view>
<view class="th" style="flex: 2;">账号名称</view>
<view class="th" style="flex: 2;">平台类型</view>
<view class="th" style="flex: 2;">AppID/账号</view>
<view class="th" style="flex: 1;">状态</view>
<view class="th" style="flex: 2;">创建时间</view>
<view class="th" style="flex: 2;">操作</view>
</view>
<view class="table-body">
<view v-for="item in pagedList" :key="item.id" class="tr">
<view class="td" style="flex: 0 0 60px;">{{ item.id }}</view>
<view class="td" style="flex: 2;">{{ item.name }}</view>
<view class="td" style="flex: 2;">{{ item.platform }}</view>
<view class="td" style="flex: 2;">{{ item.appId }}</view>
<view class="td" style="flex: 1;">
<switch :checked="item.status" color="#1890ff" style="transform: scale(0.7);" />
</view>
<view class="td" style="flex: 2;">{{ item.createTime }}</view>
<view class="td" style="flex: 2;">
<text class="action-btn" @click="onEdit(item)">编辑</text>
<text class="action-btn-del" @click="onDel(item)">删除</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>
</template>
<script setup lang="uts">
import { ref, computed } from 'vue'
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
const searchKey = ref('')
type AccountItem = { id: number; name: string; platform: string; appId: string; status: boolean; createTime: string }
// ========== MOCK DATA START ==========
// TODO: 接真实接口时替换此处 accountList 为 fetchExternalAccountList() 调用
const accountList = ref<AccountItem[]>([
{ id: 20, name: '微信公众号', platform: '微信', appId: 'wx_public_001', status: true, createTime: '2025-01-01 10:00:00' },
{ id: 19, name: '微信小程序', platform: '微信', appId: 'wx_mini_001', status: true, createTime: '2025-01-02 10:00:00' },
{ id: 18, name: '支付宝商家版', platform: '支付宝', appId: 'alipay_shop_001', status: true, createTime: '2025-01-03 10:00:00' },
{ id: 17, name: '微信支付', platform: '微信支付', appId: 'wxpay_mch_001', status: true, createTime: '2025-01-04 10:00:00' },
{ id: 16, name: '百度小程序', platform: '百度', appId: 'baidu_mini_001', status: false, createTime: '2025-01-05 10:00:00' },
{ id: 15, name: '字节跳动小程序', platform: '字节跳动', appId: 'douyin_mini_001', status: true, createTime: '2025-01-06 10:00:00' },
{ id: 14, name: '阿里云短信', platform: '阿里云', appId: 'aliyun_sms_001', status: true, createTime: '2025-01-07 10:00:00' },
{ id: 13, name: '腾讯云短信', platform: '腾讯云', appId: 'tencent_sms_001', status: true, createTime: '2025-01-08 10:00:00' },
{ id: 12, name: '七牛云存储', platform: '七牛云', appId: 'qiniu_oss_001', status: false, createTime: '2025-01-09 10:00:00' },
{ id: 11, name: '阿里云OSS', platform: '阿里云', appId: 'aliyun_oss_001', status: true, createTime: '2025-01-10 10:00:00' },
{ id: 10, name: '腾讯云COS', platform: '腾讯云', appId: 'tencent_cos_001', status: true, createTime: '2025-01-11 10:00:00' },
{ id: 9, name: 'Apple登录', platform: 'Apple', appId: 'apple_signin_001', status: false, createTime: '2025-01-12 10:00:00' },
{ id: 8, name: '高德地图', platform: '高德地图', appId: 'amap_key_001', status: true, createTime: '2025-01-13 10:00:00' },
{ id: 7, name: '百度地图', platform: '百度', appId: 'bmap_key_001', status: true, createTime: '2025-01-14 10:00:00' },
{ id: 6, name: '联通支付', platform: '联通', appId: 'union_pay_001', status: false, createTime: '2025-01-15 10:00:00' },
{ id: 5, name: 'H5微信登录', platform: '微信', appId: 'wx_h5_001', status: true, createTime: '2025-01-16 10:00:00' },
{ id: 4, name: 'App微信登录', platform: '微信', appId: 'wx_app_001', status: true, createTime: '2025-01-17 10:00:00' },
{ id: 3, name: 'QQ登录', platform: 'QQ', appId: 'qq_login_001', status: false, createTime: '2025-01-18 10:00:00' },
{ id: 2, name: '微博登录', platform: '微博', appId: 'weibo_login_001', status: false, createTime: '2025-01-19 10:00:00' },
{ id: 1, name: '易联云打印', platform: '易联云', appId: 'yly_key_001', status: true, createTime: '2025-01-20 10:00:00' }
])
// ========== 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(() => accountList.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 accountList.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() { console.log('Search:', searchKey.value) }
function onAdd() { uni.showToast({ title: '添加账号', icon: 'none' }) }
function onEdit(item: AccountItem) { uni.showToast({ title: '编辑: ' + item.name, icon: 'none' }) }
function onDel(item: AccountItem) {
uni.showModal({ title: '提示', content: '确定删除该账号吗?', success: (res) => {
if (res.confirm) uni.showToast({ title: '已删除', icon: 'success' })
}})
}
</script>
<style scoped>
.admin-page-container { 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; padding-bottom: 20px; border-bottom: 1px solid #f0f0f0; margin-bottom: 20px; }
.search-item { display: flex; flex-direction: row; align-items: center; margin-right: 20px; }
.label { font-size: 14px; color: #606266; margin-right: 8px; }
.input { width: 220px; height: 32px; padding: 0 10px; border: 1px solid #dcdfe6; border-radius: 4px; font-size: 14px; }
.btn { height: 32px; padding: 0 15px; font-size: 14px; border-radius: 4px; border: none; }
.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: 13px; font-weight: bold; color: #515a6e; border-bottom: 1px solid #f0f0f0; text-align: center; }
.tr { display: flex; flex-direction: row; align-items: center; border-bottom: 1px solid #f0f0f0; min-height: 50px; }
.td { padding: 10px; font-size: 13px; color: #515a6e; text-align: center; }
.action-btn { font-size: 13px; color: #1890ff; margin-right: 8px; cursor: pointer; }
.action-btn-del { font-size: 13px; color: #ed4014; cursor: pointer; }
</style>

View File

@@ -1,12 +1,140 @@
<template>
<AdminLayout currentPage="i18n-language-detail">
<view class="page">
<view class="header">
<text class="title">语言详情</text>
</view>
<view class="content">
<text class="tip">TODO: 语言详情</text>
</view>
</view>
</AdminLayout>
<view class="admin-page-container">
<view class="page-card">
<view class="search-wrap">
<view class="search-item">
<text class="label">翻译key</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: 0 0 60px;">ID</view>
<view class="th" style="flex: 2;">翻译键(key)</view>
<view class="th" style="flex: 3;">中文原文</view>
<view class="th" style="flex: 3;">翻译内容</view>
<view class="th" style="flex: 1.5;">操作</view>
</view>
<view class="table-body">
<view v-for="item in pagedList" :key="item.id" class="tr">
<view class="td" style="flex: 0 0 60px;">{{ item.id }}</view>
<view class="td" style="flex: 2;">{{ item.key }}</view>
<view class="td" style="flex: 3;">{{ item.original }}</view>
<view class="td" style="flex: 3;">{{ item.translation }}</view>
<view class="td" style="flex: 1.5;">
<text class="action-btn" @click="onEdit(item)">编辑</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 searchKey = ref('')
type TranslationItem = { id: number; key: string; original: string; translation: string }
// ========== MOCK DATA START ==========
const translationList = ref<TranslationItem[]>([
{ id: 1, key: 'common.confirm', original: '确定', translation: 'Confirm' },
{ id: 2, key: 'common.cancel', original: '取消', translation: 'Cancel' },
{ id: 3, key: 'common.save', original: '保存', translation: 'Save' },
{ id: 4, key: 'common.delete', original: '删除', translation: 'Delete' },
{ id: 5, key: 'common.edit', original: '编辑', translation: 'Edit' },
{ id: 6, key: 'common.add', original: '添加', translation: 'Add' },
{ id: 7, key: 'common.search', original: '搜索', translation: 'Search' },
{ id: 8, key: 'common.reset', original: '重置', translation: 'Reset' },
{ id: 9, key: 'common.loading', original: '加载中...', translation: 'Loading...' },
{ id: 10, key: 'common.no_data', original: '暂无数据', translation: 'No Data' },
{ id: 11, key: 'order.status.pending', original: '待支付', translation: 'Pending' },
{ id: 12, key: 'order.status.paid', original: '已支付', translation: 'Paid' },
{ id: 13, key: 'order.status.shipped', original: '已发货', translation: 'Shipped' },
{ id: 14, key: 'order.status.received', original: '已收货', translation: 'Received' },
{ id: 15, key: 'order.status.cancelled', original: '已取消', translation: 'Cancelled' },
{ id: 16, key: 'product.out_of_stock', original: '已售罄', translation: 'Out of Stock' },
{ id: 17, key: 'user.login', original: '登录', translation: 'Login' },
{ id: 18, key: 'user.logout', original: '登出', translation: 'Logout' },
{ id: 19, key: 'user.register', original: '注册', translation: 'Register' },
{ id: 20, key: 'user.profile', original: '个人中心', translation: 'Profile' }
])
// ========== 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(() => translationList.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 translationList.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() { console.log('Search:', searchKey.value) }
function onAdd() { uni.showToast({ title: '添加翻译', icon: 'none' }) }
function onEdit(item: TranslationItem) { uni.showToast({ title: '编辑: ' + item.key, icon: 'none' }) }
</script>
<style scoped>
.admin-page-container { 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; padding-bottom: 20px; border-bottom: 1px solid #f0f0f0; margin-bottom: 20px; }
.search-item { display: flex; flex-direction: row; align-items: center; margin-right: 20px; }
.label { font-size: 14px; color: #606266; margin-right: 8px; }
.input { width: 220px; height: 32px; padding: 0 10px; border: 1px solid #dcdfe6; border-radius: 4px; font-size: 14px; }
.btn { height: 32px; padding: 0 15px; font-size: 14px; border-radius: 4px; border: none; }
.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: 13px; font-weight: bold; color: #515a6e; border-bottom: 1px solid #f0f0f0; text-align: center; }
.tr { display: flex; flex-direction: row; align-items: center; border-bottom: 1px solid #f0f0f0; min-height: 50px; }
.td { padding: 10px; font-size: 13px; color: #515a6e; text-align: center; }
.action-btn { font-size: 13px; color: #1890ff; margin-right: 8px; cursor: pointer; }
</style>

View File

@@ -1,12 +1,137 @@
<template>
<AdminLayout currentPage="i18n-language-list">
<view class="page">
<view class="header">
<text class="title">语言列表</text>
</view>
<view class="content">
<text class="tip">TODO: 语言列表</text>
</view>
</view>
</AdminLayout>
<view class="admin-page-container">
<view class="page-card">
<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: 0 0 60px;">ID</view>
<view class="th" style="flex: 2;">语言名称</view>
<view class="th" style="flex: 1;">简称</view>
<view class="th" style="flex: 1;">是否启用</view>
<view class="th" style="flex: 1;">排序</view>
<view class="th" style="flex: 2;">操作</view>
</view>
<view class="table-body">
<view v-for="item in pagedList" :key="item.id" class="tr">
<view class="td" style="flex: 0 0 60px;">{{ item.id }}</view>
<view class="td" style="flex: 2;">{{ item.name }}</view>
<view class="td" style="flex: 1;">{{ item.code }}</view>
<view class="td" style="flex: 1;">
<switch :checked="item.status" color="#1890ff" style="transform: scale(0.7);" />
</view>
<view class="td" style="flex: 1;">{{ item.sort }}</view>
<view class="td" style="flex: 2;">
<text class="action-btn" @click="onEdit(item)">编辑</text>
<text class="action-btn" @click="onTranslate(item)">翻译管理</text>
<text class="action-btn-del" @click="onDel(item)">删除</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'
type LangItem = { id: number; name: string; code: string; status: boolean; sort: number }
// ========== MOCK DATA START ==========
const languageList = ref<LangItem[]>([
{ id: 1, name: '中文简体', code: 'zh-CN', status: true, sort: 1 },
{ id: 2, name: '中文繁体', code: 'zh-TW', status: true, sort: 2 },
{ id: 3, name: '英语', code: 'en-US', status: true, sort: 3 },
{ id: 4, name: '日语', code: 'ja-JP', status: true, sort: 4 },
{ id: 5, name: '韩语', code: 'ko-KR', status: true, sort: 5 },
{ id: 6, name: '法语', code: 'fr-FR', status: false, sort: 6 },
{ id: 7, name: '德语', code: 'de-DE', status: false, sort: 7 },
{ id: 8, name: '西班牙语', code: 'es-ES', status: false, sort: 8 },
{ id: 9, name: '葡萄牙语', code: 'pt-PT', status: false, sort: 9 },
{ id: 10, name: '阿拉伯语', code: 'ar-SA', status: false, sort: 10 },
{ id: 11, name: '俄语', code: 'ru-RU', status: false, sort: 11 },
{ id: 12, name: '意大利语', code: 'it-IT', status: false, sort: 12 },
{ id: 13, name: '泰语', code: 'th-TH', status: true, sort: 13 },
{ id: 14, name: '越南语', code: 'vi-VN', status: true, sort: 14 },
{ id: 15, name: '印尼语', code: 'id-ID', status: false, sort: 15 },
{ id: 16, name: '马来语', code: 'ms-MY', status: false, sort: 16 },
{ id: 17, name: '印地语', code: 'hi-IN', status: false, sort: 17 },
{ id: 18, name: '土耳其语', code: 'tr-TR', status: false, sort: 18 },
{ id: 19, name: '波兰语', code: 'pl-PL', status: false, sort: 19 },
{ id: 20, name: '荷兰语', code: 'nl-NL', status: false, sort: 20 }
])
// ========== 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(() => languageList.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 languageList.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 onAdd() { uni.showToast({ title: '添加语言', icon: 'none' }) }
function onEdit(item: LangItem) { uni.showToast({ title: '编辑: ' + item.name, icon: 'none' }) }
function onTranslate(item: LangItem) { uni.showToast({ title: '翻译管理: ' + item.name, icon: 'none' }) }
function onDel(item: LangItem) {
uni.showModal({ title: '提示', content: '确定删除该语言吗?', success: (res) => {
if (res.confirm) uni.showToast({ title: '已删除', icon: 'success' })
}})
}
</script>
<style scoped>
.admin-page-container { padding: 0; background-color: transparent; min-height: auto; }
.page-card { background-color: #fff; border-radius: 4px; padding: 20px; }
.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: 13px; font-weight: bold; color: #515a6e; border-bottom: 1px solid #f0f0f0; text-align: center; }
.tr { display: flex; flex-direction: row; align-items: center; border-bottom: 1px solid #f0f0f0; min-height: 50px; }
.td { padding: 10px; font-size: 13px; color: #515a6e; text-align: center; }
.action-btn { font-size: 13px; color: #1890ff; margin-right: 8px; cursor: pointer; }
.action-btn-del { font-size: 13px; color: #ed4014; cursor: pointer; }
</style>

View File

@@ -1,12 +1,144 @@
<template>
<AdminLayout currentPage="i18n-region-list">
<view class="page">
<view class="header">
<text class="title">地区列表</text>
</view>
<view class="content">
<text class="tip">TODO: 地区列表</text>
</view>
</view>
</AdminLayout>
<view class="admin-page-container">
<view class="page-card">
<view class="search-wrap">
<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="table-wrap">
<view class="table-header">
<view class="th" style="flex: 0 0 60px;">ID</view>
<view class="th" style="flex: 2;">地区名称</view>
<view class="th" style="flex: 2;">父级地区</view>
<view class="th" style="flex: 1.5;">地区代码</view>
<view class="th" style="flex: 1;">层级</view>
<view class="th" style="flex: 2;">操作</view>
</view>
<view class="table-body">
<view v-for="item in pagedList" :key="item.id" class="tr">
<view class="td" style="flex: 0 0 60px;">{{ item.id }}</view>
<view class="td" style="flex: 2;">{{ item.name }}</view>
<view class="td" style="flex: 2;">{{ item.parentName }}</view>
<view class="td" style="flex: 1.5;">{{ item.code }}</view>
<view class="td" style="flex: 1;">第{{ item.level }}级</view>
<view class="td" style="flex: 2;">
<text class="action-btn" @click="onEdit(item)">编辑</text>
<text class="action-btn-del" @click="onDel(item)">删除</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 searchKey = ref('')
type RegionItem = { id: number; name: string; parentName: string; code: string; level: number }
// ========== MOCK DATA START ==========
const regionList = ref<RegionItem[]>([
{ id: 1, name: '北京市', parentName: '中国', code: '110000', level: 1 },
{ id: 2, name: '天津市', parentName: '中国', code: '120000', level: 1 },
{ id: 3, name: '河北省', parentName: '中国', code: '130000', level: 1 },
{ id: 4, name: '山西省', parentName: '中国', code: '140000', level: 1 },
{ id: 5, name: '内蒙古自治区', parentName: '中国', code: '150000', level: 1 },
{ id: 6, name: '辽宁省', parentName: '中国', code: '210000', level: 1 },
{ id: 7, name: '吉林省', parentName: '中国', code: '220000', level: 1 },
{ id: 8, name: '黑龙江省', parentName: '中国', code: '230000', level: 1 },
{ id: 9, name: '上海市', parentName: '中国', code: '310000', level: 1 },
{ id: 10, name: '江苏省', parentName: '中国', code: '320000', level: 1 },
{ id: 11, name: '浙江省', parentName: '中国', code: '330000', level: 1 },
{ id: 12, name: '安徽省', parentName: '中国', code: '340000', level: 1 },
{ id: 13, name: '福建省', parentName: '中国', code: '350000', level: 1 },
{ id: 14, name: '江西省', parentName: '中国', code: '360000', level: 1 },
{ id: 15, name: '山东省', parentName: '中国', code: '370000', level: 1 },
{ id: 16, name: '河南省', parentName: '中国', code: '410000', level: 1 },
{ id: 17, name: '湖北省', parentName: '中国', code: '420000', level: 1 },
{ id: 18, name: '湖南省', parentName: '中国', code: '430000', level: 1 },
{ id: 19, name: '广东省', parentName: '中国', code: '440000', level: 1 },
{ id: 20, name: '广西壮族自治区', parentName: '中国', code: '450000', level: 1 }
])
// ========== 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(() => regionList.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 regionList.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() { console.log('Search:', searchKey.value) }
function onEdit(item: RegionItem) { uni.showToast({ title: '编辑: ' + item.name, icon: 'none' }) }
function onDel(item: RegionItem) {
uni.showModal({ title: '提示', content: '确定删除该地区吗?', success: (res) => {
if (res.confirm) uni.showToast({ title: '已删除', icon: 'success' })
}})
}
</script>
<style scoped>
.admin-page-container { 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; padding-bottom: 20px; border-bottom: 1px solid #f0f0f0; margin-bottom: 20px; }
.search-item { display: flex; flex-direction: row; align-items: center; margin-right: 20px; }
.label { font-size: 14px; color: #606266; margin-right: 8px; }
.input { width: 220px; height: 32px; padding: 0 10px; border: 1px solid #dcdfe6; border-radius: 4px; font-size: 14px; }
.btn { height: 32px; padding: 0 15px; font-size: 14px; border-radius: 4px; border: none; }
.btn-primary { background-color: #1890ff; color: #fff; }
.table-wrap { width: 100%; border: 1px solid #f0f0f0; }
.table-header { display: flex; flex-direction: row; background-color: #f8f8f9; }
.th { padding: 12px 10px; font-size: 13px; font-weight: bold; color: #515a6e; border-bottom: 1px solid #f0f0f0; text-align: center; }
.tr { display: flex; flex-direction: row; align-items: center; border-bottom: 1px solid #f0f0f0; min-height: 50px; }
.td { padding: 10px; font-size: 13px; color: #515a6e; text-align: center; }
.action-btn { font-size: 13px; color: #1890ff; margin-right: 8px; cursor: pointer; }
.action-btn-del { font-size: 13px; color: #ed4014; cursor: pointer; }
</style>

View File

@@ -46,7 +46,7 @@
</view>
<view class="table-body">
<view v-for="item in dataList" :key="item.id" class="table-row">
<view v-for="item in pagedList" :key="item.id" class="table-row">
<view class="col col-id"><text>{{ item.id }}</text></view>
<view class="col col-user"><text>{{ item.user }}</text></view>
<view class="col col-action"><text>{{ item.action }}</text></view>
@@ -58,17 +58,30 @@
</view>
</view>
<!-- 分页 -->
<view class="pagination">
<text class="page-info">共 583387 条 15条/页</text>
</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>
</view>
</template>
<script setup lang="uts">
import { ref } from 'vue'
import { ref, computed } from 'vue'
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
const dataList = ref([
{ id: 585387, user: '5 / demo', action: '系统日志', link: 'system/log', ip: '223.104.72.77', type: 'system', time: '2026-02-11 18:49' },
@@ -81,8 +94,49 @@ const dataList = ref([
{ id: 585380, user: '5 / demo', action: '定时任务类型', link: 'system/crontab/mark', ip: '223.104.72.77', type: 'system', time: '2026-02-11 18:47' },
{ id: 585379, user: '5 / demo', action: '定时任务列表', link: 'system/crontab/list', ip: '223.104.72.77', type: 'system', time: '2026-02-11 18:47' },
{ id: 585378, user: '5 / demo', action: '保存组合数据', link: 'setting/group', ip: '223.104.72.77', type: 'system', time: '2026-02-11 18:47' },
{ id: 585377, user: '5 / demo', action: '保存系统配置分类', link: 'setting/config_class', ip: '223.104.72.77', type: 'system', time: '2026-02-11 18:47' }
{ id: 585377, user: '5 / demo', action: '保存系统配置分类', link: 'setting/config_class', ip: '223.104.72.77', type: 'system', time: '2026-02-11 18:47' },
{ id: 585376, user: '5 / demo', action: '神识别相册管理', link: 'system/gallery', ip: '115.29.168.1', type: 'system', time: '2026-02-11 18:45' },
{ id: 585375, user: '3 / admin', action: '订单列表', link: 'order/list', ip: '116.228.88.5', type: 'system', time: '2026-02-11 18:43' },
{ id: 585374, user: '3 / admin', action: '商品列表', link: 'product/list', ip: '116.228.88.5', type: 'system', time: '2026-02-11 18:42' },
{ id: 585373, user: '3 / admin', action: '用户列表', link: 'user/list', ip: '116.228.88.5', type: 'system', time: '2026-02-11 18:41' },
{ id: 585372, user: '5 / demo', action: '分销分红记录', link: 'distribution/brokerage', ip: '223.104.72.77', type: 'system', time: '2026-02-11 18:40' },
{ id: 585371, user: '5 / demo', action: '财务提现列表', link: 'finance/withdraw', ip: '223.104.72.77', type: 'system', time: '2026-02-11 18:39' },
{ id: 585370, user: '3 / admin', action: '商品分类列表', link: 'product/category', ip: '116.228.88.5', type: 'system', time: '2026-02-11 18:38' },
{ id: 585369, user: '1 / 超级管理员', action: '系统监控', link: 'system/monitor', ip: '127.0.0.1', type: 'system', time: '2026-02-11 18:37' }
])
// ========== 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(() => dataList.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 dataList.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' })