Merge remote-tracking branch 'origin/huangzhenbao-admin'
This commit is contained in:
310
pages/mall/admin/setting/auth/admin-management/index.uvue
Normal file
310
pages/mall/admin/setting/auth/admin-management/index.uvue
Normal file
@@ -0,0 +1,310 @@
|
||||
<template>
|
||||
<view class="admin-page-container">
|
||||
<view class="page-card">
|
||||
<!-- 搜索栏 -->
|
||||
<view class="search-wrap">
|
||||
<view class="search-item">
|
||||
<text class="label">状态:</text>
|
||||
<picker mode="selector" :range="statusRange" @change="onStatusChange">
|
||||
<view class="picker-input">{{ statusText }}</view>
|
||||
</picker>
|
||||
</view>
|
||||
<view class="search-item">
|
||||
<text class="label">搜索:</text>
|
||||
<input class="input" placeholder="请输入姓名或者账号" v-model="searchKey" />
|
||||
</view>
|
||||
<button class="btn btn-primary" @click="onSearch">查询</button>
|
||||
</view>
|
||||
|
||||
<view class="action-wrap">
|
||||
<button class="btn btn-primary" @click="onAdd">添加管理员</button>
|
||||
</view>
|
||||
|
||||
<!-- 表格区域 -->
|
||||
<view class="table-wrap">
|
||||
<view class="table-header">
|
||||
<view class="th" style="flex: 2;">姓名</view>
|
||||
<view class="th" style="flex: 2;">账号</view>
|
||||
<view class="th" style="flex: 2;">身份</view>
|
||||
<view class="th" style="flex: 3;">最后一次登录时间</view>
|
||||
<view class="th" style="flex: 3;">最后一次登录ip</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: 2;">{{ item.name }}</view>
|
||||
<view class="td" style="flex: 2;">{{ item.account }}</view>
|
||||
<view class="td" style="flex: 2;">{{ item.role }}</view>
|
||||
<view class="td" style="flex: 3;">{{ item.lastLoginTime }}</view>
|
||||
<view class="td" style="flex: 3;">{{ item.lastLoginIp }}</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;">
|
||||
<text class="action-btn" @click="onEdit(item)">编辑</text>
|
||||
<text class="action-btn-del" @click="onDelete(item)">删除</text>
|
||||
</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, computed } from 'vue'
|
||||
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||
|
||||
const searchKey = ref('')
|
||||
const statusRange = ['所有', '启用', '禁用']
|
||||
const statusIndex = ref(0)
|
||||
const statusText = ref('请选择')
|
||||
|
||||
type AdminItem = {
|
||||
id: number
|
||||
name: string
|
||||
account: string
|
||||
role: string
|
||||
lastLoginTime: string
|
||||
lastLoginIp: string
|
||||
status: boolean
|
||||
}
|
||||
|
||||
// ========== MOCK DATA START ==========
|
||||
// TODO: 接真实接口时替换此处 adminList 为 fetchAdminList() 调用
|
||||
const adminList = ref<AdminItem[]>([
|
||||
{ id: 20, name: '张三', account: 'zhangsan', role: '超级管理员', lastLoginTime: '2025-06-28 10:30:00', lastLoginIp: '192.168.1.1', status: true },
|
||||
{ id: 19, name: '李四', account: 'lisi', role: '运营管理员', lastLoginTime: '2025-06-27 09:15:00', lastLoginIp: '192.168.1.2', status: true },
|
||||
{ id: 18, name: '王五', account: 'wangwu', role: '财务管理员', lastLoginTime: '2025-06-26 14:20:00', lastLoginIp: '10.0.0.5', status: true },
|
||||
{ id: 17, name: '赵六', account: 'zhaoliu', role: '客服专员', lastLoginTime: '2025-06-25 11:00:00', lastLoginIp: '10.0.0.6', status: false },
|
||||
{ id: 16, name: '陈七', account: 'chenqi', role: '商品管理员', lastLoginTime: '2025-06-24 16:45:00', lastLoginIp: '172.16.0.1', status: true },
|
||||
{ id: 15, name: '周八', account: 'zhouba', role: '订单管理员', lastLoginTime: '2025-06-23 08:30:00', lastLoginIp: '172.16.0.2', status: true },
|
||||
{ id: 14, name: '吴九', account: 'wujiu', role: '营销专员', lastLoginTime: '2025-06-22 13:00:00', lastLoginIp: '192.168.2.1', status: true },
|
||||
{ id: 13, name: '郑十', account: 'zhengshi', role: '内容管理员', lastLoginTime: '2025-06-21 10:00:00', lastLoginIp: '192.168.2.2', status: false },
|
||||
{ id: 12, name: '马一一', account: 'mayiyi', role: '数据分析师', lastLoginTime: '2025-06-20 15:20:00', lastLoginIp: '10.0.1.1', status: true },
|
||||
{ id: 11, name: '刘二二', account: 'liuerer', role: '技术支持', lastLoginTime: '2025-06-19 09:40:00', lastLoginIp: '10.0.1.2', status: true },
|
||||
{ id: 10, name: '张三三', account: 'zhangsansan', role: '分销管理员', lastLoginTime: '2025-06-18 11:30:00', lastLoginIp: '172.16.1.1', status: true },
|
||||
{ id: 9, name: '李四四', account: 'lisisi', role: '仓库管理员', lastLoginTime: '2025-06-17 14:00:00', lastLoginIp: '172.16.1.2', status: false },
|
||||
{ id: 8, name: '王五五', account: 'wangwuwu', role: '客服小组长', lastLoginTime: '2025-06-16 10:10:00', lastLoginIp: '192.168.3.1', status: true },
|
||||
{ id: 7, name: '赵六六', account: 'zhaoliuliu', role: '运营小组长', lastLoginTime: '2025-06-15 09:00:00', lastLoginIp: '192.168.3.2', status: true },
|
||||
{ id: 6, name: '陈七七', account: 'chenqiqi', role: '商品小组长', lastLoginTime: '2025-06-14 16:00:00', lastLoginIp: '10.0.2.1', status: true },
|
||||
{ id: 5, name: '周八八', account: 'zhoubaba', role: '订单小组长', lastLoginTime: '2025-06-13 15:00:00', lastLoginIp: '10.0.2.2', status: false },
|
||||
{ id: 4, name: '吴九九', account: 'wujiujiu', role: '营销小组长', lastLoginTime: '2025-06-12 11:00:00', lastLoginIp: '172.16.2.1', status: true },
|
||||
{ id: 3, name: '马小明', account: 'maxiaoming', role: '普通管理员', lastLoginTime: '2025-06-11 10:20:00', lastLoginIp: '172.16.2.2', status: true },
|
||||
{ id: 2, name: '李小花', account: 'lixiaohua', role: '普通管理员', lastLoginTime: '2025-06-10 08:50:00', lastLoginIp: '192.168.4.1', status: true },
|
||||
{ id: 1, name: 'admin', account: 'admin', role: '超级管理员', lastLoginTime: '2025-06-29 22:00:00', lastLoginIp: '127.0.0.1', 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(() => adminList.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 adminList.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 onStatusChange(e: any) {
|
||||
statusIndex.value = parseInt(e.detail.value.toString())
|
||||
statusText.value = statusRange[statusIndex.value]
|
||||
}
|
||||
|
||||
function onSearch() {
|
||||
console.log('Search:', searchKey.value, statusText.value)
|
||||
}
|
||||
|
||||
function onAdd() {
|
||||
console.log('Add admin')
|
||||
}
|
||||
|
||||
function onEdit(item: AdminItem) {
|
||||
console.log('Edit admin:', item.account)
|
||||
}
|
||||
|
||||
function onDelete(item: AdminItem) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定删除该管理员吗?',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
uni.showToast({ title: '已删除', icon: 'success' })
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.admin-page-container {
|
||||
/* 使用 Layout 的背景和内边距 */
|
||||
padding: 0;
|
||||
background-color: transparent;
|
||||
min-height: auto;
|
||||
}
|
||||
|
||||
.page-card {
|
||||
background-color: #fff;
|
||||
border-radius: 4px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.search-wrap {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
padding-bottom: 20px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.search-item {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
margin-right: 20px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.label {
|
||||
font-size: 14px;
|
||||
color: #606266;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.picker-input {
|
||||
width: 150px;
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
padding: 0 10px;
|
||||
border: 1px solid #dcdfe6;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
color: #606266;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.input {
|
||||
width: 220px;
|
||||
height: 32px;
|
||||
padding: 0 10px;
|
||||
border: 1px solid #dcdfe6;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
.btn {
|
||||
height: 32px;
|
||||
line-height: 30px;
|
||||
padding: 0 15px;
|
||||
font-size: 14px;
|
||||
border-radius: 4px;
|
||||
border: none;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: #1890ff;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.action-wrap {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.table-wrap {
|
||||
width: 100%;
|
||||
border: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.table-header {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
background-color: #f8f8f9;
|
||||
}
|
||||
|
||||
.th {
|
||||
padding: 12px 10px;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
color: #515a6e;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.table-body {
|
||||
min-height: 100px;
|
||||
}
|
||||
|
||||
.tr {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
min-height: 54px;
|
||||
}
|
||||
|
||||
.td {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
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>
|
||||
189
pages/mall/admin/setting/auth/menu-management/index.uvue
Normal file
189
pages/mall/admin/setting/auth/menu-management/index.uvue
Normal file
@@ -0,0 +1,189 @@
|
||||
<template>
|
||||
<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: 4; text-align: left; padding-left: 20px;">按钮名称</view>
|
||||
<view class="th" style="flex: 3;">类型</view>
|
||||
<view class="th" style="flex: 2;">排序</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 permissionList" :key="item.id" class="tr">
|
||||
<view class="td" style="flex: 4; text-align: left; padding-left: 20px;">
|
||||
<text v-if="item.hasChildren" class="expand-icon">▶</text>
|
||||
<text class="menu-name">{{ item.name }}</text>
|
||||
</view>
|
||||
<view class="td" style="flex: 3;">{{ item.type }}</view>
|
||||
<view class="td" style="flex: 2;">{{ item.sort }}</view>
|
||||
<view class="td" style="flex: 2;">
|
||||
<switch :checked="item.isshow" color="#1890ff" @change="onToggleShow(item)" />
|
||||
</view>
|
||||
<view class="td" style="flex: 2;">
|
||||
<text class="action-btn" @click="onEdit(item)">编辑</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ref, reactive } from 'vue'
|
||||
|
||||
const searchKey = ref('')
|
||||
|
||||
type PermissionItem = {
|
||||
id: number
|
||||
name: string
|
||||
type: string
|
||||
sort: number
|
||||
isshow: boolean
|
||||
hasChildren: boolean
|
||||
}
|
||||
|
||||
const permissionList = reactive<PermissionItem[]>([
|
||||
{ id: 1, name: '主页', type: '菜单:/admin/index', sort: 127, isshow: true, hasChildren: false },
|
||||
{ id: 2, name: '用户', type: '菜单:/admin/user', sort: 125, isshow: true, hasChildren: true },
|
||||
{ id: 3, name: '订单', type: '菜单:/admin/order', sort: 120, isshow: true, hasChildren: true },
|
||||
{ id: 4, name: '商品', type: '菜单:/admin/product', sort: 115, isshow: true, hasChildren: true },
|
||||
{ id: 5, name: '营销', type: '菜单:/admin/marketing', sort: 110, isshow: true, hasChildren: true }
|
||||
])
|
||||
|
||||
function onSearch() {
|
||||
console.log('Search:', searchKey.value)
|
||||
}
|
||||
|
||||
function onToggleShow(item: PermissionItem) {
|
||||
item.isshow = !item.isshow
|
||||
}
|
||||
|
||||
function onEdit(item: PermissionItem) {
|
||||
console.log('Edit:', item.name)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.admin-page-container {
|
||||
/* 使用 Layout 的背景和内边距 */
|
||||
padding: 0;
|
||||
background-color: transparent;
|
||||
min-height: auto;
|
||||
}
|
||||
|
||||
.page-card {
|
||||
background-color: #fff;
|
||||
border-radius: 4px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.search-wrap {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
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: 200px;
|
||||
height: 32px;
|
||||
padding: 0 10px;
|
||||
border: 1px solid #dcdfe6;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
.btn {
|
||||
height: 32px;
|
||||
line-height: 30px;
|
||||
padding: 0 15px;
|
||||
font-size: 14px;
|
||||
border-radius: 4px;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.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: 14px;
|
||||
font-weight: bold;
|
||||
color: #515a6e;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.tr {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.td {
|
||||
padding: 12px 10px;
|
||||
font-size: 14px;
|
||||
color: #515a6e;
|
||||
text-align: center;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.expand-icon {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.menu-name {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
color: #1890ff;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
@@ -1,263 +0,0 @@
|
||||
<template>
|
||||
<view class="admin-page-container">
|
||||
<view class="page-card">
|
||||
<!-- 顶部操作栏 -->
|
||||
<view class="action-wrap">
|
||||
<button class="btn btn-primary" @click="onAdd(null)">添加顶级权限</button>
|
||||
<button class="btn btn-ghost ml-10" @click="loadData">刷新</button>
|
||||
</view>
|
||||
|
||||
<!-- 树形表格区域 -->
|
||||
<view class="table-wrap border-shadow">
|
||||
<view class="table-header">
|
||||
<view class="th" style="flex: 4; text-align: left; padding-left: 20px;">菜单/按钮名称</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: 3;">操作</view>
|
||||
</view>
|
||||
|
||||
<view class="table-body">
|
||||
<view v-if="loading" class="loading-box">
|
||||
<text>加载中...</text>
|
||||
</view>
|
||||
<view v-else-if="permissionList.length === 0" class="no-data">
|
||||
<text class="no-data-text">暂无数据</text>
|
||||
</view>
|
||||
|
||||
<!-- 递归渲染或平铺渲染 (这里采用平铺+缩进模拟树形) -->
|
||||
<view v-else v-for="item in permissionList" :key="item.id" class="tr">
|
||||
<view class="td" style="flex: 4; text-align: left; padding-left: 20px;">
|
||||
<text class="menu-name">{{ item.name }}</text>
|
||||
</view>
|
||||
<view class="td" style="flex: 2;"><text class="td-txt-small">{{ item.code }}</text></view>
|
||||
<view class="td" style="flex: 2;">
|
||||
<text :class="['type-tag', item.type === 'menu' ? 'menu' : 'button']">
|
||||
{{ item.type === 'menu' ? '菜单' : '按钮' }}
|
||||
</text>
|
||||
</view>
|
||||
<view class="td" style="flex: 1;"><text class="td-txt">{{ item.sort_order }}</text></view>
|
||||
<view class="td" style="flex: 1;">
|
||||
<switch :checked="item.is_visible" color="#1890ff" scale="0.6" @change="onToggleVisible(item)" />
|
||||
</view>
|
||||
<view class="td" style="flex: 3;">
|
||||
<view class="op-links">
|
||||
<text class="action-btn" @click="onAdd(item.id)">新增子项</text>
|
||||
<text class="op-split">|</text>
|
||||
<text class="action-btn" @click="onEdit(item)">编辑</text>
|
||||
<text class="op-split">|</text>
|
||||
<text class="action-btn danger" @click="onDelete(item)">删除</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 添加/编辑 弹窗 -->
|
||||
<view v-if="showModal" class="modal-overlay" @click="closeModal">
|
||||
<view class="modal-card" @click.stop>
|
||||
<view class="modal-header">
|
||||
<text class="modal-title">{{ isEdit ? '编辑权限' : '添加权限' }}</text>
|
||||
<text class="close-btn" @click="closeModal">×</text>
|
||||
</view>
|
||||
<view class="modal-body">
|
||||
<scroll-view scroll-y="true" style="max-height: 500px;">
|
||||
<view class="form-item">
|
||||
<text class="f-label">父级ID:</text>
|
||||
<input class="f-input disabled" :value="form.parent_id || '顶级'" disabled />
|
||||
</view>
|
||||
<view class="form-item">
|
||||
<text class="f-label">名称:</text>
|
||||
<input class="f-input" v-model="form.name" placeholder="请输入菜单或按钮名称" />
|
||||
</view>
|
||||
<view class="form-item">
|
||||
<text class="f-label">编码:</text>
|
||||
<input class="f-input" v-model="form.code" placeholder="如: user_view" />
|
||||
</view>
|
||||
<view class="form-item">
|
||||
<text class="f-label">类型:</text>
|
||||
<radio-group class="radio-group" @change="(e : any) => form.type = e.detail.value">
|
||||
<label class="radio-label"><radio value="menu" :checked="form.type === 'menu'" color="#1890ff" /> 菜单</label>
|
||||
<label class="radio-label"><radio value="button" :checked="form.type === 'button'" color="#1890ff" /> 按钮</label>
|
||||
</radio-group>
|
||||
</view>
|
||||
<view class="form-item" v-if="form.type === 'menu'">
|
||||
<text class="f-label">路由路径:</text>
|
||||
<input class="f-input" v-model="form.path" placeholder="请输入前端路由地址" />
|
||||
</view>
|
||||
<view class="form-item">
|
||||
<text class="f-label">排序:</text>
|
||||
<input class="f-input" type="number" v-model="form.sort_order" />
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
<view class="modal-footer">
|
||||
<button class="btn" @click="closeModal">取消</button>
|
||||
<button class="btn btn-primary" @click="handleSave">提交</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { fetchPermissionList, savePermission, deletePermission, type AdminPermission } from '@/services/admin/authService.uts'
|
||||
|
||||
const permissionList = ref<AdminPermission[]>([])
|
||||
const loading = ref(false)
|
||||
const showModal = ref(false)
|
||||
const isEdit = ref(false)
|
||||
|
||||
const form = reactive({
|
||||
id: '' as string | null,
|
||||
parent_id: '' as string | null,
|
||||
name: '',
|
||||
code: '',
|
||||
type: 'menu',
|
||||
path: '',
|
||||
icon: '',
|
||||
sort_order: 0,
|
||||
is_visible: true
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
loadData()
|
||||
})
|
||||
|
||||
async function loadData() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await fetchPermissionList()
|
||||
permissionList.value = res
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '加载失败', icon: 'none' })
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function onAdd(parentId : string | null) {
|
||||
isEdit.value = false
|
||||
form.id = null
|
||||
form.parent_id = parentId
|
||||
form.name = ''
|
||||
form.code = ''
|
||||
form.type = 'menu'
|
||||
form.path = ''
|
||||
form.sort_order = 0
|
||||
form.is_visible = true
|
||||
showModal.value = true
|
||||
}
|
||||
|
||||
function onEdit(item : AdminPermission) {
|
||||
isEdit.value = true
|
||||
form.id = item.id
|
||||
form.parent_id = item.parent_id
|
||||
form.name = item.name
|
||||
form.code = item.code
|
||||
form.type = item.type
|
||||
form.path = item.path || ''
|
||||
form.sort_order = item.sort_order
|
||||
form.is_visible = item.is_visible
|
||||
showModal.value = true
|
||||
}
|
||||
|
||||
async function onToggleVisible(item : AdminPermission) {
|
||||
const nextVal = !item.is_visible
|
||||
const ok = await savePermission({ ...item, is_visible: nextVal })
|
||||
if (ok != null) {
|
||||
item.is_visible = nextVal
|
||||
uni.showToast({ title: '显示状态已更新' })
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSave() {
|
||||
if (!form.name || !form.code) {
|
||||
uni.showToast({ title: '请填写必填项', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
loading.value = true
|
||||
try {
|
||||
const resId = await savePermission(form)
|
||||
if (resId != null) {
|
||||
uni.showToast({ title: '保存成功' })
|
||||
showModal.value = false
|
||||
loadData()
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function onDelete(item : AdminPermission) {
|
||||
uni.showModal({
|
||||
title: '确认删除',
|
||||
content: `确定要删除权限项 "${item.name}" 吗?此操作不可撤销。`,
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
const ok = await deletePermission(item.id)
|
||||
if (ok) {
|
||||
uni.showToast({ title: '删除成功' })
|
||||
loadData()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function closeModal() {
|
||||
showModal.value = false
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.admin-page-container { padding: 24px; background-color: #f5f7f9; min-height: 100vh; }
|
||||
.page-card { background-color: #fff; border-radius: 4px; padding: 24px; }
|
||||
|
||||
.action-wrap { margin-bottom: 24px; display: flex; flex-direction: row; }
|
||||
.btn { height: 32px; padding: 0 16px; font-size: 14px; border-radius: 4px; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; }
|
||||
.btn-primary { background-color: #1890ff; color: #fff; }
|
||||
.btn-ghost { background-color: #fff; color: #666; border: 1px solid #dcdfe6; }
|
||||
.ml-10 { margin-left: 10px; }
|
||||
|
||||
.table-wrap { border: 1px solid #f0f0f0; border-radius: 4px; }
|
||||
.table-header { display: flex; flex-direction: row; background-color: #f8f8f9; }
|
||||
.th { padding: 12px 10px; font-size: 14px; font-weight: bold; color: #515a6e; border-bottom: 1px solid #f0f0f0; text-align: center; }
|
||||
.tr { display: flex; flex-direction: row; border-bottom: 1px solid #f0f0f0; min-height: 50px; align-items: center; }
|
||||
.td { padding: 8px 10px; font-size: 13px; color: #606266; text-align: center; display: flex; align-items: center; justify-content: center; }
|
||||
|
||||
.menu-name { font-weight: 500; color: #333; }
|
||||
.td-txt-small { font-size: 12px; color: #999; }
|
||||
|
||||
.type-tag { padding: 2px 8px; border-radius: 4px; font-size: 11px; }
|
||||
.type-tag.menu { background-color: #e6f7ff; color: #1890ff; border: 1px solid #91d5ff; }
|
||||
.type-tag.button { background-color: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f; }
|
||||
|
||||
.op-links { display: flex; flex-direction: row; align-items: center; gap: 8px; }
|
||||
.action-btn { color: #1890ff; font-size: 13px; cursor: pointer; }
|
||||
.danger { color: #ff4d4f; }
|
||||
.op-split { color: #eee; }
|
||||
|
||||
.loading-box, .no-data { padding: 60px 0; text-align: center; width: 100%; }
|
||||
.no-data-text { font-size: 14px; color: #ccc; }
|
||||
|
||||
/* Modal */
|
||||
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 1000; display: flex; align-items: center; justify-content: center; }
|
||||
.modal-card { width: 500px; background-color: #fff; border-radius: 8px; overflow: hidden; }
|
||||
.modal-header { padding: 16px 20px; border-bottom: 1px solid #f0f0f0; display: flex; flex-direction: row; justify-content: space-between; align-items: center; }
|
||||
.modal-title { font-size: 16px; font-weight: bold; color: #333; }
|
||||
.close-btn { font-size: 24px; color: #999; cursor: pointer; }
|
||||
.modal-body { padding: 24px; }
|
||||
.form-item { margin-bottom: 20px; display: flex; flex-direction: row; align-items: center; }
|
||||
.align-start { align-items: flex-start; }
|
||||
.f-label { width: 90px; font-size: 14px; color: #666; text-align: right; margin-right: 15px; }
|
||||
.f-input { flex: 1; border: 1px solid #dcdfe6; height: 36px; padding: 0 12px; border-radius: 4px; font-size: 14px; }
|
||||
.f-input.disabled { background-color: #f5f5f5; color: #999; }
|
||||
.radio-group { display: flex; flex-direction: row; gap: 20px; }
|
||||
.radio-label { display: flex; flex-direction: row; align-items: center; font-size: 14px; }
|
||||
.modal-footer { padding: 16px 24px; border-top: 1px solid #f0f0f0; display: flex; flex-direction: row; justify-content: flex-end; gap: 12px; }
|
||||
</style>
|
||||
175
pages/mall/admin/setting/auth/role-management/index.uvue
Normal file
175
pages/mall/admin/setting/auth/role-management/index.uvue
Normal file
@@ -0,0 +1,175 @@
|
||||
<template>
|
||||
<view class="admin-page-container">
|
||||
<view class="page-card">
|
||||
<!-- 搜索栏 -->
|
||||
<view class="search-wrap">
|
||||
<view class="search-item">
|
||||
<text class="label">状态:</text>
|
||||
<picker mode="selector" :range="statusRange" @change="onStatusChange">
|
||||
<view class="picker-input">{{ statusText }}</view>
|
||||
</picker>
|
||||
</view>
|
||||
<view class="search-item">
|
||||
<text class="label">身份昵称:</text>
|
||||
<input class="input" placeholder="请输入身份昵称" v-model="searchKey" />
|
||||
</view>
|
||||
<button class="btn btn-primary" @click="onSearch">查询</button>
|
||||
</view>
|
||||
|
||||
<view class="action-wrap">
|
||||
<button class="btn btn-primary" @click="onAdd">添加身份</button>
|
||||
</view>
|
||||
|
||||
<!-- 表格区域 -->
|
||||
<view class="table-wrap">
|
||||
<view class="table-header">
|
||||
<view class="th" style="flex: 1;">ID</view>
|
||||
<view class="th" style="flex: 3;">身份昵称</view>
|
||||
<view class="th" style="flex: 2;">状态</view>
|
||||
<view class="th" style="flex: 2;">操作</view>
|
||||
</view>
|
||||
<view class="table-body">
|
||||
<view class="no-data">
|
||||
<text class="no-data-text">暂无数据</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ref } from 'vue'
|
||||
|
||||
const searchKey = ref('')
|
||||
const statusRange = ['所有', '启用', '禁用']
|
||||
const statusIndex = ref(0)
|
||||
const statusText = ref('请选择')
|
||||
|
||||
function onStatusChange(e: any) {
|
||||
statusIndex.value = parseInt(e.detail.value.toString())
|
||||
statusText.value = statusRange[statusIndex.value]
|
||||
}
|
||||
|
||||
function onSearch() {
|
||||
console.log('Search:', searchKey.value, statusText.value)
|
||||
}
|
||||
|
||||
function onAdd() {
|
||||
console.log('Add role')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.admin-page-container {
|
||||
/* 使用 Layout 的背景和内边距 */
|
||||
padding: 0;
|
||||
background-color: transparent;
|
||||
min-height: auto;
|
||||
}
|
||||
|
||||
.page-card {
|
||||
background-color: #fff;
|
||||
border-radius: 4px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.search-wrap {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
padding-bottom: 20px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.search-item {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
margin-right: 20px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.label {
|
||||
font-size: 14px;
|
||||
color: #606266;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.picker-input {
|
||||
width: 150px;
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
padding: 0 10px;
|
||||
border: 1px solid #dcdfe6;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
color: #606266;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.input {
|
||||
width: 180px;
|
||||
height: 32px;
|
||||
padding: 0 10px;
|
||||
border: 1px solid #dcdfe6;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
.btn {
|
||||
height: 32px;
|
||||
line-height: 30px;
|
||||
padding: 0 15px;
|
||||
font-size: 14px;
|
||||
border-radius: 4px;
|
||||
border: none;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: #1890ff;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.action-wrap {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.table-wrap {
|
||||
width: 100%;
|
||||
border: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.table-header {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
background-color: #f8f8f9;
|
||||
}
|
||||
|
||||
.th {
|
||||
padding: 12px 10px;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
color: #515a6e;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.table-body {
|
||||
min-height: 100px;
|
||||
}
|
||||
|
||||
.no-data {
|
||||
padding: 40px 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.no-data-text {
|
||||
font-size: 14px;
|
||||
color: #c5c8ce;
|
||||
}
|
||||
</style>
|
||||
@@ -1,272 +0,0 @@
|
||||
<template>
|
||||
<view class="admin-page-container">
|
||||
<view class="page-card">
|
||||
<!-- 搜索栏 -->
|
||||
<view class="search-wrap">
|
||||
<view class="search-item">
|
||||
<text class="label">状态:</text>
|
||||
<uni-data-select v-model="statusValue" :localdata="statusOptions" style="width: 120px;" @change="handleQuery" />
|
||||
</view>
|
||||
<view class="search-item">
|
||||
<text class="label">身份昵称:</text>
|
||||
<input class="input" placeholder="请输入身份昵称" v-model="searchKey" @confirm="handleQuery" />
|
||||
</view>
|
||||
<button class="btn btn-primary" @click="handleQuery">查询</button>
|
||||
</view>
|
||||
|
||||
<view class="action-wrap">
|
||||
<button class="btn btn-primary" @click="onAdd">添加身份</button>
|
||||
</view>
|
||||
|
||||
<!-- 表格区域 -->
|
||||
<view class="table-wrap border-shadow">
|
||||
<view class="table-header">
|
||||
<view class="th" style="flex: 1;">序号</view>
|
||||
<view class="th" style="flex: 3;">身份昵称</view>
|
||||
<view class="th" style="flex: 2;">状态</view>
|
||||
<view class="th" style="flex: 2;">操作</view>
|
||||
</view>
|
||||
<view class="table-body">
|
||||
<view v-if="loading" class="loading-box">
|
||||
<text>加载中...</text>
|
||||
</view>
|
||||
<view v-else-if="roleList.length === 0" class="no-data">
|
||||
<text class="no-data-text">暂无数据</text>
|
||||
</view>
|
||||
<view v-else v-for="(item, index) in roleList" :key="item.id" class="tr">
|
||||
<view class="td" style="flex: 1;"><text class="td-txt">{{ (page - 1) * pageSize + index + 1 }}</text></view>
|
||||
<view class="td" style="flex: 3;"><text class="td-txt">{{ item.name }} ({{ item.code }})</text></view>
|
||||
<view class="td" style="flex: 2;">
|
||||
<switch :checked="item.is_active" color="#1890ff" scale="0.7" @change="onToggleStatus(item)" />
|
||||
</view>
|
||||
<view class="td" style="flex: 2;">
|
||||
<text class="action-btn" @click="onEdit(item)">编辑</text>
|
||||
<view class="divider"></view>
|
||||
<text class="action-btn danger" @click="onDelete(item)">删除</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 分页栏 -->
|
||||
<view class="pagination-footer">
|
||||
<text class="total-txt">共 {{ total }} 条</text>
|
||||
<view class="page-btns">
|
||||
<text :class="['p-btn', page <= 1 ? 'disabled' : '']" @click="prevPage"> < </text>
|
||||
<text class="p-btn active">{{ page }}</text>
|
||||
<text :class="['p-btn', roleList.length < pageSize ? 'disabled' : '']" @click="nextPage"> > </text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 添加/编辑 弹窗 -->
|
||||
<view v-if="showModal" class="modal-overlay" @click="closeModal">
|
||||
<view class="modal-card" @click.stop>
|
||||
<view class="modal-header">
|
||||
<text class="modal-title">{{ isEdit ? '编辑身份' : '添加身份' }}</text>
|
||||
<text class="close-btn" @click="closeModal">×</text>
|
||||
</view>
|
||||
<view class="modal-body">
|
||||
<view class="form-item">
|
||||
<text class="f-label">身份名称:</text>
|
||||
<input class="f-input" v-model="form.name" placeholder="请输入身份名称" />
|
||||
</view>
|
||||
<view class="form-item">
|
||||
<text class="f-label">身份编码:</text>
|
||||
<input class="f-input" v-model="form.code" placeholder="如: super_admin" :disabled="isEdit" />
|
||||
</view>
|
||||
<view class="form-item">
|
||||
<text class="f-label">描述:</text>
|
||||
<textarea class="f-textarea" v-model="form.description" placeholder="请输入备注描述" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="modal-footer">
|
||||
<button class="btn" @click="closeModal">取消</button>
|
||||
<button class="btn btn-primary" @click="handleSave">保存</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { fetchRolePage, saveRole, deleteRole, type AdminRole } from '@/services/admin/authService.uts'
|
||||
|
||||
const roleList = ref<AdminRole[]>([])
|
||||
const loading = ref(false)
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = 15
|
||||
const searchKey = ref('')
|
||||
const statusValue = ref('all')
|
||||
|
||||
const statusOptions = [
|
||||
{ value: 'all', text: '所有' },
|
||||
{ value: '1', text: '启用' },
|
||||
{ value: '0', text: '禁用' }
|
||||
]
|
||||
|
||||
// 弹窗表单状态
|
||||
const showModal = ref(false)
|
||||
const isEdit = ref(false)
|
||||
const form = reactive({
|
||||
id: '' as string | null,
|
||||
name: '',
|
||||
code: '',
|
||||
description: '',
|
||||
is_active: true
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
loadData()
|
||||
})
|
||||
|
||||
async function loadData() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await fetchRolePage(page.value, pageSize, searchKey.value || null)
|
||||
roleList.value = res.items
|
||||
total.value = res.total
|
||||
} catch (e) {
|
||||
uni.showToast({ title: '加载失败', icon: 'none' })
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleQuery() {
|
||||
page.value = 1
|
||||
loadData()
|
||||
}
|
||||
|
||||
function onAdd() {
|
||||
isEdit.value = false
|
||||
form.id = null
|
||||
form.name = ''
|
||||
form.code = ''
|
||||
form.description = ''
|
||||
form.is_active = true
|
||||
showModal.value = true
|
||||
}
|
||||
|
||||
function onEdit(item : AdminRole) {
|
||||
isEdit.value = true
|
||||
form.id = item.id
|
||||
form.name = item.name
|
||||
form.code = item.code
|
||||
form.description = item.description || ''
|
||||
form.is_active = item.is_active
|
||||
showModal.value = true
|
||||
}
|
||||
|
||||
function closeModal() {
|
||||
showModal.value = false
|
||||
}
|
||||
|
||||
async function handleSave() {
|
||||
if (!form.name || !form.code) {
|
||||
uni.showToast({ title: '请完善必要信息', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
loading.value = true
|
||||
try {
|
||||
const resId = await saveRole(form)
|
||||
if (resId != null) {
|
||||
uni.showToast({ title: '保存成功' })
|
||||
closeModal()
|
||||
loadData()
|
||||
} else {
|
||||
uni.showToast({ title: '保存失败', icon: 'none' })
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function onDelete(item : AdminRole) {
|
||||
uni.showModal({
|
||||
title: '删除确认',
|
||||
content: `确定要删除角色 "${item.name}" 吗?\n\n⚠️ 警告:该操作将同时解除所有关联管理员的身份并清空该角色的权限配置!`,
|
||||
confirmText: '确认删除',
|
||||
confirmColor: '#ff4d4f',
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
const ok = await deleteRole(item.id)
|
||||
if (ok) {
|
||||
uni.showToast({ title: '删除成功' })
|
||||
loadData()
|
||||
}
|
||||
} catch (e: any) {
|
||||
const errMsg = e?.message || '删除失败'
|
||||
uni.showToast({ title: errMsg, icon: 'none', duration: 3000 })
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function onToggleStatus(item : AdminRole) {
|
||||
const nextStatus = !item.is_active
|
||||
const ok = await saveRole({ ...item, is_active: nextStatus })
|
||||
if (ok != null) {
|
||||
item.is_active = nextStatus
|
||||
uni.showToast({ title: '状态已更新' })
|
||||
}
|
||||
}
|
||||
|
||||
function prevPage() { if (page.value > 1) { page.value--; loadData(); } }
|
||||
function nextPage() { if (roleList.value.length >= pageSize) { page.value++; loadData(); } }
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.admin-page-container { padding: 24px; background-color: #f5f7f9; min-height: 100vh; }
|
||||
.page-card { background-color: #fff; border-radius: 4px; padding: 24px; }
|
||||
|
||||
.search-wrap { display: flex; flex-direction: row; align-items: center; padding-bottom: 24px; border-bottom: 1px solid #f0f0f0; margin-bottom: 24px; }
|
||||
.search-item { display: flex; flex-direction: row; align-items: center; margin-right: 24px; }
|
||||
.label { font-size: 14px; color: #606266; margin-right: 8px; }
|
||||
.input { width: 200px; height: 32px; border: 1px solid #dcdfe6; border-radius: 4px; padding: 0 12px; font-size: 14px; }
|
||||
|
||||
.btn { height: 32px; padding: 0 20px; border-radius: 4px; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; }
|
||||
.btn-primary { background-color: #1890ff; color: #fff; font-size: 14px; }
|
||||
|
||||
.action-wrap { margin-bottom: 20px; }
|
||||
|
||||
.table-wrap { border: 1px solid #f0f0f0; border-radius: 4px; }
|
||||
.table-header { display: flex; flex-direction: row; background-color: #f8f8f9; }
|
||||
.th { padding: 12px 10px; font-size: 14px; font-weight: bold; color: #515a6e; border-bottom: 1px solid #f0f0f0; text-align: center; }
|
||||
.tr { display: flex; flex-direction: row; border-bottom: 1px solid #f0f0f0; min-height: 54px; align-items: center; }
|
||||
.td { padding: 10px; display: flex; align-items: center; justify-content: center; }
|
||||
.td-txt { font-size: 13px; color: #606266; }
|
||||
|
||||
.action-btn { color: #1890ff; font-size: 13px; cursor: pointer; }
|
||||
.danger { color: #ff4d4f; }
|
||||
.divider { width: 1px; height: 12px; background-color: #e8e8e8; margin: 0 8px; }
|
||||
|
||||
.no-data { padding: 60px 0; text-align: center; }
|
||||
.no-data-text { font-size: 14px; color: #c5c8ce; }
|
||||
.loading-box { padding: 60px 0; text-align: center; color: #1890ff; }
|
||||
|
||||
.pagination-footer { margin-top: 24px; display: flex; flex-direction: row; align-items: center; justify-content: flex-end; gap: 12px; }
|
||||
.total-txt { font-size: 13px; color: #999; }
|
||||
.page-btns { display: flex; flex-direction: row; gap: 8px; }
|
||||
.p-btn { width: 30px; height: 30px; border: 1px solid #dcdee2; display: flex; align-items: center; justify-content: center; border-radius: 4px; cursor: pointer; font-size: 13px; }
|
||||
.p-btn.active { background-color: #1890ff; color: #fff; border-color: #1890ff; }
|
||||
.p-btn.disabled { opacity: 0.5; cursor: not-allowed; }
|
||||
|
||||
/* 弹窗样式 */
|
||||
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 1000; display: flex; align-items: center; justify-content: center; }
|
||||
.modal-card { width: 500px; background-color: #fff; border-radius: 8px; overflow: hidden; }
|
||||
.modal-header { padding: 16px 20px; border-bottom: 1px solid #f0f0f0; display: flex; flex-direction: row; justify-content: space-between; align-items: center; }
|
||||
.modal-title { font-size: 16px; font-weight: bold; color: #333; }
|
||||
.close-btn { font-size: 24px; color: #999; cursor: pointer; }
|
||||
.modal-body { padding: 24px; }
|
||||
.form-item { margin-bottom: 20px; display: flex; flex-direction: row; align-items: flex-start; }
|
||||
.f-label { width: 90px; font-size: 14px; color: #666; text-align: right; padding-top: 6px; }
|
||||
.f-input { flex: 1; border: 1px solid #dcdfe6; height: 36px; padding: 0 12px; border-radius: 4px; font-size: 14px; }
|
||||
.f-textarea { flex: 1; border: 1px solid #dcdfe6; height: 80px; padding: 8px 12px; border-radius: 4px; font-size: 14px; }
|
||||
.modal-footer { padding: 16px 24px; border-top: 1px solid #f0f0f0; display: flex; flex-direction: row; justify-content: flex-end; gap: 12px; }
|
||||
</style>
|
||||
Reference in New Issue
Block a user