globalData.vue 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <div>
  3. <!-- 该组件用于加载一些全局数据,在布局组件 AppMain.vue 中加载,放在根路径是为了便于查找 -->
  4. </div>
  5. </template>
  6. <script>
  7. import { getIp } from '@/utils'
  8. import { getTicketPrintModelList, getReceiptPrintModel } from '@/api/printModal'
  9. import whitePaper from '@/pages/systemSetting/printManage/vertical'
  10. import defaultSmallTicket from '@/pages/systemSetting/smallTicket/defaultTemp'
  11. export default {
  12. created () {
  13. getIp()
  14. // 获取打印模板
  15. this.getTicketPrintModelList()
  16. this.$store.dispatch('setTravelAgencyType')
  17. // 获取所有票种列表
  18. this.$store.dispatch('getTicketTypeList')
  19. this.$store.dispatch('setCustomerType')
  20. // 设置全局 支付方式
  21. this.$store.dispatch('getPayChannel')
  22. // 获取票种分类
  23. // this.$store.dispatch('getTicketCategory')
  24. // 获取售票员列表
  25. this.$store.dispatch('getSalesList')
  26. // 获取自助机列表
  27. this.$store.dispatch('getTermDevices')
  28. // getMyAccount
  29. this.$store.dispatch('getMyAccount')
  30. // 获取销售渠道
  31. this.$store.dispatch('getSaleChannel')
  32. this.$store.dispatch('getSystemConfigList')
  33. // 获取旅行社列表
  34. // this.$store.dispatch('getAgencyList')
  35. // 获取景点列表
  36. this.$store.dispatch('getScenicList')
  37. // 获取账号信息
  38. // this.$store.dispatch('getAccount')
  39. // 获取场次信息
  40. // this.$store.dispatch('getBatchConfigList')
  41. },
  42. methods: {
  43. // 提前设置打印模板
  44. getTicketPrintModelList () {
  45. const params = {
  46. pageNum: 0,
  47. pageSize: -1,
  48. name: '',
  49. content: ''
  50. }
  51. getTicketPrintModelList(params).then(res => {
  52. const list = res.data.records || []
  53. let id = this.$localStore.get('defaultTemplate')
  54. let target = id ? list.find(i => i.id === id) : list.find(i => i.isDefault)
  55. // 设置当前打印模板
  56. this.$store.commit('SET_PRINT_TEMPLATE', target ? JSON.parse(target.content) : whitePaper)
  57. if (target) {
  58. this.$localStore.set('defaultTemplate', target.id)
  59. }
  60. // 设置打印模板列表
  61. list.length > 0 && this.$store.commit('SET_PRINT_TEMPLATE_LIST', list)
  62. })
  63. },
  64. getReceiptPrintModel () {
  65. getReceiptPrintModel().then(res => {
  66. let id = this.$localStore.get('defaultSmallTicketTemplate')
  67. const list = res.data.records || []
  68. let target = id ? list.find(i => i.id === id) : list.find(i => i.isDefault)
  69. // 设置当前打印模板
  70. target && this.$store.commit('SET_SMALL_TICKET_TEMPLATE', target ? JSON.parse(target.content) : defaultSmallTicket)
  71. if (target) {
  72. this.$localStore.set('defaultSmallTicketTemplate', target.id)
  73. }
  74. // 设置打印模板列表
  75. list.length > 0 && this.$store.commit('SET_SMALL_TICKET_TEMPLATE_LIST', res.list)
  76. })
  77. }
  78. }
  79. }
  80. </script>
  81. <style lang="scss" scoped>
  82. </style>