BasicLayout.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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. </transition>
  44. </a-layout-content>
  45. <!-- 视频播放弹窗 -->
  46. <a-modal
  47. v-model="isShowVideoVal"
  48. wrapClassName="vidio_cont"
  49. :footer="null"
  50. centered
  51. :maskClosable="false"
  52. :destroyOnClose="true"
  53. :width="1000"
  54. @cancel="closeVido">
  55. <video-player
  56. class="video-player vjs-custom-skin"
  57. ref="videoPlayer"
  58. :playsinline="true"
  59. :options="playerOptions"
  60. ></video-player>
  61. </a-modal>
  62. <!-- layout footer -->
  63. <a-layout-footer>
  64. <!-- <global-footer /> -->
  65. </a-layout-footer>
  66. <!-- Setting Drawer (show in development mode) -->
  67. <!-- <setting-drawer v-if="!production"></setting-drawer> -->
  68. </a-layout>
  69. </a-layout>
  70. </template>
  71. <script>
  72. import { triggerWindowResizeEvent } from '@/utils/util'
  73. import { mapState, mapActions, mapGetters } from 'vuex'
  74. import { mixin, mixinDevice } from '@/utils/mixin'
  75. import config from '@/config/defaultSettings'
  76. import RouteView from './RouteView'
  77. import SideMenu from '@/components/Menu/SideMenu'
  78. import GlobalHeader from '@/components/GlobalHeader'
  79. import GlobalFooter from '@/components/GlobalFooter'
  80. import SettingDrawer from '@/components/SettingDrawer'
  81. import { asyncRouterMap } from '@/config/router.config'
  82. import store from '@/store'
  83. export default {
  84. name: 'BasicLayout',
  85. mixins: [mixin, mixinDevice],
  86. provide () {
  87. return {
  88. reloadView: this.reloadView
  89. }
  90. },
  91. components: {
  92. RouteView,
  93. SideMenu,
  94. GlobalHeader,
  95. GlobalFooter,
  96. SettingDrawer
  97. },
  98. data () {
  99. return {
  100. production: config.production,
  101. collapsed: false,
  102. menus: [],
  103. isRouterAlive: true
  104. }
  105. },
  106. computed: {
  107. ...mapState({
  108. // 动态主路由
  109. mainMenu: state => state.permission.routers,
  110. multiTab: state => state.app.multiTab,
  111. fixedHeader: state => state.app.fixedHeader
  112. }),
  113. ...mapGetters(['nowRoute', 'isShowVideo']),
  114. isShowVideoVal: {
  115. get () {
  116. return this.$store.state.app.isShowVideo
  117. },
  118. set (newValue) {
  119. this.$store.state.app.isShowVideo = newValue
  120. }
  121. },
  122. contentPaddingLeft () {
  123. if (!this.fixSidebar || this.isMobile()) {
  124. return '0'
  125. }
  126. if (this.sidebarOpened) {
  127. return '230px'
  128. }
  129. return '80px'
  130. },
  131. playerOptions () {
  132. const playerOptions = {
  133. playbackRates: [0.7, 1.0, 1.5, 2.0], // 播放速度
  134. autoplay: true, // 如果true,浏览器准备好时开始回放。
  135. muted: false, // 默认情况下将会消除任何音频。
  136. loop: false, // 导致视频一结束就重新开始。
  137. preload: 'auto', // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频(如果浏览器支持)
  138. language: 'zh-CN',
  139. aspectRatio: '16:9', // 将播放器置于流畅模式,并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字(例如"16:9"或"4:3")
  140. fluid: true, // 当true时,Video.js player将拥有流体大小。换句话说,它将按比例缩放以适应其容器。
  141. sources: [{
  142. type: '', // 这里的种类支持很多种:基本视频格式、直播、流媒体等,具体可以参看git网址项目
  143. src: '' // url地址
  144. }],
  145. poster: '../assets/bg_movie@2x.png', // 你的封面地址
  146. // width: document.documentElement.clientWidth, //播放器宽度
  147. notSupportedMessage: '此视频暂无法播放,请稍后再试', // 允许覆盖Video.js无法播放媒体源时显示的默认信息。
  148. controlBar: {
  149. timeDivider: true,
  150. durationDisplay: true,
  151. remainingTimeDisplay: false,
  152. fullscreenToggle: true // 全屏按钮
  153. }
  154. }
  155. const isSaleOrder = this.nowRoute.indexOf('salesQuery') > -1 // 当前展示是否为销售单模块
  156. const isSalesReturn = this.nowRoute.indexOf('salesReturn') > -1 // 当前展示是否为销售退货模块
  157. const isPurchaseOrder = this.nowRoute.indexOf('purchaseOrder') > -1 // 当前展示是否为采购单管理模块
  158. const isPurchaseReturn = this.nowRoute.indexOf('purchaseReturn') > -1 // 当前展示是否为采购退货模块
  159. if (isSaleOrder) {
  160. playerOptions.sources[0].src = 'https://jianguan-images.oss-cn-beijing.aliyuncs.com/helpvideo/1%E6%B1%BD%E9%85%8D%E9%94%80%E5%94%AE%E9%9F%B3%E9%A2%91%E6%96%87%E5%AD%97%E5%B7%B2%E5%8A%A0.mp4'
  161. }
  162. if (isSalesReturn) {
  163. playerOptions.sources[0].src = 'https://jianguan-images.oss-cn-beijing.aliyuncs.com/helpvideo/2%E6%B1%BD%E9%85%8D%E9%94%80%E5%94%AE%E9%80%80%E8%B4%A7%E9%9F%B3%E9%A2%91%E6%96%87%E5%AD%97.mp4'
  164. }
  165. if (isPurchaseOrder) {
  166. playerOptions.sources[0].src = 'https://jianguan-images.oss-cn-beijing.aliyuncs.com/helpvideo/3%E6%B1%BD%E9%85%8D%E9%87%87%E8%B4%AD%E9%9F%B3%E9%A2%91%E6%96%87%E5%AD%97.mp4'
  167. }
  168. if (isPurchaseReturn) {
  169. playerOptions.sources[0].src = 'https://jianguan-images.oss-cn-beijing.aliyuncs.com/helpvideo/4%E6%B1%BD%E9%85%8D%E9%87%87%E8%B4%AD%E9%80%80%E8%B4%A7%E6%96%87%E5%AD%97%E8%AF%AD%E9%9F%B3.mp4'
  170. }
  171. // console.log(playerOptions, 'playerOptions')
  172. return playerOptions
  173. }
  174. },
  175. watch: {
  176. sidebarOpened (val) {
  177. this.collapsed = !val
  178. }
  179. },
  180. created () {
  181. if (this.mainMenu) {
  182. this.menus = this.mainMenu.find((item) => item.path === '/').children
  183. } else {
  184. // 没有权限时只显示首页
  185. const noqx = asyncRouterMap.find((item) => item.path === '/').children
  186. this.menus = [noqx.find(item => item.path === '/home')]
  187. }
  188. this.collapsed = !this.sidebarOpened
  189. this.$store.dispatch('ToggleMultiTab', true)
  190. this.$store.dispatch('ToggleColor', '#1890FF')
  191. },
  192. mounted () {
  193. const userAgent = navigator.userAgent
  194. if (userAgent.indexOf('Edge') > -1) {
  195. this.$nextTick(() => {
  196. this.collapsed = !this.collapsed
  197. setTimeout(() => {
  198. this.collapsed = !this.collapsed
  199. }, 16)
  200. })
  201. }
  202. },
  203. methods: {
  204. ...mapActions(['setSidebar']),
  205. // 关闭视频弹窗
  206. closeVido () {
  207. store.commit('IS_ShOW_VIDEO', false)
  208. },
  209. toggle () {
  210. this.collapsed = !this.collapsed
  211. this.setSidebar(!this.collapsed)
  212. triggerWindowResizeEvent()
  213. },
  214. paddingCalc () {
  215. let left = ''
  216. if (this.sidebarOpened) {
  217. left = this.isDesktop() ? '230px' : '80px'
  218. } else {
  219. left = (this.isMobile() && '0') || ((this.fixSidebar && '80px') || '0')
  220. }
  221. return left
  222. },
  223. menuSelect () {
  224. },
  225. drawerClose () {
  226. this.collapsed = false
  227. },
  228. reloadView () {
  229. this.isRouterAlive = false
  230. this.$nextTick(() => {
  231. this.isRouterAlive = true
  232. })
  233. }
  234. }
  235. }
  236. </script>
  237. <style lang="less">
  238. @import url('../components/global.less');
  239. @import url('../components/custom.less'); // 自定义样式文件
  240. /*
  241. * The following styles are auto-applied to elements with
  242. * transition="page-transition" when their visibility is toggled
  243. * by Vue.js.
  244. *
  245. * You can easily play with the page transition by editing
  246. * these styles.
  247. */
  248. .vidio_cont .ant-modal-body {
  249. padding: 0;
  250. }
  251. .vidio_cont .ant-modal-close-x {
  252. width: 36px;
  253. height: 36px;
  254. text-align: center;
  255. line-height: 36px;
  256. color: #fff;
  257. background-color: rgba(0, 0, 0, 0.6);
  258. border-radius: 50%;
  259. position: absolute;
  260. top: 10px;
  261. right: 10px;
  262. }
  263. .page-transition-enter {
  264. opacity: 0;
  265. }
  266. .page-transition-leave-active {
  267. opacity: 0;
  268. }
  269. .page-transition-enter .page-transition-container,
  270. .page-transition-leave-active .page-transition-container {
  271. -webkit-transform: scale(1.1);
  272. transform: scale(1.1);
  273. }
  274. .setting-drawer-content{
  275. .ant-drawer-content{
  276. overflow: visible
  277. }
  278. }
  279. </style>