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="实名时间"
label-class-name="asset-label asset-label--realname-time" 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
> >
<ElDescriptionsItem <ElDescriptionsItem
label="实名同步时间" label="实名同步时间"
label-class-name="asset-label asset-label--realname-sync" 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 <ElDescriptionsItem
@@ -143,12 +143,12 @@
<ElDescriptionsItem <ElDescriptionsItem
label="卡状态同步时间" label="卡状态同步时间"
label-class-name="asset-label asset-label--card-sync" 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 <ElDescriptionsItem
label="流量同步时间" label="流量同步时间"
label-class-name="asset-label asset-label--traffic-sync" label-class-name="asset-label asset-label--traffic-sync"
>{{ formatDateTime(cardInfo?.last_data_check_at) || '-' }}</ElDescriptionsItem >{{ formatAssetInfoTime(cardInfo?.last_data_check_at) }}</ElDescriptionsItem
> >
<ElDescriptionsItem <ElDescriptionsItem
@@ -256,7 +256,7 @@
label-class-name="asset-label asset-label--realname-time" label-class-name="asset-label asset-label--realname-time"
>{{ >{{
selectedDeviceStatusCard?.real_name_at selectedDeviceStatusCard?.real_name_at
? formatDateTime(selectedDeviceStatusCard.real_name_at) ? formatAssetInfoTime(selectedDeviceStatusCard.real_name_at)
: '-' : '-'
}}</ElDescriptionsItem }}</ElDescriptionsItem
> >
@@ -467,7 +467,11 @@
<div class="binding-card-field"> <div class="binding-card-field">
<span class="binding-card-field-label">实名时间</span> <span class="binding-card-field-label">实名时间</span>
<span class="binding-card-field-value"> <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> </span>
</div> </div>
<div class="binding-card-field"> <div class="binding-card-field">
@@ -995,19 +999,19 @@
{ {
key: 'realname', key: 'realname',
label: '实名同步时间', label: '实名同步时间',
value: formatDateTime(props.cardInfo?.last_real_name_check_at) || '-', value: formatAssetInfoTime(props.cardInfo?.last_real_name_check_at),
icon: 'realname-sync' icon: 'realname-sync'
}, },
{ {
key: 'cardSync', key: 'cardSync',
label: '卡状态同步时间', label: '卡状态同步时间',
value: formatDateTime(props.cardInfo?.last_card_status_check_at) || '-', value: formatAssetInfoTime(props.cardInfo?.last_card_status_check_at),
icon: 'card-sync' icon: 'card-sync'
}, },
{ {
key: 'trafficSync', key: 'trafficSync',
label: '流量同步时间', label: '流量同步时间',
value: formatDateTime(props.cardInfo?.last_data_check_at) || '-', value: formatAssetInfoTime(props.cardInfo?.last_data_check_at),
icon: 'traffic-sync' icon: 'traffic-sync'
}, },
{ {
@@ -1140,6 +1144,34 @@
return formatDataSize(value) 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) => { const handlePollingChange = (value: string | number | boolean) => {
emit('update:pollingEnabled', Boolean(value)) emit('update:pollingEnabled', Boolean(value))

View File

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

View File

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