Files
CN_Tool_client/frontend/src/api/aireport/testDevice/index.ts
yexb 7c8e7d1b7e refactor(steady-checksquare): 更新稳态校验功能的数据结构和接口规范
- 移除 lineId 字段,统一使用 lineIds 数组字段
- 更新创建任务请求体构建逻辑,不再包含 lineId 属性
- 修改任务详情和检测项明细的接口契约验证
- 更新稳态校验 API 文档说明,移除对 lineId 的支持
- 重构稳态校验表单项验证规则
- 移除磁盘监控作业详情抽屉组件
- 移除磁盘监控作业表格组件
- 更新路由配置以支持新的系统监控路径
- 添加测试报告相关字典代码常量
- 更新 ICD 路径表单和结果面板功能
2026-07-01 13:18:17 +08:00

78 lines
2.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import http from '@/api'
import type { TestDevice } from './interface'
const TEST_DEVICE_BASE_URL = '/api/test-device'
const buildTestDeviceFormData = (request: TestDevice.TestDeviceSaveRequest, reportFile?: File | null) => {
const formData = new FormData()
// 关键业务节点:检测设备新增/编辑接口按 request JSON 分段读取业务字段,报告文件单独传 reportFile。
formData.append('request', new Blob([JSON.stringify(request)], { type: 'application/json' }))
if (reportFile) {
formData.append('reportFile', reportFile)
}
return formData
}
const buildTestDeviceImportFormData = (file: File, reportZip: File) => {
const formData = new FormData()
formData.append('file', file)
formData.append('reportZip', reportZip)
return formData
}
export const listTestDevicesApi = (params: TestDevice.TestDeviceListParams) => {
return http.post(`${TEST_DEVICE_BASE_URL}/list`, params)
}
export const createTestDeviceApi = (request: TestDevice.TestDeviceSaveRequest, reportFile: File) => {
return http.post<boolean>(`${TEST_DEVICE_BASE_URL}/add`, buildTestDeviceFormData(request, reportFile), {
headers: { 'Content-Type': 'multipart/form-data' }
})
}
export const updateTestDeviceApi = (request: TestDevice.TestDeviceSaveRequest, reportFile?: File | null) => {
return http.post<boolean>(`${TEST_DEVICE_BASE_URL}/update`, buildTestDeviceFormData(request, reportFile), {
headers: { 'Content-Type': 'multipart/form-data' }
})
}
export const deleteTestDevicesApi = (ids: string[]) => {
return http.post<boolean>(`${TEST_DEVICE_BASE_URL}/delete`, ids)
}
export const getTestDeviceDetailApi = (id: string) => {
return http.get<TestDevice.TestDeviceRecord>(`${TEST_DEVICE_BASE_URL}/${id}`)
}
export const downloadTestDeviceImportTemplateApi = () => {
return http.get(`${TEST_DEVICE_BASE_URL}/template`, undefined, { responseType: 'blob' })
}
export const importTestDevicesApi = (file: File, reportZip: File) => {
return http.post<TestDevice.TestDeviceImportResult>(
`${TEST_DEVICE_BASE_URL}/import`,
buildTestDeviceImportFormData(file, reportZip),
{
headers: { 'Content-Type': 'multipart/form-data' }
}
)
}
export const exportTestDevicesApi = (params: TestDevice.TestDeviceListParams) => {
return http.get(`${TEST_DEVICE_BASE_URL}/export`, params, { responseType: 'blob' })
}
export const previewTestDeviceReportApi = (id: string) => {
// 关键业务节点test-device 当前仅提供 /{id}/report预览与下载统一复用同一报告流避免前端误调不存在的 preview 接口。
return http.get(`${TEST_DEVICE_BASE_URL}/${id}/report`, undefined, { responseType: 'blob' })
}
export const downloadTestDeviceReportApi = (id: string) => {
return http.get(`${TEST_DEVICE_BASE_URL}/${id}/report`, undefined, { responseType: 'blob' })
}