From ef9f36c75df0b7b08615747a7e844fa1b994b525 Mon Sep 17 00:00:00 2001 From: lb Date: Fri, 26 May 2023 11:10:45 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix=20Login=E9=A1=B5=E9=9D=A2=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/index.html | 4 ++-- src/router/index.js | 57 ++++++++++++++++++++++++++++----------------- src/utils/index.js | 4 ++++ 3 files changed, 41 insertions(+), 24 deletions(-) diff --git a/public/index.html b/public/index.html index 7027717..a89db15 100644 --- a/public/index.html +++ b/public/index.html @@ -38,8 +38,8 @@ <% if (process.env.VUE_APP_NODE_ENV === 'dev') { %> diff --git a/src/router/index.js b/src/router/index.js index 1182441..8d5b302 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -9,6 +9,7 @@ import Vue from 'vue' import Router from 'vue-router' import http from '@/utils/request' import { isURL } from '@/utils/validate' +import { isAuthentcated } from '../utils' Vue.use(Router) @@ -19,7 +20,7 @@ export const pageRoutes = [ component: () => import('@/views/pages/404'), name: '404', meta: { title: '404未找到' }, - beforeEnter (to, from, next) { + beforeEnter(to, from, next) { // 拦截处理特殊业务场景 // 如果, 重定向路由包含__双下划线, 为临时添加路由 if (/__.*/.test(to.redirectedFrom)) { @@ -43,7 +44,7 @@ export const moduleRoutes = { ] } -export function addDynamicRoute (routeParams, router) { +export function addDynamicRoute(routeParams, router) { // 组装路由名称, 并判断是否已添加, 如是: 则直接跳转 var routeName = routeParams.routeName var dynamicRoute = window.SITE_CONFIG['dynamicRoutes'].filter(item => item.name === routeName)[0] @@ -82,27 +83,39 @@ router.beforeEach((to, from, next) => { // 添加动态(菜单)路由 // 已添加或者当前路由为页面路由, 可直接访问 if (window.SITE_CONFIG['dynamicMenuRoutesHasAdded'] || fnCurrentRouteIsPageRoute(to, pageRoutes)) { + // 如果是在已认证的情况下直接访问登录界面 + if (to.name === 'login') { + return next('/') + } return next() } - // 获取字典列表, 添加并全局变量保存 - http.get('/sys/dict/type/all').then(({ data: res }) => { - if (res.code !== 0) { - return - } - window.SITE_CONFIG['dictList'] = res.data - }).catch(() => {}) - // 获取菜单列表, 添加并全局变量保存 - http.get('/sys/menu/nav').then(({ data: res }) => { - if (res.code !== 0) { - Vue.prototype.$message.error(res.msg) - return next({ name: 'login' }) - } - window.SITE_CONFIG['menuList'] = res.data - fnAddDynamicMenuRoutes(window.SITE_CONFIG['menuList']) - next({ ...to, replace: true }) - }).catch(() => { + + if (isAuthentcated()) { + // 获取字典列表, 添加并全局变量保存 + http.get('/sys/dict/type/all').then(({ data: res }) => { + if (res.code !== 0) { + return + } + window.SITE_CONFIG['dictList'] = res.data + }).catch(() => { }) + + // 获取菜单列表, 添加并全局变量保存 + http.get('/sys/menu/nav').then(({ data: res }) => { + if (res.code !== 0) { + Vue.prototype.$message.error(res.msg) + return next({ name: 'login' }) + } + window.SITE_CONFIG['menuList'] = res.data + fnAddDynamicMenuRoutes(window.SITE_CONFIG['menuList']) + next({ ...to, replace: true }) + }).catch(() => { + next({ name: 'login' }) + }) + + } else { next({ name: 'login' }) - }) + } + }) /** @@ -110,7 +123,7 @@ router.beforeEach((to, from, next) => { * @param {*} route 当前路由 * @param {*} pageRoutes 页面路由 */ -function fnCurrentRouteIsPageRoute (route, pageRoutes = []) { +function fnCurrentRouteIsPageRoute(route, pageRoutes = []) { var temp = [] for (var i = 0; i < pageRoutes.length; i++) { if (route.path === pageRoutes[i].path) { @@ -128,7 +141,7 @@ function fnCurrentRouteIsPageRoute (route, pageRoutes = []) { * @param {*} menuList 菜单列表 * @param {*} routes 递归创建的动态(菜单)路由 */ -function fnAddDynamicMenuRoutes (menuList = [], routes = []) { +function fnAddDynamicMenuRoutes(menuList = [], routes = []) { var temp = [] for (var i = 0; i < menuList.length; i++) { if (menuList[i].children && menuList[i].children.length >= 1) { diff --git a/src/utils/index.js b/src/utils/index.js index bf8bb9b..b2ee02a 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -97,3 +97,7 @@ export function treeDataTranslate (data, id = 'id', pid = 'pid') { } return res } + +export function isAuthentcated() { + return Cookies.get('token') +} \ No newline at end of file From d7f9d0996f5eb70b3e924b1a3001a03e979d1131 Mon Sep 17 00:00:00 2001 From: lb Date: Fri, 26 May 2023 11:29:16 +0800 Subject: [PATCH 2/2] =?UTF-8?q?update=20material=20=E5=8E=9F=E6=96=99?= =?UTF-8?q?=E6=9C=80=E5=A4=A7=E5=B0=BA=E5=AF=B8=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/modules/pms/material/config.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/views/modules/pms/material/config.js b/src/views/modules/pms/material/config.js index e9a99f2..bc52826 100644 --- a/src/views/modules/pms/material/config.js +++ b/src/views/modules/pms/material/config.js @@ -9,6 +9,7 @@ export default function () { { width: 90, prop: "code", label: "原料编码" }, { width: 240, prop: "description", label: "原料描述" }, { width: 90, prop: "name", label: "原料名称" }, + { width: 120, prop: "maxSize", label: "原料最大尺寸", filter: val => val ?? '-' }, { width: 90, prop: "typeDictValue", label: "类型", filter: dictFilter("material_category") }, // subcomponent: {/** TODO: create a new component for this option */} }, { prop: "baseMaterialCode", label: "基础原料编码" }, { prop: "baseMaterialDescription", label: "基础原料描述" }, @@ -147,6 +148,15 @@ export default function () { elparams: { placeholder: "原料类别" }, // autoDisabled: true }, + { + input: true, + label: "原料最大尺寸", + prop: "maxSize", + rules: [ + { type: "number", message: "请输入正确的数字类型", trigger: "blur", transform: (val) => Number(val) }, + ], + elparams: { placeholder: "请输入原料最大尺寸" } + }, { select: true, label: "基础原料", @@ -156,7 +166,6 @@ export default function () { fetchData: () => this.$http.get("/pms/baseMaterial/page", { params: { limit: 999, page: 1, key: "" } }), elparams: { placeholder: "请选择基础原料" }, }, - { input: true, label: "堆积密度(g/cm³)", prop: "density", elparams: { placeholder: "堆积密度" } }, // { // input: true, // label: "设备类型", @@ -166,6 +175,7 @@ export default function () { // }, ], [ + { input: true, label: "堆积密度(g/cm³)", prop: "density", elparams: { placeholder: "请输入堆积密度" } }, { input: true, label: "加料下限", @@ -185,7 +195,9 @@ export default function () { { type: "number", message: "请输入正确的数字类型", trigger: "blur", transform: (val) => Number(val) }, ], elparams: { placeholder: "请输入加料上限" }, - }, + } + ], + [ { input: true, label: "备注", prop: "remark", elparams: { placeholder: "请输入备注" } }, // { // select: true,