c3afa824 by xiaomiao

路由前置守卫修改

1 parent 01fc196e
...@@ -8,10 +8,21 @@ export function getUserInfo () { ...@@ -8,10 +8,21 @@ export function getUserInfo () {
8 }) 8 })
9 } 9 }
10 10
11 // // 获取菜单信息
12 // export function getMenuInfo () {
13 // return request({
14 // url: SERVER.SERVERAPI + '/rest/user/getUserAuthorizationMenus',
15 // method: 'get',
16 // })
17 // }
18
11 // 获取菜单信息 19 // 获取菜单信息
12 export function getMenuInfo () { 20 export function getMenuInfo (data) {
13 return request({ 21 return request({
14 url: SERVER.SERVERAPI + '/rest/user/getUserAuthorizationMenus', 22 url: SERVER.SERVERAPI + '/rest/user/getUserAuthorizationMenus',
15 method: 'get', 23 method: 'get',
24 params: {
25 productCode: data,
26 },
16 }) 27 })
17 }
...\ No newline at end of file ...\ No newline at end of file
28 }
......
...@@ -16,247 +16,247 @@ ...@@ -16,247 +16,247 @@
16 <sidebarRight /> 16 <sidebarRight />
17 </div> 17 </div>
18 </div> 18 </div>
19 </div> 19 </div>
20 </template> 20 </template>
21 <script> 21 <script>
22 import sidebarLeft from "./Sidebar/sidebarLeft"; 22 import sidebarLeft from "./Sidebar/sidebarLeft";
23 import sidebarRight from "./Sidebar/sidebarRight"; 23 import sidebarRight from "./Sidebar/sidebarRight";
24 import { logout } from "@/api/login.js"; 24 import { logout } from "@/api/login.js";
25 import { mapGetters } from "vuex"; 25 import { mapGetters } from "vuex";
26 export default { 26 export default {
27 components: { 27 components: {
28 sidebarLeft, 28 sidebarLeft,
29 sidebarRight, 29 sidebarRight,
30 },
31 computed: {
32 ...mapGetters(["sidebar", "dicData","userInfo"]),
33 logoName() {
34 return this.dicData['sysCode'] && this.dicData['sysCode'].filter(item =>
35 item.DCODE == "systemTitle"
36 )
37 }, 30 },
38 userName(){ 31 computed: {
39 return this.userInfo ? this.userInfo.name : "" 32 ...mapGetters(["sidebar", "dicData", "userInfo"]),
40 } 33 logoName () {
41 }, 34 return this.dicData['sysCode'] && this.dicData['sysCode'].filter(item =>
42 methods: { 35 item.DCODE == "systemTitle"
43 onCancel () { 36 )
44 logout() 37 },
45 .then((res) => { 38 userName () {
46 sessionStorage.removeItem("token"); 39 return this.userInfo ? this.userInfo.name : ""
47 this.$store.dispatch("user/resetState"); 40 }
48 this.$router.replace({ 41 },
49 path: "/login/jg", 42 methods: {
50 query: { 43 onCancel () {
51 redirect: this.$route.fullPath, 44 logout()
52 }, 45 .then((res) => {
46 sessionStorage.removeItem("token");
47 this.$store.dispatch("user/resetState");
48 this.$router.replace({
49 path: "/jg",
50 query: {
51 redirect: this.$route.fullPath,
52 },
53 });
54 })
55 .catch((error) => {
56 // console.dir(error);
53 }); 57 });
54 }) 58 },
55 .catch((error) => {
56 // console.dir(error);
57 });
58 }, 59 },
59 }, 60 };
60 };
61 </script> 61 </script>
62 <style lang="scss" scoped> 62 <style lang="scss" scoped>
63 /deep/.el-menu--horizontal { 63 /deep/.el-menu--horizontal {
64 display: flex; 64 display: flex;
65 align-items: center; 65 align-items: center;
66 } 66 }
67
68 .menubg {
69 height: 34px;
70 width: 130px;
71 text-align: center;
72 color: #ffffff;
73 margin-right: 20px;
74 background: url("~@/image/navbar.png") no-repeat;
75 background-size: 100% 100%;
76 }
77
78 /deep/.el-menu-item {
79 @extend .menubg;
80 }
81
82 /deep/.el-submenu {
83 @extend .menubg;
84 }
85
86 /deep/.el-submenu__title {
87 height: 34px;
88 color: #ffffff;
89 }
90 67
91 /deep/.el-submenu__title span { 68 .menubg {
92 font-size: 14px; 69 height: 34px;
93 } 70 width: 130px;
71 text-align: center;
72 color: #ffffff;
73 margin-right: 20px;
74 background: url("~@/image/navbar.png") no-repeat;
75 background-size: 100% 100%;
76 }
94 77
95 .sidebarLeft { 78 /deep/.el-menu-item {
96 position: relative; 79 @extend .menubg;
97 top: 13px; 80 }
98 width: 30%;
99 }
100 81
101 /deep/.el-menu { 82 /deep/.el-submenu {
102 display: flex; 83 @extend .menubg;
103 justify-content: space-between; 84 }
104 }
105 85
106 /deep/.el-menu-item { 86 /deep/.el-submenu__title {
107 flex: 1; 87 height: 34px;
108 width: 100%; 88 color: #ffffff;
109 } 89 }
110 90
111 .sidebarRight { 91 /deep/.el-submenu__title span {
112 position: relative; 92 font-size: 14px;
113 top: 13px; 93 }
114 width: 30%;
115 padding-left: 20px;
116 }
117 94
118 // 导航选中背景色 95 .sidebarLeft {
119 .xuanzhong { 96 position: relative;
120 background: url("~@/image/selNavbar.png") no-repeat; 97 top: 13px;
121 background-size: 100% 100%; 98 width: 30%;
122 color: #ffffff !important; 99 }
123 font-weight: 700;
124 }
125 100
126 /deep/.el-menu-item:hover { 101 /deep/.el-menu {
127 @extend .xuanzhong; 102 display: flex;
128 } 103 justify-content: space-between;
104 }
129 105
130 /deep/.el-submenu__title:hover { 106 /deep/.el-menu-item {
131 @extend .xuanzhong; 107 flex: 1;
132 } 108 width: 100%;
109 }
133 110
134 /deep/.el-menu--horizontal .el-menu-item:not(.is-disabled):focus { 111 .sidebarRight {
135 @extend .xuanzhong; 112 position: relative;
136 } 113 top: 13px;
114 width: 30%;
115 padding-left: 20px;
116 }
137 117
138 /deep/.el-menu-item.is-active { 118 // 导航选中背景色
139 @extend .xuanzhong; 119 .xuanzhong {
140 } 120 background: url("~@/image/selNavbar.png") no-repeat;
121 background-size: 100% 100%;
122 color: #ffffff !important;
123 font-weight: 700;
124 }
141 125
142 .navbar { 126 /deep/.el-menu-item:hover {
143 height: $headerHeight; 127 @extend .xuanzhong;
144 overflow: hidden; 128 }
145 position: relative;
146 display: flex;
147 align-items: center;
148 padding: 0 20px;
149 justify-content: space-between;
150 background: url("~@/image/header.png") no-repeat;
151 background-size: 100% 100%;
152 129
153 .user { 130 /deep/.el-submenu__title:hover {
154 font-size: 12px; 131 @extend .xuanzhong;
155 color: #ffffff; 132 }
156 position: absolute;
157 right: 20px;
158 top: 0;
159 cursor: pointer;
160 133
161 .closeStyle { 134 /deep/.el-menu--horizontal .el-menu-item:not(.is-disabled):focus {
162 margin-right: 5px; 135 @extend .xuanzhong;
163 }
164 } 136 }
165 137
166 .title { 138 /deep/.el-menu-item.is-active {
167 position: absolute; 139 @extend .xuanzhong;
168 left: 0;
169 top: 10px;
170 bottom: 0;
171 right: 0;
172 margin: 0 auto;
173 font-size: 32px;
174 color: #ffffff;
175 font-weight: 700;
176 text-align: center;
177 } 140 }
178 141
179 .right-menu { 142 .navbar {
180 float: right; 143 height: $headerHeight;
181 height: 100%; 144 overflow: hidden;
182 line-height: 50px; 145 position: relative;
183 display: flex; 146 display: flex;
184 align-items: center; 147 align-items: center;
148 padding: 0 20px;
149 justify-content: space-between;
150 background: url("~@/image/header.png") no-repeat;
151 background-size: 100% 100%;
185 152
186 .shutdown { 153 .user {
187 font-size: 20px; 154 font-size: 12px;
188 margin-left: 15px; 155 color: #ffffff;
156 position: absolute;
157 right: 20px;
158 top: 0;
189 cursor: pointer; 159 cursor: pointer;
160
161 .closeStyle {
162 margin-right: 5px;
163 }
190 } 164 }
191 165
192 .organization-item { 166 .title {
193 margin-right: 40px; 167 position: absolute;
194 margin-top: -40px !important; 168 left: 0;
169 top: 10px;
170 bottom: 0;
171 right: 0;
172 margin: 0 auto;
173 font-size: 32px;
174 color: #ffffff;
175 font-weight: 700;
176 text-align: center;
195 } 177 }
196 178
197 .item { 179 .right-menu {
198 margin-right: 40px; 180 float: right;
199 margin-top: -20px; 181 height: 100%;
200 line-height: 18.4px; 182 line-height: 50px;
201 cursor: pointer; 183 display: flex;
202 position: relative; 184 align-items: center;
203 185
204 .item-box { 186 .shutdown {
205 position: absolute; 187 font-size: 20px;
206 top: -5px; 188 margin-left: 15px;
207 left: 3px;
208 width: 100%;
209 min-width: 25px;
210 height: 25px;
211 cursor: pointer; 189 cursor: pointer;
212 z-index: 100;
213 } 190 }
214 }
215
216 &:focus {
217 outline: none;
218 }
219 191
220 .right-menu-item { 192 .organization-item {
221 display: inline-block; 193 margin-right: 40px;
222 height: 100%; 194 margin-top: -40px !important;
223 font-size: 18px; 195 }
224 color: #fff;
225 vertical-align: text-bottom;
226 196
227 &.hover-effect { 197 .item {
198 margin-right: 40px;
199 margin-top: -20px;
200 line-height: 18.4px;
228 cursor: pointer; 201 cursor: pointer;
229 transition: background 0.3s; 202 position: relative;
230 display: flex;
231 align-items: center;
232 203
233 &:hover { 204 .item-box {
234 background: rgba(0, 0, 0, 0.025); 205 position: absolute;
206 top: -5px;
207 left: 3px;
208 width: 100%;
209 min-width: 25px;
210 height: 25px;
211 cursor: pointer;
212 z-index: 100;
235 } 213 }
236 } 214 }
237 }
238 215
239 .avatar-wrapper { 216 &:focus {
240 position: relative; 217 outline: none;
241 display: flex; 218 }
242 height: 40px;
243 align-items: center;
244 219
245 .user-avatar { 220 .right-menu-item {
246 cursor: pointer; 221 display: inline-block;
247 width: 35px; 222 height: 100%;
248 height: 35px; 223 font-size: 18px;
249 border-radius: 50%; 224 color: #fff;
225 vertical-align: text-bottom;
226
227 &.hover-effect {
228 cursor: pointer;
229 transition: background 0.3s;
230 display: flex;
231 align-items: center;
232
233 &:hover {
234 background: rgba(0, 0, 0, 0.025);
235 }
236 }
250 } 237 }
251 238
252 .el-icon-caret-bottom { 239 .avatar-wrapper {
253 cursor: pointer; 240 position: relative;
254 position: absolute; 241 display: flex;
255 right: -15px; 242 height: 40px;
256 top: 17px; 243 align-items: center;
257 font-size: 12px; 244
245 .user-avatar {
246 cursor: pointer;
247 width: 35px;
248 height: 35px;
249 border-radius: 50%;
250 }
251
252 .el-icon-caret-bottom {
253 cursor: pointer;
254 position: absolute;
255 right: -15px;
256 top: 17px;
257 font-size: 12px;
258 }
258 } 259 }
259 } 260 }
260 } 261 }
261 }
262 </style> 262 </style>
......
1 /*
2 * @Description:
3 * @Autor: renchao
4 * @LastEditTime: 2023-03-09 21:06:38
5 */
6 import router from "./router";
7 import store from "./store";
8 import { getMenuInfo } from "@/api/user";
9 import NProgress from "nprogress"; // progress bar
10 import "nprogress/nprogress.css"; // progress bar style
11 import getPageTitle from "@/utils/get-page-title";
12 import Cookies from "js-cookie";
13 NProgress.configure({ showSpinner: false }); // NProgress Configuration
14
15 router.beforeEach(async (to, from, next) => {
16 NProgress.start();
17 document.title = getPageTitle(to.meta.title);
18 let hasAddDict = store.state.dict.addDict;
19 let hasUser = store.state.user.hasUser;
20 let hasAddRoute = store.state.permission.addRoutes;
21 if (to.path == "/sb" || to.path == "/jg") {
22 sessionStorage.removeItem("token");
23 sessionStorage.setItem("psth", to.path)
24 next();
25 } else {
26 let code = sessionStorage.getItem("psth") == "/sb" ? "BDCSBPT" : "BDCJGPT"
27 //判断token是否存在
28 const hasToken = sessionStorage.getItem("token");
29 if (hasToken) {
30 //请求用户信息
31 if (!hasUser) {
32 store.dispatch("user/getUserInfo");
33 import("@/styles/public.scss");
34 }
35 if (hasAddRoute) {
36 next();
37 } else {
38 //请求菜单
39 const { result: getMenuData } = (await getMenuInfo(code)) || [];
40 const accessRoutes = await store.dispatch(
41 "permission/generateRoutes",
42 getMenuData
43 );
44 router.addRoutes([
45 ...accessRoutes,
46 { path: "*", redirect: "/404", hidden: true },
47 ]);
48 const routeTo = Cookies.get("routerTo");
49 if (!hasAddDict) {
50 await store.dispatch("dict/generateDic");
51 }
52 if (routeTo && routeTo !== "/") {
53 next({ ...to, replace: true });
54 } else {
55 next("/home");
56 }
57 }
58 } else {
59 next(sessionStorage.getItem("psth"));
60 }
61 }
62
63 NProgress.done();
64 });
65 router.afterEach((to) => {
66 // 解决刷新页面报404问题
67 Cookies.set("routerTo", to.fullPath);
68 NProgress.done();
69 });
1 /* 1 /*
2 * @Description: 2 * @Description:
3 * @Autor: renchao 3 * @Autor: renchao
4 * @LastEditTime: 2023-03-07 09:43:25 4 * @LastEditTime: 2023-03-09 21:06:38
5 */ 5 */
6 import router from "./router"; 6 import router from "./router";
7 import store from "./store"; 7 import store from "./store";
...@@ -18,50 +18,12 @@ router.beforeEach(async (to, from, next) => { ...@@ -18,50 +18,12 @@ router.beforeEach(async (to, from, next) => {
18 let hasAddDict = store.state.dict.addDict; 18 let hasAddDict = store.state.dict.addDict;
19 let hasUser = store.state.user.hasUser; 19 let hasUser = store.state.user.hasUser;
20 let hasAddRoute = store.state.permission.addRoutes; 20 let hasAddRoute = store.state.permission.addRoutes;
21 21 if (to.path == "/sb" || to.path == "/jg") {
22 if (to.path == "/login/sb") {
23 sessionStorage.removeItem("token");
24 next();
25 } else if (to.path !== "/login/jg") {
26 //判断token是否存在
27 const hasToken = sessionStorage.getItem("token");
28 if (hasToken) {
29 //请求用户信息
30 if (!hasUser) {
31 store.dispatch("user/getUserInfo");
32 }
33 if (hasAddRoute) {
34 next();
35 } else {
36 //请求菜单
37 const { result: getMenuData } = (await getMenuInfo()) || [];
38 const accessRoutes = await store.dispatch(
39 "permission/generateRoutes",
40 getMenuData
41 );
42 router.addRoutes([
43 ...accessRoutes,
44 { path: "*", redirect: "/404", hidden: true },
45 ]);
46 const routeTo = Cookies.get("routerTo");
47 if (!hasAddDict) {
48 await store.dispatch("dict/generateDic");
49 }
50 if (routeTo && routeTo !== "/") {
51 next({ ...to, replace: true });
52 } else {
53 alert("上报")
54 next("/home");
55 }
56 }
57 } else {
58 next("/login/sb");
59 }
60 }
61 if (to.path == "/login/jg") {
62 sessionStorage.removeItem("token"); 22 sessionStorage.removeItem("token");
23 sessionStorage.setItem("psth", to.path)
63 next(); 24 next();
64 } else if (to.path !== "/login/sb") { 25 } else {
26 let code = sessionStorage.getItem("psth") == "/sb" ? "BDCSBPT" : "BDCJGPT"
65 //判断token是否存在 27 //判断token是否存在
66 const hasToken = sessionStorage.getItem("token"); 28 const hasToken = sessionStorage.getItem("token");
67 if (hasToken) { 29 if (hasToken) {
...@@ -74,7 +36,7 @@ router.beforeEach(async (to, from, next) => { ...@@ -74,7 +36,7 @@ router.beforeEach(async (to, from, next) => {
74 next(); 36 next();
75 } else { 37 } else {
76 //请求菜单 38 //请求菜单
77 const { result: getMenuData } = (await getMenuInfo()) || []; 39 const { result: getMenuData } = (await getMenuInfo(code)) || [];
78 const accessRoutes = await store.dispatch( 40 const accessRoutes = await store.dispatch(
79 "permission/generateRoutes", 41 "permission/generateRoutes",
80 getMenuData 42 getMenuData
...@@ -90,14 +52,16 @@ router.beforeEach(async (to, from, next) => { ...@@ -90,14 +52,16 @@ router.beforeEach(async (to, from, next) => {
90 if (routeTo && routeTo !== "/") { 52 if (routeTo && routeTo !== "/") {
91 next({ ...to, replace: true }); 53 next({ ...to, replace: true });
92 } else { 54 } else {
93 alert("监管")
94 next("/home"); 55 next("/home");
95 } 56 }
96 } 57 }
58 } else if (sessionStorage.getItem("psth")) {
59 next(sessionStorage.getItem("psth"));
97 } else { 60 } else {
98 next("/login/jg"); 61 next("/jg");
99 } 62 }
100 } 63 }
64
101 NProgress.done(); 65 NProgress.done();
102 }); 66 });
103 router.afterEach((to) => { 67 router.afterEach((to) => {
......
...@@ -24,12 +24,12 @@ export const constantRoutes = [ ...@@ -24,12 +24,12 @@ export const constantRoutes = [
24 }, 24 },
25 //登录 25 //登录
26 { 26 {
27 path: "/login/jg", 27 path: "/jg",
28 name: "loginjg", 28 name: "loginjg",
29 component: () => import("@/views/loginjg/index.vue"), 29 component: () => import("@/views/loginjg/index.vue"),
30 }, 30 },
31 { 31 {
32 path: "/login/sb", 32 path: "/sb",
33 name: "loginsb", 33 name: "loginsb",
34 component: () => import("@/views/loginsb/index.vue"), 34 component: () => import("@/views/loginsb/index.vue"),
35 }, 35 },
......
1 <template>
2 <div class="bg">
3 <div class="login-inner-bg login">
4 <h2>{{ productName }}</h2>
5 <div class="user_style">
6 <h3>欢迎登录</h3>
7 <el-form :model="user" :rules="rules" ref="user" id="loginform" class="demo-ruleForm">
8 <el-form-item prop="account">
9 <el-input class="username" v-model="user.account" placeholder="请输入用户名"></el-input>
10 </el-form-item>
11 <el-form-item prop="password">
12 <el-input type="password" class="password" @keyup.enter.native="login('user')" v-model="user.password"
13 placeholder="请输入密码"></el-input>
14 </el-form-item>
15 <el-form-item class="login-btn">
16 <el-button type="primary" style="width: 100%" @click="login('user')">登录</el-button>
17 </el-form-item>
18 </el-form>
19 </div>
20 </div>
21 </div>
22 </template>
23
24 <script>
25 import { loginIn } from "@/api/login.js";
26 import { api, getAction } from "@/api/manageApi";
27 export default {
28 name: "Login",
29 data () {
30 return {
31 user: {
32 account: "",
33 password: "",
34 checkStatus: false,
35 },
36 productName: "",
37 rules: {
38 account: [{ required: true, message: "请填写帐号", trigger: "blur" }],
39 password: [{ required: true, message: "请填写密码", trigger: "blur" }],
40 },
41 };
42 },
43 created () {
44 const params = {};
45 const queryOptions = {
46 conditionGroup: {
47 conditions: [
48 {
49 property: "code",
50 value: "BDCJGPT",
51 operator: "EQ",
52 },
53 ],
54 queryRelation: "AND",
55 },
56 };
57 params.queryOptions = JSON.stringify(queryOptions);
58 //根据子系统code获取子系统详细信息
59 getAction(api.subsystem, params).then((res) => {
60 if (res.status === 1) {
61 this.productName = res.content[0].name;
62 this.$store.dispatch("products/setData", res.content[0]);
63 } else {
64 this.$message.error({ message: res.message, showClose: true });
65 }
66 });
67 },
68 mounted () {
69 // this.checkUserName();
70 },
71 methods: {
72 //记住用户名
73 checkUserName: function (flag) {
74 this.user.checkStatus = flag;
75 if (this.user.checkStatus) {
76 localStorage.setItem("accountId", this.user.account);
77 let name = localStorage.getItem("accountId");
78 if (name === "") {
79 return;
80 } else {
81 this.user.account = name;
82 }
83 } else {
84 this.user.account = localStorage.getItem("accountId");
85 }
86 },
87 login (user) {
88 var self = this;
89 this.$refs[user].validate((valid) => {
90 if (valid) {
91 loginIn(self.user.account, self.user.password)
92 .then((res) => {
93 if (res.status === 1) {
94 //存储token
95 sessionStorage.setItem("token", `Bearer ${res.content}`);
96 //登录成功后需判断有无重定向,没有重定向则跳转首页
97 this.$router.replace(this.$route.query.redirect || "/");
98 } else {
99 //错误处理
100 }
101 })
102 .catch((error) => {
103 // console.dir(error);
104 });
105 }
106 });
107 },
108 },
109 components: {},
110 };
111 </script>
112 <style scoped lang="scss">
113 .username,
114 .password {
115 position: relative;
116
117 &:before {
118 content: "";
119 display: block;
120 width: 16px;
121 height: 16px;
122 position: absolute;
123 left: 10px;
124 top: 7px;
125 background-size: 100% 100%;
126 }
127
128 /deep/ .el-input__inner {
129 text-indent: 24px;
130 border: 1px solid rgba(11, 161, 248, 0.4);
131 background-color: rgba(6, 135, 205, 0.3) !important;
132 }
133 }
134
135 .username::before {
136 background-image: url(../../image/username.png);
137 }
138
139 .password::before {
140 background-image: url(../../image/password.png);
141 }
142
143 .bg {
144 width: 100%;
145 height: 100%;
146 min-width: 1440px;
147 min-height: 560px;
148 background: url(../../image/loginBoxBg.png) no-repeat;
149 background-size: 100% 100%;
150 overflow: hidden;
151 position: relative;
152 }
153
154 .login-inner-bg {
155 background: url(../../image/loginBg.png) no-repeat;
156 width: 21.6%;
157 height: 43%;
158 min-width: 360px;
159 min-height: 380px;
160 top: 30%;
161 right: 20%;
162 position: absolute;
163 background-size: 100% 100%;
164 box-sizing: border-box;
165 padding: 56px;
166
167 h2 {
168 width: 100%;
169 font-size: 36px;
170 font-weight: 700;
171 color: #fff;
172 text-align: center;
173 white-space: nowrap;
174 position: absolute;
175 right: 0;
176 top: -70px;
177 background-image: linear-gradient(180deg,
178 rgba(99, 163, 255, 1) 0,
179 rgba(99, 163, 255, 1) 0,
180 rgba(182, 220, 255, 1) 49.731445%,
181 rgba(114, 190, 255, 1) 100%,
182 rgba(114, 190, 255, 1) 100%);
183 overflow-wrap: break-word;
184 color: rgba(255, 255, 255, 1);
185 font-size: 36px;
186 font-family: AlimamaShuHeiTi-Bold;
187 -webkit-background-clip: text;
188 -webkit-text-fill-color: transparent;
189 }
190 }
191
192 .login {
193 .user_style {
194 h3 {
195 color: #fff;
196 font-size: 22px;
197 font-weight: normal;
198 text-align: center;
199 margin: 16px auto 34px;
200 font-weight: 400;
201 }
202 }
203
204 .btn {
205 width: 100%;
206 height: 6vh;
207 background-color: #00c2de;
208 border-radius: 5px;
209 font-size: 1.4vw;
210 color: #ffffff;
211 }
212
213 .btn:hover {
214 cursor: pointer;
215 background-color: #2d8cf0;
216 }
217 }
218
219 .login #loginform {
220 .el-form-item {
221 margin-bottom: 24px !important;
222 }
223
224 .login-btn {
225 margin-top: 40px !important;
226 }
227
228 .el-button {
229 font-size: 18px;
230 background: #0d8cc0 !important;
231 color: #ffffff !important;
232 cursor: pointer !important;
233 }
234
235 .el-input__inner {
236 width: 100% !important;
237 }
238
239 .el-checkbox__label {
240 color: #fff;
241 }
242 }
243
244 .inputUser .ivu-input {
245 padding: 6px 24px !important;
246 border: 1px solid #9f9f9f !important;
247 }
248 </style>
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
60 getAction(api.subsystem, params).then((res) => { 60 getAction(api.subsystem, params).then((res) => {
61 if (res.status === 1) { 61 if (res.status === 1) {
62 this.productName = res.content[0].name; 62 this.productName = res.content[0].name;
63 this.$store.dispatch("products/setData", res.content[0]); 63 this.$store.dispatch("products/setData", res.content[0].code);
64 } else { 64 } else {
65 this.$message.error({ message: res.message, showClose: true }); 65 this.$message.error({ message: res.message, showClose: true });
66 } 66 }
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
67 getAction(api.subsystem, params).then((res) => { 67 getAction(api.subsystem, params).then((res) => {
68 if (res.status === 1) { 68 if (res.status === 1) {
69 this.productName = res.content[0].name; 69 this.productName = res.content[0].name;
70 this.$store.dispatch("products/setData", res.content[0]); 70 this.$store.dispatch("products/setData", res.content[0].code);
71 } else { 71 } else {
72 this.$message.error({ message: res.message, showClose: true }); 72 this.$message.error({ message: res.message, showClose: true });
73 } 73 }
......
...@@ -77,14 +77,14 @@ ...@@ -77,14 +77,14 @@
77 userInfo: { 77 userInfo: {
78 handler: function (val) { 78 handler: function (val) {
79 if (val) { 79 if (val) {
80 this.getUserInfo(val.id) 80 this.getUserdata(val.id)
81 } 81 }
82 } 82 }
83 } 83 }
84 }, 84 },
85 mounted () { 85 mounted () {
86 if (this.userInfo) { 86 if (this.userInfo) {
87 this.getUserInfo(this.userInfo) 87 this.getUserdata(this.userInfo)
88 } 88 }
89 this.sexList = [ 89 this.sexList = [
90 { 90 {
...@@ -105,7 +105,7 @@ ...@@ -105,7 +105,7 @@
105 ] 105 ]
106 }, 106 },
107 methods: { 107 methods: {
108 getUserInfo (p) { 108 getUserdata (p) {
109 getAction(`${api.users}/${p.id}`).then((res) => { 109 getAction(`${api.users}/${p.id}`).then((res) => {
110 if (res.status === 1) { 110 if (res.status === 1) {
111 this.form = res.content 111 this.form = res.content
...@@ -120,7 +120,7 @@ ...@@ -120,7 +120,7 @@
120 putAction(`${api.users}/${this.form.id}`, this.form).then((res) => { 120 putAction(`${api.users}/${this.form.id}`, this.form).then((res) => {
121 if (res.status === 1) { 121 if (res.status === 1) {
122 this.$message.success({ message: res.message, showClose: true }) 122 this.$message.success({ message: res.message, showClose: true })
123 this.getUserInfo(this.form.id) 123 this.getUserdata(this.form.id)
124 } else { 124 } else {
125 this.$message.error({ message: res.message, showClose: true }) 125 this.$message.error({ message: res.message, showClose: true })
126 } 126 }
......
...@@ -64,173 +64,174 @@ ...@@ -64,173 +64,174 @@
64 </template> 64 </template>
65 65
66 <script> 66 <script>
67 import Dialog from "@/components/Dialog/"; 67 import Dialog from "@/components/Dialog/";
68 import { getParentMenuListAction } from '@/api/authorityManage' 68 import { getParentMenuListAction } from '@/api/authorityManage'
69 import JsonEditor from '@/components/JsonEditors' 69 import JsonEditor from '@/components/JsonEditors'
70 import IconList from '@/components/IconList' 70 import IconList from '@/components/IconList'
71 import { validateCode } from '@/utils/validate'; 71 import { validateCode } from '@/utils/validate';
72 import { api, httpAction } from '@/api/manageApi' 72 import { api, httpAction } from '@/api/manageApi'
73 export default { 73 export default {
74 name: 'MenuModal', 74 name: 'MenuModal',
75 components: { 75 components: {
76 IconList, 76 IconList,
77 JsonEditor, 77 JsonEditor,
78 Dialog 78 Dialog
79 },
80 props: {
81 productId: {
82 type: String,
83 default: ''
84 }
85 },
86 data () {
87 return {
88 form: {
89 icon: '',
90 code: ''
91 },
92 rules: {
93 name: [{ required: true, message: '请输入菜单名称', trigger: 'blur' }],
94 code: [
95 { required: true, message: '必填', trigger: 'blur' },
96 { validator: validateCode, trigger: 'blur' }
97 ]
98 },
99 title: '',
100 type: '',
101 visible: false,
102 parentMenuList: [],
103 menuKey: 0,
104 jumpModeList: [
105 { name: '在当前页面显示', value: 1 },
106 { name: '跳转到新页面', value: 2 }
107 ],
108 setProps: {
109 value: 'id',
110 label: 'name',
111 children: 'children',
112 expandTrigger: 'hover',
113 checkStrictly: true, // 可取消关联,选择任意一级选项
114 emitPath: false
115 },
116 dataUrl: api.menus
117 }
118 },
119 computed: {
120 codeComputed: {
121 get: function () {
122 return this.form.code
123 },
124 set: function (val) {
125 this.form.code = val.toUpperCase()
126 }
127 }
128 },
129 created () { },
130 mounted () { },
131 methods: {
132 // 获取父级菜单
133 getParentMenuList (id) {
134
135 getParentMenuListAction(id).then((res) => {
136 if (res.status === 1) {
137 const list = this.$dealArrChildren(res.content)
138 if (id) {
139 this.parentMenuList = this.$dealArrDisabled(
140 this.$deepCopy(list),
141 id
142 )
143 this.menuKey++
144 } else {
145 this.parentMenuList = list
146 }
147 } else {
148 this.$message.error({ message: res.message, showClose: true })
149 }
150 })
151 },
152 getIconList () {
153 this.$refs.iconList.show(true)
154 },
155 getIconName (data) {
156 this.form.icon = data
157 }, 79 },
158 // 配置参数 80 props: {
159 getJsonString (data) { 81 productId: {
160 this.form.metadata = data 82 type: String,
161 }, 83 default: ''
162 // 新增菜单 84 }
163 add () {
164 this.getParentMenuList(this.productId)
165 this.visible = true
166 this.type = 0
167 this.form.jumpMode = 1
168 }, 85 },
169 // 编辑菜单 86 data () {
170 edit (record) { 87 return {
171 this.type = 1 88 form: {
172 // 若有id为编辑 89 icon: '',
173 if (record.id) { 90 code: ''
174 this.$nextTick(() => { 91 },
175 this.form = Object.assign({}, record) 92 rules: {
176 this.getParentMenuList(this.productId) 93 name: [{ required: true, message: '请输入菜单名称', trigger: 'blur' }],
177 }) 94 code: [
95 { required: true, message: '必填', trigger: 'blur' },
96 { validator: validateCode, trigger: 'blur' }
97 ]
98 },
99 title: '',
100 type: '',
101 visible: false,
102 parentMenuList: [],
103 menuKey: 0,
104 jumpModeList: [
105 { name: '在当前页面显示', value: 1 },
106 { name: '跳转到新页面', value: 2 }
107 ],
108 setProps: {
109 value: 'id',
110 label: 'name',
111 children: 'children',
112 expandTrigger: 'hover',
113 checkStrictly: true, // 可取消关联,选择任意一级选项
114 emitPath: false
115 },
116 dataUrl: api.menus
178 } 117 }
179 this.visible = true
180 }, 118 },
181 // 选择上级菜单 119 computed: {
182 handleChange (value) { 120 codeComputed: {
183 this.form.parentId = value 121 get: function () {
122 return this.form.code
123 },
124 set: function (val) {
125 this.form.code = val.toUpperCase()
126 }
127 }
184 }, 128 },
185 // 保存 129 created () { },
186 submitForm (submitType) { 130 mounted () { },
187 this.$refs.form.validate((valid) => { 131 methods: {
188 if (valid) { 132 // 获取父级菜单
189 let method = '' 133 getParentMenuList (id) {
190 let url = '' 134
191 const formData = this.form 135 getParentMenuListAction(id).then((res) => {
192 formData.productId = this.productId 136 if (res.status === 1) {
193 if (!formData.id) { 137 const list = this.$dealArrChildren(res.content)
194 method = 'post' 138 if (id) {
195 url = this.dataUrl 139 this.parentMenuList = this.$dealArrDisabled(
140 this.$deepCopy(list),
141 id
142 )
143 this.menuKey++
144 } else {
145 this.parentMenuList = list
146 }
196 } else { 147 } else {
197 method = 'put' 148 this.$message.error({ message: res.message, showClose: true })
198 url = `${this.dataUrl}/${formData.id}`
199 } 149 }
200 httpAction(url, formData, method) 150 })
201 .then((res) => { 151 },
202 if (res.status === 1) { 152 getIconList () {
203 this.$message.success({ 153 this.$refs.iconList.show(true)
204 message: res.message, 154 },
205 showClose: true 155 getIconName (data) {
206 }) 156 this.form.icon = data
157 },
158 // 配置参数
159 getJsonString (data) {
160 this.form.metadata = data
161 },
162 // 新增菜单
163 add () {
164 this.getParentMenuList(this.productId)
165 this.visible = true
166 this.type = 0
167 this.form.jumpMode = 1
168 },
169 // 编辑菜单
170 edit (record) {
171 this.type = 1
172 // 若有id为编辑
173 if (record.id) {
174 this.$nextTick(() => {
175 this.form = Object.assign({}, record)
176 this.getParentMenuList(this.productId)
177 })
178 }
179 this.visible = true
180 },
181 // 选择上级菜单
182 handleChange (value) {
183 this.form.parentId = value
184 },
185 // 保存
186 submitForm (submitType) {
187 this.$refs.form.validate((valid) => {
188 if (valid) {
189 let method = ''
190 let url = ''
191 const formData = this.form
192 formData.productId = this.productId
193 if (!formData.id) {
194 method = 'post'
195 url = this.dataUrl
196 } else {
197 method = 'put'
198 url = `${this.dataUrl}/${formData.id}`
199 }
200 debugger
201 httpAction(url, formData, method)
202 .then((res) => {
203 if (res.status === 1) {
204 this.$message.success({
205 message: res.message,
206 showClose: true
207 })
207 208
208 this.resetForm() 209 this.resetForm()
209 this.$emit('ok') 210 this.$emit('ok')
210 } else { 211 } else {
211 this.$message.error({ message: res.message, showClose: true }) 212 this.$message.error({ message: res.message, showClose: true })
212 } 213 }
213 }) 214 })
214 .catch((err) => { 215 .catch((err) => {
215 console.log(err) 216 console.log(err)
216 }) 217 })
218 }
219 })
220 },
221 resetForm () {
222 this.$refs.form.resetFields()
223 this.form = {
224 icon: '',
225 code: ''
217 } 226 }
218 }) 227 },
219 }, 228 close () {
220 resetForm () { 229 this.resetForm()
221 this.$refs.form.resetFields() 230 this.visible = false
222 this.form = {
223 icon: '',
224 code: ''
225 } 231 }
226 },
227 close () {
228 this.resetForm()
229 this.visible = false
230 } 232 }
231 } 233 }
232 }
233 </script> 234 </script>
234 <style scoped lang="scss"> 235 <style scoped lang="scss">
235 // @import "~@/styles/public.scss"; 236 // @import "~@/styles/public.scss";
236 </style> 237 </style>
......
...@@ -11,11 +11,6 @@ class data extends filter { ...@@ -11,11 +11,6 @@ class data extends filter {
11 width: 130 11 width: 130
12 }, 12 },
13 { 13 {
14 prop: "type",
15 label: "类别",
16 width: 200
17 },
18 {
19 prop: "description", 14 prop: "description",
20 label: "备注" 15 label: "备注"
21 } 16 }
......
...@@ -18,16 +18,6 @@ ...@@ -18,16 +18,6 @@
18 </el-form-item> 18 </el-form-item>
19 </el-col> 19 </el-col>
20 </el-row> 20 </el-row>
21 <el-row :gutter="24">
22 <el-col :span="24">
23 <el-form-item label="角色类型:" prop="roleType">
24 <el-input
25 v-model="dialogForm.roleType"
26 clearable
27 placeholder="角色类型" />
28 </el-form-item>
29 </el-col>
30 </el-row>
31 <el-row> 21 <el-row>
32 <el-col :span="24"> 22 <el-col :span="24">
33 <el-form-item label="备注:" class="form-item-mb0"> 23 <el-form-item label="备注:" class="form-item-mb0">
...@@ -75,9 +65,6 @@ ...@@ -75,9 +65,6 @@
75 roleName: [ 65 roleName: [
76 { required: true, message: '请输入角色名称', trigger: 'blur' } 66 { required: true, message: '请输入角色名称', trigger: 'blur' }
77 ], 67 ],
78 roleType: [
79 { required: true, message: '请输入角色类型', trigger: 'blur' }
80 ]
81 }, 68 },
82 roleTypeOptions: [ 69 roleTypeOptions: [
83 { name: '定制', value: '定制' }, 70 { name: '定制', value: '定制' },
...@@ -109,7 +96,6 @@ ...@@ -109,7 +96,6 @@
109 }) 96 })
110 this.dialogForm = { 97 this.dialogForm = {
111 roleName: '', 98 roleName: '',
112 roleType: ''
113 } 99 }
114 this.showAddEditDialog = val 100 this.showAddEditDialog = val
115 this.$emit('ok', this.menuType) 101 this.$emit('ok', this.menuType)
...@@ -130,7 +116,6 @@ ...@@ -130,7 +116,6 @@
130 }) 116 })
131 this.dialogForm = { 117 this.dialogForm = {
132 roleName: '', 118 roleName: '',
133 roleType: ''
134 } 119 }
135 this.showAddEditDialog = val 120 this.showAddEditDialog = val
136 this.$emit('ok', this.menuType) 121 this.$emit('ok', this.menuType)
...@@ -153,7 +138,6 @@ ...@@ -153,7 +138,6 @@
153 this.$refs.form.resetFields() 138 this.$refs.form.resetFields()
154 this.dialogForm = { 139 this.dialogForm = {
155 roleName: '', 140 roleName: '',
156 roleType: ''
157 } 141 }
158 this.showAddEditDialog = false 142 this.showAddEditDialog = false
159 } 143 }
......