plm前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

143 lines
3.5 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div
  3. class="site-wrapper"
  4. :class="{ 'site-sidebar--fold': sidebarFold }"
  5. v-loading.fullscreen.lock="loading"
  6. element-loading-text="拼命加载中..">
  7. <template v-if="!loading">
  8. <main-navbar/>
  9. <main-sidebar/>
  10. <div class="site-content__wrapper" :style="{ 'min-height': documentClientHeight + 'px' }">
  11. <main-content v-if="!$store.state.common.contentIsNeedRefresh"/>
  12. </div>
  13. </template>
  14. </div>
  15. </template>
  16. <script>
  17. import MainNavbar from './main-navbar'
  18. import MainSidebar from './main-sidebar'
  19. import MainContent from './main-content'
  20. export default {
  21. provide() {
  22. return {
  23. // 刷新
  24. refresh() {
  25. this.$store.commit('common/updateContentIsNeedRefresh', true)
  26. this.$nextTick(() => {
  27. this.$store.commit('common/updateContentIsNeedRefresh', false)
  28. })
  29. }
  30. }
  31. },
  32. data() {
  33. return {
  34. loading: true
  35. }
  36. },
  37. components: {
  38. MainNavbar,
  39. MainSidebar,
  40. MainContent
  41. },
  42. computed: {
  43. documentClientHeight: {
  44. get() {
  45. return this.$store.state.common.documentClientHeight
  46. },
  47. set(val) {
  48. this.$store.commit('common/updateDocumentClientHeight', val)
  49. }
  50. },
  51. sidebarFold: {
  52. get() {
  53. return this.$store.state.common.sidebarFold
  54. }
  55. },
  56. userId: {
  57. get() {
  58. return this.$store.state.user.id
  59. },
  60. set(val) {
  61. this.$store.commit('user/updateId', val)
  62. }
  63. },
  64. userName: {
  65. get() {
  66. return this.$store.state.user.name
  67. },
  68. set(val) {
  69. this.$store.commit('user/updateName', val)
  70. }
  71. },
  72. site: {
  73. get() {
  74. return this.$store.state.user.site
  75. },
  76. set(val) {
  77. this.$store.commit('user/updateSite', val)
  78. }
  79. },
  80. userSite: {
  81. get() {
  82. return this.$store.state.user.userSite
  83. },
  84. set(val) {
  85. this.$store.commit('user/updateUserSite', val)
  86. }
  87. },
  88. languageDefault: {
  89. get() {
  90. return this.$store.state.user.languageDefault
  91. },
  92. set(val) {
  93. this.$store.commit('user/updateLanguageDefault', val)
  94. }
  95. },
  96. userDisplay: {
  97. get() {
  98. return this.$store.state.user.userDisplay
  99. },
  100. set(val) {
  101. this.$store.commit('user/updateUserDisplay', val)
  102. }
  103. },
  104. },
  105. created() {
  106. this.getUserInfo()
  107. },
  108. mounted() {
  109. this.resetDocumentClientHeight()
  110. },
  111. methods: {
  112. // 重置窗口可视高度
  113. resetDocumentClientHeight() {
  114. this.documentClientHeight = document.documentElement['clientHeight'] - 1
  115. window.onresize = () => {
  116. this.documentClientHeight = document.documentElement['clientHeight'] - 1
  117. }
  118. },
  119. // 获取当前管理员信息
  120. getUserInfo() {
  121. this.$http({
  122. url: this.$http.adornUrl('/sys/user/info'),
  123. method: 'get',
  124. params: this.$http.adornParams()
  125. }).then(({data}) => {
  126. if (data && data.code === 0) {
  127. this.loading = false
  128. this.userId = data.user.userId
  129. this.userName = data.user.username
  130. this.userSite = data.user.site
  131. this.languageDefault = data.user.languageDefault
  132. this.site =localStorage.getItem("accessSite")
  133. this.userDisplay = data.user.userDisplay
  134. }
  135. })
  136. },
  137. }
  138. }
  139. </script>