- 更新系统名称、登录页宣传文案为37du平台相关内容 - 移除聊天功能相关代码与配置 - 新增客户端版本上报字段与设备统计接口 - 新增通知中心功能(60s轮询、localStorage已读标记) - 新增权限授权工作台相关接口与页面 - 新增统一页头组件ArtPageHeader - 调整快速入口配置指向真实功能页面 - 修复控制面地址为内网生产库
107 lines
3.8 KiB
Vue
107 lines
3.8 KiB
Vue
<script setup lang="ts">
|
|
/**
|
|
* 系统管理-菜单(37du 重构版,走 /api/admin/sys/menus,后端构建树)
|
|
* 支持:新增 / 编辑 / 删除(有子级拒绝);type: 0目录 1菜单 2按钮
|
|
*/
|
|
import { onMounted, ref } from 'vue'
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
import { sysMenuDel, sysMenus } from '@/api/sys'
|
|
import MenuDialog from './modules/menu-dialog.vue'
|
|
|
|
const loading = ref(false)
|
|
const list = ref<any[]>([])
|
|
|
|
const typeName = (t: number) => (Number(t) === 0 ? '目录' : Number(t) === 1 ? '菜单' : '按钮')
|
|
const typeTag = (t: number) => (Number(t) === 0 ? 'info' : Number(t) === 1 ? 'success' : 'warning')
|
|
|
|
async function load() {
|
|
loading.value = true
|
|
try {
|
|
const r = await sysMenus()
|
|
list.value = r.items || []
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
}
|
|
|
|
// ---- 新增/编辑对话框 ----
|
|
const dialogVisible = ref(false)
|
|
const dialogType = ref<'add' | 'edit'>('add')
|
|
const currentMenu = ref<any>(null)
|
|
const presetParentId = ref<number | null>(null)
|
|
|
|
function openAdd(parent?: any) {
|
|
dialogType.value = 'add'
|
|
currentMenu.value = null
|
|
presetParentId.value = parent ? Number(parent.id) : null
|
|
dialogVisible.value = true
|
|
}
|
|
|
|
function openEdit(row: any) {
|
|
dialogType.value = 'edit'
|
|
currentMenu.value = row
|
|
presetParentId.value = null
|
|
dialogVisible.value = true
|
|
}
|
|
|
|
async function handleDel(row: any) {
|
|
await ElMessageBox.confirm(`确认删除菜单「${row.name}」?`, '删除确认', {
|
|
type: 'warning',
|
|
confirmButtonText: '删除',
|
|
cancelButtonText: '取消'
|
|
})
|
|
await sysMenuDel(row.id)
|
|
ElMessage.success('删除成功')
|
|
load()
|
|
}
|
|
|
|
function handleSubmit() {
|
|
dialogVisible.value = false
|
|
load()
|
|
}
|
|
|
|
onMounted(load)
|
|
</script>
|
|
|
|
<template>
|
|
<div class="p-5 space-y-4">
|
|
<ArtPageHeader title="菜单管理" description="控制台菜单树与按钮权限标识维护">
|
|
<template #actions>
|
|
<el-button :loading="loading" @click="load"><ArtSvgIcon icon="ri:refresh-line" class="mr-1" />刷新</el-button>
|
|
<el-button type="primary" @click="openAdd()"><ArtSvgIcon icon="ri:add-line" class="mr-1" />新增菜单</el-button>
|
|
</template>
|
|
</ArtPageHeader>
|
|
|
|
<el-card shadow="never" class="rounded-xl">
|
|
<el-table v-loading="loading" :data="list" border stripe row-key="id" default-expand-all>
|
|
<el-table-column prop="name" label="名称" min-width="180" />
|
|
<el-table-column label="类型" width="80">
|
|
<template #default="{ row }">
|
|
<el-tag size="small" :type="typeTag(row.type)">{{ typeName(row.type) }}</el-tag>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="router" label="路由" min-width="150" show-overflow-tooltip />
|
|
<el-table-column prop="perms" label="权限标识" min-width="210" show-overflow-tooltip />
|
|
<el-table-column prop="icon" label="图标" width="130" show-overflow-tooltip />
|
|
<el-table-column prop="orderNum" label="排序" width="70" />
|
|
<el-table-column label="操作" width="170" fixed="right">
|
|
<template #default="{ row }">
|
|
<el-button v-if="Number(row.type) !== 2" link type="primary" size="small" @click="openAdd(row)">添加子级</el-button>
|
|
<el-button link type="primary" size="small" @click="openEdit(row)">编辑</el-button>
|
|
<el-button link type="danger" size="small" @click="handleDel(row)">删除</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
</el-card>
|
|
|
|
<MenuDialog
|
|
v-model:visible="dialogVisible"
|
|
:type="dialogType"
|
|
:menu-data="currentMenu"
|
|
:preset-parent-id="presetParentId"
|
|
:tree="list"
|
|
@submit="handleSubmit"
|
|
/>
|
|
</div>
|
|
</template>
|