| | |
| | | <template #default="scope"> |
| | | <el-button size="small" text type="primary" @click="onOpenMenuDialog('新增')">新增</el-button> |
| | | <el-button size="small" text type="primary" @click="onOpenMenuDialog('修改',scope.row)">修改</el-button> |
| | | <!-- <el-button size="small" text type="primary" @click="onTabelRowDel(scope.row)">删除</el-button>--> |
| | | <el-button size="small" text type="primary" @click="deleteMenu(scope.row)">删除</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | |
| | | import pinia from "/@/stores"; |
| | | import {dynamicRoutes} from "/@/router/route"; |
| | | import {useUserInfo} from "/@/stores/userInfo"; |
| | | import {initBackEndControlRoutes} from "/@/router/backEnd"; |
| | | |
| | | export default defineComponent({ |
| | | name: 'systemMenu', |
| | | components: { menuDialog }, |
| | | setup() { |
| | | const menuDialog = ref(); |
| | | const storesRoutesList = useRoutesList(); |
| | | const state = reactive({ |
| | | projectId:'1', |
| | | menuData:[], |
| | |
| | | }; |
| | | // 打开编辑菜单弹窗 |
| | | // 删除当前行 |
| | | const onTabelRowDel = (row: RouteRecordRaw) => { |
| | | const deleteMenu = (row: any) => { |
| | | ElMessageBox.confirm(`此操作将永久删除路由:${row.path}, 是否继续?`, '提示', { |
| | | confirmButtonText: '删除', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }).then(() => { |
| | | ElMessage.success('删除成功'); |
| | | }).then(async () => { |
| | | let res = await useMenuApi().deleteMenu({id:row.id}) |
| | | if(res.data.code ==='200'){ |
| | | ElMessage({ |
| | | type:'success', |
| | | duration:2000, |
| | | message:'删除成功' |
| | | }) |
| | | await getMenuList() |
| | | if(Session.get('projectId') == state.projectId) await initBackEndControlRoutes() |
| | | }else{ |
| | | ElMessage({ |
| | | type:'warning', |
| | | message:res.data.msg |
| | | }) |
| | | } |
| | | }).catch(() => {}); |
| | | }; |
| | | const getMenuList = async () => { |
| | | let res = await useMenuApi().getMenuAdmin(state.projectId) |
| | | if(res.data.code === '200'){ |
| | | state.menuTableData = res.data.data |
| | | // const storesRoutesList = useRoutesList(pinia); |
| | | // storesRoutesList.setRoutesList(res.data.data); |
| | | if(Session.get('projectId') == state.projectId) await initBackEndControlRoutes() |
| | | }else{ |
| | | ElMessage({ |
| | | type:'warning', |
| | |
| | | getMenuList, |
| | | menuDialog, |
| | | onOpenMenuDialog, |
| | | onTabelRowDel, |
| | | deleteMenu, |
| | | ...toRefs(state), |
| | | }; |
| | | }, |