ソースを参照

feat: 修改total值的格式化

zhouyuhao 9 ヶ月 前
コミット
17ffcfe411

+ 2 - 1
src/components/SelectTable/src/SelectTable.vue

@@ -2,6 +2,7 @@
 import _ from 'lodash'
 import { reactive, ref, onMounted, watch } from 'vue'
 import { ElMessage } from 'element-plus'
+import { formatNumber } from '@/utils/tools'
 
 const emit = defineEmits(['check', 'input'])
 const props = defineProps({
@@ -244,7 +245,7 @@ const onInput = () => {
         <el-table-column property="uncode" label="Uncode" />
       </el-table>
       <div class="pagination">
-        <span>Total {{ state.total }}</span>
+        <span>Total {{ formatNumber(state.total) }}</span>
         <el-pagination
           v-model:currentPage="state.currentPage"
           v-model:page-size="state.pageSize"

+ 1 - 0
src/utils/tools.ts

@@ -67,6 +67,7 @@ export const isEuropean = () => {
  * @param isEuropean - 是否为欧洲地区
  */
 export const formatNumber = (number: number, digits?: number): string => {
+  if (isNaN(number)) return '0'
   const userLanguage = userStore.userInfo?.numbers_format === 'European' ? 'de-DE' : 'zh-CN'
 
   // 设置数字格式化的选项

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

@@ -537,7 +537,7 @@ defineExpose({
     </vxe-grid>
     <vxe-grid :height="10" ref="allTableRef" class="all-table" v-bind="allTable"> </vxe-grid>
     <div class="bottom-pagination">
-      <div class="left-total-records">Total {{ pageInfo.total }}</div>
+      <div class="left-total-records">Total {{ formatNumber(pageInfo.total) }}</div>
       <div class="right-pagination">
         <el-pagination
           v-model:current-page="pageInfo.pageNo"

+ 2 - 1
src/views/Dashboard/src/DashboardView.vue

@@ -12,6 +12,7 @@ import TopMap from './components/TopMap.vue'
 import DashFilters from './components/DashFiters.vue'
 import { useRouter } from 'vue-router'
 import { ElMessage } from 'element-plus'
+import { formatNumber } from '@/utils/tools'
 
 const router = useRouter()
 const activeName = ref('first')
@@ -1163,7 +1164,7 @@ const ClickParams = (val: any) => {
               <template #content>
                 <RecentStatus :RecentStatusList="RecentStatusList"></RecentStatus>
                 <div class="pagination">
-                  <span>Total {{ pageInfo.total }}</span>
+                  <span>Total {{ formatNumber(pageInfo.total) }}</span>
                   <el-pagination
                     v-model:current-page="pageInfo.pageNo"
                     v-model:page-size="pageInfo.pageSize"

+ 5 - 1
src/views/Dashboard/src/components/BarChart.vue

@@ -106,7 +106,11 @@ const initOption = reactive({
           '</div>'
       })
       allnum = allnum.toFixed(2)
-      str += '<div style= ' + 'color:#FFF;font-family: Lato-Light>Total: ' + allnum + '</div>'
+      str +=
+        '<div style= ' +
+        'color:#FFF;font-family: Lato-Light>Total: ' +
+        formatNumber(allnum) +
+        '</div>'
       return str
     },
     textStyle: {

+ 7 - 3
src/views/Dashboard/src/components/RevenueChart.vue

@@ -159,7 +159,7 @@ const exportData = ({ filename }: any) => {
 const initOption = reactive({
   //标题
   title: {
-    text: bar_title.value || 'Total:', //主标题
+    text: bar_title.value || 'Total: 0', //主标题
     left: 19,
     top: 9.5,
     textStyle: {
@@ -203,7 +203,11 @@ const initOption = reactive({
           '</div>'
       })
       allnum = allnum.toFixed(2)
-      str += '<div style= ' + 'color:#FFF;font-family: Lato-Light>Total: ' + allnum + '</div>'
+      str +=
+        '<div style= ' +
+        'color:#FFF;font-family: Lato-Light>Total: ' +
+        formatNumber(allnum) +
+        '</div>'
       return str
     },
     textStyle: {
@@ -346,7 +350,7 @@ const initChart = () => {
       initOption.series.forEach((item: any, index: any) => {
         if (item.name == Object.keys(trueObj)) {
           initOption.series[index].label.show = true
-          initOption.title.text = `Total: ${initOption.series[index].total}`
+          initOption.title.text = `Total: ${formatNumber(initOption.series[index].total)}`
         }
       })
     } else {

+ 2 - 2
src/views/OperationLog/src/components/BookingTable/src/BookingTable.vue

@@ -6,7 +6,7 @@ import DownloadDialog from './components/DownloadDialog.vue'
 import { useRowClickStyle } from '@/hooks/rowClickStyle'
 import dayjs from 'dayjs'
 import { useThemeStore } from '@/stores/modules/theme'
-import { formatTimezone } from '@/utils/tools'
+import { formatTimezone, formatNumber } from '@/utils/tools'
 
 const themeStore = useThemeStore()
 
@@ -384,7 +384,7 @@ defineExpose({
     </vxe-grid>
     <vxe-grid :height="10" ref="allTableRef" class="all-table" v-bind="allTable"> </vxe-grid>
     <div class="bottom-pagination">
-      <div class="left-total-records">Total {{ pageInfo.total }}</div>
+      <div class="left-total-records">Total {{ formatNumber(pageInfo.total) }}</div>
       <div class="right-pagination">
         <el-pagination
           v-model:current-page="pageInfo.pageNo"

+ 2 - 2
src/views/SystemSettings/src/components/MonitoringTable/src/MonitoringTable.vue

@@ -1,7 +1,7 @@
 <script setup lang="ts">
 import { type VxeGridInstance, type VxeGridProps } from 'vxe-table'
 import { useRowClickStyle } from '@/hooks/rowClickStyle'
-import { formatTimezone } from '@/utils/tools'
+import { formatTimezone, formatNumber } from '@/utils/tools'
 import { ref, onMounted } from 'vue'
 import { useRouter } from 'vue-router'
 
@@ -201,7 +201,7 @@ onMounted(() => {
     </vxe-grid>
   </div>
   <div class="pagination">
-    <span>Total {{ pageInfo.total }}</span>
+    <span>Total {{ formatNumber(pageInfo.total) }}</span>
     <el-pagination
       v-model:current-page="pageInfo.pageNo"
       v-model:page-size="pageInfo.pageSize"

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

@@ -671,7 +671,7 @@ defineExpose({
     </vxe-grid>
     <vxe-grid :height="10" ref="allTableRef" class="all-table" v-bind="allTable"> </vxe-grid>
     <div class="bottom-pagination">
-      <div class="left-total-records">Total {{ pageInfo.total }}</div>
+      <div class="left-total-records">Total {{ formatNumber(pageInfo.total) }}</div>
       <div class="right-pagination">
         <el-pagination
           v-model:current-page="pageInfo.pageNo"

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

@@ -4,6 +4,7 @@ import { useRoute, useRouter } from 'vue-router'
 import { type VxeGridInstance, type VxeGridProps } from 'vxe-table'
 import { formatTimezone } from '@/utils/tools'
 import { useUserStore } from '@/stores/modules/user'
+import dayjs from 'dayjs'
 
 const userStore = useUserStore()
 const datePickerFormat = `${userStore.dateFormat} HH:mm:ss`
@@ -288,7 +289,7 @@ const isVerification = (value) => {
   }
 }
 const formatRowTime = (time: any) => {
-  const result = formatTimezone(time)
+  const result = dayjs(time).format('YYYY-MM-DD HH:mm:ss')
   return result === '--' ? '' : result
 }
 const handleSave = () => {