48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import { request } from '@/plugins/http-fetch';
|
|
import { parseDateToStr } from '@/utils/date-utils';
|
|
/**
|
|
* 查询公告列表
|
|
* @param query 查询参数
|
|
* @returns object
|
|
*/
|
|
export async function listMain() {
|
|
const result = await request({
|
|
url: 'systemManagement/v1/elementType/all/objectType/systemState',
|
|
method: 'get',
|
|
});
|
|
// console.log(result);
|
|
let realData = result.data.data;
|
|
const mergedData = realData.map((obj: any) => {
|
|
// console.log(obj);
|
|
const [key, value] = Object.entries(obj)[0];
|
|
const ipAddress = (value as any).ipAddress;
|
|
const systemState = (value as any).systemState;
|
|
const errCode = systemState && systemState['errorCode'];
|
|
var time = new Date();
|
|
// console.log(key, value);
|
|
let mergedObj;
|
|
if (errCode === undefined && systemState) {
|
|
mergedObj = {
|
|
...systemState,
|
|
refresh: parseDateToStr(time),
|
|
ipAddress: ipAddress,
|
|
name: key,
|
|
status: '正常',
|
|
};
|
|
} else {
|
|
mergedObj = {
|
|
version: '-',
|
|
refresh: parseDateToStr(time),
|
|
ipAddress: ipAddress,
|
|
name: key,
|
|
status: '异常',
|
|
};
|
|
}
|
|
return mergedObj;
|
|
});
|
|
|
|
// console.log(mergedData);
|
|
// console.log(rowArr)
|
|
return mergedData;
|
|
}
|