2025-12-08 08:37:07 +08:00
|
|
|
|
import createAxios from '@/utils/request'
|
2026-01-20 14:39:13 +08:00
|
|
|
|
import { genFileId, ElMessage, ElNotification } from 'element-plus'
|
2025-12-08 08:37:07 +08:00
|
|
|
|
// 查询设备数据趋势
|
|
|
|
|
|
export function getDeviceDataTrend(data: any) {
|
|
|
|
|
|
return createAxios({
|
|
|
|
|
|
url: '/cs-harmonic-boot/datatrend/querydatatrend',
|
|
|
|
|
|
method: 'POST',
|
|
|
|
|
|
data
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 波形下载
|
|
|
|
|
|
export function getFileZip(params: any) {
|
|
|
|
|
|
return createAxios({
|
|
|
|
|
|
url: '/cs-harmonic-boot/event/getFileZip',
|
|
|
|
|
|
method: 'get',
|
|
|
|
|
|
params,
|
|
|
|
|
|
responseType: 'blob'
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function exportModel(data: any) {
|
|
|
|
|
|
return createAxios({
|
|
|
|
|
|
url: '/cs-harmonic-boot/exportmodel/exportModel',
|
|
|
|
|
|
method: 'post',
|
|
|
|
|
|
data: data,
|
|
|
|
|
|
responseType: 'blob'
|
2026-01-20 14:39:13 +08:00
|
|
|
|
}).then(async res => {
|
|
|
|
|
|
let load: any = await readJsonBlob(res)
|
|
|
|
|
|
if (load.code) {
|
|
|
|
|
|
if (load.data.code == 'A0011') {
|
|
|
|
|
|
ElMessage.warning('下载失败!')
|
|
|
|
|
|
} else {
|
|
|
|
|
|
ElMessage.warning(load.data.message)
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return res
|
|
|
|
|
|
}
|
2025-12-08 08:37:07 +08:00
|
|
|
|
})
|
|
|
|
|
|
}
|
2026-01-20 14:39:13 +08:00
|
|
|
|
async function readJsonBlob(blob) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
// 1. Blob.text() 读取二进制 → 直接转为 字符串(自动处理编码)
|
|
|
|
|
|
const jsonStr = await blob.text()
|
|
|
|
|
|
// 2. JSON.parse 解析字符串 → 得到可用的 JS 对象/数组
|
|
|
|
|
|
const jsonData = JSON.parse(jsonStr)
|
|
|
|
|
|
// 3. 拿到数据,后续随便用
|
|
|
|
|
|
return {
|
|
|
|
|
|
code: true,
|
|
|
|
|
|
data: jsonData
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
return {
|
|
|
|
|
|
code: false,
|
|
|
|
|
|
data: {}
|
|
|
|
|
|
}
|
|
|
|
|
|
// console.error('解析Blob的JSON数据失败:', err)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|