HomeSide.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <el-aside width="200px">
  3. <el-menu
  4. default-active="2"
  5. class="el-menu-vertical-demo"
  6. background-color="#545c64"
  7. text-color="#fff"
  8. active-text-color="#ffd04b"
  9. >
  10. <el-submenu index="1">
  11. <template slot="title">
  12. <i class="el-icon-location"></i> <span>基础信息</span>
  13. </template>
  14. <el-menu-item-group>
  15. <template slot="title"
  16. >分组一</template
  17. >
  18. <el-menu-item index="1-1">选项1</el-menu-item>
  19. <el-menu-item index="1-2">选项2</el-menu-item>
  20. </el-menu-item-group>
  21. <el-menu-item-group title="分组2">
  22. <el-menu-item index="1-3">选项3</el-menu-item>
  23. </el-menu-item-group>
  24. <el-submenu index="1-4">
  25. <template slot="title"
  26. >选项4</template
  27. >
  28. <el-menu-item index="1-4-1">选项1</el-menu-item>
  29. </el-submenu>
  30. </el-submenu>
  31. <el-menu-item index="2">
  32. <i class="el-icon-menu"></i> <span slot="title">考务</span>
  33. </el-menu-item>
  34. <el-menu-item index="3">
  35. <i class="el-icon-document"></i> <span slot="title">题库</span>
  36. </el-menu-item>
  37. <el-menu-item index="4">
  38. <i class="el-icon-setting"></i> <span slot="title">网考</span>
  39. </el-menu-item>
  40. <el-menu-item index="5">
  41. <i class="el-icon-setting"></i> <span slot="title">阅卷</span>
  42. </el-menu-item>
  43. <el-menu-item index="6">
  44. <v-icon name="print" class="el-icon-" />
  45. <span slot="title">印刷</span>
  46. </el-menu-item>
  47. <el-menu-item index="7">
  48. <v-icon name="flag" class="el-icon-" />
  49. <span slot="title">报表</span>
  50. </el-menu-item>
  51. </el-menu>
  52. </el-aside>
  53. </template>
  54. <script>
  55. import { mapActions, mapState } from "vuex";
  56. import { USER_SIGNOUT } from "../../store/user";
  57. import { core_api } from "../../constants/constants";
  58. export default {
  59. name: "HomeSide",
  60. data() {
  61. var validatePass = (rule, value, callback) => {
  62. if (value === "") {
  63. callback(new Error("请输入密码"));
  64. } else {
  65. if (this.passForm.checkPass !== "") {
  66. this.$refs.passForm.validateField("checkPass");
  67. }
  68. callback();
  69. }
  70. };
  71. var validatePass2 = (rule, value, callback) => {
  72. if (value === "") {
  73. callback(new Error("请输入确认密码"));
  74. } else if (value !== this.passForm.pass) {
  75. callback(new Error("两次输入密码不一致!"));
  76. } else {
  77. callback();
  78. }
  79. };
  80. return {
  81. menuList: [],
  82. userDialog: false,
  83. passForm: { pass: "", checkPass: "" },
  84. passRules: {
  85. pass: [{ validator: validatePass, trigger: "blur" }],
  86. checkPass: [{ validator: validatePass2, trigger: "blur" }]
  87. }
  88. };
  89. },
  90. computed: {
  91. ...mapState({ user: state => state.user })
  92. },
  93. methods: {
  94. ...mapActions([USER_SIGNOUT]),
  95. openUserDialog() {
  96. this.passForm = { pass: "", checkPass: "" };
  97. this.userDialog = true;
  98. },
  99. //保存密码
  100. submitForm() {
  101. this.$refs.passForm.validate(valid => {
  102. if (valid) {
  103. var userId = this.user.userId;
  104. var password = encodeURIComponent(this.passForm.pass);
  105. var url =
  106. core_api +
  107. "/user/password?userId=" +
  108. userId +
  109. "&password=" +
  110. password;
  111. this.$http.put(url).then(() => {
  112. this.$notify({
  113. type: "success",
  114. message: "修改密码成功!"
  115. });
  116. this.resetForm();
  117. this.userDialog = false;
  118. });
  119. } else {
  120. console.log("error submit!");
  121. return false;
  122. }
  123. });
  124. },
  125. //重置
  126. resetForm() {
  127. this.$refs.passForm.resetFields();
  128. },
  129. isSuperAdmin() {
  130. if (!this.user.roleList) {
  131. return false;
  132. }
  133. for (let role of this.user.roleList) {
  134. if (role.roleCode == "SUPER_ADMIN") {
  135. return true;
  136. }
  137. }
  138. return false;
  139. },
  140. logout() {
  141. this.$http
  142. .post(core_api + "/auth/logout")
  143. .then(() => {
  144. const orgId = this.user.rootOrgId;
  145. this.USER_SIGNOUT();
  146. window.name = "";
  147. this.$router.replace({
  148. path: "/login" + "?orgId=" + orgId
  149. });
  150. })
  151. .catch(response => {
  152. const orgId = this.user.rootOrgId;
  153. if (response.status == 500) {
  154. this.$notify({
  155. showClose: true,
  156. message: response.data.desc,
  157. type: "error"
  158. });
  159. }
  160. this.USER_SIGNOUT();
  161. window.name = "";
  162. this.$router.replace({
  163. path: "/login" + "?orgId=" + orgId
  164. });
  165. });
  166. }
  167. },
  168. created() {
  169. var url = core_api + "/rolePrivilege/getUserPrivileges";
  170. const params = new URLSearchParams();
  171. params.append("groupCode", "PORTAL_MENUS");
  172. params.append("full", false);
  173. this.$http
  174. .post(url, params, {
  175. headers: { "content-type": "application/x-www-form-urlencoded" }
  176. })
  177. .then(response => {
  178. this.menuList = response.data;
  179. })
  180. .catch(response => {
  181. if (response.status == 500) {
  182. this.$notify({
  183. showClose: true,
  184. message: response.data.desc,
  185. type: "error"
  186. });
  187. }
  188. });
  189. }
  190. };
  191. </script>
  192. <style lang="css" scoped>
  193. .el-menu-vertical-demo {
  194. height: calc(100vh - 60px);
  195. }
  196. .el-aside {
  197. background-color: #D3DCE6;
  198. color: #333;
  199. line-height: 200px;
  200. }
  201. </style>