globalData.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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.getReceiptPrintModel()
  16. this.getTicketPrintModelList()
  17. this.$store.dispatch('setTravelAgencyType')
  18. // 获取所有票种列表
  19. this.$store.dispatch('getTicketTypeList')
  20. this.$store.dispatch('setCustomerType')
  21. // 设置全局 支付方式
  22. this.$store.dispatch('getPayChannel')
  23. // 获取票种分类
  24. this.$store.dispatch('getTicketCategory')
  25. // 获取售票员列表
  26. this.$store.dispatch('getSalesList')
  27. // getMyAccount
  28. this.$store.dispatch('getMyAccount')
  29. // 获取销售渠道
  30. this.$store.dispatch('getSaleChannel')
  31. this.$store.dispatch('getSystemConfigList')
  32. // 获取旅行社列表
  33. this.$store.dispatch('getAgencyList')
  34. // 获取景点列表
  35. this.$store.dispatch('getScenicList')
  36. // 获取账号信息
  37. this.$store.dispatch('getAccount')
  38. // 获取场次信息
  39. this.$store.dispatch('getBatchConfigList')
  40. },
  41. methods: {
  42. // 提前设置打印模板
  43. getTicketPrintModelList () {
  44. getTicketPrintModelList().then(res => {
  45. let id = this.$localStore.get('defaultTemplate')
  46. let target = res.list.find(i => i.id === id)
  47. // 设置当前打印模板
  48. this.$store.commit('SET_PRINT_TEMPLATE', target ? JSON.parse(target.content) : whitePaper)
  49. // 设置打印模板列表
  50. res.list.length > 0 && this.$store.commit('SET_PRINT_TEMPLATE_LIST', res.list)
  51. })
  52. },
  53. getReceiptPrintModel () {
  54. getReceiptPrintModel().then(res => {
  55. let id = this.$localStore.get('defaultSmallTicketTemplate')
  56. let target = res.list.find(i => i.id === id)
  57. // 设置当前打印模板
  58. target && this.$store.commit('SET_SMALL_TICKET_TEMPLATE', target ? JSON.parse(target.content) : defaultSmallTicket)
  59. // 设置打印模板列表
  60. res.list.length > 0 && this.$store.commit('SET_SMALL_TICKET_TEMPLATE_LIST', res.list)
  61. })
  62. }
  63. }
  64. }
  65. </script>
  66. <style lang="scss" scoped>
  67. </style>