fix: some
Some checks failed
构建并部署前端到测试环境 / build-and-deploy (push) Failing after 28m40s

This commit is contained in:
luo
2026-09-18 18:11:53 +08:00
parent 5e7f5eaba4
commit 08889d2e42
55 changed files with 2888 additions and 414 deletions

View File

@@ -478,8 +478,8 @@
old_asset_keyword: '',
new_asset_keyword: '',
created_at_range: [],
created_at_start: '',
created_at_end: ''
start_time: '',
end_time: ''
})
const exportQuery = computed(() => {
@@ -489,8 +489,8 @@
flow_type: searchForm.flow_type,
old_asset_keyword: searchForm.old_asset_keyword || undefined,
new_asset_keyword: searchForm.new_asset_keyword || undefined,
created_at_start: startDate || searchForm.created_at_start || undefined,
created_at_end: endDate || searchForm.created_at_end || undefined
start_time: startDate || searchForm.start_time || undefined,
end_time: endDate || searchForm.end_time || undefined
}
})
@@ -1059,11 +1059,11 @@
if (searchForm.new_asset_keyword) {
params.new_asset_keyword = searchForm.new_asset_keyword
}
if (searchForm.created_at_start) {
params.created_at_start = searchForm.created_at_start
if (searchForm.start_time) {
params.start_time = searchForm.start_time
}
if (searchForm.created_at_end) {
params.created_at_end = searchForm.created_at_end
if (searchForm.end_time) {
params.end_time = searchForm.end_time
}
const res = await ExchangeService.getExchanges(params)
@@ -1082,11 +1082,11 @@
const handleSearch = () => {
// 处理日期范围
if (searchForm.created_at_range && Array.isArray(searchForm.created_at_range)) {
searchForm.created_at_start = searchForm.created_at_range[0] || ''
searchForm.created_at_end = searchForm.created_at_range[1] || ''
searchForm.start_time = searchForm.created_at_range[0] || ''
searchForm.end_time = searchForm.created_at_range[1] || ''
} else {
searchForm.created_at_start = ''
searchForm.created_at_end = ''
searchForm.start_time = ''
searchForm.end_time = ''
}
pagination.page = 1
loadExchangeList()
@@ -1097,8 +1097,8 @@
searchForm.old_asset_keyword = ''
searchForm.new_asset_keyword = ''
searchForm.created_at_range = []
searchForm.created_at_start = ''
searchForm.created_at_end = ''
searchForm.start_time = ''
searchForm.end_time = ''
pagination.page = 1
loadExchangeList()
}

View File

@@ -21,6 +21,13 @@
临期资产 {{ summary.total_count }} 条(卡 {{ summary.card_count }},设备
{{ summary.device_count }}),0-3 天资产优先显示。
</div>
<ElTag v-if="exportTask" :type="exportStatusType" class="export-status-tag">
{{ exportTask.status_name || '处理中' }}
</ElTag>
<ElButton v-if="canDownload" type="success" link @click="downloadExport">
下载
</ElButton>
<ElButton type="primary" :loading="exporting" @click="handleExport">导出</ElButton>
</template>
</ArtTableHeader>
@@ -49,17 +56,20 @@
import { h, onMounted, reactive, ref, computed } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { ElButton, ElMessage, ElTag } from 'element-plus'
import { AssetService, PackageManageService, ShopService } from '@/api/modules'
import type {
ExpiringAssetItem,
ExpiringAssetSummary,
ExpiringAssetType,
ExpiringAssetQueryParams,
PackageResponse,
ShopResponse
import { AssetService, ExportTaskService, PackageManageService, ShopService } from '@/api/modules'
import {
ExportTaskStatus,
type ExpiringAssetItem,
type ExpiringAssetSummary,
type ExpiringAssetType,
type ExpiringAssetQueryParams,
type ExportTaskDetail,
type PackageResponse,
type ShopResponse
} from '@/types/api'
import type { SearchFormItem } from '@/types'
import { RoutesAlias } from '@/router/routesAlias'
import { useAsyncTaskPolling } from '@/composables/useAsyncTaskPolling'
import { useCheckedColumns } from '@/composables/useCheckedColumns'
import { formatDateTime } from '@/utils/business/format'
@@ -69,6 +79,7 @@
const route = useRoute()
const tableRef = ref()
const loading = ref(false)
const exporting = ref(false)
const shopLoading = ref(false)
const packageLoading = ref(false)
const shopOptions = ref<ShopResponse[]>([])
@@ -87,8 +98,8 @@
package_id: undefined,
days_min: undefined,
days_max: undefined,
expires_from: undefined,
expires_to: undefined,
start_time: undefined,
end_time: undefined,
expires_range: []
})
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
@@ -290,37 +301,41 @@
}
])
const toInteger = (value: unknown) => {
if (value === undefined || value === null || value === '') return undefined
const numberValue = Number(value)
return Number.isInteger(numberValue) ? numberValue : undefined
}
const buildFilterParams = (includePagination = true): ExpiringAssetQueryParams => {
const params: ExpiringAssetQueryParams = includePagination
? { page: pagination.currentPage, page_size: pagination.pageSize }
: {}
if (searchForm.asset_type) params.asset_type = searchForm.asset_type
const keyword = searchForm.keyword?.trim()
if (keyword) params.keyword = keyword
if (searchForm.shop_id !== undefined && searchForm.shop_id !== null) {
params.shop_id = searchForm.shop_id
}
if (searchForm.package_id !== undefined && searchForm.package_id !== null) {
params.package_id = searchForm.package_id
}
const daysMin = toInteger(searchForm.days_min)
const daysMax = toInteger(searchForm.days_max)
if (daysMin !== undefined) params.days_min = daysMin
if (daysMax !== undefined) params.days_max = daysMax
const [expiresFrom, expiresTo] = searchForm.expires_range || []
if (expiresFrom) params.start_time = expiresFrom
if (expiresTo) params.end_time = expiresTo
return params
}
const loadAssets = async () => {
loading.value = true
try {
const toInteger = (value: unknown) => {
if (value === undefined || value === null || value === '') return undefined
const numberValue = Number(value)
return Number.isInteger(numberValue) ? numberValue : undefined
}
const params: ExpiringAssetQueryParams = {
page: pagination.currentPage,
page_size: pagination.pageSize
}
if (searchForm.asset_type) params.asset_type = searchForm.asset_type
const keyword = searchForm.keyword?.trim()
if (keyword) params.keyword = keyword
if (searchForm.shop_id !== undefined && searchForm.shop_id !== null) {
params.shop_id = searchForm.shop_id
}
if (searchForm.package_id !== undefined && searchForm.package_id !== null) {
params.package_id = searchForm.package_id
}
const daysMin = toInteger(searchForm.days_min)
const daysMax = toInteger(searchForm.days_max)
if (daysMin !== undefined) params.days_min = daysMin
if (daysMax !== undefined) params.days_max = daysMax
const [expiresFrom, expiresTo] = searchForm.expires_range || []
if (expiresFrom) params.expires_from = expiresFrom
if (expiresTo) params.expires_to = expiresTo
const response = await AssetService.getExpiringAssets(params)
const response = await AssetService.getExpiringAssets(buildFilterParams())
if (response.code === 0 && response.data) {
items.value = response.data.items || []
pagination.total = response.data.total || 0
@@ -349,8 +364,8 @@
package_id: undefined,
days_min: undefined,
days_max: undefined,
expires_from: undefined,
expires_to: undefined,
start_time: undefined,
end_time: undefined,
expires_range: []
})
pagination.currentPage = 1
@@ -367,6 +382,64 @@
void loadAssets()
}
const exportTask = computed(() => exportPolling.task.value)
const canDownload = computed(
() =>
exportTask.value?.status === ExportTaskStatus.COMPLETED && !!exportTask.value?.download_url
)
const exportStatusType = computed(() => {
const status = exportTask.value?.status
if (status === ExportTaskStatus.COMPLETED) return 'success'
if (status === ExportTaskStatus.FAILED) return 'danger'
if (status === ExportTaskStatus.CANCELED) return 'info'
return 'warning'
})
const exportPolling = useAsyncTaskPolling<ExportTaskDetail>({
storageKey: 'expiring-assets:export',
fetchTask: async (taskId) => {
const res = await ExportTaskService.getExportTaskDetail(taskId)
if (res.code === 403) {
const error = new Error('暂无权限查看导出任务') as Error & { status?: number }
error.status = 403
throw error
}
if (res.code !== 0 || !res.data) throw new Error(res.msg || '获取导出任务详情失败')
return res.data
},
isForbidden: (error: any) => error?.status === 403 || error?.response?.status === 403
})
const handleExport = async () => {
exporting.value = true
try {
const res = await AssetService.exportExpiringAssets({
...buildFilterParams(false),
format: 'xlsx'
})
if (res.code !== 0 || !res.data) {
ElMessage.error(res.msg || '导出失败')
return
}
ElMessage.success(res.data.message || '导出任务已创建,请稍候')
await exportPolling.start(res.data.task_id)
} catch (error) {
console.error('导出临期资产失败:', error)
ElMessage.error('导出临期资产失败')
} finally {
exporting.value = false
}
}
const downloadExport = () => {
const url = exportTask.value?.download_url
if (!url) {
ElMessage.warning('当前任务暂无可用下载地址')
return
}
window.open(url, '_blank')
}
const goToAsset = (row: ExpiringAssetItem) => {
router.push({
path: RoutesAlias.AssetInformation,
@@ -387,9 +460,15 @@
<style scoped lang="scss">
.expiring-assets-page {
.page-intro {
display: inline-block;
margin-right: 12px;
color: var(--el-text-color-secondary);
}
.export-status-tag {
margin-right: 8px;
}
.expiry-critical,
.expiry-warning,
.expiry-notice {

View File

@@ -0,0 +1,9 @@
<template>
<ExportTaskList />
</template>
<script setup lang="ts">
import ExportTaskList from '../export-task-list/index.vue'
defineOptions({ name: 'ExportExpiringAssetTaskList' })
</script>

View File

@@ -0,0 +1,9 @@
<template>
<ExportTaskList />
</template>
<script setup lang="ts">
import ExportTaskList from '../export-task-list/index.vue'
defineOptions({ name: 'ExportOperationsActivationTaskList' })
</script>

View File

@@ -0,0 +1,9 @@
<template>
<ExportTaskList />
</template>
<script setup lang="ts">
import ExportTaskList from '../export-task-list/index.vue'
defineOptions({ name: 'ExportOperationsRenewalTaskList' })
</script>

View File

@@ -15,7 +15,7 @@
v-model:columns="columnChecks"
@refresh="handleRefresh"
>
<template #actions>
<template #left>
<ElButton
type="danger"
plain

View File

@@ -15,7 +15,7 @@
v-model:columns="columnChecks"
@refresh="handleRefresh"
>
<template #actions>
<template #left>
<ElButton @click="goAssociationList">返回关联列表</ElButton>
</template>
</ArtTableHeader>

View File

@@ -77,8 +77,8 @@
to_shop_id: undefined as number | undefined,
operator_id: undefined as number | undefined,
dateRange: [] as string[],
created_at_start: '',
created_at_end: ''
start_time: '',
end_time: ''
}
// 搜索表单
@@ -427,11 +427,11 @@
const handleSearch = () => {
// 处理日期范围
if (formFilters.dateRange && Array.isArray(formFilters.dateRange)) {
formFilters.created_at_start = formFilters.dateRange[0] || ''
formFilters.created_at_end = formFilters.dateRange[1] || ''
formFilters.start_time = formFilters.dateRange[0] || ''
formFilters.end_time = formFilters.dateRange[1] || ''
} else {
formFilters.created_at_start = ''
formFilters.created_at_end = ''
formFilters.start_time = ''
formFilters.end_time = ''
}
pagination.page = 1
getTableData()