BasicLayout.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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, commonMixin } 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, commonMixin],
  90. provide () {
  91. return {
  92. reloadView: this.reloadView,
  93. setIsHomeNav: this.setIsHomeNav
  94. }
  95. },
  96. components: {
  97. RouteView,
  98. SideMenu,
  99. GlobalHeader,
  100. GlobalFooter,
  101. SettingDrawer
  102. },
  103. data () {
  104. return {
  105. production: config.production,
  106. collapsed: false,
  107. menus: [],
  108. isRouterAlive: true
  109. }
  110. },
  111. computed: {
  112. ...mapState({
  113. // 动态主路由
  114. mainMenu: state => state.permission.routers,
  115. multiTab: state => state.app.multiTab,
  116. fixedHeader: state => state.app.fixedHeader
  117. }),
  118. ...mapGetters(['nowRoute', 'isShowVideo']),
  119. isShowVideoVal: {
  120. get () {
  121. return this.$store.state.app.isShowVideo
  122. },
  123. set (newValue) {
  124. this.$store.state.app.isShowVideo = newValue
  125. }
  126. },
  127. contentPaddingLeft () {
  128. if (!this.fixSidebar || this.isMobile()) {
  129. return '0'
  130. }
  131. if (this.sidebarOpened) {
  132. return '180px'
  133. }
  134. return '80px'
  135. },
  136. playerOptions () {
  137. const playerOptions = {
  138. playbackRates: [0.7, 1.0, 1.5, 2.0], // 播放速度
  139. autoplay: true, // 如果true,浏览器准备好时开始回放。
  140. muted: false, // 默认情况下将会消除任何音频。
  141. loop: false, // 导致视频一结束就重新开始。
  142. preload: 'auto', // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频(如果浏览器支持)
  143. language: 'zh-CN',
  144. aspectRatio: '16:9', // 将播放器置于流畅模式,并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字(例如"16:9"或"4:3")
  145. fluid: true, // 当true时,Video.js player将拥有流体大小。换句话说,它将按比例缩放以适应其容器。
  146. sources: [{
  147. type: '', // 这里的种类支持很多种:基本视频格式、直播、流媒体等,具体可以参看git网址项目
  148. src: '' // url地址
  149. }],
  150. poster: '../assets/bg_movie@2x.png', // 你的封面地址
  151. // width: document.documentElement.clientWidth, //播放器宽度
  152. notSupportedMessage: '此视频暂无法播放,请稍后再试', // 允许覆盖Video.js无法播放媒体源时显示的默认信息。
  153. controlBar: {
  154. timeDivider: true,
  155. durationDisplay: true,
  156. remainingTimeDisplay: false,
  157. fullscreenToggle: true // 全屏按钮
  158. }
  159. }
  160. const isSaleOrder = this.nowRoute.indexOf('salesQuery') > -1 // 当前展示是否为销售单模块
  161. const isSalesReturn = this.nowRoute.indexOf('salesReturn') > -1 // 当前展示是否为销售退货模块
  162. const isPurchaseOrder = this.nowRoute.indexOf('purchaseOrder') > -1 // 当前展示是否为采购单管理模块
  163. const isPurchaseReturn = this.nowRoute.indexOf('purchaseReturn') > -1 // 当前展示是否为采购退货模块
  164. if (isSaleOrder) {
  165. playerOptions.sources[0].src = 'https://jianguan-images.oss-cn-beijing.aliyuncs.com/helpvideo/1xiaoshou.mp4'
  166. }
  167. if (isSalesReturn) {
  168. playerOptions.sources[0].src = 'https://jianguan-images.oss-cn-beijing.aliyuncs.com/helpvideo/2xiaoshoutuihuo.mp4'
  169. }
  170. if (isPurchaseOrder) {
  171. playerOptions.sources[0].src = 'https://jianguan-images.oss-cn-beijing.aliyuncs.com/helpvideo/3caigou.mp4'
  172. }
  173. if (isPurchaseReturn) {
  174. playerOptions.sources[0].src = 'https://jianguan-images.oss-cn-beijing.aliyuncs.com/helpvideo/4caigoutuihuo.mp4'
  175. }
  176. // console.log(playerOptions, 'playerOptions')
  177. return playerOptions
  178. }
  179. },
  180. watch: {
  181. sidebarOpened (val) {
  182. this.collapsed = !val
  183. }
  184. },
  185. created () {
  186. if (this.mainMenu) {
  187. this.menus = this.mainMenu.find((item) => item.path === '/').children
  188. } else {
  189. // 没有权限时只显示首页
  190. const noqx = asyncRouterMap.find((item) => item.path === '/').children
  191. this.menus = [noqx.find(item => item.path === '/home')]
  192. }
  193. this.collapsed = !this.sidebarOpened
  194. this.$store.dispatch('ToggleMultiTab', true)
  195. this.$store.dispatch('ToggleColor', '#2A86F4')
  196. this.$store.dispatch('ToggleTheme', 'dark')
  197. // 判断是否是当月25日后
  198. this.$store.state.app.isLastDayForMonth = moment().date() >= 25
  199. if (this.$store.state.app.isLastDayForMonth && this.$hasPermissions('M_mothEndTips')) {
  200. this.$notification.warning({
  201. message: '提示',
  202. description: `临到月底了,请尽快处理系统中没有完结的单据!`
  203. })
  204. }
  205. },
  206. mounted () {
  207. const userAgent = navigator.userAgent
  208. if (userAgent.indexOf('Edge') > -1) {
  209. this.$nextTick(() => {
  210. this.collapsed = !this.collapsed
  211. setTimeout(() => {
  212. this.collapsed = !this.collapsed
  213. }, 16)
  214. })
  215. }
  216. },
  217. methods: {
  218. ...mapActions(['setSidebar']),
  219. // 关闭视频弹窗
  220. closeVido () {
  221. store.commit('IS_ShOW_VIDEO', false)
  222. },
  223. toggle () {
  224. this.collapsed = !this.collapsed
  225. this.setSidebar(!this.collapsed)
  226. triggerWindowResizeEvent()
  227. },
  228. paddingCalc () {
  229. let left = ''
  230. if (this.sidebarOpened) {
  231. left = this.isDesktop() ? '160px' : '80px'
  232. } else {
  233. left = (this.isMobile() && '0') || ((this.fixSidebar && '80px') || '0')
  234. }
  235. return left
  236. },
  237. menuSelect () {
  238. },
  239. drawerClose () {
  240. this.collapsed = false
  241. },
  242. reloadView () {
  243. this.isRouterAlive = false
  244. this.$nextTick(() => {
  245. this.isRouterAlive = true
  246. })
  247. }
  248. }
  249. }
  250. </script>
  251. <style lang="less">
  252. @import url('../components/global.less');
  253. </style>