| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- // store/guide.ts
- import { defineStore } from 'pinia'
- import { useDriver } from '@/utils/driverGuide'
- const oceanSteps: any = [
- {
- element: '#driver-step-tracking-detail-1',
- popover: {
- title: '',
- description: 'Main operation button area',
- side: 'bottom',
- align: 'start'
- }
- },
- {
- element: '#driver-step-tracking-detail-2',
- popover: {
- description: 'Key shipment status',
- side: 'bottom',
- align: 'start'
- }
- },
- {
- element: '#driver-step-tracking-detail-3',
- popover: {
- description: 'Detail container status of each container',
- side: 'bottom',
- align: 'start'
- }
- },
- {
- element: '#tracking-map',
- popover: {
- description: `
- <ul>
- <li>Actual Line(Actual Trajectory)</li>
- <li>Virtual Line(Planned Trajectory)</li>
- <li>Arrow (Current Real-time Position)</li>
- </ol>
- `,
- side: 'bottom',
- align: 'start'
- }
- },
- {
- element: '#driver-step-tracking-detail-5',
- popover: {
- description: `
- <ul>
- <li>Upload Files</li>
- <li>Clickable download icons to download files</li>
- </ol>
- `,
- side: 'bottom',
- align: 'start'
- }
- },
- {
- element: '#driver-step-tracking-detail-6',
- popover: {
- description: `
- <p>Send email to site staff</p>
- <p>Enter contents you want to communicate with, click “Send
- Email” button to send out.
- </p>
- `,
- side: 'bottom',
- align: 'start'
- }
- },
- {
- element: '#page-guide-btn-guide',
- popover: {
- title: '',
- description:
- 'After closing, you can still click the "page guide" button to view the page guide of the current page.',
- side: 'bottom'
- }
- }
- ]
- const airSteps: any = [
- {
- element: '#driver-step-tracking-detail-1',
- popover: {
- title: '',
- description: 'Main operation button area',
- side: 'bottom',
- align: 'start'
- }
- },
- {
- element: '#driver-step-tracking-detail-2',
- popover: {
- description: 'Key shipment status',
- side: 'bottom',
- align: 'start'
- }
- },
- {
- element: '#tracking-map',
- popover: {
- description: `
- <ul>
- <li>Actual Line(Actual Trajectory)</li>
- <li>Virtual Line(Planned Trajectory)</li>
- <li>Arrow (Current Real-time Position)</li>
- </ol>
- `,
- side: 'bottom',
- align: 'start'
- }
- },
- {
- element: '#driver-step-tracking-detail-5',
- popover: {
- description: `
- <ul>
- <li>Upload Files</li>
- <li>Clickable download icons to download files</li>
- </ol>
- `,
- side: 'bottom',
- align: 'start'
- }
- },
- {
- element: '#driver-step-tracking-detail-6',
- popover: {
- description: `
- <p>Send email to site staff</p>
- <p>Enter contents you want to communicate with, click “Send
- Email” button to send out.
- </p>
- `,
- side: 'bottom',
- align: 'start'
- }
- },
- {
- element: '#page-guide-btn-guide',
- popover: {
- title: '',
- description:
- 'After closing, you can still click the "page guide" button to view the page guide of the current page.',
- side: 'bottom'
- }
- }
- ]
- const guideTimer = ref<ReturnType<typeof setTimeout> | null>(null)
- export const useGuideStore = defineStore('guide', {
- state: () => ({
- booking: {
- isShowMoreFiltersGuidePhoto: false,
- isShowDownloadFileGuidePhoto: false,
- isShowFilterGuidePhoto: false,
- isShowCustomizeColumnsGuidePhoto: false
- },
- tracking: {
- isShowFilterGuidePhoto: false,
- isShowMoreFiltersGuidePhoto: false,
- isShowDownloadFileGuidePhoto: false,
- isShowCustomizeColumnsGuidePhoto: false
- },
- dashboard: {
- isShowViewManagementGuidePhoto: false,
- isShowTransportModeGuidePhoto: false,
- isShowSaveConfigGuidePhoto: false,
- isShowKpiChartGuidePhoto: false
- },
- trackingDetail: {
- mode: 'Ocean Freight'
- }
- }),
- actions: {
- resetGuide(key: string) {
- if (this.booking[key] !== undefined) {
- this.booking[key] = false
- } else if (this.tracking[key] !== undefined) {
- this.tracking[key] = false
- } else if (this.dashboard[key] !== undefined) {
- this.dashboard[key] = false
- }
- },
- handleTrackingDetailGuide() {
- let steps = []
- if (this.trackingDetail.mode === 'Ocean Freight') {
- steps = oceanSteps
- } else if (this.trackingDetail.mode === 'Air Freight') {
- steps = airSteps
- } else {
- return
- }
- const { start, movePrevious, hasNextStep, moveTo, destroy } = useDriver(steps, {
- onPrevClick: () => {
- if (guideTimer.value) {
- clearTimeout(guideTimer.value)
- guideTimer.value = null
- }
- movePrevious()
- },
- onHighlightStarted: () => {
- if (!hasNextStep()) {
- guideTimer.value = setTimeout(() => {
- destroy()
- }, 3000)
- }
- },
- onDestroyStarted: (element, step, options) => {
- if (hasNextStep()) {
- moveTo(options.config.steps.length - 1)
- return
- }
- destroy()
- },
- onDestroyed: () => {
- if (guideTimer.value) {
- clearTimeout(guideTimer.value)
- guideTimer.value = null
- }
- }
- })
- start() // 开始引导
- }
- }
- })
|