|
@@ -1,193 +1,116 @@
|
|
<template>
|
|
<template>
|
|
- <el-aside width="200px">
|
|
|
|
|
|
+ <el-aside width="200px" v-if="menuList.length > 0">
|
|
|
|
+ <div
|
|
|
|
+ style="height: 50px; margin-top: 20px; margin-left: 20px; font-size: 20px"
|
|
|
|
+ >
|
|
|
|
+ <i class="el-icon-location"></i> <span>{{ group.name }}</span>
|
|
|
|
+ </div>
|
|
<el-menu
|
|
<el-menu
|
|
- default-active="2"
|
|
|
|
class="el-menu-vertical-demo"
|
|
class="el-menu-vertical-demo"
|
|
background-color="#545c64"
|
|
background-color="#545c64"
|
|
text-color="#fff"
|
|
text-color="#fff"
|
|
active-text-color="#ffd04b"
|
|
active-text-color="#ffd04b"
|
|
>
|
|
>
|
|
- <el-submenu index="1">
|
|
|
|
|
|
+ <el-submenu
|
|
|
|
+ v-for="menu1 in menuList1"
|
|
|
|
+ :key="menu1.id"
|
|
|
|
+ :index="menu1.nodeCode"
|
|
|
|
+ >
|
|
<template slot="title">
|
|
<template slot="title">
|
|
- <i class="el-icon-location"></i> <span>基础信息</span>
|
|
|
|
- </template>
|
|
|
|
|
|
+ {{ menu1.name }}</template
|
|
|
|
+ >
|
|
<el-menu-item-group>
|
|
<el-menu-item-group>
|
|
- <template slot="title"
|
|
|
|
- >分组一</template
|
|
|
|
|
|
+ <el-menu-item
|
|
|
|
+ v-for="menu2 in menuList2(menu1)"
|
|
|
|
+ :index="menu2.nodeCode"
|
|
|
|
+ :key="menu2.id"
|
|
>
|
|
>
|
|
- <el-menu-item index="1-1">选项1</el-menu-item>
|
|
|
|
- <el-menu-item index="1-2">选项2</el-menu-item>
|
|
|
|
- </el-menu-item-group>
|
|
|
|
- <el-menu-item-group title="分组2">
|
|
|
|
- <el-menu-item index="1-3">选项3</el-menu-item>
|
|
|
|
|
|
+ <router-link :to="{ path: menu2.ext5 }">
|
|
|
|
+ <i class="fa fa-circle-o"></i>{{ menu2.name }}
|
|
|
|
+ </router-link>
|
|
|
|
+ </el-menu-item>
|
|
</el-menu-item-group>
|
|
</el-menu-item-group>
|
|
- <el-submenu index="1-4">
|
|
|
|
- <template slot="title"
|
|
|
|
- >选项4</template
|
|
|
|
- >
|
|
|
|
- <el-menu-item index="1-4-1">选项1</el-menu-item>
|
|
|
|
- </el-submenu>
|
|
|
|
</el-submenu>
|
|
</el-submenu>
|
|
- <el-menu-item index="2">
|
|
|
|
- <i class="el-icon-menu"></i> <span slot="title">考务</span>
|
|
|
|
- </el-menu-item>
|
|
|
|
- <el-menu-item index="3">
|
|
|
|
- <i class="el-icon-document"></i> <span slot="title">题库</span>
|
|
|
|
- </el-menu-item>
|
|
|
|
- <el-menu-item index="4">
|
|
|
|
- <i class="el-icon-setting"></i> <span slot="title">网考</span>
|
|
|
|
- </el-menu-item>
|
|
|
|
- <el-menu-item index="5">
|
|
|
|
- <i class="el-icon-setting"></i> <span slot="title">阅卷</span>
|
|
|
|
- </el-menu-item>
|
|
|
|
- <el-menu-item index="6">
|
|
|
|
- <v-icon name="print" class="el-icon-" />
|
|
|
|
- <span slot="title">印刷</span>
|
|
|
|
- </el-menu-item>
|
|
|
|
- <el-menu-item index="7">
|
|
|
|
- <v-icon name="flag" class="el-icon-" />
|
|
|
|
- <span slot="title">报表</span>
|
|
|
|
- </el-menu-item>
|
|
|
|
</el-menu>
|
|
</el-menu>
|
|
</el-aside>
|
|
</el-aside>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-import { mapActions, mapState } from "vuex";
|
|
|
|
-import { USER_SIGNOUT } from "../../store/user";
|
|
|
|
|
|
+import { mapState } from "vuex";
|
|
import { core_api } from "../../constants/constants";
|
|
import { core_api } from "../../constants/constants";
|
|
|
|
|
|
|
|
+const routesToMenu = [
|
|
|
|
+ {
|
|
|
|
+ path: "/basic",
|
|
|
|
+ name: "基础信息",
|
|
|
|
+ groupCode: "BASIC_MENUS"
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ path: "/examwork",
|
|
|
|
+ name: "考务管理",
|
|
|
|
+ groupCode: "EXAM_WORK_MENUS"
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ path: "/questions",
|
|
|
|
+ name: "题库",
|
|
|
|
+ groupCode: "QUESTIONS_WORK_MENUS"
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ path: "/oe",
|
|
|
|
+ name: "网考",
|
|
|
|
+ groupCode: "NETEXAM_WORK_MENUS"
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ path: "/marking",
|
|
|
|
+ name: "阅卷",
|
|
|
|
+ groupCode: "MARK_WORK_MENUS"
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ path: "/portal",
|
|
|
|
+ groupCode: "PORTAL_MENUS"
|
|
|
|
+ }
|
|
|
|
+];
|
|
|
|
+
|
|
export default {
|
|
export default {
|
|
name: "HomeSide",
|
|
name: "HomeSide",
|
|
data() {
|
|
data() {
|
|
- var validatePass = (rule, value, callback) => {
|
|
|
|
- if (value === "") {
|
|
|
|
- callback(new Error("请输入密码"));
|
|
|
|
- } else {
|
|
|
|
- if (this.passForm.checkPass !== "") {
|
|
|
|
- this.$refs.passForm.validateField("checkPass");
|
|
|
|
- }
|
|
|
|
- callback();
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
- var validatePass2 = (rule, value, callback) => {
|
|
|
|
- if (value === "") {
|
|
|
|
- callback(new Error("请输入确认密码"));
|
|
|
|
- } else if (value !== this.passForm.pass) {
|
|
|
|
- callback(new Error("两次输入密码不一致!"));
|
|
|
|
- } else {
|
|
|
|
- callback();
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
return {
|
|
return {
|
|
- menuList: [],
|
|
|
|
- userDialog: false,
|
|
|
|
- passForm: { pass: "", checkPass: "" },
|
|
|
|
- passRules: {
|
|
|
|
- pass: [{ validator: validatePass, trigger: "blur" }],
|
|
|
|
- checkPass: [{ validator: validatePass2, trigger: "blur" }]
|
|
|
|
- }
|
|
|
|
|
|
+ group: null,
|
|
|
|
+ menuList: []
|
|
};
|
|
};
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
- ...mapState({ user: state => state.user })
|
|
|
|
|
|
+ ...mapState({ user: state => state.user }),
|
|
|
|
+ menuList1() {
|
|
|
|
+ return this.menuList.filter(
|
|
|
|
+ m => m.parentId === null && m.ext1 === "menu"
|
|
|
|
+ );
|
|
|
|
+ }
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
- ...mapActions([USER_SIGNOUT]),
|
|
|
|
- openUserDialog() {
|
|
|
|
- this.passForm = { pass: "", checkPass: "" };
|
|
|
|
- this.userDialog = true;
|
|
|
|
- },
|
|
|
|
- //保存密码
|
|
|
|
- submitForm() {
|
|
|
|
- this.$refs.passForm.validate(valid => {
|
|
|
|
- if (valid) {
|
|
|
|
- var userId = this.user.userId;
|
|
|
|
- var password = encodeURIComponent(this.passForm.pass);
|
|
|
|
- var url =
|
|
|
|
- core_api +
|
|
|
|
- "/user/password?userId=" +
|
|
|
|
- userId +
|
|
|
|
- "&password=" +
|
|
|
|
- password;
|
|
|
|
- this.$http.put(url).then(() => {
|
|
|
|
- this.$notify({
|
|
|
|
- type: "success",
|
|
|
|
- message: "修改密码成功!"
|
|
|
|
- });
|
|
|
|
- this.resetForm();
|
|
|
|
- this.userDialog = false;
|
|
|
|
- });
|
|
|
|
- } else {
|
|
|
|
- console.log("error submit!");
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
|
|
+ async getUserPrivileges(groupCode) {
|
|
|
|
+ var url = core_api + "/rolePrivilege/getUserPrivileges";
|
|
|
|
+ const params = new URLSearchParams();
|
|
|
|
+ params.append("groupCode", groupCode);
|
|
|
|
+ params.append("full", false);
|
|
|
|
+ const res = await this.$http.post(url, params, {
|
|
|
|
+ headers: { "content-type": "application/x-www-form-urlencoded" }
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ return res.data;
|
|
},
|
|
},
|
|
- //重置
|
|
|
|
- resetForm() {
|
|
|
|
- this.$refs.passForm.resetFields();
|
|
|
|
- },
|
|
|
|
- isSuperAdmin() {
|
|
|
|
- if (!this.user.roleList) {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- for (let role of this.user.roleList) {
|
|
|
|
- if (role.roleCode == "SUPER_ADMIN") {
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return false;
|
|
|
|
- },
|
|
|
|
- logout() {
|
|
|
|
- this.$http
|
|
|
|
- .post(core_api + "/auth/logout")
|
|
|
|
- .then(() => {
|
|
|
|
- const orgId = this.user.rootOrgId;
|
|
|
|
- this.USER_SIGNOUT();
|
|
|
|
- window.name = "";
|
|
|
|
- this.$router.replace({
|
|
|
|
- path: "/login" + "?orgId=" + orgId
|
|
|
|
- });
|
|
|
|
- })
|
|
|
|
- .catch(response => {
|
|
|
|
- const orgId = this.user.rootOrgId;
|
|
|
|
- if (response.status == 500) {
|
|
|
|
- this.$notify({
|
|
|
|
- showClose: true,
|
|
|
|
- message: response.data.desc,
|
|
|
|
- type: "error"
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- this.USER_SIGNOUT();
|
|
|
|
- window.name = "";
|
|
|
|
- this.$router.replace({
|
|
|
|
- path: "/login" + "?orgId=" + orgId
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
|
|
+ menuList2(menu1) {
|
|
|
|
+ return this.menuList.filter(
|
|
|
|
+ m => m.parentId === menu1.id && m.ext1 === "menu"
|
|
|
|
+ );
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- created() {
|
|
|
|
- var url = core_api + "/rolePrivilege/getUserPrivileges";
|
|
|
|
- const params = new URLSearchParams();
|
|
|
|
- params.append("groupCode", "PORTAL_MENUS");
|
|
|
|
- params.append("full", false);
|
|
|
|
- this.$http
|
|
|
|
- .post(url, params, {
|
|
|
|
- headers: { "content-type": "application/x-www-form-urlencoded" }
|
|
|
|
- })
|
|
|
|
- .then(response => {
|
|
|
|
- this.menuList = response.data;
|
|
|
|
- })
|
|
|
|
- .catch(response => {
|
|
|
|
- if (response.status == 500) {
|
|
|
|
- this.$notify({
|
|
|
|
- showClose: true,
|
|
|
|
- message: response.data.desc,
|
|
|
|
- type: "error"
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ async created() {
|
|
|
|
+ this.group = routesToMenu.find(v => this.$route.path.startsWith(v.path));
|
|
|
|
+ const groupCode = this.group && this.group.groupCode;
|
|
|
|
+ if (groupCode) {
|
|
|
|
+ this.menuList = await this.getUserPrivileges(groupCode);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|
|
@@ -197,8 +120,7 @@ export default {
|
|
height: calc(100vh - 60px);
|
|
height: calc(100vh - 60px);
|
|
}
|
|
}
|
|
.el-aside {
|
|
.el-aside {
|
|
- background-color: #D3DCE6;
|
|
|
|
- color: #333;
|
|
|
|
- line-height: 200px;
|
|
|
|
|
|
+ background-color: #545c64;
|
|
|
|
+ color: #fff;
|
|
}
|
|
}
|
|
</style>
|
|
</style>
|