feat: 菜单初始化

This commit is contained in:
admin 2024-09-08 14:47:11 +08:00
parent 48a6f3cabc
commit ba1f0964d2
12 changed files with 142 additions and 904 deletions

View File

@ -6,7 +6,7 @@ VITE_APP_BASE_API = '/'
# /test/sh0001/api
# 线上接口地址
VITE_APP_API_URL = 'https://cloud.52zaisheng.cn'
VITE_APP_API_URL = 'https://ifanda.52zaisheng.cn/dy'
# 开发接口地址
# VITE_APP_API_URL = http://localhost:8989

View File

@ -1,870 +0,0 @@
[
{
"path": "/self/receive-core",
"component": "Layout",
"name": "/receive-core",
"meta": {
"title": "收货入库",
"icon": "el-icon-operation",
"hidden": false,
"alwaysShow": false,
"params": null
},
"children": [
{
"path": "receive-pricing",
"component": "self/receive-core/pricing",
"name": "receive-pricing",
"meta": {
"title": "待定价",
"icon": "el-icon-Star",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": {
"scaleStatus": 0
}
}
},
{
"path": "receive-waiting-tare",
"component": "self/receive-core/pricing",
"name": "receive-waiting-tare",
"meta": {
"title": "待过皮重",
"icon": "el-icon-Star",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": {
"scaleStatus": 1
}
}
},
{
"path": "receive-review",
"component": "self/receive-core/pricing",
"name": "receive-review",
"meta": {
"title": "待审核",
"icon": "el-icon-Star",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": {
"scaleStatus": 2
}
}
},
{
"path": "receive-waiting-pay",
"component": "self/receive-core/pricing",
"name": "receive-waiting-pay",
"meta": {
"title": "待付款",
"icon": "el-icon-Star",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": {
"scaleStatus": 3
}
}
},
{
"path": "receive-pay",
"component": "self/receive-core/pricing",
"name": "receive-pay",
"meta": {
"title": "已付款",
"icon": "el-icon-Star",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": {
"scaleStatus": 4
}
}
},
{
"path": "receive-spl",
"component": "self/receive-core/receive-spl",
"name": "receive-spl",
"meta": {
"title": "收货补单",
"icon": "el-icon-menu",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
}
]
},
{
"path": "/self/shipment-core",
"component": "Layout",
"name": "/shipment-core",
"meta": {
"title": "出货销售",
"icon": "el-icon-operation",
"hidden": false,
"alwaysShow": false,
"params": null
},
"children": [
{
"path": "shipmenting",
"component": "self/shipment-core/shipmenting",
"name": "shipmenting",
"meta": {
"title": "待出货",
"icon": "el-icon-Star",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": {
"scaleStatus": 0
}
}
},
{
"path": "shipment-gross",
"component": "self/shipment-core/shipmenting",
"name": "shipment-gross",
"meta": {
"title": "待过毛重",
"icon": "el-icon-Star",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": {
"scaleStatus": 1
}
}
},
{
"path": "shipment-settlement",
"component": "self/shipment-core/shipmenting",
"name": "shipment-settlement",
"meta": {
"title": "待结算",
"icon": "el-icon-Star",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": {
"scaleStatus": 2
}
}
},
{
"path": "shipment-payment",
"component": "self/shipment-core/shipmenting",
"name": "shipment-payment",
"meta": {
"title": "待收款",
"icon": "el-icon-Star",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": {
"scaleStatus": 3
}
}
},
{
"path": "shipment-paied",
"component": "self/shipment-core/shipmenting",
"name": "shipment-paied",
"meta": {
"title": "已收款",
"icon": "el-icon-Star",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": {
"scaleStatus": 4
}
}
},
{
"path": "shipment-spl",
"component": "self/shipment-core/shipment-spl",
"name": "shipment-spl",
"meta": {
"title": "出货补单",
"icon": "el-icon-menu",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
}
]
},
{
"path": "/self/receive-data",
"component": "Layout",
"name": "/receive-data",
"meta": {
"title": "收货数据",
"icon": "el-icon-operation",
"hidden": false,
"alwaysShow": false,
"params": null
},
"children": [
{
"path": "receive-detail",
"component": "self/receive-data/receive-detail",
"name": "receive-detail",
"meta": {
"title": "收货明细",
"icon": "el-icon-menu",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "receive-summary",
"component": "self/receive-data/receive-summary",
"name": "receive-summary",
"meta": {
"title": "收货汇总",
"icon": "el-icon-menu",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "receive-cancel",
"component": "self/receive-data/receive-cancel",
"name": "receive-cancel",
"meta": {
"title": "收货作废",
"icon": "el-icon-menu",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "supplier-rank",
"component": "self/receive-data/supplier-rank",
"name": "supplier-rank",
"meta": {
"title": "供应商排行",
"icon": "el-icon-menu",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
}
]
},
{
"path": "/self/shipment-data",
"component": "Layout",
"name": "/shipment-data",
"meta": {
"title": "出货数据",
"icon": "el-icon-operation",
"hidden": false,
"alwaysShow": false,
"params": null
},
"children": [
{
"path": "shipment-detail",
"component": "self/shipment-data/shipment-detail",
"name": "shipment-detail",
"meta": {
"title": "出货明细",
"icon": "el-icon-menu",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "shipment-summary",
"component": "self/shipment-data/shipment-summary",
"name": "shipment-summary",
"meta": {
"title": "出货汇总",
"icon": "el-icon-menu",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "shipment-cancel",
"component": "self/shipment-data/shipment-cancel",
"name": "shipment-cancel",
"meta": {
"title": "出货作废",
"icon": "el-icon-menu",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "customer-rank",
"component": "self/shipment-data/customer-rank",
"name": "customer-rank",
"meta": {
"title": "客户排行",
"icon": "el-icon-menu",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
}
]
},
{
"path": "/self/my-account",
"component": "Layout",
"name": "/my-account",
"meta": {
"title": "我的账本",
"icon": "el-icon-operation",
"hidden": false,
"alwaysShow": false,
"params": null
},
"children": [
{
"path": "business-overview",
"component": "self/my-account/business-overview",
"name": "business-overview",
"meta": {
"title": "经营概况",
"icon": "el-icon-menu",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "supplier-reconciliation",
"component": "self/my-account/supplier-reconciliation",
"name": "supplier-reconciliation",
"meta": {
"title": "供应商对账",
"icon": "el-icon-menu",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "customer-reconciliation",
"component": "self/my-account/customer-reconciliation",
"name": "customer-reconciliation",
"meta": {
"title": "客户对账",
"icon": "el-icon-menu",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "payment-details",
"component": "self/my-account/payment-details",
"name": "payment-details",
"meta": {
"title": "付款明细",
"icon": "el-icon-menu",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "collection-details",
"component": "self/my-account/collection-details",
"name": "collection-details",
"meta": {
"title": "收款明细",
"icon": "el-icon-menu",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
}
]
},
{
"path": "/self/params-mgt",
"component": "Layout",
"name": "/params-mgt",
"meta": {
"title": "参数管理",
"icon": "el-icon-operation",
"hidden": false,
"alwaysShow": false,
"params": null
},
"children": [
{
"path": "receive-type",
"component": "self/params-mgt/receive-type",
"name": "receive-type",
"meta": {
"title": "收货分类",
"icon": "el-icon-menu",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "receive-product",
"component": "self/params-mgt/receive-product",
"name": "receive-product",
"meta": {
"title": "收货产品",
"icon": "el-icon-menu",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "shipment-type",
"component": "self/params-mgt/shipment-type",
"name": "shipment-type",
"meta": {
"title": "出货分类",
"icon": "el-icon-menu",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "shipment-product",
"component": "self/params-mgt/shipment-product",
"name": "shipment-product",
"meta": {
"title": "出货产品",
"icon": "el-icon-menu",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "supplier-type",
"component": "self/params-mgt/supplier-type",
"name": "supplier-type",
"meta": {
"title": "供应商分类",
"icon": "el-icon-menu",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "supplier-mgt",
"component": "self/params-mgt/supplier-mgt",
"name": "supplier-mgt",
"meta": {
"title": "供应商管理",
"icon": "el-icon-menu",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "customer-mgt",
"component": "self/params-mgt/customer-mgt",
"name": "customer-mgt",
"meta": {
"title": "客户管理",
"icon": "el-icon-user",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "stock-card-mgt",
"component": "self/params-mgt/stock-card-mgt",
"name": "stock-card-mgt",
"meta": {
"title": "库存卡管理",
"icon": "el-icon-postcard",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "user-mgt",
"component": "self/params-mgt/user-mgt",
"name": "user-mgt",
"meta": {
"title": "用户管理",
"icon": "el-icon-user",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "role-mgt",
"component": "self/params-mgt/role-mgt",
"name": "role-mgt",
"meta": {
"title": "角色管理",
"icon": "el-icon-menu",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
}
]
},
{
"path": "/self/other-config",
"component": "Layout",
"name": "/other-config",
"meta": {
"title": "其他配置",
"icon": "system",
"hidden": false,
"alwaysShow": false,
"params": null
},
"children": [
{
"path": "print-template",
"component": "self/other-config/print-template",
"name": "print",
"meta": {
"title": "打印模板",
"icon": "el-icon-printer",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "other",
"component": "self/other-config/other",
"name": "config",
"meta": {
"title": "其他配置",
"icon": "el-icon-setting",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
}
]
},
{
"path": "/system",
"component": "Layout",
"redirect": "/system/user",
"name": "/system",
"meta": {
"title": "系统管理",
"icon": "system",
"hidden": false,
"alwaysShow": false,
"params": null
},
"children": [
{
"path": "user",
"component": "system/user/index",
"name": "User",
"meta": {
"title": "用户管理",
"icon": "el-icon-User",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "role",
"component": "system/role/index",
"name": "Role",
"meta": {
"title": "角色管理",
"icon": "role",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "menu",
"component": "system/menu/index",
"name": "Menu",
"meta": {
"title": "菜单管理",
"icon": "menu",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "dept",
"component": "system/dept/index",
"name": "Dept",
"meta": {
"title": "部门管理",
"icon": "tree",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "dict",
"component": "system/dict/index",
"name": "Dict",
"meta": {
"title": "字典管理",
"icon": "dict",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
}
]
},
{
"path": "/component",
"component": "Layout",
"name": "/component",
"meta": {
"title": "组件封装",
"icon": "menu",
"hidden": false,
"alwaysShow": false,
"params": null
},
"children": [
{
"path": "curd",
"component": "demo/curd/index",
"name": "Curd",
"meta": {
"title": "增删改查",
"icon": "",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "table-select",
"component": "demo/table-select/index",
"name": "TableSelect",
"meta": {
"title": "列表选择器",
"icon": "",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "wang-editor",
"component": "demo/wang-editor",
"name": "WangEditor",
"meta": {
"title": "富文本编辑器",
"icon": "",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "upload",
"component": "demo/upload",
"name": "Upload",
"meta": {
"title": "图片上传",
"icon": "",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "icon-selector",
"component": "demo/icon-selector",
"name": "IconSelector",
"meta": {
"title": "图标选择器",
"icon": "",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "dict-demo",
"component": "demo/dict",
"name": "DictDemo",
"meta": {
"title": "字典组件",
"icon": "",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
}
]
},
{
"path": "/route-param",
"component": "Layout",
"name": "/routeParam",
"meta": {
"title": "路由参数",
"icon": "el-icon-ElementPlus",
"hidden": false,
"alwaysShow": true,
"params": null
},
"children": [
{
"path": "route-param-type1",
"component": "demo/route-param",
"name": "RouteParamType1",
"meta": {
"title": "参数(type=1)",
"icon": "el-icon-Star",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": {
"type": "1"
}
}
},
{
"path": "route-param-type2",
"component": "demo/route-param",
"name": "RouteParamType2",
"meta": {
"title": "参数(type=2)",
"icon": "el-icon-StarFilled",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": {
"type": "2"
}
}
}
]
},
{
"path": "/function",
"component": "Layout",
"name": "/function",
"meta": {
"title": "功能演示",
"icon": "menu",
"hidden": false,
"alwaysShow": false,
"params": null
},
"children": [
{
"path": "icon-demo",
"component": "demo/icons",
"name": "IconDemo",
"meta": {
"title": "Icons",
"icon": "el-icon-Notification",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "/function/websocket",
"component": "demo/websocket",
"name": "/function/websocket",
"meta": {
"title": "Websocket",
"icon": "",
"hidden": false,
"keepAlive": true,
"alwaysShow": false,
"params": null
}
},
{
"path": "other/:id",
"component": "demo/other",
"name": "Other/:id",
"meta": {
"title": "敬请期待...",
"icon": "",
"hidden": false,
"alwaysShow": false,
"params": null
}
}
]
}
]

View File

@ -1 +1,104 @@
[]
[
{
"path": "/self/battery",
"component": "Layout",
"name": "/battery",
"meta": {
"title": "电池回收",
"icon": "",
"hidden": false,
"alwaysShow": false,
"params": null
},
"children": [
{
"path": "b-inquiry",
"component": "self/battery/b-inquiry",
"name": "b-inquiry",
"meta": {
"title": "询价管理",
"icon": "",
"hidden": false,
"keepAlive": true,
"alwaysShow": false
}
},
{
"path": "b-regis",
"component": "self/battery/b-regis",
"name": "b-regis",
"meta": {
"title": "登记列表",
"icon": "",
"hidden": false,
"keepAlive": true,
"alwaysShow": false
}
}
]
},
{
"path": "/self/vehicle",
"component": "Layout",
"name": "/vehicle",
"meta": {
"title": "汽车回收",
"icon": "",
"hidden": false,
"alwaysShow": false,
"params": null
},
"children": [
{
"path": "v-inquiry",
"component": "self/vehicle/v-inquiry",
"name": "v-inquiry",
"meta": {
"title": "询价管理",
"icon": "",
"hidden": false,
"keepAlive": true,
"alwaysShow": false
}
},
{
"path": "v-regis",
"component": "self/vehicle/v-regis",
"name": "v-regis",
"meta": {
"title": "登记列表",
"icon": "",
"hidden": false,
"keepAlive": true,
"alwaysShow": false
}
}
]
},
{
"path": "/self/steel",
"component": "Layout",
"name": "/steel",
"meta": {
"title": "废钢回收",
"icon": "",
"hidden": false,
"alwaysShow": false,
"params": null
},
"children": [
{
"path": "s-regis",
"component": "self/steel/s-regis",
"name": "s-regis",
"meta": {
"title": "申请列表",
"icon": "",
"hidden": false,
"keepAlive": true,
"alwaysShow": false
}
}
]
}
]

View File

@ -71,7 +71,8 @@
:src="userStore.user.avatar + '?imageView2/1/w/80/h/80'"
class="rounded-full mr-10px w24px w24px"
/> -->
<span>{{ userStore.user.userInfo.name }}</span>
<!-- userStore.user.userInfo.name -->
<span>admin</span>
</div>
<template #dropdown>
<el-dropdown-menu>

View File

@ -16,18 +16,18 @@ export function setupPermission() {
NProgress.start();
const hasToken = localStorage.getItem(TOKEN_KEY);
if (hasToken) {
if (true) {
if (to.path === "/login") {
// 如果已登录,跳转到首页
next({ path: "/" });
NProgress.done();
} else {
const userStore = useUserStore();
debugger;
// const userStore = useUserStore();
await userStore.getUserInfo();
// await userStore.getUserInfo();
const permissionStore = usePermissionStore();
const dynamicRoutes = await permissionStore.generateRoutes();
const dynamicRoutes = permissionStore.routes;
dynamicRoutes.forEach((route: RouteRecordRaw) =>
router.addRoute(route)
);
@ -56,14 +56,6 @@ export function setupPermission() {
// }
}
} else {
// 未登录
if (whiteList.includes(to.path)) {
next(); // 在白名单,直接进入
} else {
// 不在白名单,重定向到登录页
redirectToLogin(to, next);
NProgress.done();
}
}
});
@ -88,19 +80,20 @@ export function hasAuth(
value: string | string[],
type: "button" | "role" = "button"
) {
const { roleList, perm } = useUserStore().user;
// const { roleList, perm } = useUserStore().user;
if (roleList.length === 0) {
ElMessage.error("当前用户未配置任何权限");
return false;
}
// 超级管理员 拥有所有权限
if (type === "button" && roleList[0].roleCode.includes("ROOT")) {
return true;
}
// if (roleList.length === 0) {
// ElMessage.error("当前用户未配置任何权限");
// return false;
// }
// // 超级管理员 拥有所有权限
// if (type === "button" && roleList[0].roleCode.includes("ROOT")) {
// return true;
// }
const auths = type === "button" ? perm : roleList;
return typeof value === "string"
? auths.includes(value)
: value.some((perm) => auths.includes(perm));
// const auths = type === "button" ? perm : roleList;
// return typeof value === "string"
// ? auths.includes(value)
// : value.some((perm) => auths.includes(perm));
return true;
}

View File

@ -41,7 +41,6 @@ export const constantRoutes: RouteRecordRaw[] = [
icon: "homepage",
affix: true,
keepAlive: true,
hidden: true,
},
},
{
@ -122,9 +121,9 @@ const router = createRouter({
// 全局注册 router
export function setupRouter(app: App<Element>) {
// const permissionStore = usePermissionStore();
// const dynamicRoutes = permissionStore.routes;
// dynamicRoutes.forEach((route: RouteRecordRaw) => router.addRoute(route));
const permissionStore = usePermissionStore();
const dynamicRoutes = permissionStore.routes;
dynamicRoutes.forEach((route: RouteRecordRaw) => router.addRoute(route));
app.use(router);
}

View File

@ -10,6 +10,7 @@ import menusJson from "@/json/menus.json";
const menus = menusJson;
export const usePermissionStore = defineStore("permission", () => {
// console.log(transformRoutes(menus as any));
/**
*
*/
@ -28,13 +29,19 @@ export const usePermissionStore = defineStore("permission", () => {
*/
function generateRoutes() {
return new Promise<RouteRecordRaw[]>((resolve, reject) => {
const dynamicRoutes = transformRoutes(menus);
const dynamicRoutes = transformRoutes([]);
routes.value = constantRoutes.concat(dynamicRoutes);
// dynamicRoutes.forEach((route: RouteRecordRaw) =>
// router.addRoute(route)
// );
resolve(dynamicRoutes);
// MenuAPI.getRoutes()
// .then((data) => {
// const dynamicRoutes = transformRoutes(data);
// routes.value = constantRoutes.concat(dynamicRoutes);
// // dynamicRoutes.forEach((route: RouteRecordRaw) =>
// // router.addRoute(route)
// // );
// resolve(dynamicRoutes);
// })
// .catch((error) => {

View File

@ -0,0 +1 @@
<template><div>111</div></template>

View File

@ -0,0 +1 @@
<template><div>222</div></template>

View File

@ -0,0 +1 @@
<template><div>333</div></template>

View File

@ -0,0 +1 @@
<template><div>444</div></template>

View File

@ -0,0 +1 @@
<template><div>555</div></template>