MainLayout.vue 9.5 KB

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