Переглянути джерело

Merge branch 'dev_zyh' of United_Software/k_online_ui into dev

Jack Zhou 1 рік тому
батько
коміт
84cdd9d86d

+ 1 - 1
.env.development

@@ -1,2 +1,2 @@
 VITE_API_HOST = 'http://192.168.0.161/Customer_Service_Online'
-VITE_BASE_URL = 'k_new_online'
+VITE_BASE_URL = '/k_new_online/'

+ 2 - 0
.env.product

@@ -0,0 +1,2 @@
+VITE_API_HOST = 'https://online.kln.com/online_backend'
+VITE_BASE_URL = '/'

+ 2 - 2
.env.test

@@ -1,2 +1,2 @@
-VITE_API_HOST = 'https://ra.kerryapex.com/online_backend'
-VITE_BASE_URL = 'new'
+VITE_API_HOST = 'https://ra.kerryapex.com/new/online_backend'
+VITE_BASE_URL = '/new/'

+ 2 - 0
package.json

@@ -11,6 +11,7 @@
     "preview": "vite preview",
     "build-only": "vite build",
     "build:test": "vite build --mode test",
+    "build:pro": "vite build --mode product",
     "build:dev": "vite build --mode development",
     "type-check": "vue-tsc --build --force",
     "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
@@ -31,6 +32,7 @@
     "lodash": "^4.17.21",
     "mitt": "^3.0.1",
     "moment": "^2.30.1",
+    "moment-timezone": "^0.5.46",
     "pinia": "^2.2.2",
     "sass-loader": "^16.0.2",
     "vue": "^3.4.29",

+ 2 - 1
src/auto-imports.d.ts

@@ -3,6 +3,7 @@
 // @ts-nocheck
 // noinspection JSUnusedGlobalSymbols
 // Generated by unplugin-auto-import
+// biome-ignore lint: disable
 export {}
 declare global {
   const $api: typeof import('@/api/index')['default']
@@ -68,6 +69,6 @@ declare global {
 // for type re-export
 declare global {
   // @ts-ignore
-  export type { Component, ComponentPublicInstance, ComputedRef, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, VNode, WritableComputedRef } from 'vue'
+  export type { Component, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue'
   import('vue')
 }

+ 1 - 20
src/components/ContainerStatus/src/ContainerStatus.vue

@@ -1,6 +1,6 @@
 <script setup lang="ts">
-import dayjs from 'dayjs'
 import emptyImage from './image/no-data.png'
+import { formatTimezone } from '@/utils/tools'
 
 const props = defineProps({
   data: Object
@@ -26,25 +26,6 @@ watch(
     deep: true
   }
 )
-
-const formatTimezone = (time: string, timezone: string) => {
-  if (!time) return '--'
-  let formattedTime = ''
-  // 有时分秒才有添加时区的必要
-  if (time.length > 12) {
-    formattedTime = dayjs(time).format('MMM-DD-YYYY hh:mm A')
-    let gmtOffset = ''
-    if (timezone && timezone.length > 3) {
-      const timeZoneOffset = dayjs().tz(timezone).format('Z')
-      // 替换 "+07:00" 为 "GMT+7"
-      gmtOffset = `(GMT${timeZoneOffset.slice(0, 3)})`
-    }
-    return `${formattedTime} ${gmtOffset}`
-  } else {
-    formattedTime = dayjs(time).format('MMM-DD-YYYY')
-    return formattedTime
-  }
-}
 </script>
 
 <template>

+ 1 - 1
src/router/index.ts

@@ -3,7 +3,7 @@ import { useUserStore } from '@/stores/modules/user'
 import { useBreadCrumb } from '@/stores/modules/breadCrumb'
 
 const router = createRouter({
-  history: createWebHistory(`/${import.meta.env.VITE_BASE_URL}/`),
+  history: createWebHistory(`${import.meta.env.VITE_BASE_URL}`),
   routes: [
     {
       path: '/',

+ 18 - 0
src/stores/modules/loadingState.ts

@@ -0,0 +1,18 @@
+import { defineStore } from 'pinia'
+
+interface LoadingState {
+  trackingTableLoading: boolean
+}
+
+export const useLoadingState = defineStore('loadingState', {
+  state: (): LoadingState => ({
+    trackingTableLoading: JSON.parse(localStorage.getItem('trackingTableLoading')) || false
+  }),
+  getters: {},
+  actions: {
+    setTrackingTableLoading(state: boolean) {
+      localStorage.setItem('trackingTableLoading', JSON.stringify(state))
+      this.trackingTableLoading = state
+    }
+  }
+})

+ 17 - 0
src/utils/tools.ts

@@ -0,0 +1,17 @@
+import moment from 'moment-timezone'
+
+export const formatTimezone = (time: string, timezone: string) => {
+  if (!time) return '--'
+  let formattedTime = ''
+  if (time.length > 12) {
+    formattedTime = moment(time).format('MMM-DD-YYYY hh:mm A')
+    let gmtOffset = ''
+    const timeZoneOffset = moment().tz(timezone).format('Z')
+    // 替换 "+07:00" 为 "GMT+07"
+    gmtOffset = `(GMT${timeZoneOffset.slice(0, 3)})`
+    return `${formattedTime} ${gmtOffset}`
+  } else {
+    formattedTime = moment(time).format('MMM-DD-YYYY')
+    return formattedTime
+  }
+}

+ 1 - 25
src/views/Booking/src/components/BookingDetail/src/BookingDetail.vue

@@ -7,12 +7,7 @@ import { cloneDeep } from 'lodash'
 import { transportationMode } from '@/components/TransportationMode'
 import { useRoute } from 'vue-router'
 import { useOverflow } from '@/hooks/useOverflow'
-import dayjs from 'dayjs'
-import timezone from 'dayjs/plugin/timezone'
-import utc from 'dayjs/plugin/utc'
-
-dayjs.extend(utc)
-dayjs.extend(timezone)
+import { formatTimezone } from '@/utils/tools'
 
 const route = useRoute()
 
@@ -91,25 +86,6 @@ const getData = () => {
 }
 getData()
 
-const formatTimezone = (time: string, timezone: string) => {
-  if (!time) return '--'
-  let formattedTime = ''
-  // 有时分秒才有添加时区的必要
-  if (time.length > 12) {
-    formattedTime = dayjs(time).format('MMM-DD-YYYY hh:mm A')
-    let gmtOffset = ''
-    if (timezone && timezone.length > 3) {
-      const timeZoneOffset = dayjs().tz(timezone).format('Z')
-      // 替换 "+07:00" 为 "GMT+7"
-      gmtOffset = `(GMT${timeZoneOffset.slice(0, 3)})`
-    }
-    return `${formattedTime} ${gmtOffset}`
-  } else {
-    formattedTime = dayjs(time).format('MMM-DD-YYYY')
-    return formattedTime
-  }
-}
-
 const originRef = ref()
 const destinationRef = ref()
 const { isOverflow: isOriginOverflow } = useOverflow(originRef, allData)

+ 6 - 0
src/views/Layout/src/components/Header/HeaderView.vue

@@ -6,6 +6,7 @@ import { useRouter, useRoute } from 'vue-router'
 import { useUserStore } from '@/stores/modules/user'
 import { useHeaderSearch } from '@/stores/modules/headerSearch'
 import { onBeforeRouteUpdate } from 'vue-router'
+import { useLoadingState } from '@/stores/modules/loadingState'
 
 const userStore = useUserStore()
 const route = useRoute()
@@ -53,6 +54,8 @@ const handleSearch = () => {
       }
     })
   } else {
+    const trackingTableLoadingState = useLoadingState()
+    trackingTableLoadingState.setTrackingTableLoading(true)
     // 已登录
     $api
       .getTrackingTableData({
@@ -76,6 +79,9 @@ const handleSearch = () => {
           })
         }
       })
+      .finally(() => {
+        trackingTableLoadingState.setTrackingTableLoading(false)
+      })
   }
 }
 onBeforeRouteUpdate((to, from, next) => {

+ 3 - 24
src/views/Tracking/src/components/PublicTracking/src/components/MilestonesTable.vue

@@ -1,13 +1,9 @@
 <script setup lang="ts">
-import dayjs from 'dayjs'
-import timezone from 'dayjs/plugin/timezone'
-import utc from 'dayjs/plugin/utc'
 import { type VxeGridInstance, type VxeGridProps } from 'vxe-table'
-import { autoWidth } from '@/utils/table'
+// import { autoWidth } from '@/utils/table'
 import { useRowClickStyle } from '@/hooks/rowClickStyle'
+import { formatTimezone } from '@/utils/tools'
 
-dayjs.extend(utc)
-dayjs.extend(timezone)
 const props = defineProps({
   height: {
     type: Number,
@@ -45,24 +41,7 @@ const handleColumns = (columns: any) => {
     if (item.formatter === 'dateTime') {
       curColumn = {
         ...curColumn,
-        formatter: ({ cellValue, row }: any) => {
-          if (!cellValue) return '--'
-          let formattedTime = ''
-          // 有时分秒才有添加时区的必要
-          if (cellValue.length > 12) {
-            formattedTime = dayjs(cellValue).format('MMM-DD-YYYY hh:mm A')
-            let gmtOffset = ''
-            if (row.timezone && row.timezone.length > 3) {
-              const timeZoneOffset = dayjs().tz(row.timezone).format('Z')
-              // 替换 "+07:00" 为 "GMT+7"
-              gmtOffset = `(GMT${timeZoneOffset.slice(0, 3)})`
-            }
-            return `${formattedTime} ${gmtOffset}`
-          } else {
-            formattedTime = dayjs(cellValue).format('MMM-DD-YYYY')
-            return formattedTime
-          }
-        }
+        formatter: ({ cellValue, row }: any) => formatTimezone(cellValue, row.timezone)
       }
     }
     return curColumn

+ 1 - 24
src/views/Tracking/src/components/PublicTracking/src/components/PublicTrackingDetail.vue

@@ -3,13 +3,9 @@ import BasicInformation from './BasicInformation.vue'
 import MilestonesTable from './MilestonesTable.vue'
 import { transportationMode } from '@/components/TransportationMode'
 import { useRoute } from 'vue-router'
-import dayjs from 'dayjs'
-import timezone from 'dayjs/plugin/timezone'
-import utc from 'dayjs/plugin/utc'
 import { useOverflow } from '@/hooks/useOverflow'
+import { formatTimezone } from '@/utils/tools'
 
-dayjs.extend(utc)
-dayjs.extend(timezone)
 const route = useRoute()
 
 const allData: any = ref({
@@ -68,25 +64,6 @@ if (Object.keys(sharedData).length === 0) {
   allData.value = sharedData
 }
 
-const formatTimezone = (time: string, timezone: string) => {
-  if (!time) return '--'
-  let formattedTime = ''
-  // 有时分秒才有添加时区的必要
-  if (time.length > 12) {
-    formattedTime = dayjs(time).format('MMM-DD-YYYY hh:mm A')
-    let gmtOffset = ''
-    if (timezone && timezone.length > 3) {
-      const timeZoneOffset = dayjs().tz(timezone).format('Z')
-      // 替换 "+07:00" 为 "GMT+7"
-      gmtOffset = `(GMT${timeZoneOffset.slice(0, 3)})`
-    }
-    return `${formattedTime} ${gmtOffset}`
-  } else {
-    formattedTime = dayjs(time).format('MMM-DD-YYYY')
-    return formattedTime
-  }
-}
-
 const originRef = ref()
 const destinationRef = ref()
 const { isOverflow: isOriginOverflow } = useOverflow(originRef, allData)

+ 1 - 25
src/views/Tracking/src/components/TrackingDetail/src/TrackingDetail.vue

@@ -1,7 +1,4 @@
 <script setup lang="ts">
-import dayjs from 'dayjs'
-import timezone from 'dayjs/plugin/timezone'
-import utc from 'dayjs/plugin/utc'
 import { VueDraggable } from 'vue-draggable-plus'
 import BasicInformation from './components/BasicInformation.vue'
 import ContainersView from './components/ContainersView.vue'
@@ -16,9 +13,7 @@ import { cloneDeep } from 'lodash'
 import { transportationMode } from '@/components/TransportationMode'
 import { useRoute } from 'vue-router'
 import { useOverflow } from '@/hooks/useOverflow'
-
-dayjs.extend(utc)
-dayjs.extend(timezone)
+import { formatTimezone } from '@/utils/tools'
 
 const route = useRoute()
 
@@ -110,25 +105,6 @@ const getData = () => {
 }
 getData()
 
-const formatTimezone = (time: string, timezone: string) => {
-  if (!time) return '--'
-  let formattedTime = ''
-  // 有时分秒才有添加时区的必要
-  if (time.length > 12) {
-    formattedTime = dayjs(time).format('MMM-DD-YYYY hh:mm A')
-    let gmtOffset = ''
-    if (timezone && timezone.length > 3) {
-      const timeZoneOffset = dayjs().tz(timezone).format('Z')
-      // 替换 "+07:00" 为 "GMT+7"
-      gmtOffset = `(GMT${timeZoneOffset.slice(0, 3)})`
-    }
-    return `${formattedTime} ${gmtOffset}`
-  } else {
-    formattedTime = dayjs(time).format('MMM-DD-YYYY')
-    return formattedTime
-  }
-}
-
 const originRef = ref()
 const destinationRef = ref()
 const { isOverflow: isOriginOverflow } = useOverflow(originRef, allData)

+ 3 - 26
src/views/Tracking/src/components/TrackingDetail/src/components/MilestonesTable.vue

@@ -1,13 +1,8 @@
 <script setup lang="ts">
-import dayjs from 'dayjs'
-import timezone from 'dayjs/plugin/timezone'
-import utc from 'dayjs/plugin/utc'
 import { type VxeGridInstance, type VxeGridProps } from 'vxe-table'
-import { autoWidth } from '@/utils/table'
+// import { autoWidth } from '@/utils/table'
 import { useRowClickStyle } from '@/hooks/rowClickStyle'
-
-dayjs.extend(utc)
-dayjs.extend(timezone)
+import { formatTimezone } from '@/utils/tools'
 
 const props = defineProps({
   data: Object
@@ -45,25 +40,7 @@ const handleColumns = (columns: any) => {
     if (item.formatter === 'dateTime') {
       curColumn = {
         ...curColumn,
-        formatter: ({ row, cellValue }: any) => {
-          if (!cellValue) return '--'
-
-          let formattedTime = ''
-          // 有时分秒才有添加时区的必要
-          if (cellValue.length > 12) {
-            formattedTime = dayjs(cellValue).format('MMM-DD-YYYY hh:mm A')
-            let gmtOffset = ''
-            if (row.timezone && row.timezone.length > 3) {
-              const timeZoneOffset = dayjs().tz(row.timezone).format('Z')
-              // 替换 "+07:00" 为 "GMT+7"
-              gmtOffset = `(GMT${timeZoneOffset.slice(0, 3)})`
-            }
-            return `${formattedTime} ${gmtOffset}`
-          } else {
-            formattedTime = dayjs(cellValue).format('MMM-DD-YYYY')
-            return formattedTime
-          }
-        }
+        formatter: ({ row, cellValue }: any) => formatTimezone(cellValue, row.timezone)
       }
     }
     return curColumn

+ 6 - 1
src/views/Tracking/src/components/TrackingTable/src/TrackingTable.vue

@@ -6,6 +6,7 @@ import dayjs from 'dayjs'
 import { useRouter } from 'vue-router'
 import { ref, onMounted } from 'vue'
 import { transportationMode } from '@/components/TransportationMode'
+import { useLoadingState } from '@/stores/modules/loadingState'
 
 const router = useRouter()
 const props = defineProps({
@@ -145,6 +146,7 @@ const getSharedTableData = () => {
   const trackingData = JSON.parse(localStorage.getItem('searchData'))?.trackingData
   if (trackingData) {
     pageInfo.value.pageSize = Number(trackingData.ps)
+    sessionStorage.setItem('trackingTablePageInfo', JSON.stringify(pageInfo.value))
     assignTableData(trackingData)
     selectedNumber.value = 0
     selectedTableData.value = []
@@ -493,6 +495,9 @@ const handleVGM = (row) => {
     query: { a: row.__serial_no, _schemas: row._schemas }
   })
 }
+
+const loadingState = useLoadingState()
+
 defineExpose({
   searchTableData,
   getSharedTableData,
@@ -524,7 +529,7 @@ defineExpose({
 
     <vxe-grid
       ref="tableRef"
-      v-vloading="tableLoadingColumn || tableLoadingTable"
+      v-vloading="tableLoadingColumn || tableLoadingTable || loadingState.trackingTableLoading"
       :height="props.height"
       :style="{ border: 'none' }"
       v-bind="trackingTable"