MainLayout.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <template>
  2. <div class="main-layout">
  3. <header class="header qm-primary-text">
  4. <Poptip v-if="ifShowQr" trigger="hover" width="280">
  5. <span class="name-arrow">手机端登录(Android)</span>
  6. <div slot="content">
  7. <Tabs type="card">
  8. <TabPane label="下载安卓apk">
  9. <div class="qm-primary-text flex-center">
  10. <qrcode :value="qrValue" :options="{ width: 200 }"></qrcode>
  11. </div>
  12. </TabPane>
  13. <TabPane label="绑定用户">
  14. <div class="qm-primary-text flex-center">
  15. <qrcode :value="qrValue" :options="{ width: 200 }"></qrcode>
  16. <div>请使用“云考”App扫描</div>
  17. </div>
  18. </TabPane>
  19. </Tabs>
  20. </div>
  21. </Poptip>
  22. <span v-if="ifShowQr" style="margin: auto 20px">|</span>
  23. <Poptip trigger="hover" width="300">
  24. <span class="name-arrow"
  25. >{{ user.displayName }} &nbsp;
  26. <i
  27. class="ivu-icon ivu-icon-md-arrow-dropdown"
  28. style="vertical-align: middle;"
  29. ></i>
  30. </span>
  31. <div slot="content">
  32. <div class="info qm-primary-text">
  33. <div class="hr info-row">
  34. <div>底照</div>
  35. <div>
  36. <img class="user-avatar" :src="user.photoPath" alt="无底照" />
  37. </div>
  38. </div>
  39. <div class="hr info-row">
  40. <div>学号</div>
  41. <div>{{ user.studentCodeList.join(",") }}</div>
  42. </div>
  43. <div class="hr info-row">
  44. <div>身份证号</div>
  45. <div>{{ user.identityNumber }}</div>
  46. </div>
  47. <div class="hr info-row">
  48. <div>学习中心</div>
  49. <div>{{ user.orgName }}</div>
  50. </div>
  51. <div
  52. v-if="!isEpcc"
  53. style="grid-column: span 2; place-self: center; width: 100%; padding-top: 10px"
  54. >
  55. <i-button class="qm-primary-button" long @click="goChangePwd">
  56. 修改密码
  57. </i-button>
  58. </div>
  59. </div>
  60. </div>
  61. </Poptip>
  62. <span style="margin: auto 20px">|</span>
  63. <a
  64. class="qm-primary-text"
  65. style="display: inline-block; margin-right: 20px; text-align: center;"
  66. @click="() => logout('?LogoutReason=正常退出')"
  67. >
  68. {{ isEpcc ? "返回" : "退出登录" }}
  69. </a>
  70. </header>
  71. <transition name="fade" appear>
  72. <main :key="$route.path" class="content">
  73. <slot></slot>
  74. </main>
  75. </transition>
  76. <nav class="nav">
  77. <img :src="getLogo" class="qm-logo" />
  78. <ul>
  79. <!-- <li v-if="menus.map(v => v.routeCode).includes('STU_ONLINE_EXAM')">
  80. <router-link
  81. class="link"
  82. to="/online-exam"
  83. ondragstart="return false;"
  84. >
  85. {{ menus.find(v => v.routeCode === "STU_ONLINE_EXAM").name }}
  86. </router-link>
  87. </li>
  88. <li v-if="menus.map(v => v.routeCode).includes('STU_ONLINE_HOMEWORK')">
  89. <router-link
  90. class="link"
  91. to="/online-homework"
  92. ondragstart="return false;"
  93. >
  94. {{ menus.find(v => v.routeCode === "STU_ONLINE_HOMEWORK").name }}
  95. </router-link>
  96. </li>
  97. <li v-if="menus.map(v => v.routeCode).includes('STU_ONLINE_PRACTICE')">
  98. <router-link
  99. class="link"
  100. to="/online-practice"
  101. ondragstart="return false;"
  102. >
  103. {{ menus.find(v => v.routeCode === "STU_ONLINE_PRACTICE").name }}
  104. </router-link>
  105. </li>
  106. <li v-if="menus.map(v => v.routeCode).includes('STU_OFFLINE_EXAM')">
  107. <router-link
  108. class="link"
  109. to="/offline-exam"
  110. ondragstart="return false;"
  111. >
  112. {{ menus.find(v => v.routeCode === "STU_OFFLINE_EXAM").name }}
  113. </router-link>
  114. </li>
  115. <li v-if="menus.map(v => v.routeCode).includes('STU_NOTICE')">
  116. <router-link
  117. class="link"
  118. to="/site-message"
  119. ondragstart="return false;"
  120. >
  121. <Badge :count="messageUnread" :offset="[20, -20]">
  122. {{ menus.find(v => v.routeCode === "STU_NOTICE").name }}
  123. </Badge>
  124. </router-link>
  125. </li>
  126. <li v-if="menus.map(v => v.routeCode).includes('STU_MODIFY_PWD')">
  127. <router-link class="link" to="/password" ondragstart="return false;">
  128. {{ menus.find(v => v.routeCode === "STU_MODIFY_PWD").name }}
  129. </router-link>
  130. </li> -->
  131. <li v-for="(menu, index) in menus" :key="index">
  132. <router-link class="link" :to="menu.link" ondragstart="return false;">
  133. <Badge
  134. v-if="menu.routeCode === 'STU_NOTICE'"
  135. :count="messageUnread"
  136. :offset="[20, -20]"
  137. >
  138. {{ menu.name }}
  139. </Badge>
  140. <span v-else>
  141. {{ menu.name }}
  142. </span>
  143. </router-link>
  144. </li>
  145. </ul>
  146. </nav>
  147. <footer class="footer">©️2020 启明泰和</footer>
  148. <SiteMessagePopup />
  149. </div>
  150. </template>
  151. <script>
  152. import { mapState, mapGetters, mapMutations } from "vuex";
  153. import VueQrcode from "@chenfengyuan/vue-qrcode";
  154. import SiteMessagePopup from "./SiteMessagePopup.vue";
  155. export default {
  156. name: "MainLayout",
  157. components: {
  158. qrcode: VueQrcode,
  159. SiteMessagePopup,
  160. },
  161. data() {
  162. return {
  163. appDownloadUrl: "fetching...",
  164. ifShowQr: false,
  165. menus: [],
  166. };
  167. },
  168. computed: {
  169. ...mapState(["user", "siteMessages", "QECSConfig"]),
  170. ...mapGetters(["isEpcc", "isCug"]),
  171. messageUnread() {
  172. return this.siteMessages.filter(v => v.hasRead === false).length;
  173. },
  174. qrValue() {
  175. const { rootOrgId, studentCodeList, identityNumber } = this.user;
  176. return JSON.stringify({
  177. rootOrgId,
  178. studentCode: studentCodeList.join(","),
  179. identityNumber,
  180. });
  181. },
  182. // ifShowQr() {
  183. // const shouldShow = this.QECSConfig.SHOW_STUDENT_CLIENT_APP_QRCODE;
  184. // return shouldShow === "true";
  185. // },
  186. getLogo() {
  187. return this.QECSConfig.IS_CUSTOM_MENU_LOGO === "true"
  188. ? this.QECSConfig.CUS_MENU_LOGO_FILE_URL
  189. : require("./qm-logo.png");
  190. },
  191. },
  192. async created() {
  193. const r = await this.$http.get(
  194. "/api/ecs_core/systemProperty/APP_DOWNLOAD_URL"
  195. );
  196. this.appDownloadUrl = r.data;
  197. const r2 = await this.$http.get(
  198. `/api/ecs_core/org/property/${this.user.rootOrgId}/APP_ENABLED`
  199. );
  200. this.ifShowQr = r2.data;
  201. var url =
  202. "/api/ecs_core/rolePrivilege/getStudentClientMenu?rootOrgId=" +
  203. this.user.rootOrgId;
  204. // const params = new URLSearchParams();
  205. // params.append("groupCode", "BASIC_MENUS");
  206. // params.append("full", false);
  207. // const res = await this.$http.post(url, params, {
  208. // headers: { "content-type": "application/x-www-form-urlencoded" },
  209. // });
  210. const links = {
  211. STU_ONLINE_EXAM: "/online-exam",
  212. STU_ONLINE_HOMEWORK: "/online-homework",
  213. STU_ONLINE_PRACTICE: "/online-practice",
  214. STU_OFFLINE_EXAM: "/offline-exam",
  215. STU_NOTICE: "/site-message",
  216. STU_MODIFY_PWD: "/password",
  217. };
  218. const res = await this.$http.get(url);
  219. // console.log(res);
  220. this.menus = res.data
  221. .sort((a, b) => b.weight - a.weight)
  222. .map(v => {
  223. return {
  224. routeCode: v.routeCode.toUpperCase(),
  225. name: v.name,
  226. link: links[v.routeCode.toUpperCase()],
  227. };
  228. });
  229. this.updateMenus(this.menus);
  230. },
  231. methods: {
  232. ...mapMutations(["updateMenus"]),
  233. goChangePwd() {
  234. this.$router.push("/password");
  235. },
  236. },
  237. };
  238. </script>
  239. <style scoped>
  240. .main-layout {
  241. display: grid;
  242. grid-template-areas: "nav header" "nav content" "nav footer";
  243. min-height: 100vh;
  244. grid-template-columns: 180px 1fr;
  245. grid-template-rows: auto 1fr auto;
  246. }
  247. .header {
  248. grid-area: header;
  249. height: 50px;
  250. background-color: #ffffff;
  251. box-shadow: 0px 1px 0px 0px #eeeeee;
  252. text-align: right;
  253. line-height: 50px;
  254. }
  255. .user-avatar {
  256. display: inline-block;
  257. width: 80px;
  258. height: 80px;
  259. object-fit: contain;
  260. }
  261. .info {
  262. width: 260px;
  263. }
  264. .info > div {
  265. min-height: 50px;
  266. }
  267. .hr {
  268. border-bottom: 1px solid #eeeeee;
  269. }
  270. .info-row {
  271. display: grid;
  272. grid-template-columns: 1fr 2fr;
  273. align-items: center;
  274. }
  275. .info-row > div:nth-of-type(odd) {
  276. justify-self: left;
  277. }
  278. .info-row > div:nth-of-type(even) {
  279. justify-self: right;
  280. }
  281. .name-arrow:hover .ivu-icon-md-arrow-dropdown::before {
  282. content: "\F343";
  283. }
  284. .nav {
  285. grid-area: nav;
  286. background-color: rgb(113, 113, 113);
  287. background-repeat: repeat;
  288. width: 180px;
  289. min-height: 100vh;
  290. display: flex;
  291. flex-direction: column;
  292. }
  293. .qm-logo {
  294. width: 80px;
  295. height: 68px;
  296. margin: 30px auto;
  297. }
  298. .flex-center {
  299. display: flex;
  300. flex-direction: column;
  301. align-items: center;
  302. }
  303. .link {
  304. background-image: url(./link.png);
  305. background-repeat: no-repeat;
  306. background-position: 30px 50%;
  307. padding-left: 45px;
  308. text-align: left;
  309. padding-right: 20px;
  310. line-height: 40px;
  311. width: 100%;
  312. display: inline-block;
  313. color: #ffffff;
  314. }
  315. .link >>> .ivu-badge-count {
  316. z-index: 1;
  317. }
  318. .router-link-active,
  319. .link:hover {
  320. background-image: url(./link-active.png);
  321. background-color: rgba(255, 255, 255, 0.5);
  322. color: #fafafa;
  323. }
  324. .footer {
  325. grid-area: footer;
  326. margin-bottom: 10px;
  327. }
  328. </style>