fix: 格式化时间
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 5m44s

This commit is contained in:
luo
2026-09-08 14:33:59 +08:00
parent 01cddd7eda
commit 65cc63674e
3 changed files with 93 additions and 38 deletions

View File

@@ -118,13 +118,13 @@
label="实名时间"
label-class-name="asset-label asset-label--realname-time"
>{{
cardInfo?.real_name_at ? formatDateTime(cardInfo.real_name_at) : '-'
cardInfo?.real_name_at ? formatAssetInfoTime(cardInfo.real_name_at) : '-'
}}</ElDescriptionsItem
>
<ElDescriptionsItem
label="实名同步时间"
label-class-name="asset-label asset-label--realname-sync"
>{{ formatDateTime(cardInfo?.last_real_name_check_at) || '-' }}</ElDescriptionsItem
>{{ formatAssetInfoTime(cardInfo?.last_real_name_check_at) }}</ElDescriptionsItem
>
<ElDescriptionsItem
@@ -143,12 +143,12 @@
<ElDescriptionsItem
label="卡状态同步时间"
label-class-name="asset-label asset-label--card-sync"
>{{ formatDateTime(cardInfo?.last_card_status_check_at) || '-' }}</ElDescriptionsItem
>{{ formatAssetInfoTime(cardInfo?.last_card_status_check_at) }}</ElDescriptionsItem
>
<ElDescriptionsItem
label="流量同步时间"
label-class-name="asset-label asset-label--traffic-sync"
>{{ formatDateTime(cardInfo?.last_data_check_at) || '-' }}</ElDescriptionsItem
>{{ formatAssetInfoTime(cardInfo?.last_data_check_at) }}</ElDescriptionsItem
>
<ElDescriptionsItem
@@ -256,7 +256,7 @@
label-class-name="asset-label asset-label--realname-time"
>{{
selectedDeviceStatusCard?.real_name_at
? formatDateTime(selectedDeviceStatusCard.real_name_at)
? formatAssetInfoTime(selectedDeviceStatusCard.real_name_at)
: '-'
}}</ElDescriptionsItem
>
@@ -467,7 +467,11 @@
<div class="binding-card-field">
<span class="binding-card-field-label">实名时间</span>
<span class="binding-card-field-value">
{{ bindingCard.real_name_at ? formatDateTime(bindingCard.real_name_at) : '-' }}
{{
bindingCard.real_name_at
? formatAssetInfoTime(bindingCard.real_name_at)
: '-'
}}
</span>
</div>
<div class="binding-card-field">
@@ -995,19 +999,19 @@
{
key: 'realname',
label: '实名同步时间',
value: formatDateTime(props.cardInfo?.last_real_name_check_at) || '-',
value: formatAssetInfoTime(props.cardInfo?.last_real_name_check_at),
icon: 'realname-sync'
},
{
key: 'cardSync',
label: '卡状态同步时间',
value: formatDateTime(props.cardInfo?.last_card_status_check_at) || '-',
value: formatAssetInfoTime(props.cardInfo?.last_card_status_check_at),
icon: 'card-sync'
},
{
key: 'trafficSync',
label: '流量同步时间',
value: formatDateTime(props.cardInfo?.last_data_check_at) || '-',
value: formatAssetInfoTime(props.cardInfo?.last_data_check_at),
icon: 'traffic-sync'
},
{
@@ -1140,6 +1144,34 @@
return formatDataSize(value)
}
/**
* 接口中的这几项时间以其原始文本为基准直接加 8 小时;时区后缀不参与换算。
* 例如 2026-08-06T11:54:26.693382+08:00 显示为 2026-08-06 19:54:26。
*/
const formatAssetInfoTime = (value?: string | null) => {
if (!value?.trim()) return '-'
const timeText = value.trim()
const match = timeText.match(
/^(\d{4})-(\d{2})-(\d{2})(?:T|\s)(\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?$/i
)
if (!match) return '-'
const [, year, month, day, hours, minutes, seconds = '00'] = match
const date = new Date(
Date.UTC(
Number(year),
Number(month) - 1,
Number(day),
Number(hours) + 8,
Number(minutes),
Number(seconds)
)
)
return formatDateTime(date)
}
// 处理轮询开关变化
const handlePollingChange = (value: string | number | boolean) => {
emit('update:pollingEnabled', Boolean(value))

View File

@@ -238,7 +238,10 @@
<span style="font-weight: bold; color: #409eff">{{ selectedDevices.length }}</span>
</ElFormItem>
<ElFormItem label="选设备方式" prop="selection_type">
<ElRadioGroup v-model="seriesBindingForm.selection_type">
<ElRadioGroup
v-model="seriesBindingForm.selection_type"
@change="handleDeviceBatchSelectionTypeChange"
>
<ElRadio label="list">设备ID列表</ElRadio>
<ElRadio label="range">设备号范围</ElRadio>
<ElRadio label="filter">筛选条件</ElRadio>
@@ -736,7 +739,10 @@
</ElSelect>
</ElFormItem>
<ElFormItem label="选设备方式" prop="selection_type">
<ElRadioGroup v-model="enterpriseDeviceAuthorizeForm.selection_type">
<ElRadioGroup
v-model="enterpriseDeviceAuthorizeForm.selection_type"
@change="handleDeviceBatchSelectionTypeChange"
>
<ElRadio label="list">设备号列表</ElRadio>
<ElRadio label="filter">筛选条件</ElRadio>
</ElRadioGroup>
@@ -842,7 +848,10 @@
</ElSelect>
</ElFormItem>
<ElFormItem label="选设备方式" prop="selection_type">
<ElRadioGroup v-model="enterpriseDeviceRecallForm.selection_type">
<ElRadioGroup
v-model="enterpriseDeviceRecallForm.selection_type"
@change="handleDeviceBatchSelectionTypeChange"
>
<ElRadio label="list">设备号列表</ElRadio>
<ElRadio label="filter">筛选条件</ElRadio>
</ElRadioGroup>
@@ -1355,7 +1364,7 @@
// 搜索表单
const searchForm = reactive<Record<string, any>>({ ...initialSearchState })
// 搜索批次号(用于搜索表单)
// 批次号仅在用户切换至筛选条件或输入批次号搜索时加载。
const loadSearchBatchNoOptions = async (batchNo?: string) => {
try {
const params: any = {
@@ -1374,11 +1383,14 @@
}
}
// 搜索批次号
const handleSearchBatchNo = (query: string) => {
if (query) {
loadSearchBatchNoOptions(query)
} else {
loadSearchBatchNoOptions(query || undefined)
}
const handleDeviceBatchSelectionTypeChange = (
selectionType: string | number | boolean | undefined
) => {
if (selectionType === DeviceSelectionType.FILTER) {
loadSearchBatchNoOptions()
}
}
@@ -2517,7 +2529,6 @@
resetEnterpriseDeviceAuthorizeForm()
await Promise.all([
handleSearchEnterprise(),
loadSearchBatchNoOptions(),
loadTopLevelShopCascadeOptions()
])
enterpriseDeviceAuthorizeDialogVisible.value = true
@@ -2526,7 +2537,7 @@
const showEnterpriseDeviceRecallDialog = async () => {
resetEnterpriseDeviceRecallForm()
await Promise.all([handleSearchEnterprise(), loadSearchBatchNoOptions()])
await handleSearchEnterprise()
enterpriseDeviceRecallDialogVisible.value = true
enterpriseDeviceRecallFormRef.value?.clearValidate()
}
@@ -2667,7 +2678,7 @@
selection_type:
selectedDevices.value.length > 0 ? DeviceSelectionType.LIST : DeviceSelectionType.FILTER
})
await Promise.all([loadPackageSeriesList(), loadSearchBatchNoOptions()])
await loadPackageSeriesList()
seriesBindingDialogVisible.value = true
seriesBindingFormRef.value?.clearValidate()
}

View File

@@ -119,7 +119,10 @@
/>
</ElFormItem>
<ElFormItem label="选卡方式" prop="selection_type">
<ElRadioGroup v-model="allocateForm.selection_type">
<ElRadioGroup
v-model="allocateForm.selection_type"
@change="handleCardBatchSelectionTypeChange"
>
<ElRadio label="list">ICCID列表</ElRadio>
<ElRadio label="range">号段范围</ElRadio>
<ElRadio label="filter">筛选条件</ElRadio>
@@ -246,7 +249,10 @@
>
<ElForm ref="recallFormRef" :model="recallForm" :rules="recallRules" label-width="100px">
<ElFormItem label="选卡方式" prop="selection_type">
<ElRadioGroup v-model="recallForm.selection_type">
<ElRadioGroup
v-model="recallForm.selection_type"
@change="handleCardBatchSelectionTypeChange"
>
<ElRadio label="list">ICCID列表</ElRadio>
<ElRadio label="range">号段范围</ElRadio>
<ElRadio label="filter">筛选条件</ElRadio>
@@ -415,7 +421,10 @@
</ElSelect>
</ElFormItem>
<ElFormItem label="选卡方式" prop="selection_type">
<ElRadioGroup v-model="enterpriseCardAuthorizeForm.selection_type">
<ElRadioGroup
v-model="enterpriseCardAuthorizeForm.selection_type"
@change="handleCardBatchSelectionTypeChange"
>
<ElRadio label="list">ICCID列表</ElRadio>
<ElRadio label="range">号段范围</ElRadio>
<ElRadio label="filter">筛选条件</ElRadio>
@@ -568,7 +577,10 @@
</ElSelect>
</ElFormItem>
<ElFormItem label="选卡方式" prop="selection_type">
<ElRadioGroup v-model="enterpriseCardRecallForm.selection_type">
<ElRadioGroup
v-model="enterpriseCardRecallForm.selection_type"
@change="handleCardBatchSelectionTypeChange"
>
<ElRadio label="list">ICCID列表</ElRadio>
<ElRadio label="range">号段范围</ElRadio>
<ElRadio label="filter">筛选条件</ElRadio>
@@ -739,7 +751,10 @@
label-width="100"
>
<ElFormItem label="选卡方式" prop="selection_type">
<ElRadioGroup v-model="seriesBindingForm.selection_type">
<ElRadioGroup
v-model="seriesBindingForm.selection_type"
@change="handleCardBatchSelectionTypeChange"
>
<ElRadio label="list">ICCID列表</ElRadio>
<ElRadio label="range">号段范围</ElRadio>
<ElRadio label="filter">筛选条件</ElRadio>
@@ -1338,10 +1353,9 @@
}
}
// 批量分配对话框批次号选项
// 批次号仅在用户切换至筛选条件时加载;避免弹窗打开即请求导入任务列表。
const allocateBatchNoOptions = ref<any[]>([])
// 加载批量分配对话框批次号选项
const loadAllocateBatchNoOptions = async (batchNo?: string) => {
try {
const params: any = {
@@ -1360,11 +1374,14 @@
}
}
// 搜索批量分配对话框批次号
const handleSearchAllocateBatchNo = (query: string) => {
if (query) {
loadAllocateBatchNoOptions(query)
} else {
loadAllocateBatchNoOptions(query || undefined)
}
const handleCardBatchSelectionTypeChange = (
selectionType: string | number | boolean | undefined
) => {
if (selectionType === CardSelectionType.FILTER) {
loadAllocateBatchNoOptions()
}
}
@@ -2481,7 +2498,6 @@
remark: ''
})
loadAllocateCarrierOptions()
loadAllocateBatchNoOptions()
if (allocateFormRef.value) {
allocateFormRef.value.resetFields()
}
@@ -2507,7 +2523,6 @@
recallFormRef.value.resetFields()
}
loadAllocateCarrierOptions()
loadAllocateBatchNoOptions()
}
// 关闭批量分配对话框
@@ -2677,7 +2692,6 @@
await Promise.all([
handleSearchEnterprise(),
loadAllocateCarrierOptions(),
loadAllocateBatchNoOptions(),
loadTopLevelShopCascadeOptions()
])
enterpriseCardAuthorizeDialogVisible.value = true
@@ -2688,8 +2702,7 @@
resetEnterpriseCardRecallForm()
await Promise.all([
handleSearchEnterprise(),
loadAllocateCarrierOptions(),
loadAllocateBatchNoOptions()
loadAllocateCarrierOptions()
])
enterpriseCardRecallDialogVisible.value = true
enterpriseCardRecallFormRef.value?.clearValidate()
@@ -2812,8 +2825,7 @@
})
await Promise.all([
loadPackageSeriesList(),
loadAllocateCarrierOptions(),
loadAllocateBatchNoOptions()
loadAllocateCarrierOptions()
])
seriesBindingDialogVisible.value = true
seriesBindingFormRef.value?.clearValidate()