guide.ts 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. // store/guide.ts
  2. import { defineStore } from 'pinia'
  3. import { useDriver } from '@/utils/driverGuide'
  4. const oceanSteps: any = [
  5. {
  6. element: '#driver-step-tracking-detail-1',
  7. popover: {
  8. title: '',
  9. description: 'Main operation button area',
  10. side: 'bottom',
  11. align: 'start'
  12. }
  13. },
  14. {
  15. element: '#driver-step-tracking-detail-2',
  16. popover: {
  17. description: 'Key shipment status',
  18. side: 'bottom',
  19. align: 'start'
  20. }
  21. },
  22. {
  23. element: '#driver-step-tracking-detail-3',
  24. popover: {
  25. description: 'Detail container status of each container',
  26. side: 'bottom',
  27. align: 'start'
  28. }
  29. },
  30. {
  31. element: '#tracking-map',
  32. popover: {
  33. description: `
  34. <ul>
  35. <li>Actual Line(Actual Trajectory)</li>
  36. <li>Virtual Line(Planned Trajectory)</li>
  37. <li>Arrow (Current Real-time Position)</li>
  38. </ol>
  39. `,
  40. side: 'bottom',
  41. align: 'start'
  42. }
  43. },
  44. {
  45. element: '#driver-step-tracking-detail-5',
  46. popover: {
  47. description: `
  48. <ul>
  49. <li>Upload Files</li>
  50. <li>Clickable download icons to download files</li>
  51. </ol>
  52. `,
  53. side: 'bottom',
  54. align: 'start'
  55. }
  56. },
  57. {
  58. element: '#driver-step-tracking-detail-6',
  59. popover: {
  60. description: `
  61. <p>Send email to site staff</p>
  62. <p>Enter contents you want to communicate with, click “Send
  63. Email” button to send out.
  64. </p>
  65. `,
  66. side: 'bottom',
  67. align: 'start'
  68. }
  69. },
  70. {
  71. element: '#page-guide-btn-guide',
  72. popover: {
  73. title: '',
  74. description:
  75. 'After closing, you can still click the "Page Guide" button to view the page guide of the current page.',
  76. side: 'bottom'
  77. }
  78. }
  79. ]
  80. const airSteps: any = [
  81. {
  82. element: '#driver-step-tracking-detail-1',
  83. popover: {
  84. title: '',
  85. description: 'Main operation button area',
  86. side: 'bottom',
  87. align: 'start'
  88. }
  89. },
  90. {
  91. element: '#driver-step-tracking-detail-2',
  92. popover: {
  93. description: 'Key shipment status',
  94. side: 'bottom',
  95. align: 'start'
  96. }
  97. },
  98. {
  99. element: '#tracking-map',
  100. popover: {
  101. description: `
  102. <ul>
  103. <li>Actual Line(Actual Trajectory)</li>
  104. <li>Virtual Line(Planned Trajectory)</li>
  105. <li>Arrow (Current Real-time Position)</li>
  106. </ol>
  107. `,
  108. side: 'bottom',
  109. align: 'start'
  110. }
  111. },
  112. {
  113. element: '#driver-step-tracking-detail-5',
  114. popover: {
  115. description: `
  116. <ul>
  117. <li>Upload Files</li>
  118. <li>Clickable download icons to download files</li>
  119. </ol>
  120. `,
  121. side: 'bottom',
  122. align: 'start'
  123. }
  124. },
  125. {
  126. element: '#driver-step-tracking-detail-6',
  127. popover: {
  128. description: `
  129. <p>Send email to site staff</p>
  130. <p>Enter contents you want to communicate with, click “Send
  131. Email” button to send out.
  132. </p>
  133. `,
  134. side: 'bottom',
  135. align: 'start'
  136. }
  137. },
  138. {
  139. element: '#page-guide-btn-guide',
  140. popover: {
  141. title: '',
  142. description:
  143. 'After closing, you can still click the "Page Guide" button to view the page guide of the current page.',
  144. side: 'bottom'
  145. }
  146. }
  147. ]
  148. const guideTimer = ref<ReturnType<typeof setTimeout> | null>(null)
  149. export const useGuideStore = defineStore('guide', {
  150. state: () => ({
  151. booking: {
  152. isShowMoreFiltersGuidePhoto: false,
  153. isShowDownloadFileGuidePhoto: false,
  154. isShowFilterGuidePhoto: false,
  155. isShowCustomizeColumnsGuidePhoto: false
  156. },
  157. tracking: {
  158. isShowFilterGuidePhoto: false,
  159. isShowMoreFiltersGuidePhoto: false,
  160. isShowDownloadFileGuidePhoto: false,
  161. isShowCustomizeColumnsGuidePhoto: false
  162. },
  163. dashboard: {
  164. isShowViewManagementGuidePhoto: false,
  165. isShowTransportModeGuidePhoto: false,
  166. isShowSaveConfigGuidePhoto: false,
  167. isShowKpiChartGuidePhoto: false
  168. },
  169. trackingDetail: {
  170. mode: 'Ocean Freight'
  171. }
  172. }),
  173. actions: {
  174. resetGuide(key: string) {
  175. if (this.booking[key] !== undefined) {
  176. this.booking[key] = false
  177. } else if (this.tracking[key] !== undefined) {
  178. this.tracking[key] = false
  179. } else if (this.dashboard[key] !== undefined) {
  180. this.dashboard[key] = false
  181. }
  182. },
  183. handleTrackingDetailGuide() {
  184. let steps = []
  185. if (this.trackingDetail.mode === 'Ocean Freight') {
  186. steps = oceanSteps
  187. } else if (this.trackingDetail.mode === 'Air Freight') {
  188. steps = airSteps
  189. } else {
  190. return
  191. }
  192. const { start, movePrevious, hasNextStep, moveTo, destroy } = useDriver(steps, {
  193. onPrevClick: () => {
  194. if (guideTimer.value) {
  195. clearTimeout(guideTimer.value)
  196. guideTimer.value = null
  197. }
  198. movePrevious()
  199. },
  200. onHighlightStarted: () => {
  201. if (!hasNextStep()) {
  202. guideTimer.value = setTimeout(() => {
  203. destroy()
  204. }, 3000)
  205. }
  206. },
  207. onDestroyStarted: (element, step, options) => {
  208. if (hasNextStep()) {
  209. moveTo(options.config.steps.length - 1)
  210. return
  211. }
  212. destroy()
  213. },
  214. onDestroyed: () => {
  215. if (guideTimer.value) {
  216. clearTimeout(guideTimer.value)
  217. guideTimer.value = null
  218. }
  219. }
  220. })
  221. start() // 开始引导
  222. }
  223. }
  224. })