소스 검색

Merge branch 'dev_zyh' of United_Software/k_online_ui into dev

Jack Zhou 1 년 전
부모
커밋
80dc7cb3cf

+ 2 - 2
src/router/index.ts

@@ -97,14 +97,14 @@ router.beforeEach(async (to, from, next) => {
   // 如果手动跳转登录页,清除登录信息
   if (to.path === '/login') {
     const userStore = useUserStore()
-    userStore.logout()
+    await userStore.logout()
   }
   // 未登录白名单
   const whiteList = ['/login', '/public-tracking', '/public-tracking/detail', '/reset-password']
   // 判断是否登录
   if (!whiteList.includes(to.path) && !localStorage.getItem('username')) {
     const userStore = useUserStore()
-    userStore.logout()
+    await userStore.logout()
     if (whiteList.includes(from.path)) {
       ElMessage.warning({
         message: 'Please log in to use this feature.',

+ 2 - 2
src/stores/modules/user.ts

@@ -13,9 +13,9 @@ export const useUserStore = defineStore('user', {
       localStorage.setItem('username', username)
       this.username = username
     },
-    logout(isNeedLogout: boolean = true) {
+    async logout(isNeedLogout: boolean = true) {
       if (isNeedLogout) {
-        $api.logout().then(() => {})
+        await $api.logout().then(() => {})
       }
       localStorage.removeItem('username')
       this.username = ''

+ 2 - 2
src/utils/axios.ts

@@ -45,8 +45,8 @@ class HttpAxios {
   }
 
   _requestInterceptors = (config: AxiosRequestConfig) => {
-    const _config = { timeout: this.timeout }
-    return { ...config, ..._config }
+    // const _config = { timeout: this.timeout }
+    // return { ...config, ..._config }
     return config
   }
   /**

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

@@ -1,5 +1,7 @@
 <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'
@@ -9,6 +11,8 @@ import { transportationMode } from '@/components/TransportationMode'
 import { useRoute } from 'vue-router'
 import { useOverflow } from '@/hooks/useOverflow'
 
+dayjs.extend(utc)
+dayjs.extend(timezone)
 const route = useRoute()
 
 // 可拖拽模块的列表
@@ -89,6 +93,14 @@ getData()
 const formatTime = (time: string) => {
   return time ? dayjs(time).format('MMM-DD-YYYY hh:mm A') : '--'
 }
+const formatTimezone = (tiem: string, timezone: string) => {
+  if (!tiem) return '--'
+  const formattedTime = dayjs(tiem).format('MMM-DD-YYYY hh:mm A')
+  const timeZoneOffset = dayjs().tz(timezone).format('Z')
+  // 替换 "+07:00" 为 "GMT+7"
+  const gmtOffset = `GMT${timeZoneOffset.slice(0, 3)}`
+  return `${formattedTime} (${gmtOffset})`
+}
 
 const originRef = ref()
 const destinationRef = ref()
@@ -115,7 +127,6 @@ const { isOverflow: isDestinationOverflow } = useOverflow(destinationRef, allDat
           <div class="origin">
             <div class="title">Origin</div>
             <div class="content">
-              <!-- <span>{{ allData?.transportInfo?.origin }}</span> -->
               <el-tooltip v-if="isOriginOverflow" placement="top">
                 <template #content>{{ allData?.transportInfo?.origin || '--' }}</template>
                 <span ref="originRef" class="info single-line-ellipsis">{{
@@ -281,6 +292,7 @@ const { isOverflow: isDestinationOverflow } = useOverflow(destinationRef, allDat
         }
       }
       .transport-way {
+        flex: 1 1 20%;
         display: flex;
         flex-direction: row;
         justify-content: flex-start;

+ 6 - 1
src/views/Booking/src/components/BookingTable/src/BookingTable.vue

@@ -138,7 +138,8 @@ const searchTableData = (data: any) => {
       if (res.code === 200) {
         bookingTable.value.data = res.data.searchData || []
         pageInfo.value.total = Number(res.data.rc)
-        tableLoading.value = false
+        tempSearch.value = res.data.tmp_search
+
         // 拥有所有字段的表格
         setTimeout(() => {
           allTable.value.columns = handleColumns(res.data.allColums, 'all')
@@ -150,6 +151,10 @@ const searchTableData = (data: any) => {
         }, 1000)
       }
     })
+    .finally(() => {
+      tableRef.value && autoWidth(bookingTable.value, tableRef.value)
+      tableLoadingTableData.value = false
+    })
 }
 
 onMounted(() => {

+ 0 - 3
src/views/Layout/src/components/Header/components/LogoutDialog.vue

@@ -1,6 +1,5 @@
 <script setup lang="ts">
 import { useRouter } from 'vue-router'
-import { useUserStore } from '@/stores/modules/user'
 
 const router = useRouter()
 const dialogVisible = ref(false)
@@ -9,10 +8,8 @@ const openDialog = () => {
   dialogVisible.value = true
 }
 
-const userStore = useUserStore()
 const handleLogout = () => {
   dialogVisible.value = false
-  userStore.logout()
   router.push('/login')
   sessionStorage.clear()
 }

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

@@ -225,6 +225,7 @@ const { isOverflow: isDestinationOverflow } = useOverflow(destinationRef, allDat
         }
       }
       .transport-way {
+        flex: 1 1 20%;
         display: flex;
         flex-direction: row;
         justify-content: flex-start;

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

@@ -356,6 +356,7 @@ const { isOverflow: isDestinationOverflow } = useOverflow(destinationRef, allDat
         }
       }
       .transport-way {
+        flex: 1 1 20%;
         display: flex;
         flex-direction: row;
         justify-content: flex-start;

+ 22 - 10
src/views/Tracking/src/components/TrackingTable/src/TrackingTable.vue

@@ -133,7 +133,7 @@ const getSharedTableData = () => {
   return false
 }
 
-const getTableData = async (isInit: boolean, isPageChange?: boolean) => {
+const getTableData = async (isPageChange?: boolean) => {
   const rc = isPageChange ? pageInfo.value.total : -1
   tableLoadingTableData.value = true
 
@@ -184,8 +184,8 @@ const getTableData = async (isInit: boolean, isPageChange?: boolean) => {
         if (res.code === 200) {
           trackingTable.value.data = res.data.searchData || []
           pageInfo.value.total = Number(res.data.rc)
-
           tempSearch.value = res.data.tmp_search
+
           if (res.data.canEdiVgm && trackingTable.value.columns.length > 0) {
             const index = trackingTable.value.columns.findIndex(
               (item: any) => item.title === 'Action'
@@ -212,10 +212,8 @@ const getTableData = async (isInit: boolean, isPageChange?: boolean) => {
       })
   }
   nextTick(() => {
-    if (!isInit) {
-      tableRef.value && autoWidth(trackingTable.value, tableRef.value)
-      tableLoadingTableData.value = false
-    }
+    tableRef.value && autoWidth(trackingTable.value, tableRef.value)
+    tableLoadingTableData.value = false
   })
 }
 
@@ -235,8 +233,21 @@ const searchTableData = (data: any) => {
       if (res.code === 200) {
         trackingTable.value.data = res.data.searchData
         pageInfo.value.total = Number(res.data.rc)
-        tableLoading.value = false
-
+        tempSearch.value = res.data.tmp_search
+
+        if (res.data.canEdiVgm && trackingTable.value.columns.length > 0) {
+          const index = trackingTable.value.columns.findIndex(
+            (item: any) => item.title === 'Action'
+          )
+          if (index === -1) {
+            trackingTable.value.columns.push({
+              title: 'Action',
+              fixed: 'right',
+              width: 80,
+              slots: { default: 'action' }
+            })
+          }
+        }
         // 拥有所有字段的表格
         setTimeout(() => {
           allTable.value.columns = handleColumns(res.data.allColums, 'all')
@@ -248,6 +259,7 @@ const searchTableData = (data: any) => {
       }
     })
     .finally(() => {
+      tableRef.value && autoWidth(trackingTable.value, tableRef.value)
       tableLoadingTableData.value = false
     })
 }
@@ -577,8 +589,8 @@ defineExpose({
           background
           layout="sizes, prev, pager, next"
           :total="pageInfo.total"
-          @size-change="getTableData(false, true)"
-          @current-change="getTableData(false, true)"
+          @size-change="getTableData(true)"
+          @current-change="getTableData(true)"
         />
       </div>
     </div>