Files
admin-govern/src/views/auth/menu/index.vue

97 lines
2.9 KiB
Vue
Raw Normal View History

2023-12-22 16:19:33 +08:00
<template>
2023-12-27 15:06:57 +08:00
<div class='default-main'>
<TableHeader>
<template v-slot:operation>
<el-button :icon='Plus' type='primary' @click='addMenu'>添加</el-button>
</template>
</TableHeader>
<Table ref='tableRef' :pagination='false' />
<popupForm ref='popupRef'></popupForm>
</div>
2023-12-22 16:19:33 +08:00
</template>
2023-12-27 10:39:40 +08:00
<script setup lang='ts'>
2023-12-27 15:06:57 +08:00
import { Plus } from '@element-plus/icons-vue'
2023-12-22 16:19:33 +08:00
import { ref, onMounted, provide } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
2023-12-26 16:17:30 +08:00
import TableHeader from '@/components/table/header/index.vue'
2023-12-27 10:39:40 +08:00
import popupForm from './popupForm.vue'
2023-12-27 15:06:57 +08:00
import { useNavTabs } from '@/stores/navTabs'
2023-12-26 16:17:30 +08:00
2023-12-22 16:19:33 +08:00
defineOptions({
name: 'auth/menu'
})
const tableRef = ref()
2023-12-27 10:39:40 +08:00
const popupRef = ref()
2023-12-27 15:06:57 +08:00
const navTabs = useNavTabs()
2023-12-22 16:19:33 +08:00
const tableStore = new TableStore({
2023-12-27 15:06:57 +08:00
url: '/user-boot/function/getRouteMenu',
2023-12-22 16:19:33 +08:00
column: [
2023-12-27 15:06:57 +08:00
{ title: '菜单名称', field: 'title', align: 'left', treeNode: true },
2023-12-22 16:19:33 +08:00
{
2023-12-27 15:06:57 +08:00
title: '图标',
field: 'icon',
2023-12-22 16:19:33 +08:00
align: 'center',
width: '60',
2023-12-26 16:17:30 +08:00
render: 'icon'
2023-12-22 16:19:33 +08:00
},
{
2023-12-27 15:06:57 +08:00
title: '操作',
2023-12-22 16:19:33 +08:00
align: 'center',
width: '130',
render: 'buttons',
buttons: [
{
name: 'edit',
title: '编辑',
type: 'primary',
icon: 'el-icon-EditPen',
2023-12-27 10:39:40 +08:00
render: 'tipButton',
click: (row) => {
popupRef.value.open('编辑菜单', row)
}
},
{
name: 'del',
title: '删除',
type: 'danger',
icon: 'el-icon-Delete',
render: 'confirmButton',
popconfirm: {
2023-12-27 15:06:57 +08:00
confirmButtonText: '确认',
2023-12-27 10:39:40 +08:00
cancelButtonText: '取消',
confirmButtonType: 'danger',
2023-12-27 15:06:57 +08:00
title: '确定删除该菜单吗?'
2023-12-27 10:39:40 +08:00
},
click: (row) => {
}
2023-12-22 16:19:33 +08:00
}
]
}
]
})
provide('tableStore', tableStore)
onMounted(() => {
tableStore.table.ref = tableRef.value
2023-12-27 15:06:57 +08:00
// tableStore.index()
const handlerRouter = (arr: any[]) => {
return arr.map((item: any, index: number) => {
if (item.children && item.children.length > 0) {
item.children = handlerRouter(item.children)
}
return {
2024-01-05 14:07:53 +08:00
...item.meta,
...item
2023-12-27 15:06:57 +08:00
}
})
}
tableStore.table.data = handlerRouter(navTabs.state.tabsViewRoutes)
tableStore.table.loading = false
2023-12-22 16:19:33 +08:00
})
2023-12-27 10:39:40 +08:00
const addMenu = () => {
console.log(popupRef)
popupRef.value.open('新增菜单')
}
2023-12-22 16:19:33 +08:00
</script>