| | |
| | | enUS, |
| | | }; |
| | | |
| | | if (globalState.token == '' || globalState.token == null) { |
| | | let token = localStorage.getItem('token') |
| | | let user = JSON.parse(localStorage.getItem('user')) |
| | | globalState.token = token; |
| | | globalState.user = user; |
| | | } |
| | | // if (globalState.token == '' || globalState.token == null) { |
| | | // let token = localStorage.getItem('token') |
| | | // let user = JSON.parse(localStorage.getItem('user')) |
| | | // let locale = localStorage.getItem('locale') |
| | | // globalState.token = token; |
| | | // globalState.user = user; |
| | | // globalState.locale = locale; |
| | | // } |
| | | </script> |
| | | |
| | | <template> |
| | |
| | | 'common.confirm':'Confirm', |
| | | 'common.cancel':'Cancel', |
| | | 'common.reset':'Reset', |
| | | 'common.operation':'Operation', |
| | | 'common.username':'Username', |
| | | 'common.nickname':'Nickname', |
| | | 'common.sex':'Sex', |
| | |
| | | 'common.account.logout': 'Logout', |
| | | 'common.search.placeholder': 'Please enter search content', |
| | | 'common.loading.api.message': 'Calling Server...', |
| | | 'common.loading': 'Loading', |
| | | '':'', |
| | | '':'', |
| | | '':'', |
| | |
| | | '':'', |
| | | '':'', |
| | | '':'', |
| | | 'db.sys_host.name':'Name', |
| | | 'db.sys_host.status':'Status', |
| | | 'db.sys_host.create_time':'createTime', |
| | | 'db.sys_host.update_time':'updateTime', |
| | | 'db.sys_host.memo':'Memo', |
| | | }; |
| | |
| | | import router from './router' |
| | | import Antd from 'ant-design-vue'; |
| | | import 'ant-design-vue/dist/reset.css'; |
| | | import { initRouter } from '@/router/index.js' |
| | | import { globalState } from './config.js' |
| | | |
| | | const app = createApp(App) |
| | | |
| | | app.use(createPinia()) |
| | | app.use(router) |
| | | app.use(Antd) |
| | | const initToken = async () => { |
| | | if (globalState.token == '' || globalState.token == null) { |
| | | let token = localStorage.getItem('token') |
| | | let user = JSON.parse(localStorage.getItem('user')) |
| | | let locale = localStorage.getItem('locale') |
| | | globalState.token = token; |
| | | globalState.user = user; |
| | | globalState.locale = locale; |
| | | } |
| | | } |
| | | |
| | | app.mount('#app') |
| | | const boot = async () => { |
| | | await initToken(); |
| | | await initRouter() |
| | | |
| | | //wait route load |
| | | app.use(createPinia()) |
| | | app.use(router) |
| | | app.use(Antd) |
| | | app.mount('#app') |
| | | } |
| | | boot() |
| | | |
| | | |
| | |
| | | import { createRouter, createWebHistory } from 'vue-router' |
| | | import HomeView from '../views/HomeView.vue' |
| | | import MenuView from '../views/system/menu/index.vue' |
| | | import LoginView from '../views/login/LoginView.vue' |
| | | import UserLoginView from '../views/system/userLogin/index.vue' |
| | | import UserView from '../views/system/user/index.vue' |
| | | import { get } from '@/utils/request.js' |
| | | |
| | | const router = createRouter({ |
| | | history: createWebHistory(import.meta.env.BASE_URL), |
| | |
| | | { |
| | | path: '/', |
| | | name: '主页', |
| | | component: HomeView, |
| | | component: () => import('@/views/HomeView.vue'), |
| | | meta: { |
| | | keepAlive: true // 设置keepAlive,让此路由页面被缓存 |
| | | }, |
| | |
| | | { |
| | | path: '/login', |
| | | name: '登录', |
| | | component: LoginView, |
| | | component: () => import('@/views/login/LoginView.vue'), |
| | | }, |
| | | { |
| | | path: '/system/menu', |
| | | name: '菜单管理', |
| | | component: MenuView, |
| | | meta: { |
| | | keepAlive: true // 设置keepAlive,让此路由页面被缓存 |
| | | }, |
| | | }, |
| | | { |
| | | path: '/system/userLogin', |
| | | name: '登录日志', |
| | | component: UserLoginView, |
| | | meta: { |
| | | keepAlive: true // 设置keepAlive,让此路由页面被缓存 |
| | | }, |
| | | }, |
| | | { |
| | | path: '/system/user', |
| | | name: '用户管理', |
| | | component: UserView, |
| | | meta: { |
| | | keepAlive: true // 设置keepAlive,让此路由页面被缓存 |
| | | }, |
| | | }, |
| | | |
| | | // { |
| | | // path: '/system/menu', |
| | | // name: '菜单管理', |
| | | // component: () => import('@/views/system/menu/index.vue'), |
| | | // meta: { |
| | | // keepAlive: true // 设置keepAlive,让此路由页面被缓存 |
| | | // }, |
| | | // }, |
| | | // { |
| | | // path: '/system/userLogin', |
| | | // name: '登录日志', |
| | | // component: () => import('@/views/system/userLogin/index.vue'), |
| | | // meta: { |
| | | // keepAlive: true // 设置keepAlive,让此路由页面被缓存 |
| | | // }, |
| | | // }, |
| | | // { |
| | | // path: '/system/user', |
| | | // name: '用户管理', |
| | | // component: () => import('@/views/system/user/index.vue'), |
| | | // meta: { |
| | | // keepAlive: true // 设置keepAlive,让此路由页面被缓存 |
| | | // }, |
| | | // }, |
| | | // { |
| | | // path: '/system/host', |
| | | // name: '机构管理', |
| | | // component: () => import('@/views/system/host/index.vue'), |
| | | // meta: { |
| | | // keepAlive: true // 设置keepAlive,让此路由页面被缓存 |
| | | // }, |
| | | // }, |
| | | ] |
| | | }) |
| | | |
| | | export const initRouter = async () => { |
| | | const modules = import.meta.glob('/src/views/**/index.vue'); |
| | | const resp = await get('/api/auth/router', {}); |
| | | let result = resp.data; |
| | | let data = result.data; |
| | | console.log(result); |
| | | data.forEach((item) => { |
| | | const module = modules[`/src/views${item.route}/index.vue`]; |
| | | if (module) { |
| | | const itemRouter = { |
| | | path: item.route, |
| | | name: item.name, |
| | | component: module, |
| | | meta: { |
| | | keepAlive: true // 设置keepAlive,让此路由页面被缓存 |
| | | } |
| | | } |
| | | router.addRoute(itemRouter) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | export default router |
| | |
| | | timeout: 30000, |
| | | }) |
| | | |
| | | export const get = (url, params) => { |
| | | export const get = async (url, params) => { |
| | | return instance({ |
| | | url: url, |
| | | method: 'get', |
| | |
| | | }) |
| | | } |
| | | |
| | | export const post = (url, data) => { |
| | | export const post = async (url, data) => { |
| | | return instance({ |
| | | url: url, |
| | | method: 'post', |
| | |
| | | }) |
| | | } |
| | | |
| | | export const postBlob = (url, data) => { |
| | | export const postBlob = async (url, data) => { |
| | | return instance({ |
| | | url: url, |
| | | method: 'post', |
| | |
| | | }) |
| | | } |
| | | |
| | | export const postForm = (url, params) => { |
| | | export const postForm = async (url, params) => { |
| | | return instance({ |
| | | url: url, |
| | | method: 'post', |
| | |
| | | <script setup> |
| | | import { nextTick, ref, inject, computed } from 'vue'; |
| | | import { nextTick, ref, inject } from 'vue'; |
| | | import { useRouter } from "vue-router"; |
| | | import { get, post } from '@/utils/request.js' |
| | | import { get, post, postForm } from '@/utils/request.js' |
| | | import { logout } from '@/config.js'; |
| | | import * as Icons from "@ant-design/icons-vue"; |
| | | import { message } from 'ant-design-vue'; |
| | | import { |
| | | MenuUnfoldOutlined, |
| | | MenuFoldOutlined, |
| | |
| | | }; |
| | | |
| | | getMenu() |
| | | |
| | | function getMenu() { |
| | | post('/api/menu/tree', {}).then((result) => { |
| | | console.log(result.data.data); |
| | | get('/api/auth/menu', {}).then((result) => { |
| | | menuCache.value = result.data.data; |
| | | }) |
| | | } |
| | | |
| | | function menuSelect(item) { |
| | | console.log(item.key); |
| | | router.push({ |
| | | path: item.key |
| | | }) |
| | | |
| | | let name = item.item.name; |
| | | currentCache.value = name; |
| | | console.log(routerCache.value); |
| | | // console.log(routerCache.value); |
| | | |
| | | if (name != undefined && routerCache.value.indexOf(name) == -1) { |
| | | routerCache.value.push(item.item.name) |
| | |
| | | } |
| | | |
| | | function reloadTabs() { |
| | | isRouterAlive.value = false; |
| | | nextTick(() => { |
| | | isRouterAlive.value = true; |
| | | }) |
| | | const hide = message.loading(formatMessage('common.loading', '加载中')); |
| | | try { |
| | | isRouterAlive.value = false; |
| | | nextTick(() => { |
| | | isRouterAlive.value = true; |
| | | message.success(formatMessage('common.success', '加载成功')); |
| | | }) |
| | | } catch (error) { |
| | | message.error(formatMessage('common.fail', '加载失败')); |
| | | } finally { |
| | | hide(); |
| | | } |
| | | } |
| | | |
| | | function switchTabs(name) { |
| | |
| | | currentCache.value = name; |
| | | selectedKeys.value = [routerCacheMap.value.get(name)] |
| | | |
| | | console.log(routerCacheMap, name, routerCacheMap.value.get(name)); |
| | | // console.log(routerCacheMap, name, routerCacheMap.value.get(name)); |
| | | |
| | | } |
| | | |
| | | const switchLocale = (locale) => { |
| | | globalState.locale = locale; |
| | | localStorage.setItem('locale', locale) |
| | | reloadTabs() |
| | | console.log(locale); |
| | | } |
| | | |
| | | </script> |
| | |
| | | theme="dark" mode="inline"> |
| | | <div> |
| | | <a-menu-item key="/" name="主页"> |
| | | <HomeOutlined /> {{ formatMessage('common.home','主页') }} |
| | | <HomeOutlined /> {{ formatMessage('common.home', '主页') }} |
| | | </a-menu-item> |
| | | </div> |
| | | |
| | |
| | | </a> |
| | | <template #overlay> |
| | | <a-menu @click="logout"> |
| | | <a-menu-item key="logout">{{ formatMessage('common.account.logout','退出') }}</a-menu-item> |
| | | <a-menu-item key="logout">{{ formatMessage('common.account.logout', '退出') }}</a-menu-item> |
| | | </a-menu> |
| | | </template> |
| | | </a-dropdown> |
| | |
| | | continue; |
| | | } |
| | | sb.append(" {\n") |
| | | .append(" title: '").append(column.getComment()).append("',\n") |
| | | .append(" title: formatMessage('db.").append(table).append(".").append(column.getName()).append("', '").append(column.getComment()).append("'),").append("\n") |
| | | .append(" dataIndex: '"); |
| | | if ("Date".equals(column.getType()) || !Cools.isEmpty(column.getEnums()) || !Cools.isEmpty(column.getForeignKeyMajor())){ |
| | | // 时间、枚举 格式化 主键修饰 |
| | |
| | | const columns = [ |
| | | @{TABLECOLUMNS} |
| | | { |
| | | title: '操作', |
| | | title: formatMessage('common.operation', '操作'), |
| | | name: 'oper', |
| | | dataIndex: 'oper', |
| | | key: 'oper', |
| | |
| | | content: formatMessage('page.delete.confirm', '确定删除该项吗?'), |
| | | maskClosable: true, |
| | | onOk: async () => { |
| | | post('/api/@{SIMPLEENTITYNAME}/remove/' + rows.map((row) => row.id).join(','), {}).then(resp => { |
| | | let result = resp.data; |
| | | if (result.code === 200) { |
| | | message.success(result.msg); |
| | | } else { |
| | | message.error(result.msg); |
| | | } |
| | | getPage() |
| | | }) |
| | | const hide = message.loading(formatMessage('common.loading', '请求中')); |
| | | try { |
| | | post('/api/@{SIMPLEENTITYNAME}/remove/' + rows.map((row) => row.id).join(','), {}).then(resp => { |
| | | let result = resp.data; |
| | | if (result.code === 200) { |
| | | message.success(result.msg); |
| | | } else { |
| | | message.error(result.msg); |
| | | } |
| | | getPage() |
| | | hide() |
| | | }) |
| | | } catch (error) { |
| | | message.error(formatMessage('common.fail', '请求失败')); |
| | | } |
| | | }, |
| | | }); |
| | | } |
| | |
| | | package com.zy.asrs.wms.system.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.R; |
| | | import com.zy.asrs.wms.common.annotation.OperationLog; |
| | |
| | | import com.zy.asrs.wms.system.controller.param.LoginParam; |
| | | import com.zy.asrs.wms.system.controller.param.UpdatePasswordParam; |
| | | import com.zy.asrs.wms.system.controller.result.LoginResult; |
| | | import com.zy.asrs.wms.system.entity.Host; |
| | | import com.zy.asrs.wms.system.entity.Menu; |
| | | import com.zy.asrs.wms.system.entity.User; |
| | | import com.zy.asrs.wms.system.entity.UserLogin; |
| | | import com.zy.asrs.wms.system.service.HostService; |
| | | import com.zy.asrs.wms.system.service.RoleMenuService; |
| | | import com.zy.asrs.wms.system.service.UserLoginService; |
| | | import com.zy.asrs.wms.system.service.UserService; |
| | | import com.zy.asrs.wms.system.entity.*; |
| | | import com.zy.asrs.wms.system.service.*; |
| | | import com.zy.asrs.wms.utils.JwtUtil; |
| | | import com.zy.asrs.wms.utils.Utils; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | private RoleMenuService roleMenuService; |
| | | @Resource |
| | | private HostService hostService; |
| | | @Resource |
| | | private UserRoleService userRoleService; |
| | | @Resource |
| | | private MenuService menuService; |
| | | |
| | | @PostMapping("/login") |
| | | public R login(@RequestBody LoginParam param, HttpServletRequest request) { |
| | |
| | | return R.error("修改失败"); |
| | | } |
| | | |
| | | @GetMapping("/auth/router") |
| | | public R router() { |
| | | List<UserRole> userRoles = userRoleService.list(new LambdaQueryWrapper<UserRole>().eq(UserRole::getUserId, getLoginUserId())); |
| | | if (userRoles.isEmpty()) { |
| | | return R.error(); |
| | | } |
| | | ArrayList<Long> roles = new ArrayList<>(); |
| | | for (UserRole userRole : userRoles) { |
| | | roles.add(userRole.getRoleId()); |
| | | } |
| | | |
| | | ArrayList<Long> menus = new ArrayList<>(); |
| | | List<RoleMenu> roleMenus = roleMenuService.list(new LambdaQueryWrapper<RoleMenu>().in(RoleMenu::getRoleId, roles)); |
| | | for (RoleMenu roleMenu : roleMenus) { |
| | | if(!menus.contains(roleMenu.getMenuId())) { |
| | | menus.add(roleMenu.getMenuId()); |
| | | } |
| | | } |
| | | |
| | | List<Menu> menuList = menuService.list(new LambdaQueryWrapper<Menu>() |
| | | .in(Menu::getId, menus) |
| | | .eq(Menu::getType, Menu.TYPE_MENU) |
| | | .eq(Menu::getPath, 1) |
| | | .orderByAsc(Menu::getId)); |
| | | |
| | | return R.ok().add(menuList); |
| | | } |
| | | |
| | | } |