소스 검색

feat: 修改时间和数值的部分格式化

zhouyuhao 9 달 전
부모
커밋
f6ae34bdc6

+ 2 - 6
src/components/ShipmentStatus/src/ShipmentStatus.vue

@@ -1,6 +1,6 @@
 <script setup lang="ts">
-import dayjs from 'dayjs'
 import { useOverflow } from '@/hooks/useOverflow'
+import { formatTimezone } from '@/utils/tools'
 
 const props = defineProps({
   data: Object
@@ -34,10 +34,6 @@ const getDateHeight = (index: number) => {
   return 42 + 26 * index
 }
 
-const formatDate = (date: string) => {
-  return date ? dayjs(date).format('MMM-DD-YYYY') : '--'
-}
-
 const pathRef = ref()
 
 const { isOverflow: isPathOverflow } = useOverflow(pathRef, props)
@@ -76,7 +72,7 @@ const { isOverflow: isPathOverflow } = useOverflow(pathRef, props)
             <div class="step-dot"></div>
             <div class="label">{{ dateItem.label }}</div>
             <div class="divider"></div>
-            <div class="date">{{ formatDate(dateItem.date) }}</div>
+            <div class="date">{{ formatTimezone(dateItem.date) }}</div>
           </div>
         </div>
       </div>

+ 7 - 28
src/utils/tools.ts

@@ -1,6 +1,7 @@
 import moment from 'moment-timezone'
 
-export const formatTimezone = (time: string, timezone: string) => {
+const formatString = 'MMM/DD/YYYY'
+export const formatTimezone = (time: string, timezone?: string) => {
   if (!time) return '--'
   let formattedTime = ''
   if (time.length > 12) {
@@ -37,29 +38,6 @@ export const formatTimezoneByUTCorGMT = (time: string, timezone: string) => {
   }
 }
 
-const formatString = 'MMM/DD/YYYY'
-/**
- * 根据用户偏好 格式化时间
- */
-export const formatTimezoneByUser = (time: string, timezone?: string) => {
-  if (!time) return '--'
-  let formattedTime = ''
-  if (time.length > 12) {
-    formattedTime = moment(time).format(`${formatString} hh:mm A`)
-    if (!timezone) {
-      return formattedTime
-    }
-    let gmtOffset = ''
-    const timeZoneOffset = moment.tz(`${moment().year()}-01-01`, timezone).format('Z')
-    // 替换 "+07:00" 为 "GMT+07"
-    gmtOffset = `(GMT${timeZoneOffset.slice(0, 3)})`
-    return `${formattedTime} ${gmtOffset}`
-  } else {
-    formattedTime = moment(time).format(formatString)
-    return formattedTime
-  }
-}
-
 /**
  * 判断是否是欧洲地区
  */
@@ -72,16 +50,17 @@ export const isEuropean = () => {
 /**
  * 根据传入的地区 格式化数字
  * @param number - 需要格式化的数字
+ * @param digits - 小数位数
  * @param isEuropean - 是否为欧洲地区
  */
-export const formatNumber = (number: number, isEuropean: boolean): string => {
+export const formatNumber = (number: number, digits: number, isEuropean?: boolean): string => {
   const userLanguage = isEuropean ? 'de-DE' : 'zh-CN'
 
   // 设置数字格式化的选项
   const options: Intl.NumberFormatOptions = {
-    style: 'decimal'
-    // minimumFractionDigits: 2,
-    // maximumFractionDigits: 2
+    style: 'decimal',
+    minimumFractionDigits: digits
+    // maximumFractionDigits: 3
   }
 
   // 其他地区使用默认格式

+ 12 - 3
src/views/Booking/src/components/BookingDetail/src/components/BasicInformation.vue

@@ -2,6 +2,7 @@
 import { useRouter } from 'vue-router'
 import XEClipboard from 'xe-clipboard'
 import AddReferenceDialog from './AddReferenceDialog.vue'
+import { formatNumber } from '@/utils/tools'
 
 const router = useRouter()
 
@@ -108,6 +109,14 @@ const allData: any = ref({
   ]
 })
 
+// 从开始位置截取字符串,并格式化数字(因为后端接口返回的内容带有字符串,所以需要截取)
+const substringFromStart = (str: string, start: number) => {
+  if (!str) {
+    return formatNumber(0, 3)
+  }
+  return formatNumber(Number(str.slice(0, start)), 3)
+}
+
 const convertData = (data: any) => {
   return {
     basicInformation: {
@@ -186,15 +195,15 @@ const convertData = (data: any) => {
       },
       {
         label: 'G. Weight',
-        content: data.packing['G. Weight'] || '--'
+        content: substringFromStart(data.packing['G. Weight'], -4) + ' KGS'
       },
       {
         label: 'Ch. Weight',
-        content: data.packing['Ch. Weight'] || '--'
+        content: substringFromStart(data.packing['Ch. Weight'], -4) + ' KGS'
       },
       {
         label: 'Volume',
-        content: data.packing['Volume'] || '--'
+        content: substringFromStart(data.packing['Volume'], -4) + ' CBM'
       }
     ],
     marksAndDescription: [

+ 4 - 14
src/views/Booking/src/components/BookingDetail/src/components/ContainersView.vue

@@ -1,8 +1,8 @@
 <script setup lang="ts">
-import dayjs from 'dayjs'
 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'
 
 const props = defineProps({
   data: Object
@@ -35,20 +35,10 @@ const handleColumns = (columns: any) => {
     }
 
     // 格式化
-    if (item.formatter === 'date') {
+    if (item.formatter === 'date' || item.formatter === 'dateTime') {
       curColumn = {
         ...curColumn,
-        sortBy: ({ row, column }: any) => {
-          return dayjs(row[column.field]).unix()
-        },
-        formatter: ({ cellValue }: any) =>
-          cellValue ? dayjs(cellValue).format('MMM-DD-YYYY ') : '--'
-      }
-    } else if (item.formatter === 'dateTime') {
-      curColumn = {
-        ...curColumn,
-        formatter: ({ cellValue }: any) =>
-          cellValue ? dayjs(cellValue).format('MMM-DD-YYYY HH:mm:ss') : '--'
+        formatter: ({ cellValue }: any) => formatTimezone(cellValue)
       }
     }
     return curColumn

+ 3 - 3
src/views/Booking/src/components/BookingDetail/src/components/EmailView.vue

@@ -2,7 +2,7 @@
 import '@wangeditor/editor/dist/css/style.css'
 import { Editor, Toolbar } from '@wangeditor/editor-for-vue'
 import { i18nChangeLanguage, DomEditor } from '@wangeditor/editor'
-import dayjs from 'dayjs'
+import { formatTimezone } from '@/utils/tools'
 
 i18nChangeLanguage('en')
 
@@ -152,7 +152,7 @@ const sendEmail = () => {
         emailRecords.value = res.data.emailRecords
       }
     })
-    .catch((err: any) => {
+    .catch(() => {
       ElMessage.error('Failed to send email')
     })
 }
@@ -221,7 +221,7 @@ const sendEmail = () => {
             <div>{{ item.name?.slice(0, 1) }}</div>
           </div>
           <div class="name">{{ item.name }}</div>
-          <div class="date">{{ dayjs(item.creatTime).format('MM-DD-YYYY HH:mm:ss') }}</div>
+          <div class="date">{{ formatTimezone(item.creatTime) }}</div>
         </div>
         <div class="content">
           {{ item.content }}

+ 3 - 9
src/views/Booking/src/components/BookingTable/src/BookingTable.vue

@@ -9,6 +9,7 @@ import { useRouter } from 'vue-router'
 import { transportationMode } from '@/components/transportationMode'
 import { useThemeStore } from '@/stores/modules/theme'
 import { useVisitedRowState } from '@/stores/modules/visitedRow'
+import { formatTimezone } from '@/utils/tools'
 
 const visitedRowState = useVisitedRowState()
 const themeStore = useThemeStore()
@@ -58,17 +59,10 @@ const handleColumns = (columns: any, status?: string) => {
       }
     }
     // 格式化
-    if (item.formatter === 'date') {
+    if (item.formatter === 'date' || item.formatter === 'dateTime') {
       curColumn = {
         ...curColumn,
-        formatter: ({ cellValue }: any) =>
-          cellValue ? dayjs(cellValue).format('MMM-DD-YYYY ') : '--'
-      }
-    } else if (item.formatter === 'dateTime') {
-      curColumn = {
-        ...curColumn,
-        formatter: ({ cellValue }: any) =>
-          cellValue ? dayjs(cellValue).format('MMM-DD-YYYY HH:mm:ss') : '--'
+        formatter: ({ cellValue }: any) => formatTimezone(cellValue)
       }
     }
     return curColumn

+ 4 - 10
src/views/OperationLog/src/components/BookingTable/src/BookingTable.vue

@@ -2,10 +2,11 @@
 import { ref, nextTick, onMounted } from 'vue'
 import { type VxeGridInstance, type VxeGridProps } from 'vxe-table'
 import DownloadDialog from './components/DownloadDialog.vue'
-import { autoWidth } from '@/utils/table'
+// import { autoWidth } from '@/utils/table'
 import { useRowClickStyle } from '@/hooks/rowClickStyle'
 import dayjs from 'dayjs'
 import { useThemeStore } from '@/stores/modules/theme'
+import { formatTimezone } from '@/utils/tools'
 
 const themeStore = useThemeStore()
 
@@ -46,17 +47,10 @@ const handleColumns = (columns: any, status?: string) => {
       }
     }
     // 格式化
-    if (item.formatter === 'date') {
+    if (item.formatter === 'date' || item.formatter === 'dateTime') {
       curColumn = {
         ...curColumn,
-        formatter: ({ cellValue }: any) =>
-          cellValue ? dayjs(cellValue).format('MMM-DD-YYYY ') : '--'
-      }
-    } else if (item.formatter === 'dateTime') {
-      curColumn = {
-        ...curColumn,
-        formatter: ({ cellValue }: any) =>
-          cellValue ? dayjs(cellValue).format('YYYY/MM/DD HH:mm:ss') : '--'
+        formatter: ({ cellValue }: any) => formatTimezone(cellValue)
       }
     }
     return curColumn

+ 0 - 510
src/views/OperationLog/src/components/BookingTable/src/BookingTableColumns.ts

@@ -1,510 +0,0 @@
-import dayjs from 'dayjs'
-
-const BookingTableColumns: any = [
-  {
-    field: 'booking_no',
-    title: 'Booking No.',
-    slots: {
-      default: 'bookingNo'
-    },
-    type: 'link'
-  },
-  {
-    field: 'm_bol',
-    title: 'MBOL No.'
-  },
-  {
-    field: 'h_bol',
-    title: 'HBOL No.'
-  },
-  {
-    field: 'po_no',
-    title: 'PO No.'
-  },
-  {
-    field: 'quote_no',
-    title: 'Quote No.'
-  },
-  {
-    field: 'carrier_booking',
-    title: 'Carrier Booking No.'
-  },
-  {
-    field: 'contract',
-    title: 'Contract No.'
-  },
-  {
-    field: 'mode',
-    title: 'Transportation Mode',
-    type: 'mode',
-    slots: {
-      default: 'mode'
-    }
-  },
-  {
-    field: 'status',
-    title: 'Status',
-    type: 'status',
-    slots: {
-      default: 'status'
-    }
-  },
-  {
-    field: 'shipper',
-    title: 'Shipper'
-  },
-  {
-    field: 'consignee',
-    title: 'Consignee'
-  },
-  {
-    field: 'origin',
-    title: 'Origin Agent'
-  },
-  {
-    field: 'agent',
-    title: 'Destination Agent'
-  },
-  {
-    field: 'sales_rep',
-    title: 'Sales'
-  },
-  {
-    field: 'created_time',
-    title: 'Creation Time',
-    formatter: ({ cellValue }: any) => {
-      return cellValue ? dayjs(cellValue).format('MMM-DD-YYYY HH:mm:ss') : '--'
-    }
-  },
-  {
-    field: 'confirmation_time',
-    title: 'Confirmation Time',
-    formatter: ({ cellValue }: any) => {
-      return cellValue ? dayjs(cellValue).format('MMM-DD-YYYY HH:mm:ss') : '--'
-    }
-  },
-  {
-    field: 'f_etd',
-    title: 'ETD',
-    formatter: ({ cellValue }: any) => {
-      return cellValue ? dayjs(cellValue).format('MMM-DD-YYYY') : '--'
-    }
-  },
-  {
-    field: 'f_eta',
-    title: 'ETA',
-    formatter: ({ cellValue }: any) => {
-      return cellValue ? dayjs(cellValue).format('MMM-DD-YYYY') : '--'
-    }
-  },
-  {
-    field: 'place_of_receipt_exp',
-    title: 'Place of Receipt'
-  },
-  {
-    field: 'fport_of_loading_exp',
-    title: 'Port of Loading'
-  },
-  {
-    field: 'place_of_delivery_exp',
-    title: 'Place of Delivery'
-  },
-  {
-    field: 'final_desination_exp',
-    title: 'Destination'
-  },
-  {
-    field: 'from_station',
-    title: 'Origin'
-  },
-  {
-    field: 'f_carrier',
-    title: 'Carrier'
-  },
-  {
-    field: 'f_voyage',
-    title: 'Voyage'
-  },
-  {
-    field: 'f_vessel',
-    title: 'Vessel'
-  },
-  {
-    field: 'week',
-    title: 'Week'
-  },
-  {
-    field: 'd20',
-    title: 'D20'
-  },
-  {
-    field: 'sd40',
-    title: 'D40'
-  },
-  {
-    field: 'd45',
-    title: 'D45'
-  },
-  {
-    field: 'rd40',
-    title: 'RD'
-  },
-  {
-    field: 'hq40',
-    title: 'HQ'
-  },
-  {
-    field: 'created_by',
-    title: 'Created by'
-  },
-  {
-    field: 'terms',
-    title: 'Other info'
-  }
-]
-
-const addOtherConfig = () => {
-  BookingTableColumns.forEach((item: any) => {
-    item.sortable = true
-  })
-}
-addOtherConfig()
-
-const defaultColumns = [
-  'Transportation Mode',
-  'Status',
-  'Booking No.',
-  'MBOL No.',
-  'HBOL No.',
-  'PO No.',
-  'Shipper',
-  'Consignee',
-  'Origin',
-  'Destination',
-  'Creation Time',
-  'ETD',
-  'ETA',
-  'Week',
-  'Vessel',
-  'Voyage',
-  'Created by',
-  'Other info'
-]
-
-// 分组
-const groupColumns = [
-  {
-    name: 'All',
-    children: [
-      {
-        label: 'Booking No.',
-        field: 'booking_no'
-      },
-      {
-        label: 'MBOL No.',
-        field: 'm_bol'
-      },
-      {
-        label: 'HBOL No.',
-        field: 'h_bol'
-      },
-      {
-        label: 'PO No.',
-        field: 'po_no'
-      },
-      {
-        label: 'Quote No.',
-        field: 'quote_no'
-      },
-      {
-        label: 'Carrier Booking No.',
-        field: 'carrier_booking'
-      },
-      {
-        label: 'Contract No.',
-        field: 'contract'
-      },
-      {
-        label: 'Transportation Mode',
-        field: 'mode'
-      },
-      {
-        label: 'Status',
-        field: 'status'
-      },
-      {
-        label: 'Shipper',
-        field: 'shipper'
-      },
-      {
-        label: 'Consignee',
-        field: 'consignee'
-      },
-      {
-        label: 'Origin Agent',
-        field: 'origin'
-      },
-      {
-        label: 'Destination Agent',
-        field: 'agent'
-      },
-      {
-        label: 'Sales',
-        field: 'sales_rep'
-      },
-      {
-        label: 'Creation Time',
-        field: 'created_time'
-      },
-      {
-        label: 'Confirmation Time',
-        field: 'confirmation_time'
-      },
-      {
-        label: 'ETD',
-        field: 'f_etd'
-      },
-      {
-        label: 'ETA',
-        field: 'f_eta'
-      },
-      {
-        label: 'Place of Receipt',
-        field: 'place_of_receipt_exp'
-      },
-      {
-        label: 'Port of Loading',
-        field: 'fport_of_loading_exp'
-      },
-      {
-        label: 'Place of Delivery',
-        field: 'place_of_delivery_exp'
-      },
-      {
-        label: 'Destination',
-        field: 'final_desination_exp'
-      },
-      {
-        label: 'Origin',
-        field: 'from_station'
-      },
-      {
-        label: 'Carrier',
-        field: 'f_carrier'
-      },
-      {
-        label: 'Voyage',
-        field: 'f_voyage'
-      },
-      {
-        label: 'Vessel',
-        field: 'f_vessel'
-      },
-      {
-        label: 'Week',
-        field: 'week'
-      },
-      {
-        label: 'D20',
-        field: 'd20'
-      },
-      {
-        label: 'D40',
-        field: 'sd40'
-      },
-      {
-        label: 'D45',
-        field: 'd45'
-      },
-      {
-        label: 'RD',
-        field: 'rd40'
-      },
-      {
-        label: 'HQ',
-        field: 'hq40'
-      },
-      {
-        label: 'Created by',
-        field: 'created_by'
-      },
-      {
-        label: 'Other info',
-        field: 'terms'
-      }
-    ]
-  },
-  {
-    name: 'Reference No.',
-    children: [
-      {
-        label: 'Booking No.',
-        field: 'booking_no'
-      },
-      {
-        label: 'MBOL No.',
-        field: 'm_bol'
-      },
-      {
-        label: 'HBOL No.',
-        field: 'h_bol'
-      },
-      {
-        label: 'PO No.',
-        field: 'po_no'
-      },
-      {
-        label: 'Quote No.',
-        field: 'quote_no'
-      },
-      {
-        label: 'Carrier Booking No.',
-        field: 'carrier_booking'
-      },
-      {
-        label: 'Contract No.',
-        field: 'contract'
-      }
-    ]
-  },
-  {
-    name: 'General',
-    children: [
-      {
-        label: 'Transportation Mode',
-        field: 'mode'
-      },
-      {
-        label: 'Status',
-        field: 'status'
-      }
-    ]
-  },
-  {
-    name: 'Parties',
-    children: [
-      {
-        label: 'Shipper',
-        field: 'shipper'
-      },
-      {
-        label: 'Consignee',
-        field: 'consignee'
-      },
-      {
-        label: 'Origin Agent',
-        field: 'origin'
-      },
-      {
-        label: 'Destination Agent',
-        field: 'agent'
-      },
-      {
-        label: 'Sales',
-        field: 'sales_rep'
-      }
-    ]
-  },
-  {
-    name: 'Time',
-    children: [
-      {
-        label: 'Creation Time',
-        field: 'created_time'
-      },
-      {
-        label: 'Confirmation Time',
-        field: 'confirmation_time'
-      },
-      {
-        label: 'ETD',
-        field: 'f_etd'
-      },
-      {
-        label: 'ETA',
-        field: 'f_eta'
-      }
-    ]
-  },
-  {
-    name: 'Places',
-    children: [
-      {
-        label: 'Place of Receipt',
-        field: 'place_of_receipt_exp'
-      },
-      {
-        label: 'Port of Loading',
-        field: 'fport_of_loading_exp'
-      },
-      {
-        label: 'Place of Delivery',
-        field: 'place_of_delivery_exp'
-      },
-      {
-        label: 'Destination',
-        field: 'final_desination_exp'
-      },
-      {
-        label: 'Origin',
-        field: 'from_station'
-      }
-    ]
-  },
-  {
-    name: 'Transportation',
-    children: [
-      {
-        label: 'Carrier',
-        field: 'f_carrier'
-      },
-      {
-        label: 'Voyage',
-        field: 'voyage_m_voyage'
-      },
-      {
-        label: 'Vessel',
-        field: 'vessel_m_vessel'
-      },
-      {
-        label: 'Week',
-        field: 'week'
-      },
-      {
-        label: 'D20',
-        field: 'd20'
-      },
-      {
-        label: 'D40',
-        field: 'sd40'
-      },
-      {
-        label: 'D45',
-        field: 'd45'
-      },
-      {
-        label: 'RD',
-        field: 'rd40'
-      },
-      {
-        label: 'HQ',
-        field: 'hq40'
-      }
-    ]
-  },
-  {
-    name: 'Others',
-    children: [
-      {
-        label: 'Created by',
-        field: 'created_by'
-      },
-      {
-        label: 'Other info',
-        field: 'terms'
-      }
-    ]
-  }
-]
-
-export { BookingTableColumns, defaultColumns, groupColumns }

+ 13 - 3
src/views/Tracking/src/components/PublicTracking/src/components/BasicInformation.vue

@@ -1,5 +1,6 @@
 <script setup lang="ts">
 import XEClipboard from 'xe-clipboard'
+import { formatNumber } from '@/utils/tools'
 
 const props = defineProps({
   data: Object
@@ -77,6 +78,15 @@ const allData: any = ref({
     }
   ]
 })
+
+// 从开始位置截取字符串,并格式化数字(因为后端接口返回的内容带有字符串,所以需要截取)
+const substringFromStart = (str: string, start: number) => {
+  if (!str) {
+    return formatNumber(0, 3)
+  }
+  return formatNumber(Number(str.slice(0, start)), 3)
+}
+
 const convertData = (data: any) => {
   return {
     basicInformation: {
@@ -128,15 +138,15 @@ const convertData = (data: any) => {
       },
       {
         label: 'G. Weight',
-        content: data.packing['G. Weight'] || '--'
+        content: substringFromStart(data.packing['G. Weight'], -4) + ' KGS'
       },
       {
         label: 'Ch. Weight',
-        content: data.packing['Ch. Weight'] || '--'
+        content: substringFromStart(data.packing['Ch. Weight'], -4) + ' KGS'
       },
       {
         label: 'Volume',
-        content: data.packing.Volume || '--'
+        content: substringFromStart(data.packing['Volume'], -4) + ' CBM'
       }
     ]
   }

+ 14 - 5
src/views/Tracking/src/components/TrackingDetail/src/components/BasicInformation.vue

@@ -1,6 +1,7 @@
 <script setup lang="ts">
 import XEClipboard from 'xe-clipboard'
-import AddReferenceDialog from './AddReferenceDialog.vue'
+// import AddReferenceDialog from './AddReferenceDialog.vue'
+import { formatNumber } from '@/utils/tools'
 
 const props = defineProps({
   data: Object
@@ -109,6 +110,14 @@ const allData: any = ref({
   ]
 })
 
+// 从开始位置截取字符串,并格式化数字(因为后端接口返回的内容带有字符串,所以需要截取)
+const substringFromStart = (str: string, start: number) => {
+  if (!str) {
+    return formatNumber(0, 3)
+  }
+  return formatNumber(Number(str.slice(0, start)), 3)
+}
+
 const convertData = (data: any) => {
   return {
     basicInformation: {
@@ -186,15 +195,15 @@ const convertData = (data: any) => {
       },
       {
         label: 'G. Weight',
-        content: data.packing['G. Weight'] || '--'
+        content: substringFromStart(data.packing['G. Weight'], -4) + ' KGS'
       },
       {
         label: 'Ch. Weight',
-        content: data.packing['Ch. Weight'] || '--'
+        content: substringFromStart(data.packing['Ch. Weight'], -4) + ' KGS'
       },
       {
         label: 'Volume',
-        content: data.packing.Volume || '--'
+        content: substringFromStart(data.packing['Volume'], -4) + ' CBM'
       }
     ],
     marksAndDescription: [
@@ -281,7 +290,7 @@ onBeforeUnmount(() => {
   window.removeEventListener('resize', checkTextOverflow)
 })
 
-const addReferenceRef = ref()
+// const addReferenceRef = ref()
 // const addReference = () => {
 //   addReferenceRef.value.openDialog()
 // }

+ 4 - 14
src/views/Tracking/src/components/TrackingDetail/src/components/ContainersView.vue

@@ -1,8 +1,8 @@
 <script setup lang="ts">
-import dayjs from 'dayjs'
 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'
 
 const props = defineProps({
   data: Object
@@ -36,20 +36,10 @@ const handleColumns = (columns: any) => {
     }
 
     // 格式化
-    if (item.formatter === 'date') {
+    if (item.formatter === 'date' || item.formatter === 'dateTime') {
       curColumn = {
         ...curColumn,
-        sortBy: ({ row, column }: any) => {
-          return dayjs(row[column.field]).unix()
-        },
-        formatter: ({ cellValue }: any) =>
-          cellValue ? dayjs(cellValue).format('MMM-DD-YYYY ') : '--'
-      }
-    } else if (item.formatter === 'dateTime') {
-      curColumn = {
-        ...curColumn,
-        formatter: ({ cellValue }: any) =>
-          cellValue ? dayjs(cellValue).format('MMM-DD-YYYY HH:mm:ss') : '--'
+        formatter: ({ cellValue }: any) => formatTimezone(cellValue)
       }
     }
     return curColumn

+ 2 - 2
src/views/Tracking/src/components/TrackingDetail/src/components/EmailDrawer.vue

@@ -1,8 +1,8 @@
 <script setup lang="ts">
-import dayjs from 'dayjs'
 import '@wangeditor/editor/dist/css/style.css'
 import { Editor, Toolbar } from '@wangeditor/editor-for-vue'
 import { i18nChangeLanguage, DomEditor } from '@wangeditor/editor'
+import { formatTimezone } from '@/utils/tools'
 
 i18nChangeLanguage('en')
 
@@ -224,7 +224,7 @@ const sendEmail = () => {
             <div>{{ item.name?.slice(0, 1) }}</div>
           </div>
           <div class="name">{{ item.name }}</div>
-          <div class="date">{{ dayjs(item.creatTime).format('MM-DD-YYYY HH:mm:ss') }}</div>
+          <div class="date">{{ formatTimezone(item.creatTime) }}</div>
         </div>
         <div class="content">
           {{ item.content }}

+ 7 - 7
src/views/Tracking/src/components/TrackingDetail/src/components/RoutesView.vue

@@ -1,7 +1,7 @@
 <script setup lang="ts">
 import { transportationMode } from '@/components/transportationMode'
 import { useOverflow } from '@/hooks/useOverflow'
-import { formatTimezoneByUser } from '@/utils/tools'
+import { formatTimezone } from '@/utils/tools'
 
 const props = defineProps({
   data: Object
@@ -107,11 +107,11 @@ const { isOverflow: isDetailDestinationOverflow } = useOverflow(detailDestinatio
           </div>
           <div class="etd border-right">
             <div class="title">ETD</div>
-            <div class="content">{{ formatTimezoneByUser(item.etd) }}</div>
+            <div class="content">{{ formatTimezone(item.etd) }}</div>
           </div>
           <div class="eta">
             <div class="title">ETA</div>
-            <div class="content">{{ formatTimezoneByUser(item.eta) }}</div>
+            <div class="content">{{ formatTimezone(item.eta) }}</div>
             <span
               :class="{ collapse: item.isCollapse }"
               class="font_family icon-icon_dropdown_b"
@@ -144,12 +144,12 @@ const { isOverflow: isDetailDestinationOverflow } = useOverflow(detailDestinatio
               <div class="etd">
                 <span class="font_family icon-icon_date_b"></span>
                 <span>ETD: </span>
-                <span class="value">{{ formatTimezoneByUser(item.etd) }}</span>
+                <span class="value">{{ formatTimezone(item.etd) }}</span>
               </div>
               <div class="atd">
                 <span class="font_family icon-icon_date_b"></span>
                 <span>ATD: </span>
-                <span class="value">{{ formatTimezoneByUser(item.atd) }}</span>
+                <span class="value">{{ formatTimezone(item.atd) }}</span>
               </div>
             </div>
             <div class="destination">
@@ -169,12 +169,12 @@ const { isOverflow: isDetailDestinationOverflow } = useOverflow(detailDestinatio
               <div class="eta">
                 <span class="font_family icon-icon_date_b"></span>
                 <span>ETA: </span>
-                <span class="value">{{ formatTimezoneByUser(item.eta) }}</span>
+                <span class="value">{{ formatTimezone(item.eta) }}</span>
               </div>
               <div class="ata">
                 <span class="font_family icon-icon_date_b"></span>
                 <span>ATA: </span>
-                <span class="value">{{ formatTimezoneByUser(item.ata) }}</span>
+                <span class="value">{{ formatTimezone(item.ata) }}</span>
               </div>
             </div>
           </div>

+ 3 - 9
src/views/Tracking/src/components/TrackingTable/src/TrackingTable.vue

@@ -9,6 +9,7 @@ import { transportationMode } from '@/components/transportationMode'
 import { useLoadingState } from '@/stores/modules/loadingState'
 import { useThemeStore } from '@/stores/modules/theme'
 import { useVisitedRowState } from '@/stores/modules/visitedRow'
+import { formatTimezone } from '@/utils/tools'
 
 const visitedRowState = useVisitedRowState()
 const themeStore = useThemeStore()
@@ -55,17 +56,10 @@ const handleColumns = (columns: any, status?: string) => {
       }
     }
     // 格式化
-    if (item.formatter === 'date') {
+    if (item.formatter === 'date' || item.formatter === 'dateTime') {
       curColumn = {
         ...curColumn,
-        formatter: ({ cellValue }: any) =>
-          cellValue ? dayjs(cellValue).format('MMM-DD-YYYY ') : '--'
-      }
-    } else if (item.formatter === 'dateTime') {
-      curColumn = {
-        ...curColumn,
-        formatter: ({ cellValue }: any) =>
-          cellValue ? dayjs(cellValue).format('MMM-DD-YYYY HH:mm:ss') : '--'
+        formatter: ({ cellValue }: any) => formatTimezone(cellValue)
       }
     }
     return curColumn

+ 11 - 13
src/views/Tracking/src/components/TrackingTable/src/components/VGMView.vue

@@ -1,8 +1,8 @@
 <script setup lang="ts">
-import dayjs from 'dayjs'
 import { useRoute, useRouter } from 'vue-router'
-import { autoWidth } from '@/utils/table'
+// import { autoWidth } from '@/utils/table'
 import { type VxeGridInstance, type VxeGridProps } from 'vxe-table'
+import { formatTimezone } from '@/utils/tools'
 
 const route = useRoute()
 const router = useRouter()
@@ -144,8 +144,7 @@ const handleColumns = (columns: any) => {
     if (item.edit_type === 'dateTime') {
       curColumn = {
         ...curColumn,
-        formatter: ({ cellValue }: any) =>
-          cellValue ? dayjs(cellValue).format('MMM-DD-YYYY HH:mm:ss') : '--'
+        formatter: ({ cellValue }: any) => formatTimezone(cellValue)
       }
     }
     return curColumn
@@ -181,11 +180,11 @@ const convertData = (data: any) => {
       },
       {
         label: 'ETD',
-        value: formatTime(data.ETD)
+        value: formatTimezone(data.ETD)
       },
       {
         label: 'ETA ',
-        value: formatTime(data.ETA)
+        value: formatTimezone(data.ETA)
       },
       {
         label: 'Last Updated User',
@@ -193,7 +192,7 @@ const convertData = (data: any) => {
       },
       {
         label: 'Last Updated Time',
-        value: formatTime(data?.['Last updated Time'])
+        value: formatTimezone(data?.['Last updated Time'])
       }
     ],
     formData: {
@@ -285,6 +284,10 @@ const isVerification = (value) => {
     }
   }
 }
+const formatRowTime = (time: any) => {
+  const result = formatTimezone(time)
+  return result === '--' ? '' : result
+}
 const handleSave = () => {
   generalInfo.value.formData.is_send && verificationData()
   if (
@@ -319,9 +322,7 @@ const handleSave = () => {
       if (item === '_X_ROW_KEY') return
       if (item === 'vgm_date' || item === 'vgm_time') {
         Object.assign(tableInfo, {
-          [item]: tableRowData.map((row) =>
-            row[item] ? dayjs(row[item]).format('YYYY-MM-DD HH:mm:ss') : ''
-          )
+          [item]: tableRowData.map((row) => formatRowTime(row[item]))
         })
         return
       }
@@ -348,9 +349,6 @@ const handleSave = () => {
     })
 }
 
-const formatTime = (time: string) => {
-  return time ? dayjs(time).format('MMM/DD/YYYY') : '--'
-}
 const stopScroll = (evt) => {
   evt = evt || window.event
   if (evt.preventDefault) {