App.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <div id="app">
  3. <router-view />
  4. </div>
  5. </template>
  6. <script>
  7. export default {
  8. name: 'App',
  9. components: {},
  10. data() {
  11. return {};
  12. },
  13. created() {
  14. this.initDataFun(); // 初始化数据
  15. },
  16. mounted() {},
  17. methods: {
  18. // 初始化数据
  19. initDataFun() {
  20. // 从session中取工种信息,存在即存储到vuex中
  21. let ENGINEERING_WORK_LIST = sessionStorage.getItem(
  22. 'ENGINEERING_WORK_LIST'
  23. );
  24. if (ENGINEERING_WORK_LIST) {
  25. this.$store.commit(
  26. 'common/SET_ENGINEERING_WORK_LIST',
  27. JSON.parse(ENGINEERING_WORK_LIST)
  28. );
  29. }
  30. // 从session中取试题类型信息,存在即存储到vuex中
  31. let EXAM_QUESTION_TYPE_CONDITION_PARENT = sessionStorage.getItem(
  32. 'EXAM_QUESTION_TYPE_CONDITION_PARENT'
  33. );
  34. if (EXAM_QUESTION_TYPE_CONDITION_PARENT) {
  35. this.$store.commit(
  36. 'common/SET_EXAM_QUESTION_TYPE_CONDITION_PARENT',
  37. JSON.parse(EXAM_QUESTION_TYPE_CONDITION_PARENT)
  38. );
  39. }
  40. this.$store.commit('common/SET_SCREENHEIGHT', document.body.clientHeight); // 赋值网页内容区域可视化高度值
  41. this.$store.commit('common/SET_SCREENWIDTH', document.body.clientWidth); // 赋值网页内容区域可视化宽度值
  42. // 监听屏幕高度变化,同步表单高度
  43. window.onresize = () => {
  44. return (() => {
  45. this.$store.commit(
  46. 'common/SET_SCREENHEIGHT',
  47. document.body.clientHeight
  48. ); // 赋值网页内容区域可视化高度值
  49. this.$store.commit(
  50. 'common/SET_SCREENWIDTH',
  51. document.body.clientWidth
  52. ); // 赋值网页内容区域可视化宽度值
  53. this.$store.commit('common/SET_WINDOW_ONRESIZE'); // 通知网页内容区域可视化宽高有变化
  54. })();
  55. };
  56. },
  57. },
  58. };
  59. </script>
  60. <style>
  61. #app {
  62. }
  63. </style>