Browse Source

feat: 修改登录不同返回的UI,时区时间的修改

zhouyuhao 1 year ago
parent
commit
5479ce8144

+ 14 - 0
src/api/module/common.ts

@@ -40,6 +40,20 @@ export const changePwdByLogin = (params: any, config: any) => {
   )
   )
 }
 }
 
 
+/**
+ * 获取菜单列表
+ */
+export const getMenuList = (params: any, config: any) => {
+  return HttpAxios.get(
+    `${baseUrl}`,
+    {
+      action: 'main',
+      ...params
+    },
+    config
+  )
+}
+
 /**
 /**
  * 获取日志列
  * 获取日志列
  */
  */

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

@@ -3,6 +3,7 @@
 // @ts-nocheck
 // @ts-nocheck
 // noinspection JSUnusedGlobalSymbols
 // noinspection JSUnusedGlobalSymbols
 // Generated by unplugin-auto-import
 // Generated by unplugin-auto-import
+// biome-ignore lint: disable
 export {}
 export {}
 declare global {
 declare global {
   const $api: typeof import('@/api/index')['default']
   const $api: typeof import('@/api/index')['default']
@@ -68,6 +69,6 @@ declare global {
 // for type re-export
 // for type re-export
 declare global {
 declare global {
   // @ts-ignore
   // @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')
   import('vue')
 }
 }

+ 51 - 60
src/views/Layout/src/components/Menu/MenuView.vue

@@ -1,71 +1,62 @@
 <script setup lang="ts">
 <script setup lang="ts">
 import { useRoute, useRouter } from 'vue-router'
 import { useRoute, useRouter } from 'vue-router'
+import { useUserStore } from '@/stores/modules/user'
 
 
 const route = useRoute()
 const route = useRoute()
 const router = useRouter()
 const router = useRouter()
+const userStore = useUserStore()
 
 
 const isCollapse = defineModel<boolean>()
 const isCollapse = defineModel<boolean>()
-const menuList = [
-  {
-    index: '1',
-    label: 'Dashboard',
-    icon: 'icon_data_fill_b',
-    path: '/dashboard'
-  },
-  // {
-  //   index: '2',
-  //   label: 'Quote',
-  //   icon: 'icon_quote__fill_b',
-  //   path: '/booking/detail'
-  // },
-  {
-    index: '3',
-    label: 'Booking',
-    icon: 'icon_booking__fill_b',
-    path: '/booking'
-  },
-  {
-    index: '4',
-    label: 'Tracking',
-    icon: 'icon_tracking__fill_b',
-    path: '/tracking'
-  },
-  // {
-  //   index: '5',
-  //   label: 'Report',
-  //   icon: 'icon_report__fill_b',
-  //   path: '/tracking/detail'
-  // },
-  {
-    index: '6',
-    label: 'System Management',
-    icon: 'icon_system__management_fill_b',
-    type: 'list',
-    children: [
-      // {
-      //   index: '5-1',
-      //   label: 'Account Management',
-      //   path: '/public-tracking'
-      // },
-      // {
-      //   index: '5-2',
-      //   label: 'Permission Management',
-      //   path: '/public-tracking/detail'
-      // },
-      // {
-      //   index: '5-3',
-      //   label: 'System Configuration',
-      //   path: '/login'
-      // },
-      {
-        index: '5-4',
-        label: 'Operation Log',
-        path: '/Operationlog'
-      }
-    ]
-  }
-]
+// [
+//   {
+//     index: '1',
+//     label: 'Dashboard',
+//     icon: 'icon_data_fill_b',
+//     path: '/dashboard'
+//   },
+//   {
+//     index: '3',
+//     label: 'Booking',
+//     icon: 'icon_booking__fill_b',
+//     path: '/booking'
+//   },
+//   {
+//     index: '4',
+//     label: 'Tracking',
+//     icon: 'icon_tracking__fill_b',
+//     path: '/tracking'
+//   },
 
 
+//   {
+//     index: '6',
+//     label: 'System Management',
+//     icon: 'icon_system__management_fill_b',
+//     type: 'list',
+//     children: [
+//       {
+//         index: '5-4',
+//         label: 'Operation Log',
+//         path: '/Operationlog'
+//       }
+//     ]
+//   }
+// ]
+const menuList = ref()
+watch(
+  () => userStore.username,
+  () => {
+    getMenuList()
+  }
+)
+const getMenuList = () => {
+  $api.getMenuList().then((res) => {
+    if (res.code === 200) {
+      menuList.value = res.data
+    }
+  })
+  // return menuList
+}
+getMenuList()
 //监听窗口大小
 //监听窗口大小
 const handler = () => {
 const handler = () => {
   return (() => {
   return (() => {

+ 21 - 13
src/views/Login/src/loginView.vue

@@ -68,6 +68,7 @@ watch(status, () => {
     email: false,
     email: false,
     code: false
     code: false
   }
   }
+  isRememerPwd.value = false
   verificationCode.value = ''
   verificationCode.value = ''
   getCode()
   getCode()
 })
 })
@@ -166,10 +167,7 @@ const handleLogin = () => {
           loginError.value.code = true
           loginError.value.code = true
         } else if (data.msg === 'error_times') {
         } else if (data.msg === 'error_times') {
           errorTipsRef.value.openDialog()
           errorTipsRef.value.openDialog()
-        }
-      } else if (res.code === 500) {
-        const { data } = res
-        if (data.msg === 'passwordExpires') {
+        } else if (data.msg === 'passwordExpires') {
           ElMessageBox.alert('Password expired, please change your password', 'Prompt', {
           ElMessageBox.alert('Password expired, please change your password', 'Prompt', {
             confirmButtonText: 'OK',
             confirmButtonText: 'OK',
             type: 'warning',
             type: 'warning',
@@ -179,12 +177,6 @@ const handleLogin = () => {
           router.push({
           router.push({
             name: 'Reset Password'
             name: 'Reset Password'
           })
           })
-        } else {
-          ElMessageBox.alert(data.desc, {
-            confirmButtonText: 'OK',
-            type: 'warning',
-            confirmButtonClass: 'el-button--dark'
-          })
         }
         }
       }
       }
     })
     })
@@ -193,6 +185,21 @@ const handleLogin = () => {
     })
     })
 }
 }
 
 
+// 从忘记密码返回登录
+const backLogin = (emailTips: boolean) => {
+  status.value = 'login'
+  isEmailTips.value = emailTips
+  // 如果是成功忘记密码,清空保存的账号密码
+  // 如果是直接返回登录,获取保存的账号密码
+  setTimeout(() => {
+    if (emailTips) {
+      clearCredentials()
+    } else {
+      getCredentials()
+    }
+  }, 0)
+}
+
 const isUserNameExit = ref(false)
 const isUserNameExit = ref(false)
 
 
 const handleForgot = () => {
 const handleForgot = () => {
@@ -205,11 +212,12 @@ const handleSendPassword = () => {
   $api
   $api
     .forgotPassword({
     .forgotPassword({
       login: loginForm.value.username,
       login: loginForm.value.username,
-      email: loginForm.value.email
+      email: loginForm.value.email,
+      verifcation_code: loginForm.value.code
     })
     })
     .then((res: any) => {
     .then((res: any) => {
       if (res.code === 200) {
       if (res.code === 200) {
-        isEmailTips.value = true
+        backLogin(true)
       }
       }
     })
     })
 }
 }
@@ -375,7 +383,7 @@ const errorTipsRef = ref()
         <el-button @click="handleSendPassword" class="el-button--dark login-btn"
         <el-button @click="handleSendPassword" class="el-button--dark login-btn"
           >Send Password</el-button
           >Send Password</el-button
         >
         >
-        <div @click="status = 'login'" class="back-text">
+        <div @click="backLogin(false)" class="back-text">
           <span class="font_family icon-icon_back_b"></span>
           <span class="font_family icon-icon_back_b"></span>
           <span class="text"> Back to login</span>
           <span class="text"> Back to login</span>
         </div>
         </div>

+ 7 - 4
src/views/Tracking/src/components/PublicTracking/src/components/MilestonesTable.vue

@@ -41,13 +41,16 @@ const handleColumns = (columns: any) => {
     }
     }
 
 
     // 格式化
     // 格式化
-    if (item.type === 'dateTime') {
+    if (item.formatter === 'dateTime') {
       curColumn = {
       curColumn = {
         ...curColumn,
         ...curColumn,
         formatter: ({ cellValue, row }: any) => {
         formatter: ({ cellValue, row }: any) => {
-          return cellValue
-            ? dayjs(cellValue).tz(row.timezone).format('MMM-DD-YYYY hh:mm A (z)')
-            : '--'
+          if (!cellValue) return '--'
+          const formattedTime = dayjs(cellValue).format('MMM-DD-YYYY hh:mm A')
+          const timeZoneOffset = dayjs().tz(row.timezone).format('Z')
+          // 替换 "+07:00" 为 "GMT+7"
+          const gmtOffset = `GMT${timeZoneOffset.slice(0, 3)}`
+          return `${formattedTime} (${gmtOffset})`
         }
         }
       }
       }
     }
     }

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

@@ -122,7 +122,11 @@ const formatTime = (time: string) => {
         <div class="no">Tracking No. {{ allData?.transportInfo?.['Tracking No.'] }}</div>
         <div class="no">Tracking No. {{ allData?.transportInfo?.['Tracking No.'] }}</div>
         <VTag large type="Confirmed">{{ allData?.transportInfo?.status }}</VTag>
         <VTag large type="Confirmed">{{ allData?.transportInfo?.status }}</VTag>
         <div class="right-operation">
         <div class="right-operation">
-          <el-button type="default" @click="handleAMSISF">
+          <el-button
+            v-if="allData?.canViewAMSLog || allData?.canViewISFLog"
+            type="default"
+            @click="handleAMSISF"
+          >
             <span class="font_family icon-icon_log_b" style="margin-right: 4px"></span
             <span class="font_family icon-icon_log_b" style="margin-right: 4px"></span
             >AMS/ISF</el-button
             >AMS/ISF</el-button
           >
           >

+ 2 - 2
src/views/Tracking/src/components/TrackingDetail/src/components/AMS&ISF.vue

@@ -6,6 +6,8 @@ const drawer = ref(false)
 const openDrawer = (data: any) => {
 const openDrawer = (data: any) => {
   getData(data)
   getData(data)
   drawer.value = true
   drawer.value = true
+  canViewAMSLog.value = data.canViewISFLog
+  canViewISFLog.value = data.canViewAMSLog
 }
 }
 
 
 const canViewAMSLog = ref(false)
 const canViewAMSLog = ref(false)
@@ -41,8 +43,6 @@ const getData = (pageData: any) => {
         // 获取数据
         // 获取数据
         const data = res.data
         const data = res.data
         const { amsLog, isfLog } = res.data
         const { amsLog, isfLog } = res.data
-        canViewAMSLog.value = data.canViewAMSLog
-        canViewISFLog.value = data.canViewISFLog
         AMSTableData.value.columns = handleColumns(amsLog.amsLog_column)
         AMSTableData.value.columns = handleColumns(amsLog.amsLog_column)
         AMSTableData.value.data = amsLog.data
         AMSTableData.value.data = amsLog.data
         ISFTableData.value.columns = handleColumns(isfLog.isfLog_column)
         ISFTableData.value.columns = handleColumns(isfLog.isfLog_column)

+ 9 - 26
src/views/Tracking/src/components/TrackingDetail/src/components/AttachmentView.vue

@@ -13,28 +13,8 @@ const tableData = ref<VxeGridProps<any>>({
   maxHeight: 440,
   maxHeight: 440,
   border: true,
   border: true,
   round: true,
   round: true,
-  columns: [
-    {
-      field: 'fileType',
-      title: 'File Type',
-      minWidth: 120
-    },
-    {
-      field: 'fileName',
-      title: 'File',
-      minWidth: 80
-    },
-    {
-      title: 'Action',
-      width: 90,
-      slots: { default: 'action' }
-    }
-  ],
-  data: [
-    {
-      description: 'Description'
-    }
-  ],
+  columns: [],
+  data: [],
   scrollY: { enabled: true, oSize: 20, gt: 30 },
   scrollY: { enabled: true, oSize: 20, gt: 30 },
   stripe: true,
   stripe: true,
   emptyText: ' ',
   emptyText: ' ',
@@ -96,7 +76,12 @@ onMounted(() => {
   tableRef.value && autoWidth(tableData.value, tableRef.value)
   tableRef.value && autoWidth(tableData.value, tableRef.value)
 })
 })
 const handleDownload = (row: any) => {
 const handleDownload = (row: any) => {
-  const url = row.file?.url
+  // 如果from_system的值是TOPOCEAN_KSMART,不需要拼接url
+  const url =
+    row.from_system === 'TOPOCEAN_KSMART'
+      ? row.file?.url
+      : import.meta.env.VITE_API_HOST + '/' + row.file?.url
+  // const url = row.file?.url
   // 创建一个隐藏的 <a> 标签
   // 创建一个隐藏的 <a> 标签
   const link = document.createElement('a')
   const link = document.createElement('a')
   link.href = url
   link.href = url
@@ -109,9 +94,7 @@ const handleDownload = (row: any) => {
   link.click()
   link.click()
   document.body.removeChild(link)
   document.body.removeChild(link)
 }
 }
-const handleDelete = (row: any) => {
-  console.log('Delete', row)
-}
+const handleDelete = (row: any) => {}
 const uploadFilesRef = ref<InstanceType<typeof UploadFilesDialog> | null>(null)
 const uploadFilesRef = ref<InstanceType<typeof UploadFilesDialog> | null>(null)
 
 
 const openUploadFilesDialog = () => {
 const openUploadFilesDialog = () => {

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

@@ -1,5 +1,11 @@
 <script setup lang="ts">
 <script setup lang="ts">
 import dayjs from 'dayjs'
 import dayjs from 'dayjs'
+import timezone from 'dayjs/plugin/timezone'
+import utc from 'dayjs/plugin/utc'
+
+dayjs.extend(utc)
+dayjs.extend(timezone)
+
 import { type VxeGridInstance, type VxeGridProps } from 'vxe-table'
 import { type VxeGridInstance, type VxeGridProps } from 'vxe-table'
 import { autoWidth } from '@/utils/table'
 import { autoWidth } from '@/utils/table'
 import { useRowClickStyle } from '@/hooks/rowClickStyle'
 import { useRowClickStyle } from '@/hooks/rowClickStyle'
@@ -13,42 +19,8 @@ const tableData = ref<VxeGridProps<any>>({
   round: true,
   round: true,
   minHeight: 70,
   minHeight: 70,
   maxHeight: 500,
   maxHeight: 500,
-  columns: [
-    {
-      field: 'milestones',
-      title: 'Milestones',
-      minWidth: 120
-    },
-    {
-      field: 'dateTime',
-      title: 'Date Time',
-      minWidth: 80
-    },
-    {
-      field: 'locations',
-      title: 'Locations',
-      minWidth: 80
-    },
-    {
-      field: 'remarks',
-      title: 'Remarks',
-      minWidth: 80
-    }
-  ],
-  data: [
-    {
-      milestones: 'Milestone 1',
-      dateTime: 'Jun-08-2024 12:00 AM',
-      locations: 'Shenzhen',
-      remarks: 'Remarks 1'
-    },
-    {
-      milestones: 'Milestone 2',
-      dateTime: 'Jun-10-2024 12:00 AM',
-      locations: 'Valencia',
-      remarks: 'Remarks 2'
-    }
-  ],
+  columns: [],
+  data: [],
   scrollY: { enabled: true, oSize: 20, gt: 30 },
   scrollY: { enabled: true, oSize: 20, gt: 30 },
   stripe: true,
   stripe: true,
   emptyText: ' ',
   emptyText: ' ',
@@ -74,10 +46,13 @@ const handleColumns = (columns: any) => {
     if (item.formatter === 'dateTime') {
     if (item.formatter === 'dateTime') {
       curColumn = {
       curColumn = {
         ...curColumn,
         ...curColumn,
-        formatter: ({ cellValue, row }: any) => {
-          return cellValue
-            ? dayjs(cellValue).tz(row.timezone).format('MMM-DD-YYYY hh:mm A (z)')
-            : '--'
+        formatter: ({ row, cellValue }: any) => {
+          if (!cellValue) return '--'
+          const formattedTime = dayjs(cellValue).format('MMM-DD-YYYY hh:mm A')
+          const timeZoneOffset = dayjs().tz(row.timezone).format('Z')
+          // 替换 "+07:00" 为 "GMT+7"
+          const gmtOffset = `GMT${timeZoneOffset.slice(0, 3)}`
+          return `${formattedTime} (${gmtOffset})`
         }
         }
       }
       }
     }
     }

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

@@ -288,7 +288,7 @@ const handleSave = () => {
   $api
   $api
     .saveVGMData({
     .saveVGMData({
       serial_no: allData.value.serial_no,
       serial_no: allData.value.serial_no,
-      _schemas: allData.value.schemas,
+      schemas: allData.value.schemas,
       ...generalData,
       ...generalData,
       ...tableInfo
       ...tableInfo
     })
     })