You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
General-AI-Platform-Web-Client/mock/pools/alarmData.ts

53 lines
1.4 KiB
TypeScript

function generateRandomDateTime(year) {
// 生成随机月份1-12
const month = Math.floor(Math.random() * 12) + 1;
// 生成随机日期1-31
const day = Math.floor(Math.random() * 31) + 1;
// 生成随机小时0-23
const hour = Math.floor(Math.random() * 24);
// 生成随机分钟0-59
const minute = Math.floor(Math.random() * 60);
// 生成随机秒钟0-59
const second = Math.floor(Math.random() * 60);
// 返回随机日期和时间的字符串
return `${year}-${month < 10 ? "0" : ""}${month}-${
day < 10 ? "0" : ""
}${day} ${hour < 10 ? "0" : ""}${hour}:${minute < 10 ? "0" : ""}${minute}:${
second < 10 ? "0" : ""
}${second}`;
}
function fetchList(): Record<string, any>[] {
const currList: Record<string, any>[] = [];
// const nameArr = ["玩手机监测", "控制器", "视频监控"];
// const deviceGroupArr = [""]
for (let i = 0; i < 35; i++) {
currList.push({
id: 1,
createTime: generateRandomDateTime(2023),
updateTime: "2023-10-17T02:35:41.14308Z",
name: "表面缺陷",
code: "DC0000" + i,
level: Math.floor(Math.random() * 6) + 1,
deviceGroup: "设备组" + parseInt(Math.random() * 10) + 1,
remark: ""
});
}
return currList;
}
const currentData = fetchList();
export const alarmListData = {
data: {
list: currentData,
total: currentData.length,
page: 1,
pageSize: 10
}
};