BasicLayout.vue 15 KB

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