2023-12-22 16:19:33 +08:00
|
|
|
|
<template>
|
2024-01-05 15:14:35 +08:00
|
|
|
|
<div class="default-main">
|
2023-12-27 15:06:57 +08:00
|
|
|
|
<TableHeader>
|
|
|
|
|
|
<template v-slot:operation>
|
2024-01-15 16:15:24 +08:00
|
|
|
|
<el-button :icon="Plus" type="primary" @click="addMenu">新增</el-button>
|
2023-12-27 15:06:57 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</TableHeader>
|
2024-01-15 16:15:24 +08:00
|
|
|
|
<Table ref="tableRef" />
|
2024-01-05 15:14:35 +08:00
|
|
|
|
<popupForm ref="popupRef"></popupForm>
|
2023-12-27 15:06:57 +08:00
|
|
|
|
</div>
|
2023-12-22 16:19:33 +08:00
|
|
|
|
</template>
|
2024-01-05 15:14:35 +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'
|
2024-01-05 16:28:23 +08:00
|
|
|
|
import { delMenu } from '@/api/systerm'
|
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({
|
2024-01-15 16:15:24 +08:00
|
|
|
|
showPage: false,
|
2024-01-05 15:14:35 +08:00
|
|
|
|
url: '/user-boot/function/functionTree',
|
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',
|
2024-01-05 15:14:35 +08:00
|
|
|
|
click: row => {
|
2023-12-27 10:39:40 +08:00
|
|
|
|
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
|
|
|
|
},
|
2024-01-05 16:28:23 +08:00
|
|
|
|
click: row => {
|
|
|
|
|
|
delMenu(row.id).then(() => {
|
|
|
|
|
|
tableStore.index()
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2023-12-22 16:19:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
}
|
2024-01-05 16:28:23 +08:00
|
|
|
|
],
|
|
|
|
|
|
loadCallback:()=>{
|
|
|
|
|
|
// 过滤数组中type等于1的数据,children下钻
|
|
|
|
|
|
const filterData = (arr:any[])=>{
|
|
|
|
|
|
return arr.filter((item:any)=>{
|
|
|
|
|
|
if (item.children.length) {
|
|
|
|
|
|
item.children = filterData(item.children)
|
|
|
|
|
|
}
|
|
|
|
|
|
return item.type != 1
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
tableStore.table.data = filterData(tableStore.table.data)
|
|
|
|
|
|
}
|
2023-12-22 16:19:33 +08:00
|
|
|
|
})
|
|
|
|
|
|
provide('tableStore', tableStore)
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
tableStore.table.ref = tableRef.value
|
2024-01-05 15:14:35 +08:00
|
|
|
|
tableStore.index()
|
2023-12-27 15:06:57 +08:00
|
|
|
|
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>
|