7db45342 by 任超

Merge branch 'master' into dev

2 parents 45b88067 c195fd34
/*
* @Description:
* @Autor: renchao
* @LastEditTime: 2023-03-23 13:17:59
*/
import request from '@/utils/request'
// let SERVER = JSON.parse(localStorage.getItem('ApiUrl'))
let SERVER = JSON.parse(localStorage.getItem('ApiUrl'))
console.log(JSON.parse(localStorage.getItem('ApiUrl')));
// 获取用户信息
export function getUserInfo () {
return request({
......@@ -9,14 +15,6 @@ export function getUserInfo () {
})
}
// // 获取菜单信息
// export function getMenuInfo () {
// return request({
// url: SERVER.SERVERAPI + '/rest/user/getUserAuthorizationMenus',
// method: 'get',
// })
// }
// 获取菜单信息
export function getMenuInfo (data) {
return request({
......
......@@ -29,7 +29,7 @@ export default {
sidebarRight,
},
computed: {
...mapGetters(["sidebar", "dicData", "userInfo"]),
...mapGetters(["sidebar", "dicData", , "permission_routes", "userInfo"]),
logoName () {
return this.dicData['sysCode'] && this.dicData['sysCode'].filter(item =>
item.DCODE == "systemTitle"
......
<!--
* @Description: log
* @Autor: renchao
* @LastEditTime: 2023-03-23 14:40:06
-->
<template>
<el-menu router :default-active="activeMenu" mode="horizontal">
<!-- 权限菜单 -->
......
<!--
* @Description:
* @Autor: renchao
* @LastEditTime: 2023-03-20 14:22:35
* @LastEditTime: 2023-03-23 15:17:24
-->
<template>
<div class="app-wrapper jgWrapper">
......@@ -12,10 +12,10 @@
</div>
</template>
<script>
import { AppMain, Navbar, Sidebar, TagsView } from './components'
import ResizeMixin from './mixin/ResizeHandler'
import { mapState } from 'vuex'
export default {
import { AppMain, Navbar, Sidebar, TagsView } from './components'
import ResizeMixin from './mixin/ResizeHandler'
import { mapState } from 'vuex'
export default {
name: 'Layout',
components: {
AppMain,
......@@ -24,7 +24,6 @@
TagsView
},
created () {
console.log("hhh");
this.$store.dispatch("products/setData", "BDCJGPT");
},
mixins: [ResizeMixin],
......@@ -35,15 +34,15 @@
fixedHeader: state => state.settings.fixedHeader
})
}
}
}
</script>
<style lang="scss">
@import "~@/styles/jgSidebar.scss";
@import "~@/styles/jgSidebar.scss";
</style>
<style lang="scss" scoped>
@import "~@/styles/mixin.scss";
@import "~@/styles/mixin.scss";
.app-wrapper {
.app-wrapper {
@include clearfix;
position: relative;
height: 100%;
......@@ -58,9 +57,9 @@
position: fixed;
top: 0;
}
}
}
.appMain {
.appMain {
// min-width: 1280px;
height: calc(100vh - 101px) !important;
box-sizing: border-box;
......@@ -68,5 +67,5 @@
.app-main {
height: 100%;
}
}
}
</style>
......
......@@ -2,7 +2,7 @@
* @Author: yangwei
* @Date: 2023-01-16 09:10:12
* @LastEditors: Please set LastEditors
* @LastEditTime: 2023-03-21 15:00:04
* @LastEditTime: 2023-03-23 15:15:02
* @FilePath: \bdcjg-web\src\main.js
* @Description:
*
......
/*
* @Description:
* @Autor: renchao
* @LastEditTime: 2023-03-21 13:52:58
* @LastEditTime: 2023-03-23 15:17:36
*/
import Vue from 'vue'
import router from "./router";
import store from "./store";
import { getMenuInfo } from "@/api/user";
......@@ -14,7 +15,6 @@ import Cookies from "js-cookie";
NProgress.configure({ showSpinner: false });
router.beforeEach(async (to, from, next) => {
getTheme()
NProgress.start();
window.document.documentElement.setAttribute("data-theme", 'blue');
document.title = getPageTitle(to.meta.title);
......@@ -23,17 +23,12 @@ router.beforeEach(async (to, from, next) => {
let hasAddRoute = store.state.permission.addRoutes;
if (to.path == "/sb" || to.path == "/jg") {
localStorage.removeItem("token");
sessionStorage.setItem("psth", to.path)
next();
} else {
let code = sessionStorage.getItem("psth") == "/sb" ? "BDCSBPT" : "BDCJGPT"
//判断token是否存在
const hasToken = localStorage.getItem("token");
if (hasToken) {
let code = Vue.prototype.BASE_API.THEME == "sb" ? "BDCSBPT" : "BDCJGPT"
//请求用户信息
if (!hasUser) {
store.dispatch("user/getUserInfo");
// import("@/styles/public.scss");
}
if (hasAddRoute) {
next();
......@@ -46,27 +41,21 @@ router.beforeEach(async (to, from, next) => {
);
router.addRoutes([
...accessRoutes,
{ path: "*", redirect: "/404", hidden: true },
{ path: "*", redirect: "/404", hidden: true }
]);
const routeTo = Cookies.get("routerTo");
if (!hasAddDict) {
await store.dispatch("dict/generateDic");
}
if (routeTo && routeTo !== "/") {
if (routeTo && routeTo !== "/" && routeTo !== "/sb" && routeTo !== "/jg") {
next({ ...to, replace: true });
} else {
next("/home");
}
next();
}
} else if (sessionStorage.getItem("psth")) {
next(sessionStorage.getItem("psth"));
} else {
next("/jg");
}
}
NProgress.done();
});
NProgress.done()
})
router.afterEach((to) => {
// 解决刷新页面报404问题
Cookies.set("routerTo", to.fullPath);
......
......@@ -33,7 +33,7 @@ export const constantRoutes = [
{
path: '/',
component: Layout,
redirect: '/jg',
redirect: '/sb',
meta: { title: '首页' },
children: [
{
......
/*
* @Description:
* @Autor: renchao
* @LastEditTime: 2023-03-23 15:26:37
*/
var Layout;
let ApiUrl = localStorage.getItem('ApiUrl')
......@@ -19,7 +24,6 @@ export default function filterAsyncRouter (routers) {
item.component = Layout
} else {
item.component = loadView(item.uri)
console.log(item.component, 'item.componentitem.component');
}
item.meta = {
title: item.name,
......
......@@ -2,7 +2,7 @@
<div class="bg">
<div class="login-logo"></div>
<div class="login-inner-bg login">
<h2>{{ productName }}</h2>
<h2>{{ BASE_API.TITLE }}</h2>
<div class="user_style">
<h3>欢迎登录</h3>
<el-form :model="user" :rules="rules" ref="user" id="loginform" class="demo-ruleForm">
......@@ -21,12 +21,11 @@
</div>
</div>
</template>
<script>
import { getMenuInfo } from "@/api/user";
import { loginIn } from "@/api/login.js";
import { api, getAction } from "@/api/manageApi";
export default {
name: "Login",
name: "jgLogin",
data () {
return {
user: {
......@@ -34,41 +33,11 @@ export default {
password: "",
checkStatus: false,
},
productName: "",
rules: {
account: [{ required: true, message: "请填写帐号", trigger: "blur" }],
password: [{ required: true, message: "请填写密码", trigger: "blur" }],
},
};
},
created () {
const params = {};
const queryOptions = {
conditionGroup: {
conditions: [
{
property: "code",
value: "BDCJGPT",
operator: "EQ",
},
],
queryRelation: "AND",
},
};
params.queryOptions = JSON.stringify(queryOptions);
//根据子系统code获取子系统详细信息
getAction(api.subsystem, params).then((res) => {
if (res.status === 1) {
this.productName = res.content[0].name;
this.$store.dispatch("products/setData", res.content[0].code);
sessionStorage.setItem("products", res.content[0].code)
} else {
this.$message.error({ message: res.message, showClose: true });
}
});
},
mounted () {
// this.checkUserName();
}
},
methods: {
//记住用户名
......@@ -87,30 +56,20 @@ export default {
}
},
login (user) {
var self = this;
this.$refs[user].validate((valid) => {
var self = this
this.$refs[user].validate(async (valid) => {
if (valid) {
loginIn(self.user.account, self.user.password)
.then((res) => {
if (res.status === 1) {
//存储token
let res = await loginIn(self.user.account, self.user.password)
if (res.status == 1) {
localStorage.setItem("token", `Bearer ${res.content}`);
//登录成功后需判断有无重定向,没有重定向则跳转首页
console.log(this.$route.query.redirect);
this.$router.replace(this.$route.query.redirect || "/home");
} else {
//错误处理
}
}
})
.catch((error) => {
// console.dir(error);
});
}
});
},
},
components: {},
};
}
}
</script>
<style scoped lang="scss">
.username,
......
......@@ -2,7 +2,7 @@
<div class="bg">
<div class="title">
<img src="../../image/bdclogo.png" alt="">
<h2>{{ productName }}</h2>
<h2>{{ BASE_API.TITLE }}</h2>
</div>
<div class="login-inner-bg login">
<div class="user_style">
......@@ -12,10 +12,10 @@
<el-input class="username" v-model="user.account" placeholder="请输入用户名"></el-input>
</el-form-item>
<el-form-item prop="password">
<el-input type="password" class="password" @keyup.native="login('user')" v-model="user.password"
placeholder="请输入密码" show-password></el-input>
<el-input type="password" class="password" v-model="user.password" placeholder="请输入密码"
show-password></el-input>
</el-form-item>
<el-form-item prop="yz">
<!-- <el-form-item prop="yz">
<div class="flex-container">
<div class="flex-input">
<el-input class="yz" @keyup.native="login('user')" v-model="user.yz" placeholder="请输入验证码"></el-input>
......@@ -26,7 +26,7 @@
<font id="renovate" @click="verification">换一批</font>
</div>
</div>
</el-form-item>
</el-form-item> -->
<el-form-item class="login-btn">
<el-button type="primary" style="width: 100%" @click="login('user')">登录</el-button>
</el-form-item>
......@@ -37,10 +37,11 @@
</template>
<script>
import { getMenuInfo } from "@/api/user";
import { loginIn } from "@/api/login.js";
import { api, getAction } from "@/api/manageApi";
export default {
name: "Login",
name: "sbLogin",
data () {
return {
user: {
......@@ -56,37 +57,6 @@ export default {
},
};
},
created () {
this.verification();
const params = {};
const queryOptions = {
conditionGroup: {
conditions: [
{
property: "code",
value: "BDCSBPT",
operator: "EQ",
},
],
queryRelation: "AND",
},
};
params.queryOptions = JSON.stringify(queryOptions);
//根据子系统code获取子系统详细信息
getAction(api.subsystem, params).then((res) => {
if (res.status === 1) {
this.productName = res.content[0].name;
this.$store.dispatch("products/setData", res.content[0].code);
sessionStorage.setItem("products", res.content[0].code)
} else {
this.$message.error({ message: res.message, showClose: true });
}
});
},
mounted () {
// this.checkUserName();
},
methods: {
verification () {
let str = '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ', code = '', i = 0;
......@@ -134,33 +104,23 @@ export default {
}
},
login (user) {
var self = this;
this.$refs[user].validate((valid) => {
var self = this
this.$refs[user].validate(async (valid) => {
if (valid) {
loginIn(self.user.account, self.user.password)
.then((res) => {
if (res.status === 1) {
this.$store.dispatch('business/setInitRules', "layout1")
//存储token
let res = await loginIn(self.user.account, self.user.password)
if (res.status == 1) {
let code = this.BASE_API.THEME == "sb" ? "BDCSBPT" : "BDCJGPT"
localStorage.setItem("token", `Bearer ${res.content}`);
this.$store.dispatch("products/setData", res.content[0].code);
sessionStorage.setItem("products", res.content[0].code)
const { result: getMenuData } = (await getMenuInfo(code)) || [];
let path1 = JSON.parse(getMenuData[0].metadata)?.path + '/' + JSON.parse(getMenuData[0].children[0].metadata)?.path
//登录成功后需判断有无重定向,没有重定向则跳转首页
this.$router.replace(this.$route.query.redirect || "/jsbwcx/index");
} else {
console.log(res);
this.$message.error({ message: res.message })
this.$router.replace(this.$route.query.redirect || path1);
}
}
})
.catch((error) => {
// console.dir(error);
});
}
});
},
},
components: {},
};
}
}
</script>
<style scoped lang="scss">
.username,
......@@ -182,8 +142,6 @@ export default {
/deep/ .el-input__inner {
color: #000 !important;
text-indent: 24px;
// border: 1px solid rgba(11, 161, 248, 0.4);
// background-color: rgba(6, 135, 205, 0.3) !important;
}
}
......@@ -350,4 +308,5 @@ export default {
.inputUser .ivu-input {
padding: 6px 24px !important;
border: 1px solid #9f9f9f !important;
}</style>
}
</style>
......