BasicLayout.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <a-layout :class="['layout', device]">
  3. <!-- SideMenu -->
  4. <a-drawer
  5. v-if="isMobile()"
  6. placement="left"
  7. :wrapClassName="`drawer-sider ${navTheme}`"
  8. :closable="false"
  9. :visible="collapsed"
  10. @close="drawerClose"
  11. >
  12. <side-menu
  13. mode="inline"
  14. :menus="menus"
  15. :theme="navTheme"
  16. :collapsed="false"
  17. :collapsible="true"
  18. @menuSelect="menuSelect"
  19. ></side-menu>
  20. </a-drawer>
  21. <side-menu
  22. v-else-if="isSideMenu()"
  23. mode="inline"
  24. :menus="menus"
  25. :theme="navTheme"
  26. :collapsed="collapsed"
  27. :collapsible="true"
  28. ></side-menu>
  29. <a-layout :class="[layoutMode, `content-width-${contentWidth}`]" :style="{ paddingLeft: contentPaddingLeft, minHeight: '100vh' }">
  30. <!-- layout header -->
  31. <global-header
  32. :mode="layoutMode"
  33. :menus="menus"
  34. :theme="navTheme"
  35. :collapsed="collapsed"
  36. :device="device"
  37. @toggle="toggle"
  38. />
  39. <!-- layout content -->
  40. <a-layout-content :style="{ height: '100%', margin: '30px 20px 0', paddingTop: multiTab&&fixedHeader ? '66px' : (!multiTab&&fixedHeader?'45px':'0') }">
  41. <transition name="page-transition">
  42. <!-- <route-view v-if="isRouterAlive"/> -->
  43. <router-view ></router-view>
  44. </transition>
  45. </a-layout-content>
  46. <!-- 视频播放弹窗 -->
  47. <div v-if="isShowVideoVal">
  48. <a-modal
  49. v-model="isShowVideoVal"
  50. wrapClassName="vidio_cont"
  51. :footer="null"
  52. centered
  53. :maskClosable="false"
  54. :destroyOnClose="true"
  55. :width="1000"
  56. @cancel="closeVido">
  57. <video-player
  58. class="video-player vjs-custom-skin"
  59. ref="videoPlayer"
  60. :playsinline="true"
  61. :options="playerOptions"
  62. ></video-player>
  63. </a-modal>
  64. </div>
  65. <!-- layout footer -->
  66. <a-layout-footer>
  67. <!-- <global-footer /> -->
  68. </a-layout-footer>
  69. <!-- Setting Drawer (show in development mode) -->
  70. <setting-drawer></setting-drawer>
  71. </a-layout>
  72. </a-layout>
  73. </template>
  74. <script>
  75. import moment from 'moment'
  76. import { triggerWindowResizeEvent } from '@/utils/util'
  77. import { mapState, mapActions, mapGetters } from 'vuex'
  78. import { mixin, mixinDevice } from '@/utils/mixin'
  79. import config from '@/config/defaultSettings'
  80. import RouteView from './RouteView'
  81. import SideMenu from '@/components/Menu/SideMenu'
  82. import GlobalHeader from '@/components/GlobalHeader'
  83. import GlobalFooter from '@/components/GlobalFooter'
  84. import SettingDrawer from '@/components/SettingDrawer'
  85. import { asyncRouterMap } from '@/config/router.config'
  86. import store from '@/store'
  87. export default {
  88. name: 'BasicLayout',
  89. mixins: [mixin, mixinDevice],
  90. provide () {
  91. return {
  92. reloadView: this.reloadView
  93. }
  94. },
  95. components: {
  96. RouteView,
  97. SideMenu,
  98. GlobalHeader,
  99. GlobalFooter,
  100. SettingDrawer
  101. },
  102. data () {
  103. return {
  104. production: config.production,
  105. collapsed: false,
  106. menus: [],
  107. isRouterAlive: true
  108. }
  109. },
  110. computed: {
  111. ...mapState({
  112. // 动态主路由
  113. mainMenu: state => state.permission.routers,
  114. multiTab: state => state.app.multiTab,
  115. fixedHeader: state => state.app.fixedHeader
  116. }),
  117. ...mapGetters(['nowRoute', 'isShowVideo']),
  118. isShowVideoVal: {
  119. get () {
  120. return this.$store.state.app.isShowVideo
  121. },
  122. set (newValue) {
  123. this.$store.state.app.isShowVideo = newValue
  124. }
  125. },
  126. contentPaddingLeft () {
  127. if (!this.fixSidebar || this.isMobile()) {
  128. return '0'
  129. }
  130. if (this.sidebarOpened) {
  131. return '180px'
  132. }
  133. return '80px'
  134. },
  135. playerOptions () {
  136. const playerOptions = {
  137. playbackRates: [0.7, 1.0, 1.5, 2.0], // 播放速度
  138. autoplay: true, // 如果true,浏览器准备好时开始回放。
  139. muted: false, // 默认情况下将会消除任何音频。
  140. loop: false, // 导致视频一结束就重新开始。
  141. preload: 'auto', // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频(如果浏览器支持)
  142. language: 'zh-CN',
  143. aspectRatio: '16:9', // 将播放器置于流畅模式,并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字(例如"16:9"或"4:3")
  144. fluid: true, // 当true时,Video.js player将拥有流体大小。换句话说,它将按比例缩放以适应其容器。
  145. sources: [{
  146. type: '', // 这里的种类支持很多种:基本视频格式、直播、流媒体等,具体可以参看git网址项目
  147. src: '' // url地址
  148. }],
  149. poster: '../assets/bg_movie@2x.png', // 你的封面地址
  150. // width: document.documentElement.clientWidth, //播放器宽度
  151. notSupportedMessage: '此视频暂无法播放,请稍后再试', // 允许覆盖Video.js无法播放媒体源时显示的默认信息。
  152. controlBar: {
  153. timeDivider: true,
  154. durationDisplay: true,
  155. remainingTimeDisplay: false,
  156. fullscreenToggle: true // 全屏按钮
  157. }
  158. }
  159. const isSaleOrder = this.nowRoute.indexOf('salesQuery') > -1 // 当前展示是否为销售单模块
  160. const isSalesReturn = this.nowRoute.indexOf('salesReturn') > -1 // 当前展示是否为销售退货模块
  161. const isPurchaseOrder = this.nowRoute.indexOf('purchaseOrder') > -1 // 当前展示是否为采购单管理模块
  162. const isPurchaseReturn = this.nowRoute.indexOf('purchaseReturn') > -1 // 当前展示是否为采购退货模块
  163. if (isSaleOrder) {
  164. playerOptions.sources[0].src = 'https://jianguan-images.oss-cn-beijing.aliyuncs.com/helpvideo/1xiaoshou.mp4'
  165. }
  166. if (isSalesReturn) {
  167. playerOptions.sources[0].src = 'https://jianguan-images.oss-cn-beijing.aliyuncs.com/helpvideo/2xiaoshoutuihuo.mp4'
  168. }
  169. if (isPurchaseOrder) {
  170. playerOptions.sources[0].src = 'https://jianguan-images.oss-cn-beijing.aliyuncs.com/helpvideo/3caigou.mp4'
  171. }
  172. if (isPurchaseReturn) {
  173. playerOptions.sources[0].src = 'https://jianguan-images.oss-cn-beijing.aliyuncs.com/helpvideo/4caigoutuihuo.mp4'
  174. }
  175. // console.log(playerOptions, 'playerOptions')
  176. return playerOptions
  177. }
  178. },
  179. watch: {
  180. sidebarOpened (val) {
  181. this.collapsed = !val
  182. }
  183. },
  184. created () {
  185. if (this.mainMenu) {
  186. this.menus = this.mainMenu.find((item) => item.path === '/').children
  187. } else {
  188. // 没有权限时只显示首页
  189. const noqx = asyncRouterMap.find((item) => item.path === '/').children
  190. this.menus = [noqx.find(item => item.path === '/home')]
  191. }
  192. this.collapsed = !this.sidebarOpened
  193. this.$store.dispatch('ToggleMultiTab', true)
  194. this.$store.dispatch('ToggleColor', '#2A86F4')
  195. this.$store.dispatch('ToggleTheme', 'dark')
  196. // 判断是否是当月25日后
  197. this.$store.state.app.isLastDayForMonth = moment().date() >= 25
  198. if (this.$store.state.app.isLastDayForMonth && this.$hasPermissions('M_mothEndTips')) {
  199. this.$notification.warning({
  200. message: '提示',
  201. description: `临到月底了,请尽快处理系统中没有完结的单据!`
  202. })
  203. }
  204. },
  205. mounted () {
  206. const userAgent = navigator.userAgent
  207. if (userAgent.indexOf('Edge') > -1) {
  208. this.$nextTick(() => {
  209. this.collapsed = !this.collapsed
  210. setTimeout(() => {
  211. this.collapsed = !this.collapsed
  212. }, 16)
  213. })
  214. }
  215. },
  216. methods: {
  217. ...mapActions(['setSidebar']),
  218. // 关闭视频弹窗
  219. closeVido () {
  220. store.commit('IS_ShOW_VIDEO', false)
  221. },
  222. toggle () {
  223. this.collapsed = !this.collapsed
  224. this.setSidebar(!this.collapsed)
  225. triggerWindowResizeEvent()
  226. },
  227. paddingCalc () {
  228. let left = ''
  229. if (this.sidebarOpened) {
  230. left = this.isDesktop() ? '160px' : '80px'
  231. } else {
  232. left = (this.isMobile() && '0') || ((this.fixSidebar && '80px') || '0')
  233. }
  234. return left
  235. },
  236. menuSelect () {
  237. },
  238. drawerClose () {
  239. this.collapsed = false
  240. },
  241. reloadView () {
  242. this.isRouterAlive = false
  243. this.$nextTick(() => {
  244. this.isRouterAlive = true
  245. })
  246. }
  247. }
  248. }
  249. </script>
  250. <style lang="less">
  251. @import url('../components/global.less');
  252. </style>