c3afa824 by xiaomiao

路由前置守卫修改

1 parent 01fc196e
......@@ -8,10 +8,21 @@ export function getUserInfo () {
})
}
// // 获取菜单信息
// export function getMenuInfo () {
// return request({
// url: SERVER.SERVERAPI + '/rest/user/getUserAuthorizationMenus',
// method: 'get',
// })
// }
// 获取菜单信息
export function getMenuInfo () {
export function getMenuInfo (data) {
return request({
url: SERVER.SERVERAPI + '/rest/user/getUserAuthorizationMenus',
method: 'get',
params: {
productCode: data,
},
})
}
\ No newline at end of file
}
......
......@@ -16,247 +16,247 @@
<sidebarRight />
</div>
</div>
</div>
</div>
</template>
<script>
import sidebarLeft from "./Sidebar/sidebarLeft";
import sidebarRight from "./Sidebar/sidebarRight";
import { logout } from "@/api/login.js";
import { mapGetters } from "vuex";
export default {
components: {
sidebarLeft,
sidebarRight,
},
computed: {
...mapGetters(["sidebar", "dicData","userInfo"]),
logoName() {
return this.dicData['sysCode'] && this.dicData['sysCode'].filter(item =>
item.DCODE == "systemTitle"
)
import sidebarLeft from "./Sidebar/sidebarLeft";
import sidebarRight from "./Sidebar/sidebarRight";
import { logout } from "@/api/login.js";
import { mapGetters } from "vuex";
export default {
components: {
sidebarLeft,
sidebarRight,
},
userName(){
return this.userInfo ? this.userInfo.name : ""
}
},
methods: {
onCancel () {
logout()
.then((res) => {
sessionStorage.removeItem("token");
this.$store.dispatch("user/resetState");
this.$router.replace({
path: "/login/jg",
query: {
redirect: this.$route.fullPath,
},
computed: {
...mapGetters(["sidebar", "dicData", "userInfo"]),
logoName () {
return this.dicData['sysCode'] && this.dicData['sysCode'].filter(item =>
item.DCODE == "systemTitle"
)
},
userName () {
return this.userInfo ? this.userInfo.name : ""
}
},
methods: {
onCancel () {
logout()
.then((res) => {
sessionStorage.removeItem("token");
this.$store.dispatch("user/resetState");
this.$router.replace({
path: "/jg",
query: {
redirect: this.$route.fullPath,
},
});
})
.catch((error) => {
// console.dir(error);
});
})
.catch((error) => {
// console.dir(error);
});
},
},
},
};
};
</script>
<style lang="scss" scoped>
/deep/.el-menu--horizontal {
display: flex;
align-items: center;
}
.menubg {
height: 34px;
width: 130px;
text-align: center;
color: #ffffff;
margin-right: 20px;
background: url("~@/image/navbar.png") no-repeat;
background-size: 100% 100%;
}
/deep/.el-menu-item {
@extend .menubg;
}
/deep/.el-submenu {
@extend .menubg;
}
/deep/.el-submenu__title {
height: 34px;
color: #ffffff;
}
/deep/.el-menu--horizontal {
display: flex;
align-items: center;
}
/deep/.el-submenu__title span {
font-size: 14px;
}
.menubg {
height: 34px;
width: 130px;
text-align: center;
color: #ffffff;
margin-right: 20px;
background: url("~@/image/navbar.png") no-repeat;
background-size: 100% 100%;
}
.sidebarLeft {
position: relative;
top: 13px;
width: 30%;
}
/deep/.el-menu-item {
@extend .menubg;
}
/deep/.el-menu {
display: flex;
justify-content: space-between;
}
/deep/.el-submenu {
@extend .menubg;
}
/deep/.el-menu-item {
flex: 1;
width: 100%;
}
/deep/.el-submenu__title {
height: 34px;
color: #ffffff;
}
.sidebarRight {
position: relative;
top: 13px;
width: 30%;
padding-left: 20px;
}
/deep/.el-submenu__title span {
font-size: 14px;
}
// 导航选中背景色
.xuanzhong {
background: url("~@/image/selNavbar.png") no-repeat;
background-size: 100% 100%;
color: #ffffff !important;
font-weight: 700;
}
.sidebarLeft {
position: relative;
top: 13px;
width: 30%;
}
/deep/.el-menu-item:hover {
@extend .xuanzhong;
}
/deep/.el-menu {
display: flex;
justify-content: space-between;
}
/deep/.el-submenu__title:hover {
@extend .xuanzhong;
}
/deep/.el-menu-item {
flex: 1;
width: 100%;
}
/deep/.el-menu--horizontal .el-menu-item:not(.is-disabled):focus {
@extend .xuanzhong;
}
.sidebarRight {
position: relative;
top: 13px;
width: 30%;
padding-left: 20px;
}
/deep/.el-menu-item.is-active {
@extend .xuanzhong;
}
// 导航选中背景色
.xuanzhong {
background: url("~@/image/selNavbar.png") no-repeat;
background-size: 100% 100%;
color: #ffffff !important;
font-weight: 700;
}
.navbar {
height: $headerHeight;
overflow: hidden;
position: relative;
display: flex;
align-items: center;
padding: 0 20px;
justify-content: space-between;
background: url("~@/image/header.png") no-repeat;
background-size: 100% 100%;
/deep/.el-menu-item:hover {
@extend .xuanzhong;
}
.user {
font-size: 12px;
color: #ffffff;
position: absolute;
right: 20px;
top: 0;
cursor: pointer;
/deep/.el-submenu__title:hover {
@extend .xuanzhong;
}
.closeStyle {
margin-right: 5px;
}
/deep/.el-menu--horizontal .el-menu-item:not(.is-disabled):focus {
@extend .xuanzhong;
}
.title {
position: absolute;
left: 0;
top: 10px;
bottom: 0;
right: 0;
margin: 0 auto;
font-size: 32px;
color: #ffffff;
font-weight: 700;
text-align: center;
/deep/.el-menu-item.is-active {
@extend .xuanzhong;
}
.right-menu {
float: right;
height: 100%;
line-height: 50px;
.navbar {
height: $headerHeight;
overflow: hidden;
position: relative;
display: flex;
align-items: center;
padding: 0 20px;
justify-content: space-between;
background: url("~@/image/header.png") no-repeat;
background-size: 100% 100%;
.shutdown {
font-size: 20px;
margin-left: 15px;
.user {
font-size: 12px;
color: #ffffff;
position: absolute;
right: 20px;
top: 0;
cursor: pointer;
.closeStyle {
margin-right: 5px;
}
}
.organization-item {
margin-right: 40px;
margin-top: -40px !important;
.title {
position: absolute;
left: 0;
top: 10px;
bottom: 0;
right: 0;
margin: 0 auto;
font-size: 32px;
color: #ffffff;
font-weight: 700;
text-align: center;
}
.item {
margin-right: 40px;
margin-top: -20px;
line-height: 18.4px;
cursor: pointer;
position: relative;
.right-menu {
float: right;
height: 100%;
line-height: 50px;
display: flex;
align-items: center;
.item-box {
position: absolute;
top: -5px;
left: 3px;
width: 100%;
min-width: 25px;
height: 25px;
.shutdown {
font-size: 20px;
margin-left: 15px;
cursor: pointer;
z-index: 100;
}
}
&:focus {
outline: none;
}
.right-menu-item {
display: inline-block;
height: 100%;
font-size: 18px;
color: #fff;
vertical-align: text-bottom;
.organization-item {
margin-right: 40px;
margin-top: -40px !important;
}
&.hover-effect {
.item {
margin-right: 40px;
margin-top: -20px;
line-height: 18.4px;
cursor: pointer;
transition: background 0.3s;
display: flex;
align-items: center;
position: relative;
&:hover {
background: rgba(0, 0, 0, 0.025);
.item-box {
position: absolute;
top: -5px;
left: 3px;
width: 100%;
min-width: 25px;
height: 25px;
cursor: pointer;
z-index: 100;
}
}
}
.avatar-wrapper {
position: relative;
display: flex;
height: 40px;
align-items: center;
&:focus {
outline: none;
}
.user-avatar {
cursor: pointer;
width: 35px;
height: 35px;
border-radius: 50%;
.right-menu-item {
display: inline-block;
height: 100%;
font-size: 18px;
color: #fff;
vertical-align: text-bottom;
&.hover-effect {
cursor: pointer;
transition: background 0.3s;
display: flex;
align-items: center;
&:hover {
background: rgba(0, 0, 0, 0.025);
}
}
}
.el-icon-caret-bottom {
cursor: pointer;
position: absolute;
right: -15px;
top: 17px;
font-size: 12px;
.avatar-wrapper {
position: relative;
display: flex;
height: 40px;
align-items: center;
.user-avatar {
cursor: pointer;
width: 35px;
height: 35px;
border-radius: 50%;
}
.el-icon-caret-bottom {
cursor: pointer;
position: absolute;
right: -15px;
top: 17px;
font-size: 12px;
}
}
}
}
}
</style>
......
/*
* @Description:
* @Autor: renchao
* @LastEditTime: 2023-03-09 21:06:38
*/
import router from "./router";
import store from "./store";
import { getMenuInfo } from "@/api/user";
import NProgress from "nprogress"; // progress bar
import "nprogress/nprogress.css"; // progress bar style
import getPageTitle from "@/utils/get-page-title";
import Cookies from "js-cookie";
NProgress.configure({ showSpinner: false }); // NProgress Configuration
router.beforeEach(async (to, from, next) => {
NProgress.start();
document.title = getPageTitle(to.meta.title);
let hasAddDict = store.state.dict.addDict;
let hasUser = store.state.user.hasUser;
let hasAddRoute = store.state.permission.addRoutes;
if (to.path == "/sb" || to.path == "/jg") {
sessionStorage.removeItem("token");
sessionStorage.setItem("psth", to.path)
next();
} else {
let code = sessionStorage.getItem("psth") == "/sb" ? "BDCSBPT" : "BDCJGPT"
//判断token是否存在
const hasToken = sessionStorage.getItem("token");
if (hasToken) {
//请求用户信息
if (!hasUser) {
store.dispatch("user/getUserInfo");
import("@/styles/public.scss");
}
if (hasAddRoute) {
next();
} else {
//请求菜单
const { result: getMenuData } = (await getMenuInfo(code)) || [];
const accessRoutes = await store.dispatch(
"permission/generateRoutes",
getMenuData
);
router.addRoutes([
...accessRoutes,
{ path: "*", redirect: "/404", hidden: true },
]);
const routeTo = Cookies.get("routerTo");
if (!hasAddDict) {
await store.dispatch("dict/generateDic");
}
if (routeTo && routeTo !== "/") {
next({ ...to, replace: true });
} else {
next("/home");
}
}
} else {
next(sessionStorage.getItem("psth"));
}
}
NProgress.done();
});
router.afterEach((to) => {
// 解决刷新页面报404问题
Cookies.set("routerTo", to.fullPath);
NProgress.done();
});
/*
* @Description:
* @Description:
* @Autor: renchao
* @LastEditTime: 2023-03-07 09:43:25
* @LastEditTime: 2023-03-09 21:06:38
*/
import router from "./router";
import store from "./store";
......@@ -18,50 +18,12 @@ router.beforeEach(async (to, from, next) => {
let hasAddDict = store.state.dict.addDict;
let hasUser = store.state.user.hasUser;
let hasAddRoute = store.state.permission.addRoutes;
if (to.path == "/login/sb") {
sessionStorage.removeItem("token");
next();
} else if (to.path !== "/login/jg") {
//判断token是否存在
const hasToken = sessionStorage.getItem("token");
if (hasToken) {
//请求用户信息
if (!hasUser) {
store.dispatch("user/getUserInfo");
}
if (hasAddRoute) {
next();
} else {
//请求菜单
const { result: getMenuData } = (await getMenuInfo()) || [];
const accessRoutes = await store.dispatch(
"permission/generateRoutes",
getMenuData
);
router.addRoutes([
...accessRoutes,
{ path: "*", redirect: "/404", hidden: true },
]);
const routeTo = Cookies.get("routerTo");
if (!hasAddDict) {
await store.dispatch("dict/generateDic");
}
if (routeTo && routeTo !== "/") {
next({ ...to, replace: true });
} else {
alert("上报")
next("/home");
}
}
} else {
next("/login/sb");
}
}
if (to.path == "/login/jg") {
if (to.path == "/sb" || to.path == "/jg") {
sessionStorage.removeItem("token");
sessionStorage.setItem("psth", to.path)
next();
} else if (to.path !== "/login/sb") {
} else {
let code = sessionStorage.getItem("psth") == "/sb" ? "BDCSBPT" : "BDCJGPT"
//判断token是否存在
const hasToken = sessionStorage.getItem("token");
if (hasToken) {
......@@ -74,7 +36,7 @@ router.beforeEach(async (to, from, next) => {
next();
} else {
//请求菜单
const { result: getMenuData } = (await getMenuInfo()) || [];
const { result: getMenuData } = (await getMenuInfo(code)) || [];
const accessRoutes = await store.dispatch(
"permission/generateRoutes",
getMenuData
......@@ -90,14 +52,16 @@ router.beforeEach(async (to, from, next) => {
if (routeTo && routeTo !== "/") {
next({ ...to, replace: true });
} else {
alert("监管")
next("/home");
}
}
} else if (sessionStorage.getItem("psth")) {
next(sessionStorage.getItem("psth"));
} else {
next("/login/jg");
next("/jg");
}
}
NProgress.done();
});
router.afterEach((to) => {
......
......@@ -24,12 +24,12 @@ export const constantRoutes = [
},
//登录
{
path: "/login/jg",
path: "/jg",
name: "loginjg",
component: () => import("@/views/loginjg/index.vue"),
},
{
path: "/login/sb",
path: "/sb",
name: "loginsb",
component: () => import("@/views/loginsb/index.vue"),
},
......
<template>
<div class="bg">
<div class="login-inner-bg login">
<h2>{{ productName }}</h2>
<div class="user_style">
<h3>欢迎登录</h3>
<el-form :model="user" :rules="rules" ref="user" id="loginform" class="demo-ruleForm">
<el-form-item prop="account">
<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.enter.native="login('user')" v-model="user.password"
placeholder="请输入密码"></el-input>
</el-form-item>
<el-form-item class="login-btn">
<el-button type="primary" style="width: 100%" @click="login('user')">登录</el-button>
</el-form-item>
</el-form>
</div>
</div>
</div>
</template>
<script>
import { loginIn } from "@/api/login.js";
import { api, getAction } from "@/api/manageApi";
export default {
name: "Login",
data () {
return {
user: {
account: "",
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]);
} else {
this.$message.error({ message: res.message, showClose: true });
}
});
},
mounted () {
// this.checkUserName();
},
methods: {
//记住用户名
checkUserName: function (flag) {
this.user.checkStatus = flag;
if (this.user.checkStatus) {
localStorage.setItem("accountId", this.user.account);
let name = localStorage.getItem("accountId");
if (name === "") {
return;
} else {
this.user.account = name;
}
} else {
this.user.account = localStorage.getItem("accountId");
}
},
login (user) {
var self = this;
this.$refs[user].validate((valid) => {
if (valid) {
loginIn(self.user.account, self.user.password)
.then((res) => {
if (res.status === 1) {
//存储token
sessionStorage.setItem("token", `Bearer ${res.content}`);
//登录成功后需判断有无重定向,没有重定向则跳转首页
this.$router.replace(this.$route.query.redirect || "/");
} else {
//错误处理
}
})
.catch((error) => {
// console.dir(error);
});
}
});
},
},
components: {},
};
</script>
<style scoped lang="scss">
.username,
.password {
position: relative;
&:before {
content: "";
display: block;
width: 16px;
height: 16px;
position: absolute;
left: 10px;
top: 7px;
background-size: 100% 100%;
}
/deep/ .el-input__inner {
text-indent: 24px;
border: 1px solid rgba(11, 161, 248, 0.4);
background-color: rgba(6, 135, 205, 0.3) !important;
}
}
.username::before {
background-image: url(../../image/username.png);
}
.password::before {
background-image: url(../../image/password.png);
}
.bg {
width: 100%;
height: 100%;
min-width: 1440px;
min-height: 560px;
background: url(../../image/loginBoxBg.png) no-repeat;
background-size: 100% 100%;
overflow: hidden;
position: relative;
}
.login-inner-bg {
background: url(../../image/loginBg.png) no-repeat;
width: 21.6%;
height: 43%;
min-width: 360px;
min-height: 380px;
top: 30%;
right: 20%;
position: absolute;
background-size: 100% 100%;
box-sizing: border-box;
padding: 56px;
h2 {
width: 100%;
font-size: 36px;
font-weight: 700;
color: #fff;
text-align: center;
white-space: nowrap;
position: absolute;
right: 0;
top: -70px;
background-image: linear-gradient(180deg,
rgba(99, 163, 255, 1) 0,
rgba(99, 163, 255, 1) 0,
rgba(182, 220, 255, 1) 49.731445%,
rgba(114, 190, 255, 1) 100%,
rgba(114, 190, 255, 1) 100%);
overflow-wrap: break-word;
color: rgba(255, 255, 255, 1);
font-size: 36px;
font-family: AlimamaShuHeiTi-Bold;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
}
.login {
.user_style {
h3 {
color: #fff;
font-size: 22px;
font-weight: normal;
text-align: center;
margin: 16px auto 34px;
font-weight: 400;
}
}
.btn {
width: 100%;
height: 6vh;
background-color: #00c2de;
border-radius: 5px;
font-size: 1.4vw;
color: #ffffff;
}
.btn:hover {
cursor: pointer;
background-color: #2d8cf0;
}
}
.login #loginform {
.el-form-item {
margin-bottom: 24px !important;
}
.login-btn {
margin-top: 40px !important;
}
.el-button {
font-size: 18px;
background: #0d8cc0 !important;
color: #ffffff !important;
cursor: pointer !important;
}
.el-input__inner {
width: 100% !important;
}
.el-checkbox__label {
color: #fff;
}
}
.inputUser .ivu-input {
padding: 6px 24px !important;
border: 1px solid #9f9f9f !important;
}
</style>
......@@ -60,7 +60,7 @@
getAction(api.subsystem, params).then((res) => {
if (res.status === 1) {
this.productName = res.content[0].name;
this.$store.dispatch("products/setData", res.content[0]);
this.$store.dispatch("products/setData", res.content[0].code);
} else {
this.$message.error({ message: res.message, showClose: true });
}
......
......@@ -67,7 +67,7 @@
getAction(api.subsystem, params).then((res) => {
if (res.status === 1) {
this.productName = res.content[0].name;
this.$store.dispatch("products/setData", res.content[0]);
this.$store.dispatch("products/setData", res.content[0].code);
} else {
this.$message.error({ message: res.message, showClose: true });
}
......
......@@ -77,14 +77,14 @@
userInfo: {
handler: function (val) {
if (val) {
this.getUserInfo(val.id)
this.getUserdata(val.id)
}
}
}
},
mounted () {
if (this.userInfo) {
this.getUserInfo(this.userInfo)
this.getUserdata(this.userInfo)
}
this.sexList = [
{
......@@ -105,7 +105,7 @@
]
},
methods: {
getUserInfo (p) {
getUserdata (p) {
getAction(`${api.users}/${p.id}`).then((res) => {
if (res.status === 1) {
this.form = res.content
......@@ -120,7 +120,7 @@
putAction(`${api.users}/${this.form.id}`, this.form).then((res) => {
if (res.status === 1) {
this.$message.success({ message: res.message, showClose: true })
this.getUserInfo(this.form.id)
this.getUserdata(this.form.id)
} else {
this.$message.error({ message: res.message, showClose: true })
}
......
......@@ -64,173 +64,174 @@
</template>
<script>
import Dialog from "@/components/Dialog/";
import { getParentMenuListAction } from '@/api/authorityManage'
import JsonEditor from '@/components/JsonEditors'
import IconList from '@/components/IconList'
import { validateCode } from '@/utils/validate';
import { api, httpAction } from '@/api/manageApi'
export default {
name: 'MenuModal',
components: {
IconList,
JsonEditor,
Dialog
},
props: {
productId: {
type: String,
default: ''
}
},
data () {
return {
form: {
icon: '',
code: ''
},
rules: {
name: [{ required: true, message: '请输入菜单名称', trigger: 'blur' }],
code: [
{ required: true, message: '必填', trigger: 'blur' },
{ validator: validateCode, trigger: 'blur' }
]
},
title: '',
type: '',
visible: false,
parentMenuList: [],
menuKey: 0,
jumpModeList: [
{ name: '在当前页面显示', value: 1 },
{ name: '跳转到新页面', value: 2 }
],
setProps: {
value: 'id',
label: 'name',
children: 'children',
expandTrigger: 'hover',
checkStrictly: true, // 可取消关联,选择任意一级选项
emitPath: false
},
dataUrl: api.menus
}
},
computed: {
codeComputed: {
get: function () {
return this.form.code
},
set: function (val) {
this.form.code = val.toUpperCase()
}
}
},
created () { },
mounted () { },
methods: {
// 获取父级菜单
getParentMenuList (id) {
getParentMenuListAction(id).then((res) => {
if (res.status === 1) {
const list = this.$dealArrChildren(res.content)
if (id) {
this.parentMenuList = this.$dealArrDisabled(
this.$deepCopy(list),
id
)
this.menuKey++
} else {
this.parentMenuList = list
}
} else {
this.$message.error({ message: res.message, showClose: true })
}
})
},
getIconList () {
this.$refs.iconList.show(true)
},
getIconName (data) {
this.form.icon = data
import Dialog from "@/components/Dialog/";
import { getParentMenuListAction } from '@/api/authorityManage'
import JsonEditor from '@/components/JsonEditors'
import IconList from '@/components/IconList'
import { validateCode } from '@/utils/validate';
import { api, httpAction } from '@/api/manageApi'
export default {
name: 'MenuModal',
components: {
IconList,
JsonEditor,
Dialog
},
// 配置参数
getJsonString (data) {
this.form.metadata = data
},
// 新增菜单
add () {
this.getParentMenuList(this.productId)
this.visible = true
this.type = 0
this.form.jumpMode = 1
props: {
productId: {
type: String,
default: ''
}
},
// 编辑菜单
edit (record) {
this.type = 1
// 若有id为编辑
if (record.id) {
this.$nextTick(() => {
this.form = Object.assign({}, record)
this.getParentMenuList(this.productId)
})
data () {
return {
form: {
icon: '',
code: ''
},
rules: {
name: [{ required: true, message: '请输入菜单名称', trigger: 'blur' }],
code: [
{ required: true, message: '必填', trigger: 'blur' },
{ validator: validateCode, trigger: 'blur' }
]
},
title: '',
type: '',
visible: false,
parentMenuList: [],
menuKey: 0,
jumpModeList: [
{ name: '在当前页面显示', value: 1 },
{ name: '跳转到新页面', value: 2 }
],
setProps: {
value: 'id',
label: 'name',
children: 'children',
expandTrigger: 'hover',
checkStrictly: true, // 可取消关联,选择任意一级选项
emitPath: false
},
dataUrl: api.menus
}
this.visible = true
},
// 选择上级菜单
handleChange (value) {
this.form.parentId = value
computed: {
codeComputed: {
get: function () {
return this.form.code
},
set: function (val) {
this.form.code = val.toUpperCase()
}
}
},
// 保存
submitForm (submitType) {
this.$refs.form.validate((valid) => {
if (valid) {
let method = ''
let url = ''
const formData = this.form
formData.productId = this.productId
if (!formData.id) {
method = 'post'
url = this.dataUrl
created () { },
mounted () { },
methods: {
// 获取父级菜单
getParentMenuList (id) {
getParentMenuListAction(id).then((res) => {
if (res.status === 1) {
const list = this.$dealArrChildren(res.content)
if (id) {
this.parentMenuList = this.$dealArrDisabled(
this.$deepCopy(list),
id
)
this.menuKey++
} else {
this.parentMenuList = list
}
} else {
method = 'put'
url = `${this.dataUrl}/${formData.id}`
this.$message.error({ message: res.message, showClose: true })
}
httpAction(url, formData, method)
.then((res) => {
if (res.status === 1) {
this.$message.success({
message: res.message,
showClose: true
})
})
},
getIconList () {
this.$refs.iconList.show(true)
},
getIconName (data) {
this.form.icon = data
},
// 配置参数
getJsonString (data) {
this.form.metadata = data
},
// 新增菜单
add () {
this.getParentMenuList(this.productId)
this.visible = true
this.type = 0
this.form.jumpMode = 1
},
// 编辑菜单
edit (record) {
this.type = 1
// 若有id为编辑
if (record.id) {
this.$nextTick(() => {
this.form = Object.assign({}, record)
this.getParentMenuList(this.productId)
})
}
this.visible = true
},
// 选择上级菜单
handleChange (value) {
this.form.parentId = value
},
// 保存
submitForm (submitType) {
this.$refs.form.validate((valid) => {
if (valid) {
let method = ''
let url = ''
const formData = this.form
formData.productId = this.productId
if (!formData.id) {
method = 'post'
url = this.dataUrl
} else {
method = 'put'
url = `${this.dataUrl}/${formData.id}`
}
debugger
httpAction(url, formData, method)
.then((res) => {
if (res.status === 1) {
this.$message.success({
message: res.message,
showClose: true
})
this.resetForm()
this.$emit('ok')
} else {
this.$message.error({ message: res.message, showClose: true })
}
})
.catch((err) => {
console.log(err)
})
this.resetForm()
this.$emit('ok')
} else {
this.$message.error({ message: res.message, showClose: true })
}
})
.catch((err) => {
console.log(err)
})
}
})
},
resetForm () {
this.$refs.form.resetFields()
this.form = {
icon: '',
code: ''
}
})
},
resetForm () {
this.$refs.form.resetFields()
this.form = {
icon: '',
code: ''
},
close () {
this.resetForm()
this.visible = false
}
},
close () {
this.resetForm()
this.visible = false
}
}
}
</script>
<style scoped lang="scss">
// @import "~@/styles/public.scss";
// @import "~@/styles/public.scss";
</style>
......
......@@ -11,11 +11,6 @@ class data extends filter {
width: 130
},
{
prop: "type",
label: "类别",
width: 200
},
{
prop: "description",
label: "备注"
}
......
......@@ -18,16 +18,6 @@
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="24">
<el-col :span="24">
<el-form-item label="角色类型:" prop="roleType">
<el-input
v-model="dialogForm.roleType"
clearable
placeholder="角色类型" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item label="备注:" class="form-item-mb0">
......@@ -75,9 +65,6 @@
roleName: [
{ required: true, message: '请输入角色名称', trigger: 'blur' }
],
roleType: [
{ required: true, message: '请输入角色类型', trigger: 'blur' }
]
},
roleTypeOptions: [
{ name: '定制', value: '定制' },
......@@ -109,7 +96,6 @@
})
this.dialogForm = {
roleName: '',
roleType: ''
}
this.showAddEditDialog = val
this.$emit('ok', this.menuType)
......@@ -130,7 +116,6 @@
})
this.dialogForm = {
roleName: '',
roleType: ''
}
this.showAddEditDialog = val
this.$emit('ok', this.menuType)
......@@ -153,7 +138,6 @@
this.$refs.form.resetFields()
this.dialogForm = {
roleName: '',
roleType: ''
}
this.showAddEditDialog = false
}
......