App.vue 2.1 KB

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