|
|
/*
|
|
|
* @Author: donghao donghao@supervision.ltd
|
|
|
* @Date: 2024-01-17 13:54:43
|
|
|
* @LastEditors: donghao donghao@supervision.ltd
|
|
|
* @LastEditTime: 2024-01-18 15:37:29
|
|
|
* @FilePath: \General-AI-Platform-Web-Client\mock\alarm.ts
|
|
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
|
*/
|
|
|
import { MockMethod } from "vite-plugin-mock";
|
|
|
|
|
|
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 < 10; i++) {
|
|
|
currList.push({
|
|
|
id: 1,
|
|
|
createTime: generateRandomDateTime(2023),
|
|
|
updateTime: "2023-10-17T02:35:41.14308Z",
|
|
|
name: "表面缺陷",
|
|
|
code: "DC00001",
|
|
|
level: "1",
|
|
|
deviceGroup: "设备组" + parseInt(Math.random() * 10) + 1,
|
|
|
remark: ""
|
|
|
});
|
|
|
}
|
|
|
return currList;
|
|
|
}
|
|
|
export default [
|
|
|
{
|
|
|
url: "/getAlarmList",
|
|
|
method: "post",
|
|
|
response: () => {
|
|
|
return {
|
|
|
success: true,
|
|
|
data: {
|
|
|
list: fetchList()
|
|
|
}
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
] as MockMethod[];
|