BasicLayout.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  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 class="notes-box" v-if="notesList.length && nowRoute.indexOf('notice')<0">
  48. <div v-for="item in notesList" :key="item.id">
  49. <a-alert v-if="item.notice.bizType=='TEMP_ORDER'" type="error" showIcon closable @close="setRead(item)">
  50. <div slot="description">
  51. 【急送提醒】{{ item.notice.plainContent }} <a-button @click="toAction(item)" size="small" type="link" class="button-info">点击查看</a-button>
  52. </div>
  53. </a-alert>
  54. <a-alert v-if="item.notice.bizType=='SHELF_REPLENISH'" type="info" showIcon closable @close="setRead(item)">
  55. <div slot="description">
  56. 【补货提醒】{{ item.notice.plainContent }} <a-button @click="toAction(item)" size="small" type="link" class="button-info">立即处理</a-button>
  57. </div>
  58. </a-alert>
  59. <a-alert v-if="item.notice.bizType=='SHELF_ORDER'" type="info" showIcon closable @close="setRead(item)">
  60. <div slot="description">
  61. 【订单提醒】{{ item.notice.plainContent }} <a-button @click="toAction(item)" size="small" type="link" class="button-info">点击查看</a-button>
  62. </div>
  63. </a-alert>
  64. <a-alert v-if="item.notice.bizType=='SHELF_WARN'" type="error" showIcon closable @close="setRead(item)">
  65. <div slot="description">
  66. 【货架异常提醒】{{ item.notice.plainContent }} <a-button @click="toAction(item)" size="small" type="link" class="button-info">点击查看</a-button>
  67. </div>
  68. </a-alert>
  69. </div>
  70. <div class="notes-more" @click="toNotes">更多消息>></div>
  71. </div>
  72. <audio controls="controls" hidden :src="mp3" ref="audio"></audio>
  73. <!-- 视频播放弹窗 -->
  74. <div v-if="isShowVideoVal">
  75. <a-modal
  76. v-model="isShowVideoVal"
  77. wrapClassName="vidio_cont"
  78. :footer="null"
  79. centered
  80. :maskClosable="false"
  81. :destroyOnClose="true"
  82. :width="1000"
  83. @cancel="closeVido">
  84. <video-player
  85. class="video-player vjs-custom-skin"
  86. ref="videoPlayer"
  87. :playsinline="true"
  88. :options="playerOptions"
  89. ></video-player>
  90. </a-modal>
  91. </div>
  92. <!-- pdf 预览 -->
  93. <pdfViewModal ref="pdfview" :openModal="showPdfView" @cancel="showPdfView=false"></pdfViewModal>
  94. <!-- 选择打印机 -->
  95. <selectPrint ref="selectPrint" :openModal="showSelectPrint" @cancel="showSelectPrint=false"></selectPrint>
  96. <!-- layout footer -->
  97. <a-layout-footer>
  98. <!-- <global-footer /> -->
  99. </a-layout-footer>
  100. <!-- Setting Drawer (show in development mode) -->
  101. <!-- <setting-drawer></setting-drawer> -->
  102. </a-layout>
  103. </a-layout>
  104. </template>
  105. <script>
  106. import moment from 'moment'
  107. import { triggerWindowResizeEvent } from '@/utils/util'
  108. import { mapState, mapActions, mapGetters } from 'vuex'
  109. import { mixin, mixinDevice, commonMixin } from '@/utils/mixin'
  110. import config from '@/config/defaultSettings'
  111. import pdfViewModal from '@/views/common/pdfViewModal.vue'
  112. import selectPrint from '@/views/common/selectPrint.vue'
  113. import RouteView from './RouteView'
  114. import SideMenu from '@/components/Menu/SideMenu'
  115. import GlobalHeader from '@/components/GlobalHeader'
  116. import GlobalFooter from '@/components/GlobalFooter'
  117. import SettingDrawer from '@/components/SettingDrawer'
  118. import { asyncRouterMap } from '@/config/router.config'
  119. import mp3 from '@/assets/notes.mp3'
  120. import store from '@/store'
  121. export default {
  122. name: 'BasicLayout',
  123. mixins: [mixin, mixinDevice, commonMixin],
  124. provide () {
  125. return {
  126. setIsHomeNav: this.setIsHomeNav,
  127. reloadView: this.reloadView
  128. }
  129. },
  130. components: {
  131. RouteView,
  132. SideMenu,
  133. GlobalHeader,
  134. GlobalFooter,
  135. SettingDrawer,
  136. pdfViewModal,
  137. selectPrint
  138. },
  139. data () {
  140. return {
  141. production: config.production,
  142. collapsed: false,
  143. menus: [],
  144. isRouterAlive: true,
  145. showPdfView: false,
  146. showSelectPrint: false,
  147. notesList: [],
  148. mp3: mp3
  149. }
  150. },
  151. computed: {
  152. ...mapState({
  153. // 动态主路由
  154. mainMenu: state => state.permission.routers,
  155. multiTab: state => state.app.multiTab,
  156. fixedHeader: state => state.app.fixedHeader
  157. }),
  158. ...mapGetters(['nowRoute', 'isShowVideo']),
  159. isShowVideoVal () {
  160. return this.$store.state.app.isShowVideo
  161. },
  162. // 接受到ws消息
  163. wsMessage () {
  164. return this.$store.getters.wsMessageData()
  165. },
  166. contentPaddingLeft () {
  167. if (!this.fixSidebar || this.isMobile()) {
  168. return '0'
  169. }
  170. if (this.sidebarOpened) {
  171. return '180px'
  172. }
  173. return '80px'
  174. },
  175. playerOptions () {
  176. const playerOptions = {
  177. playbackRates: [0.7, 1.0, 1.5, 2.0], // 播放速度
  178. autoplay: true, // 如果true,浏览器准备好时开始回放。
  179. muted: false, // 默认情况下将会消除任何音频。
  180. loop: false, // 导致视频一结束就重新开始。
  181. preload: 'auto', // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频(如果浏览器支持)
  182. language: 'zh-CN',
  183. aspectRatio: '16:9', // 将播放器置于流畅模式,并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字(例如"16:9"或"4:3")
  184. fluid: true, // 当true时,Video.js player将拥有流体大小。换句话说,它将按比例缩放以适应其容器。
  185. sources: [{
  186. type: '', // 这里的种类支持很多种:基本视频格式、直播、流媒体等,具体可以参看git网址项目
  187. src: '' // url地址
  188. }],
  189. poster: '../assets/bg_movie@2x.png', // 你的封面地址
  190. // width: document.documentElement.clientWidth, //播放器宽度
  191. notSupportedMessage: '此视频暂无法播放,请稍后再试', // 允许覆盖Video.js无法播放媒体源时显示的默认信息。
  192. controlBar: {
  193. timeDivider: true,
  194. durationDisplay: true,
  195. remainingTimeDisplay: false,
  196. fullscreenToggle: true // 全屏按钮
  197. }
  198. }
  199. // 当前展示是否为销售单模块
  200. if (this.nowRoute.indexOf('salesQuery') > -1) {
  201. playerOptions.sources[0].src = 'https://jianguan-images.oss-cn-beijing.aliyuncs.com/helpvideo/1xiaoshou.mp4'
  202. }
  203. // 当前展示是否为销售退货模块
  204. if (this.nowRoute.indexOf('salesReturn') > -1) {
  205. playerOptions.sources[0].src = 'https://jianguan-images.oss-cn-beijing.aliyuncs.com/helpvideo/2xiaoshoutuihuo.mp4'
  206. }
  207. // 当前展示是否为采购单管理模块
  208. if (this.nowRoute.indexOf('purchaseOrder') > -1) {
  209. playerOptions.sources[0].src = 'https://jianguan-images.oss-cn-beijing.aliyuncs.com/helpvideo/3caigou.mp4'
  210. }
  211. // 当前展示是否为采购退货模块
  212. if (this.nowRoute.indexOf('purchaseReturn') > -1) {
  213. playerOptions.sources[0].src = 'https://jianguan-images.oss-cn-beijing.aliyuncs.com/helpvideo/4caigoutuihuo.mp4'
  214. }
  215. return playerOptions
  216. }
  217. },
  218. watch: {
  219. sidebarOpened (val) {
  220. this.collapsed = !val
  221. },
  222. // 监听ws消息通知
  223. wsMessage (a, b) {
  224. if (a !== b && a) {
  225. // 新未读消息
  226. if (a.type == 'new_remind' && this.nowRoute.indexOf('notice') < 0) {
  227. this.getNotes()
  228. // 播放音效
  229. this.playAudio()
  230. }
  231. }
  232. },
  233. // 打印预览
  234. '$store.state.app.showPdfPrintView' (newValue, oldValue) {
  235. if (newValue) {
  236. this.showPdfView = newValue
  237. this.$nextTick(() => {
  238. this.$refs.pdfview.setData(this.$store.state.app.pdfPrintList)
  239. })
  240. }
  241. },
  242. // 选择打印机
  243. '$store.state.app.showSelectPrint' (newValue, oldValue) {
  244. if (newValue) {
  245. this.showSelectPrint = newValue
  246. }
  247. }
  248. },
  249. created () {
  250. if (this.mainMenu) {
  251. this.menus = this.mainMenu.find((item) => item.path === '/').children
  252. } else {
  253. // 没有权限时只显示首页
  254. const noqx = asyncRouterMap.find((item) => item.path === '/').children
  255. this.menus = [noqx.find(item => item.path === '/home')]
  256. }
  257. // 重置主题,字体,布局
  258. this.collapsed = !this.sidebarOpened
  259. this.$store.dispatch('ToggleMultiTab', true)
  260. this.$store.dispatch('ToggleColor', '#2A86F4')
  261. this.$store.dispatch('ToggleTheme', localStorage.getItem('DEFAULT_THEME') || 'dark')
  262. this.$store.dispatch('ToggleFontSize', localStorage.getItem('DEFAULT_FONT_SIZE') || 'small')
  263. // 判断是否是当月25日后
  264. this.$store.state.app.isLastDayForMonth = moment().date() >= 25
  265. if (this.$store.state.app.isLastDayForMonth && this.$hasPermissions('M_mothEndTips')) {
  266. this.$notification.warning({
  267. message: '提示',
  268. description: `临到月底了,请尽快处理系统中没有完结的单据!`
  269. })
  270. }
  271. // 打印设置
  272. this.$store.commit('SET_pdfPrintList', [])
  273. this.$store.commit('SET_showPdfPrint', false)
  274. this.$store.commit('SET_showSelectPrint', false)
  275. this.$store.commit('SET_printLoading', false)
  276. this.$store.commit('SET_printDefNeedle', localStorage.getItem('DEFAULT_PRINT_NEEDLE') || undefined)
  277. this.$store.commit('SET_printDefInk', localStorage.getItem('DEFAULT_PRINT_INK') || undefined)
  278. // 消息通知
  279. this.getNotes()
  280. },
  281. mounted () {
  282. const userAgent = navigator.userAgent
  283. if (userAgent.indexOf('Edge') > -1) {
  284. this.$nextTick(() => {
  285. this.collapsed = !this.collapsed
  286. setTimeout(() => {
  287. this.collapsed = !this.collapsed
  288. }, 16)
  289. })
  290. }
  291. },
  292. methods: {
  293. ...mapActions([
  294. 'setSidebar',
  295. 'getMessageList', // 查询列表
  296. 'hasRead' // 设置已读
  297. ]),
  298. reloadView () {},
  299. // 关闭视频弹窗
  300. closeVido () {
  301. store.commit('IS_ShOW_VIDEO', false)
  302. },
  303. toggle () {
  304. this.collapsed = !this.collapsed
  305. this.setSidebar(!this.collapsed)
  306. triggerWindowResizeEvent()
  307. },
  308. paddingCalc () {
  309. let left = ''
  310. if (this.sidebarOpened) {
  311. left = this.isDesktop() ? '160px' : '80px'
  312. } else {
  313. left = (this.isMobile() && '0') || ((this.fixSidebar && '80px') || '0')
  314. }
  315. return left
  316. },
  317. menuSelect () {
  318. },
  319. drawerClose () {
  320. this.collapsed = false
  321. },
  322. playAudio () {
  323. this.$refs.audio.currentTime = 0// 从头开始播放
  324. this.$refs.audio.play() // 播放
  325. },
  326. // 获取最新消息
  327. getNotes () {
  328. this.getMessageList({
  329. pageNo: 1,
  330. pageSize: 5,
  331. notice: {
  332. type: 'tx'
  333. },
  334. readFlag: 0
  335. }).then((res) => {
  336. if (res.status == 200) {
  337. const data = res.data
  338. for (var i = 0; i < data.list.length; i++) {
  339. if (data.list[i].notice.extInfo) {
  340. data.list[i].notice.extInfo = JSON.parse(data.list[i].notice.extInfo)
  341. }
  342. }
  343. this.notesList = res.data.list
  344. } else {
  345. this.notesList = []
  346. }
  347. })
  348. },
  349. toAction (data) {
  350. // 急送订单
  351. if (data.notice.extInfo.bizType == 'TEMP_ORDER') {
  352. this.$router.push({ name: 'salesDetail', params: { sn: data.notice.extInfo.bizSn } })
  353. }
  354. // 补货订单
  355. if (data.notice.extInfo.bizType == 'SHELF_REPLENISH') {
  356. this.$router.push({ name: 'replenishmentManagement', query: { bizType: 'WAIT_CONFIRM' } })
  357. }
  358. // 货架订单
  359. if (data.notice.extInfo.bizType == 'SHELF_ORDER') {
  360. this.$router.push({ name: 'shelfOrderDetail', params: { sn: data.notice.extInfo.bizSn } })
  361. }
  362. // 货架异常
  363. if (data.notice.extInfo.bizType == 'SHELF_WARN') {
  364. this.$router.push({ name: 'shelfOrderList', query: { shelfSn: data.notice.extInfo.bizSn } })
  365. }
  366. // 设置已读
  367. this.setRead(data)
  368. },
  369. // 设置已读
  370. setRead (row) {
  371. this.hasRead({ msg_id: row.id }).then(res => {
  372. // 刷新列表
  373. if (res.status == 200) {
  374. this.getNotes()
  375. }
  376. })
  377. },
  378. toNotes () {
  379. this.$router.push({ path: '/notice' })
  380. }
  381. }
  382. }
  383. </script>
  384. <style lang="less">
  385. @import url('../components/global.less');
  386. .notes-box{
  387. position:fixed;
  388. right:0;
  389. bottom:0;
  390. min-width:400px;
  391. z-index: 10000;
  392. .ant-alert-with-description .ant-alert-close-icon{
  393. top: 13px;
  394. }
  395. .ant-alert, .ant-alert-info{
  396. padding: 10px 30px!important;
  397. }
  398. .ant-alert .ant-alert-icon, .ant-alert-info .ant-alert-icon{
  399. top: 16px !important;
  400. left: 10px !important;
  401. font-size: 18px;
  402. }
  403. .ant-alert-with-description .ant-alert-description{
  404. font-size: 14px;
  405. }
  406. .notes-more{
  407. padding: 10px;
  408. text-align:center;
  409. color:#00aaff;
  410. font-size: 14px;
  411. cursor:pointer;
  412. background: #fff;
  413. border: 1px solid #eee;
  414. border-radius: 5px 5px 0 0;
  415. }
  416. }
  417. </style>