Explorar o código

style: 修改时间的格式化,有时分秒才显示时区

zhouyuhao hai 1 ano
pai
achega
e134c14879

+ 15 - 9
src/components/ContainerStatus/src/ContainerStatus.vue

@@ -28,16 +28,21 @@ watch(
 
 const formatTimezone = (time: string, timezone: string) => {
   if (!time) return '--'
-
-  const formattedTime =
-    time.length > 12 ? dayjs(time).format('MMM-DD-YYYY hh:mm A') : dayjs(time).format('MMM-DD-YYYY')
-  let gmtOffset = ''
-  if (timezone && timezone.length > 3) {
-    const timeZoneOffset = dayjs().tz(timezone).format('Z')
-    // 替换 "+07:00" 为 "GMT+7"
-    gmtOffset = `(GMT${timeZoneOffset.slice(0, 3)})`
+  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
   }
-  return `${formattedTime} ${gmtOffset}`
 }
 </script>
 
@@ -162,6 +167,7 @@ const formatTimezone = (time: string, timezone: string) => {
         }
       }
       .right-country {
+        width: 94px;
         padding: 0 24px;
         line-height: 52px;
         font-weight: 700;

+ 14 - 7
src/views/Booking/src/components/BookingDetail/src/BookingDetail.vue

@@ -93,14 +93,21 @@ getData()
 
 const formatTimezone = (time: string, timezone: string) => {
   if (!time) return '--'
-  const formattedTime = dayjs(time).format('MMM-DD-YYYY')
-  let gmtOffset = ''
-  if (timezone && timezone.length > 3) {
-    const timeZoneOffset = dayjs().tz(timezone).format('Z')
-    // 替换 "+07:00" 为 "GMT+7"
-    gmtOffset = `(GMT${timeZoneOffset.slice(0, 3)})`
+  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
   }
-  return `${formattedTime} ${gmtOffset}`
 }
 
 const originRef = ref()

+ 2 - 1
src/views/Login/src/loginView.vue

@@ -235,9 +235,10 @@ const handleSendPassword = () => {
         if (data.msg === 'verifcation_error') {
           loginError.value.code = true
         }
+        getCode()
       }
     })
-    .finally(() => {
+    .catch(() => {
       getCode()
     })
 }

+ 14 - 10
src/views/Tracking/src/components/PublicTracking/src/components/MilestonesTable.vue

@@ -47,17 +47,21 @@ const handleColumns = (columns: any) => {
         ...curColumn,
         formatter: ({ cellValue, row }: any) => {
           if (!cellValue) return '--'
-          const formattedTime =
-            cellValue.length > 12
-              ? dayjs(cellValue).format('MMM-DD-YYYY hh:mm A')
-              : dayjs(cellValue).format('MMM-DD-YYYY')
-          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)})`
+          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
           }
-          return `${formattedTime} ${gmtOffset}`
         }
       }
     }

+ 14 - 7
src/views/Tracking/src/components/PublicTracking/src/components/PublicTrackingDetail.vue

@@ -70,14 +70,21 @@ if (Object.keys(sharedData).length === 0) {
 
 const formatTimezone = (time: string, timezone: string) => {
   if (!time) return '--'
-  const formattedTime = dayjs(time).format('MMM-DD-YYYY')
-  let gmtOffset = ''
-  if (timezone && timezone.length > 3) {
-    const timeZoneOffset = dayjs().tz(timezone).format('Z')
-    // 替换 "+07:00" 为 "GMT+7"
-    gmtOffset = `(GMT${timeZoneOffset.slice(0, 3)})`
+  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
   }
-  return `${formattedTime} ${gmtOffset}`
 }
 
 const originRef = ref()

+ 16 - 9
src/views/Tracking/src/components/TrackingDetail/src/TrackingDetail.vue

@@ -110,16 +110,23 @@ const getData = () => {
 }
 getData()
 
-const formatTimezone = (tiem: string, timezone: string) => {
-  if (!tiem) return '--'
-  const formattedTime = dayjs(tiem).format('MMM-DD-YYYY')
-  let gmtOffset = ''
-  if (timezone && timezone.length > 3) {
-    const timeZoneOffset = dayjs().tz(timezone).format('Z')
-    // 替换 "+07:00" 为 "GMT+7"
-    gmtOffset = `(GMT${timeZoneOffset.slice(0, 3)})`
+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
   }
-  return `${formattedTime} ${gmtOffset}`
 }
 
 const originRef = ref()

+ 15 - 10
src/views/Tracking/src/components/TrackingDetail/src/components/MilestonesTable.vue

@@ -47,17 +47,22 @@ const handleColumns = (columns: any) => {
         ...curColumn,
         formatter: ({ row, cellValue }: any) => {
           if (!cellValue) return '--'
-          const formattedTime =
-            cellValue.length > 12
-              ? dayjs(cellValue).format('MMM-DD-YYYY hh:mm A')
-              : dayjs(cellValue).format('MMM-DD-YYYY')
-          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)})`
+
+          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
           }
-          return `${formattedTime} ${gmtOffset}`
         }
       }
     }

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

@@ -51,7 +51,13 @@ watch(
 )
 
 const formatDate = (date: string) => {
-  return date ? dayjs(date).format('MMM-DD-YYYY HH:mm A') : '--'
+  if (!date) {
+    return '--'
+  } else {
+    return date.length > 12
+      ? dayjs(date).format('MMM-DD-YYYY hh:mm A')
+      : dayjs(date).format('MMM-DD-YYYY')
+  }
 }
 
 const basicOriginRef = ref()

+ 10 - 35
src/views/Tracking/src/components/TrackingTable/src/components/VGMView.vue

@@ -260,42 +260,17 @@ const verificationData = () => {
   if (!generalInfo.value.formData.is_send) {
     return
   }
-  if (
-    generalInfo.value.formData.Submitter === null ||
-    generalInfo.value.formData.Submitter === undefined ||
-    generalInfo.value.formData.Submitter === ''
-  ) {
-    isVerificationError.value.submitter = true
-  } else {
-    isVerificationError.value.submitter = false
-  }
-  if (
-    generalInfo.value.formData.signature === null ||
-    generalInfo.value.formData.signature === undefined ||
-    generalInfo.value.formData.signature === ''
-  ) {
-    isVerificationError.value.signature = true
-  } else {
-    isVerificationError.value.signature = false
-  }
-  if (
-    generalInfo.value.formData.authorized_email === null ||
-    generalInfo.value.formData.authorized_email === undefined ||
-    generalInfo.value.formData.authorized_email === ''
-  ) {
-    isVerificationError.value.authorized_email = true
-  } else {
-    isVerificationError.value.authorized_email = false
-  }
-  if (
-    generalInfo.value.formData.authorized_tel === null ||
-    generalInfo.value.formData.authorized_tel === undefined ||
-    generalInfo.value.formData.authorized_tel === ''
-  ) {
-    isVerificationError.value.authorized_tel = true
-  } else {
-    isVerificationError.value.authorized_tel = false
+
+  const checkField = (field, errorKey) => {
+    const fieldValue = generalInfo.value.formData[field]
+    isVerificationError.value[errorKey] =
+      fieldValue === null || fieldValue === undefined || fieldValue === ''
   }
+
+  checkField('Submitter', 'submitter')
+  checkField('signature', 'signature')
+  checkField('authorized_email', 'authorized_email')
+  checkField('authorized_tel', 'authorized_tel')
 }
 
 const isVerification = (value) => {