移动home接口
This commit is contained in:
47
src/api/index.ts
Normal file
47
src/api/index.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
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;
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
import { request } from '@/plugins/http-fetch';
|
||||
//import * as apple from '@/utils/date-utils';
|
||||
import {parseDateToStr} from '@/utils/date-utils';
|
||||
/**
|
||||
* 查询公告列表
|
||||
* @param query 查询参数
|
||||
* @returns object
|
||||
*/
|
||||
export async function listMain() {
|
||||
var allStatus= await request({
|
||||
url: 'systemManagement/v1/elementType/all/objectType/systemState',
|
||||
method: 'get',
|
||||
});
|
||||
console.log(allStatus)
|
||||
let realData=allStatus.data.data;
|
||||
const mergedData = realData.map(obj => {
|
||||
const [key, value] = Object.entries(obj)[0];
|
||||
var time=new Date();
|
||||
//console.log([key, value])
|
||||
let mergedObj;
|
||||
if (typeof (value.systemState.errorCode) === 'undefined'&&Object.keys(value.systemState).length !== 0){
|
||||
mergedObj = { ...value.systemState, refresh:parseDateToStr(time),ipAddress: value.ipAddress, name: key,status:"正常" };
|
||||
|
||||
}else {
|
||||
mergedObj = {version:"-",refresh:parseDateToStr(time),ipAddress: value.ipAddress, name: key,status:"异常" };
|
||||
|
||||
}
|
||||
return mergedObj;
|
||||
});
|
||||
|
||||
console.log(mergedData);
|
||||
// console.log(rowArr)
|
||||
return mergedData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询公告详细
|
||||
* @param menuId 公告ID
|
||||
* @returns object
|
||||
*/
|
||||
export function getNotice(noticeId: string | number) {
|
||||
return request({
|
||||
url: `/system/notice/${noticeId}`,
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增公告
|
||||
* @param data 公告对象
|
||||
* @returns object
|
||||
*/
|
||||
export function addNotice(data: Record<string, any>) {
|
||||
return request({
|
||||
url: '/system/notice',
|
||||
method: 'post',
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改公告
|
||||
* @param data 公告对象
|
||||
* @returns object
|
||||
*/
|
||||
export function updateNotice(data: Record<string, any>) {
|
||||
return request({
|
||||
url: '/system/notice',
|
||||
method: 'put',
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除公告
|
||||
* @param noticeId 公告ID
|
||||
* @returns object
|
||||
*/
|
||||
export function delNotice(noticeId: string | number) {
|
||||
return request({
|
||||
url: `/system/notice/${noticeId}`,
|
||||
method: 'delete',
|
||||
});
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import { PageContainer } from '@ant-design-vue/pro-layout';
|
||||
import { onMounted } from 'vue';
|
||||
import { ColumnsType } from 'ant-design-vue/lib/table';
|
||||
import { reactive, toRaw } from 'vue';
|
||||
import { listMain } from '@/api/system/home';
|
||||
import { listMain } from '@/api/index';
|
||||
import { TooltipComponent } from 'echarts/components';
|
||||
import { GaugeChart } from 'echarts/charts';
|
||||
import { CanvasRenderer } from 'echarts/renderers';
|
||||
|
||||
Reference in New Issue
Block a user