types.ts 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961
  1. export enum OssType {
  2. ALIYUN = 'aliyun',
  3. MINIO = 'minio',
  4. }
  5. // 全局配置常量
  6. export interface GlobalConfig {
  7. OSS_BASE_URL: string;
  8. OSS_TYPE: OssType;
  9. API_BASE_URL: string;
  10. APP_NAME: string;
  11. ENV: string;
  12. DEFAULT_THEME: string;
  13. MAP_CONFIG: {
  14. KEY: string;
  15. VERSION: string;
  16. PLUGINS: string[];
  17. MAP_MODE: MapMode;
  18. };
  19. CHART_THEME: string;
  20. ENABLE_THEME_CONFIG: boolean;
  21. THEME: ThemeSettings | null;
  22. }
  23. // 定义类型
  24. export interface User {
  25. id: number;
  26. username: string;
  27. nickname?: string;
  28. email?: string;
  29. phone?: string;
  30. role: string;
  31. avatar?: string;
  32. }
  33. export interface MenuItem {
  34. id: number;
  35. name: string;
  36. path: string;
  37. icon: string;
  38. component: string;
  39. parent_id?: number;
  40. children?: MenuItem[];
  41. }
  42. // 认证上下文类型
  43. export interface AuthContextType {
  44. user: User | null;
  45. token: string | null;
  46. login: (username: string, password: string) => Promise<void>;
  47. logout: () => Promise<void>;
  48. isAuthenticated: boolean;
  49. isLoading: boolean;
  50. }
  51. // 主题上下文类型
  52. export interface ThemeContextType {
  53. isDark: boolean;
  54. currentTheme: ThemeSettings;
  55. updateTheme: (theme: Partial<ThemeSettings>) => void; // 实时预览
  56. saveTheme: (theme: Partial<ThemeSettings>) => Promise<ThemeSettings>; // 保存到后端
  57. resetTheme: () => Promise<ThemeSettings>;
  58. toggleTheme: () => void; // 切换主题模式
  59. }
  60. // 主题模式枚举
  61. export enum ThemeMode {
  62. LIGHT = 'light',
  63. DARK = 'dark'
  64. }
  65. // 字体大小枚举
  66. export enum FontSize {
  67. SMALL = 'small',
  68. MEDIUM = 'medium',
  69. LARGE = 'large'
  70. }
  71. // 紧凑模式枚举
  72. export enum CompactMode {
  73. NORMAL = 0, // 正常模式
  74. COMPACT = 1 // 紧凑模式
  75. }
  76. // 主题设置类型
  77. export interface ThemeSettings {
  78. /** 主键ID */
  79. id?: number;
  80. /** 用户ID */
  81. user_id: number;
  82. /** 主题模式(light/dark) */
  83. theme_mode: ThemeMode;
  84. /** 主题主色 */
  85. primary_color: string;
  86. /** 背景色 */
  87. background_color?: string;
  88. /** 文字颜色 */
  89. text_color?: string;
  90. /** 边框圆角 */
  91. border_radius?: number;
  92. /** 字体大小(small/medium/large) */
  93. font_size: FontSize;
  94. /** 是否紧凑模式(0否 1是) */
  95. is_compact: CompactMode;
  96. /** 创建时间 */
  97. created_at?: string;
  98. /** 更新时间 */
  99. updated_at?: string;
  100. }
  101. // 启用/禁用状态枚举
  102. export enum EnableStatus {
  103. DISABLED = 0, // 禁用
  104. ENABLED = 1 // 启用
  105. }
  106. // 启用/禁用状态中文映射
  107. export const EnableStatusNameMap: Record<EnableStatus, string> = {
  108. [EnableStatus.DISABLED]: '禁用',
  109. [EnableStatus.ENABLED]: '启用'
  110. };
  111. // 删除状态枚举
  112. export enum DeleteStatus {
  113. NOT_DELETED = 0, // 未删除
  114. DELETED = 1 // 已删除
  115. }
  116. // 删除状态中文映射
  117. export const DeleteStatusNameMap: Record<DeleteStatus, string> = {
  118. [DeleteStatus.NOT_DELETED]: '未删除',
  119. [DeleteStatus.DELETED]: '已删除'
  120. };
  121. // 设备通信协议类型枚举
  122. export enum DeviceProtocolType {
  123. SNMP = 'SNMP', // 简单网络管理协议(网络设备管理)
  124. HTTP = 'HTTP', // 超文本传输协议(Web服务)
  125. MODBUS = 'MODBUS', // Modbus协议(工业自动化标准通信协议)
  126. MQTT = 'MQTT', // 消息队列遥测传输(物联网消息协议)
  127. SOCKET = 'SOCKET', // Socket通信(基础网络通信)
  128. OPC = 'OPC', // OPC统一架构(工业设备互操作性标准)
  129. RS485 = 'RS485', // RS485串行通信(工业现场总线)
  130. TCP = 'TCP' // TCP网络协议(可靠的网络传输协议)
  131. }
  132. // 设备通信协议类型中文映射
  133. export const DeviceProtocolTypeNameMap: Record<DeviceProtocolType, string> = {
  134. [DeviceProtocolType.SNMP]: 'SNMP',
  135. [DeviceProtocolType.HTTP]: 'HTTP',
  136. [DeviceProtocolType.MODBUS]: 'MODBUS',
  137. [DeviceProtocolType.MQTT]: 'MQTT',
  138. [DeviceProtocolType.SOCKET]: 'SOCKET',
  139. [DeviceProtocolType.OPC]: 'OPC',
  140. [DeviceProtocolType.RS485]: 'RS485',
  141. [DeviceProtocolType.TCP]: 'TCP'
  142. };
  143. // 统一的监控指标类型枚举
  144. export enum MetricType {
  145. TEMPERATURE = 'temperature',
  146. HUMIDITY = 'humidity',
  147. VOLTAGE = 'voltage',
  148. CPU_USAGE = 'cpu_usage',
  149. MEMORY_USAGE = 'memory_usage',
  150. DISK_USAGE = 'disk_usage',
  151. NETWORK_TRAFFIC = 'network_traffic',
  152. PING_TIME = 'ping_time',
  153. PACKET_LOSS = 'packet_loss',
  154. SNMP_RESPONSE_TIME = 'snmp_response_time',
  155. SNMP_ERRORS = 'snmp_errors',
  156. HTTP_RESPONSE_TIME = 'http_response_time',
  157. HTTP_STATUS = 'http_status',
  158. TCP_CONNECTION_TIME = 'tcp_connection_time',
  159. CONNECTION_STATUS = 'connection_status'
  160. }
  161. // 监控类型中文映射
  162. export const MetricTypeNameMap: Record<MetricType, string> = {
  163. [MetricType.TEMPERATURE]: '温度',
  164. [MetricType.HUMIDITY]: '湿度',
  165. [MetricType.VOLTAGE]: '电压',
  166. [MetricType.CPU_USAGE]: 'CPU使用率',
  167. [MetricType.MEMORY_USAGE]: '内存使用率',
  168. [MetricType.DISK_USAGE]: '磁盘使用率',
  169. [MetricType.NETWORK_TRAFFIC]: '网络流量',
  170. [MetricType.PING_TIME]: 'Ping时间',
  171. [MetricType.PACKET_LOSS]: '丢包率',
  172. [MetricType.SNMP_RESPONSE_TIME]: 'SNMP响应时间',
  173. [MetricType.SNMP_ERRORS]: 'SNMP错误数',
  174. [MetricType.HTTP_RESPONSE_TIME]: 'HTTP响应时间',
  175. [MetricType.HTTP_STATUS]: 'HTTP状态码',
  176. [MetricType.TCP_CONNECTION_TIME]: 'TCP连接时间',
  177. [MetricType.CONNECTION_STATUS]: '连接状态'
  178. };
  179. // 处理类型枚举
  180. export enum HandleType {
  181. CONFIRM = 'confirm',
  182. RESOLVE = 'resolve',
  183. IGNORE = 'ignore'
  184. }
  185. // 处理类型中文映射
  186. export const HandleTypeNameMap: Record<HandleType, string> = {
  187. [HandleType.CONFIRM]: '确认',
  188. [HandleType.RESOLVE]: '解决',
  189. [HandleType.IGNORE]: '忽略'
  190. };
  191. // 问题类型枚举
  192. export enum ProblemType {
  193. DEVICE = 'device',
  194. NETWORK = 'network',
  195. POWER = 'power',
  196. CONSTRUCTION = 'construction',
  197. OTHER = 'other'
  198. }
  199. // 问题类型中文映射
  200. export const ProblemTypeNameMap: Record<ProblemType, string> = {
  201. [ProblemType.DEVICE]: '设备故障',
  202. [ProblemType.NETWORK]: '网络故障',
  203. [ProblemType.POWER]: '电源故障',
  204. [ProblemType.CONSTRUCTION]: '施工影响',
  205. [ProblemType.OTHER]: '其他原因'
  206. };
  207. // 通知类型枚举
  208. export enum NotifyType {
  209. SMS = 'sms',
  210. EMAIL = 'email',
  211. WECHAT = 'wechat'
  212. }
  213. // 通知类型中文映射
  214. export const NotifyTypeNameMap: Record<NotifyType, string> = {
  215. [NotifyType.SMS]: '短信',
  216. [NotifyType.EMAIL]: '邮件',
  217. [NotifyType.WECHAT]: '微信'
  218. };
  219. // 告警等级枚举
  220. export enum AlertLevel {
  221. MINOR = 0, // 次要
  222. NORMAL = 1, // 一般
  223. IMPORTANT = 2, // 重要
  224. URGENT = 3 // 紧急
  225. }
  226. // 告警等级中文映射
  227. export const AlertLevelNameMap: Record<AlertLevel, string> = {
  228. [AlertLevel.MINOR]: '次要',
  229. [AlertLevel.NORMAL]: '一般',
  230. [AlertLevel.IMPORTANT]: '重要',
  231. [AlertLevel.URGENT]: '紧急'
  232. };
  233. // 告警等级颜色映射
  234. export const AlertLevelColorMap: Record<AlertLevel, string> = {
  235. [AlertLevel.MINOR]: 'blue',
  236. [AlertLevel.NORMAL]: 'orange',
  237. [AlertLevel.IMPORTANT]: 'red',
  238. [AlertLevel.URGENT]: 'purple'
  239. };
  240. // 设备状态枚举(资产管理)
  241. export enum DeviceStatus {
  242. NORMAL = 0, // 正常
  243. MAINTAIN = 1, // 维护中
  244. FAULT = 2, // 故障
  245. OFFLINE = 3 // 下线
  246. }
  247. // 设备分类枚举
  248. export enum DeviceCategory {
  249. SERVER = 1, // 服务器
  250. NETWORK = 2, // 网络设备
  251. STORAGE = 3, // 存储设备
  252. SECURITY = 4, // 安全设备
  253. OTHER = 5 // 其他设备
  254. }
  255. // 区域枚举
  256. export enum AreaType {
  257. AREA_A = 1, // A区
  258. AREA_B = 2, // B区
  259. AREA_C = 3, // C区
  260. AREA_OTHER = 4 // 其他区域
  261. }
  262. // 资产状态枚举
  263. export enum AssetStatus {
  264. IN_USE = 0, // 使用中
  265. IDLE = 1, // 闲置
  266. REPAIR = 2, // 维修中
  267. SCRAPPED = 3 // 已报废
  268. }
  269. // 网络状态枚举
  270. export enum NetworkStatus {
  271. CONNECTED = 0, // 已连接
  272. DISCONNECTED = 1, // 已断开
  273. UNSTABLE = 2 // 不稳定
  274. }
  275. // 丢包状态枚举
  276. export enum PacketLossStatus {
  277. NORMAL = 0, // 正常
  278. HIGH = 1 // 丢包
  279. }
  280. // 审核状态枚举
  281. export enum AuditStatus {
  282. PENDING = 0, // 待审核
  283. APPROVED = 1, // 已通过
  284. REJECTED = 2 // 已拒绝
  285. }
  286. // 审核状态中文映射
  287. export const AuditStatusNameMap: Record<AuditStatus, string> = {
  288. [AuditStatus.PENDING]: '待审核',
  289. [AuditStatus.APPROVED]: '已通过',
  290. [AuditStatus.REJECTED]: '已拒绝'
  291. };
  292. // 设备状态中文映射(资产管理)
  293. export const DeviceStatusNameMap: Record<DeviceStatus, string> = {
  294. [DeviceStatus.NORMAL]: '正常',
  295. [DeviceStatus.MAINTAIN]: '维护中',
  296. [DeviceStatus.FAULT]: '故障',
  297. [DeviceStatus.OFFLINE]: '下线'
  298. };
  299. // 设备状态颜色映射(资产管理)
  300. export const DeviceStatusColorMap: Record<DeviceStatus, string> = {
  301. [DeviceStatus.NORMAL]: 'green',
  302. [DeviceStatus.MAINTAIN]: 'blue',
  303. [DeviceStatus.FAULT]: 'red',
  304. [DeviceStatus.OFFLINE]: 'gray'
  305. };
  306. // 设备分类中文映射
  307. export const DeviceCategoryNameMap: Record<DeviceCategory, string> = {
  308. [DeviceCategory.SERVER]: '服务器',
  309. [DeviceCategory.NETWORK]: '网络设备',
  310. [DeviceCategory.STORAGE]: '存储设备',
  311. [DeviceCategory.SECURITY]: '安全设备',
  312. [DeviceCategory.OTHER]: '其他设备'
  313. };
  314. // 告警状态枚举
  315. export enum AlertStatus {
  316. PENDING = 'pending',
  317. HANDLING = 'handling',
  318. RESOLVED = 'resolved',
  319. IGNORED = 'ignored'
  320. }
  321. // 告警状态中文映射
  322. export const AlertStatusNameMap: Record<AlertStatus, string> = {
  323. [AlertStatus.PENDING]: '待处理',
  324. [AlertStatus.HANDLING]: '处理中',
  325. [AlertStatus.RESOLVED]: '已解决',
  326. [AlertStatus.IGNORED]: '已忽略'
  327. };
  328. // 告警状态颜色映射
  329. export const AlertStatusColorMap: Record<AlertStatus, string> = {
  330. [AlertStatus.PENDING]: 'red',
  331. [AlertStatus.HANDLING]: 'blue',
  332. [AlertStatus.RESOLVED]: 'green',
  333. [AlertStatus.IGNORED]: 'gray'
  334. };
  335. // 设备在线状态枚举
  336. export enum OnlineStatus {
  337. ONLINE = 'online',
  338. OFFLINE = 'offline'
  339. }
  340. // 设备在线状态中文映射
  341. export const OnlineStatusNameMap: Record<OnlineStatus, string> = {
  342. [OnlineStatus.ONLINE]: '在线',
  343. [OnlineStatus.OFFLINE]: '离线'
  344. };
  345. // 设备在线状态颜色映射
  346. export const OnlineStatusColorMap: Record<OnlineStatus, string> = {
  347. [OnlineStatus.ONLINE]: 'green',
  348. [OnlineStatus.OFFLINE]: 'red'
  349. };
  350. // 工单状态枚举
  351. export enum WorkOrderStatus {
  352. PENDING = 0, // 待处理
  353. HANDLING = 1, // 处理中
  354. AUDITING = 2, // 待审核
  355. COMPLETED = 3, // 已完成
  356. CLOSED = 4 // 已关闭
  357. }
  358. // 工单状态中文映射
  359. export const WorkOrderStatusNameMap: Record<WorkOrderStatus, string> = {
  360. [WorkOrderStatus.PENDING]: '待处理',
  361. [WorkOrderStatus.HANDLING]: '处理中',
  362. [WorkOrderStatus.AUDITING]: '待审核',
  363. [WorkOrderStatus.COMPLETED]: '已完成',
  364. [WorkOrderStatus.CLOSED]: '已关闭'
  365. };
  366. // 工单状态颜色映射
  367. export const WorkOrderStatusColorMap: Record<WorkOrderStatus, string> = {
  368. [WorkOrderStatus.PENDING]: 'orange',
  369. [WorkOrderStatus.HANDLING]: 'blue',
  370. [WorkOrderStatus.AUDITING]: 'gold',
  371. [WorkOrderStatus.COMPLETED]: 'green',
  372. [WorkOrderStatus.CLOSED]: 'gray'
  373. };
  374. // 工单优先级枚举
  375. export enum WorkOrderPriority {
  376. NORMAL = 0, // 普通
  377. IMPORTANT = 1, // 重要
  378. URGENT = 2 // 紧急
  379. }
  380. // 工单优先级中文映射
  381. export const WorkOrderPriorityNameMap: Record<WorkOrderPriority, string> = {
  382. [WorkOrderPriority.NORMAL]: '普通',
  383. [WorkOrderPriority.IMPORTANT]: '重要',
  384. [WorkOrderPriority.URGENT]: '紧急'
  385. };
  386. // 工单优先级颜色映射
  387. export const WorkOrderPriorityColorMap: Record<WorkOrderPriority, string> = {
  388. [WorkOrderPriority.NORMAL]: 'green',
  389. [WorkOrderPriority.IMPORTANT]: 'orange',
  390. [WorkOrderPriority.URGENT]: 'red'
  391. };
  392. // 工单操作类型枚举
  393. export enum WorkOrderAction {
  394. CREATE = 'create',
  395. ACCEPT = 'accept',
  396. HANDLE = 'handle',
  397. AUDIT = 'audit',
  398. CLOSE = 'close'
  399. }
  400. // 工单操作类型中文映射
  401. export const WorkOrderActionNameMap: Record<WorkOrderAction, string> = {
  402. [WorkOrderAction.CREATE]: '创建',
  403. [WorkOrderAction.ACCEPT]: '接受',
  404. [WorkOrderAction.HANDLE]: '处理',
  405. [WorkOrderAction.AUDIT]: '审核',
  406. [WorkOrderAction.CLOSE]: '关闭'
  407. };
  408. // 服务器类型枚举
  409. export enum ServerType {
  410. STANDARD = 'standard',
  411. NETWORK = 'network',
  412. STORAGE = 'storage',
  413. SPECIAL = 'special'
  414. }
  415. // 服务器类型中文映射
  416. export const ServerTypeNameMap: Record<ServerType, string> = {
  417. [ServerType.STANDARD]: '标准服务器',
  418. [ServerType.NETWORK]: '网络设备',
  419. [ServerType.STORAGE]: '存储设备',
  420. [ServerType.SPECIAL]: '特殊设备'
  421. };
  422. // 图表类型映射
  423. export const AlertTypeMap = {
  424. temperature: { text: '温度异常', color: 'orange' },
  425. humidity: { text: '湿度异常', color: 'blue' },
  426. offline: { text: '设备离线', color: 'red' }
  427. } as const;
  428. // 工单状态映射
  429. export const StatusMap = {
  430. unread: { text: '未读', color: 'red' },
  431. read: { text: '已读', color: 'blue' },
  432. processed: { text: '已处理', color: 'green' }
  433. } as const;
  434. // 图标类型映射
  435. type IconType = 'dashboard' | 'user' | 'setting' | 'team' | 'book' | 'calendar' | 'pie-chart' | 'database';
  436. // 图标类型中文映射
  437. export const IconTypeNameMap: Record<IconType, string> = {
  438. 'dashboard': '仪表盘',
  439. 'user': '用户',
  440. 'setting': '设置',
  441. 'team': '团队',
  442. 'book': '文档',
  443. 'calendar': '日历',
  444. 'pie-chart': '图表',
  445. 'database': '数据库'
  446. };
  447. // 定义JSON数据结构接口
  448. // 附件类型定义
  449. export interface Attachment {
  450. /** 附件ID */
  451. id: string;
  452. /** 附件名称 */
  453. name: string;
  454. /** 附件访问地址 */
  455. url: string;
  456. /** 附件类型(如image/jpeg, application/pdf等) */
  457. type: string;
  458. /** 附件大小(字节) */
  459. size: number;
  460. /** 上传时间 */
  461. upload_time: string;
  462. }
  463. // 通知项配置类型定义
  464. interface NotifyItem {
  465. /** 通知项ID */
  466. id: string;
  467. /** 通知项类型 */
  468. type: string;
  469. /** 是否启用 */
  470. enabled: boolean;
  471. /** 通知配置参数 */
  472. config: Record<string, unknown>;
  473. }
  474. // 监控配置类型定义
  475. export interface MonitorConfig {
  476. /** 监控间隔(秒) */
  477. interval: number;
  478. /** 监控指标列表 */
  479. metrics: Array<{
  480. /** 指标名称 */
  481. name: string;
  482. /** 指标类型 */
  483. type: string;
  484. /** 是否启用 */
  485. enabled: boolean;
  486. /** 阈值设置 */
  487. threshold?: {
  488. /** 最小阈值 */
  489. min?: number;
  490. /** 最大阈值 */
  491. max?: number;
  492. };
  493. }>;
  494. /** 通知设置 */
  495. notification: {
  496. /** 是否启用通知 */
  497. enabled: boolean;
  498. /** 通知渠道列表 */
  499. channels: string[];
  500. };
  501. }
  502. // 告警规则类型定义
  503. export interface AlertRuleConfig {
  504. /** 规则列表 */
  505. rules: Array<{
  506. /** 监控指标 */
  507. metric: string;
  508. /** 触发条件(如>、<、=等) */
  509. condition: string;
  510. /** 阈值 */
  511. threshold: number;
  512. /** 持续时间(秒) */
  513. duration: number;
  514. /** 告警等级 */
  515. level: AlertLevel;
  516. }>;
  517. /** 动作列表 */
  518. actions: Array<{
  519. /** 动作类型 */
  520. type: string;
  521. /** 动作目标 */
  522. target: string;
  523. /** 通知模板 */
  524. template?: string;
  525. }>;
  526. }
  527. // 数据格式配置类型定义
  528. export interface DataSchema {
  529. /** 版本号 */
  530. version: string;
  531. /** 属性定义 */
  532. properties: Record<string, {
  533. /** 数据类型 */
  534. type: string;
  535. /** 描述 */
  536. description?: string;
  537. /** 是否必填 */
  538. required?: boolean;
  539. /** 格式(如日期格式) */
  540. format?: string;
  541. /** 枚举值列表 */
  542. enum?: string[];
  543. }>;
  544. /** 必填字段列表 */
  545. required: string[];
  546. }
  547. // 图标配置类型定义
  548. export interface IconConfig {
  549. /** 图标尺寸 */
  550. size: {
  551. /** 宽度 */
  552. width: number;
  553. /** 高度 */
  554. height: number;
  555. };
  556. /** 支持的文件格式 */
  557. format: string[];
  558. /** 最大文件大小(KB) */
  559. maxSize: number;
  560. }
  561. // 告警等级配置类型定义
  562. export interface AlertLevelConfig {
  563. /** 等级定义 */
  564. levels: Record<string, {
  565. /** 等级名称 */
  566. name: string;
  567. /** 等级颜色 */
  568. color: string;
  569. /** 优先级 */
  570. priority: number;
  571. /** 是否自动升级 */
  572. autoEscalation?: boolean;
  573. /** 升级延迟时间(分钟) */
  574. escalationDelay?: number;
  575. }>;
  576. /** 默认等级 */
  577. default: string;
  578. }
  579. // 监控项配置类型定义
  580. export interface MonitorItemConfig {
  581. /** 监控项列表 */
  582. items: Array<{
  583. /** 监控项名称 */
  584. name: string;
  585. /** 描述 */
  586. description: string;
  587. /** 监控项类型 */
  588. type: string;
  589. /** 单位 */
  590. unit: string;
  591. /** 默认是否启用 */
  592. defaultEnabled: boolean;
  593. /** 默认阈值 */
  594. defaultThresholds?: {
  595. /** 最小阈值 */
  596. min?: number;
  597. /** 最大阈值 */
  598. max?: number;
  599. };
  600. }>;
  601. }
  602. // 常用语列表类型定义
  603. export interface CommonPhrase {
  604. /** 常用语ID */
  605. id: string;
  606. /** 分类 */
  607. category: string;
  608. /** 内容 */
  609. content: string;
  610. /** 标签列表 */
  611. tags: string[];
  612. }
  613. // SLA配置类型定义
  614. export interface SLAConfig {
  615. /** 响应时间(分钟) */
  616. responseTime: number;
  617. /** 解决时间(分钟) */
  618. resolveTime: number;
  619. /** 工作时间 */
  620. workingHours: {
  621. /** 开始时间(HH:mm) */
  622. start: string;
  623. /** 结束时间(HH:mm) */
  624. end: string;
  625. /** 工作日(0-6,0代表周日) */
  626. workDays: number[];
  627. };
  628. /** 升级规则 */
  629. escalationRules: Array<{
  630. /** 超时时间(分钟) */
  631. timeout: number;
  632. /** 动作 */
  633. action: string;
  634. /** 目标(如用户ID、角色等) */
  635. target: string[];
  636. }>;
  637. }
  638. // 流程配置类型定义
  639. export interface WorkflowConfig {
  640. /** 流程步骤 */
  641. steps: Array<{
  642. /** 步骤名称 */
  643. name: string;
  644. /** 允许操作的角色 */
  645. roles: string[];
  646. /** 可执行的动作 */
  647. actions: string[];
  648. /** 下一步可能的步骤 */
  649. nextSteps: string[];
  650. /** 自动超时时间(分钟) */
  651. autoTimeout?: number;
  652. }>;
  653. /** 初始步骤 */
  654. initialStep: string;
  655. }
  656. // 告警处理记录表
  657. export interface AlertHandleLog {
  658. /** 主键ID */
  659. id: number;
  660. /** 关联的告警ID */
  661. alert_id: number;
  662. /** 处理人ID */
  663. handler_id: number;
  664. /** 处理类型 */
  665. handle_type: HandleType;
  666. /** 问题类型 */
  667. problem_type: ProblemType;
  668. /** 处理结果 */
  669. handle_result?: string;
  670. /** 附件列表 */
  671. attachments?: Attachment[];
  672. /** 是否禁用通知 (0否 1是) */
  673. notify_disabled?: number;
  674. /** 禁用的通知项配置 */
  675. notify_items?: NotifyItem[];
  676. /** 处理时间 */
  677. handle_time: Date;
  678. /** 是否删除 (0否 1是) */
  679. is_deleted?: DeleteStatus;
  680. /** 创建时间 */
  681. created_at: Date;
  682. /** 更新时间 */
  683. updated_at: Date;
  684. }
  685. // 告警通知配置表
  686. export interface AlertNotifyConfig {
  687. /** 主键ID */
  688. id: number;
  689. /** 关联的设备ID */
  690. device_id: number;
  691. /** 告警等级 */
  692. alert_level: AlertLevel;
  693. /** 通知类型 */
  694. notify_type: NotifyType;
  695. /** 通知模板 */
  696. notify_template?: string;
  697. /** 通知用户ID列表 */
  698. notify_users?: number[];
  699. /** 是否启用 (0否 1是) */
  700. is_enabled?: EnableStatus;
  701. /** 是否删除 (0否 1是) */
  702. is_deleted?: DeleteStatus;
  703. /** 创建时间 */
  704. created_at: Date;
  705. /** 更新时间 */
  706. updated_at: Date;
  707. }
  708. // 设备告警规则表
  709. export interface DeviceAlertRule {
  710. /** 主键ID */
  711. id: number;
  712. /** 关联的设备ID */
  713. device_id: number;
  714. /** 监控指标类型 */
  715. metric_type: string;
  716. /** 最小阈值 */
  717. min_value?: number;
  718. /** 最大阈值 */
  719. max_value?: number;
  720. /** 持续时间(秒) */
  721. duration_seconds?: number;
  722. /** 告警等级 */
  723. alert_level: AlertLevel;
  724. /** 告警消息模板 */
  725. alert_message?: string;
  726. /** 是否启用 (0否 1是) */
  727. is_enabled?: EnableStatus;
  728. /** 是否删除 (0否 1是) */
  729. is_deleted?: DeleteStatus;
  730. /** 创建时间 */
  731. created_at: Date;
  732. /** 更新时间 */
  733. updated_at: Date;
  734. }
  735. // 设备告警记录表
  736. export interface DeviceAlert {
  737. /** 主键ID */
  738. id: number;
  739. /** 关联的设备ID */
  740. device_id: number;
  741. /** 设备名称 */
  742. device_name: string;
  743. /** 监控指标类型 */
  744. metric_type: string;
  745. /** 触发值 */
  746. metric_value: number;
  747. /** 告警等级 */
  748. alert_level: AlertLevel;
  749. /** 告警消息 */
  750. alert_message: string;
  751. /** 状态 */
  752. status: AlertStatus;
  753. /** 是否删除 (0否 1是) */
  754. is_deleted?: DeleteStatus;
  755. /** 创建时间 */
  756. created_at: Date;
  757. /** 更新时间 */
  758. updated_at: Date;
  759. }
  760. // 设备分类图标表
  761. export interface DeviceCategoryIcon {
  762. /** 主键ID */
  763. id: number;
  764. /** 关联的设备分类ID */
  765. category_id: number;
  766. /** 分类图标 */
  767. icon?: string;
  768. /** 图标名称 */
  769. icon_name?: string;
  770. /** 图标类型(svg/url等) */
  771. icon_type?: string;
  772. /** 排序 */
  773. sort?: number;
  774. /** 是否为默认图标 (0否 1是) */
  775. is_default?: number;
  776. /** 是否禁用 (0否 1是) */
  777. is_disabled?: number;
  778. /** 是否被删除 (0否 1是) */
  779. is_deleted?: number;
  780. /** 创建时间 */
  781. created_at: Date;
  782. /** 更新时间 */
  783. updated_at: Date;
  784. }
  785. // 设备实例表
  786. export interface DeviceInstance {
  787. /** 关联资产ID */
  788. id: number;
  789. /** 设备类型ID */
  790. type_id: number;
  791. /** 通信协议(SNMP/HTTP/RS485/TCP等) */
  792. protocol: DeviceProtocolType;
  793. /** 通信地址 */
  794. address: string;
  795. /** 采集间隔(秒) */
  796. collect_interval?: number;
  797. /** 最后采集时间 */
  798. last_collect_time?: Date;
  799. /** 备注 */
  800. remark?: string;
  801. /** 是否启用 (0否 1是) */
  802. is_enabled?: number;
  803. /** 是否删除 (0否 1是) */
  804. is_deleted?: number;
  805. /** 创建时间 */
  806. created_at: Date;
  807. /** 更新时间 */
  808. updated_at: Date;
  809. /** 资产名称(来自zichan_info表) */
  810. asset_name?: string;
  811. /** 设备分类(来自zichan_info表) */
  812. device_category?: DeviceCategory;
  813. /** 归属区域(来自zichan_info表) */
  814. area?: AreaType;
  815. /** 供应商(来自zichan_info表) */
  816. supplier?: string;
  817. /** 设备状态(来自zichan_info表) */
  818. device_status?: DeviceStatus;
  819. }
  820. // 设备监控数据表
  821. export interface DeviceMonitorData {
  822. /** 主键ID */
  823. id: number;
  824. /** 关联的设备ID */
  825. device_id: number;
  826. /** 监控指标类型(temperature/humidity/smoke/water等) */
  827. metric_type: string;
  828. /** 监控值 */
  829. metric_value: number;
  830. /** 单位 */
  831. unit?: string;
  832. /** 状态 */
  833. status?: DeviceStatus;
  834. /** 采集时间 */
  835. collect_time: Date;
  836. /** 是否删除 (0否 1是) */
  837. is_deleted?: DeleteStatus;
  838. /** 创建时间 */
  839. created_at: Date;
  840. /** 更新时间 */
  841. updated_at: Date;
  842. }
  843. // 设备类型表
  844. export interface DeviceType {
  845. /** 主键ID */
  846. id: number;
  847. /** 类型名称 */
  848. name: string;
  849. /** 类型编码 */
  850. code: string;
  851. /** 设备类型图片URL */
  852. image_url?: string;
  853. /** 类型描述 */
  854. description?: string;
  855. /** 是否启用 (0否 1是) */
  856. is_enabled?: number;
  857. /** 是否删除 (0否 1是) */
  858. is_deleted?: number;
  859. /** 创建时间 */
  860. created_at: Date;
  861. /** 更新时间 */
  862. updated_at: Date;
  863. }
  864. // 知识库表
  865. export interface KnowInfo {
  866. /** 主键ID */
  867. id: number;
  868. /** 文章的标题 */
  869. title?: string;
  870. /** 文章的标签 */
  871. tags?: string;
  872. /** 文章的内容 */
  873. content?: string;
  874. /** 文章的作者 */
  875. author?: string;
  876. /** 文章的分类 */
  877. category?: string;
  878. /** 文章的封面图片URL */
  879. cover_url?: string;
  880. /** 审核状态 */
  881. audit_status?: number;
  882. /** 是否被删除 (0否 1是) */
  883. is_deleted?: number;
  884. /** 创建时间 */
  885. created_at: Date;
  886. /** 更新时间 */
  887. updated_at: Date;
  888. }
  889. // 操作日志表
  890. export interface OperationLog {
  891. /** 主键ID */
  892. id: number;
  893. /** 操作人ID */
  894. operator_id: number;
  895. /** 操作类型 */
  896. operation_type: string;
  897. /** 操作内容 */
  898. operation_content?: string;
  899. /** 操作结果 */
  900. operation_result?: string;
  901. /** 操作IP */
  902. ip_address?: string;
  903. /** 是否删除 (0否 1是) */
  904. is_deleted?: number;
  905. /** 创建时间 */
  906. created_at: Date;
  907. /** 更新时间 */
  908. updated_at: Date;
  909. }
  910. // 机柜信息表
  911. export interface RackInfo {
  912. /** 主键ID */
  913. id: number;
  914. /** 机柜名称 */
  915. rack_name?: string;
  916. /** 机柜编号 */
  917. rack_code?: string;
  918. /** 机柜可容纳设备数量,默认42U */
  919. capacity?: number;
  920. /** 机柜X轴位置坐标 */
  921. position_x?: number;
  922. /** 机柜Y轴位置坐标 */
  923. position_y?: number;
  924. /** 机柜Z轴位置坐标 */
  925. position_z?: number;
  926. /** 机柜所在区域 */
  927. area?: string;
  928. /** 机柜所在机房 */
  929. room?: string;
  930. /** 备注信息 */
  931. remark?: string;
  932. /** 是否禁用 (0否 1是) */
  933. is_disabled?: EnableStatus;
  934. /** 是否被删除 (0否 1是) */
  935. is_deleted?: DeleteStatus;
  936. /** 创建时间 */
  937. created_at: Date;
  938. /** 更新时间 */
  939. updated_at: Date;
  940. }
  941. // 机柜服务器表
  942. export interface RackServer {
  943. /** 主键ID */
  944. id: number;
  945. /** 关联的机柜ID */
  946. rack_id: number;
  947. /** 关联的资产ID */
  948. asset_id: number;
  949. /** 设备安装的起始U位 */
  950. start_position: number;
  951. /** 设备占用U数 */
  952. size?: number;
  953. /** 服务器类型 */
  954. server_type?: number;
  955. /** 备注信息 */
  956. remark?: string;
  957. /** 是否禁用 (0否 1是) */
  958. is_disabled?: EnableStatus;
  959. /** 是否被删除 (0否 1是) */
  960. is_deleted?: DeleteStatus;
  961. /** 创建时间 */
  962. created_at: Date;
  963. /** 更新时间 */
  964. updated_at: Date;
  965. }
  966. // 机柜服务器类型表
  967. export interface RackServerType {
  968. /** 主键ID */
  969. id: number;
  970. /** 类型名称 */
  971. name: string;
  972. /** 类型编码 */
  973. code: string;
  974. /** 类型图片 */
  975. image_url?: string;
  976. /** 类型描述 */
  977. description?: string;
  978. /** 是否启用 (0否 1是) */
  979. is_enabled?: EnableStatus;
  980. /** 是否被删除 (0否 1是) */
  981. is_deleted?: DeleteStatus;
  982. /** 创建时间 */
  983. created_at: Date;
  984. /** 更新时间 */
  985. updated_at: Date;
  986. }
  987. // 工单表
  988. export interface WorkOrder {
  989. /** 主键ID */
  990. id: number;
  991. /** 工单标题 */
  992. title: string;
  993. /** 关联设备ID */
  994. device_id?: number;
  995. /** 关联告警ID */
  996. alert_id?: number;
  997. /** 工单模板ID */
  998. template_id?: number;
  999. /** 工单内容 */
  1000. content?: string;
  1001. /** 工单状态 */
  1002. status: WorkOrderStatus;
  1003. /** 优先级 */
  1004. priority: WorkOrderPriority;
  1005. /** 创建人ID */
  1006. creator_id: number;
  1007. /** 处理人ID */
  1008. handler_id?: number;
  1009. /** 审核人ID */
  1010. auditor_id?: number;
  1011. /** 截止时间 */
  1012. deadline?: Date;
  1013. /** 处理结果 */
  1014. handle_result?: string;
  1015. /** 审核结果 */
  1016. audit_result?: string;
  1017. /** 是否删除 (0否 1是) */
  1018. is_deleted?: number;
  1019. /** 创建时间 */
  1020. created_at: Date;
  1021. /** 更新时间 */
  1022. updated_at: Date;
  1023. }
  1024. // 工单处理记录表
  1025. export interface WorkOrderLog {
  1026. /** 主键ID */
  1027. id: number;
  1028. /** 工单ID */
  1029. work_order_id: number;
  1030. /** 操作人ID */
  1031. operator_id: number;
  1032. /** 操作类型 */
  1033. action: WorkOrderAction;
  1034. /** 处理内容 */
  1035. content?: string;
  1036. /** 是否删除 (0否 1是) */
  1037. is_deleted?: number;
  1038. /** 创建时间 */
  1039. created_at: Date;
  1040. /** 更新时间 */
  1041. updated_at: Date;
  1042. }
  1043. // 工单模板表
  1044. export interface WorkOrderTemplate {
  1045. /** 主键ID */
  1046. id: number;
  1047. /** 模板名称 */
  1048. name: string;
  1049. /** 模板内容 */
  1050. content?: string;
  1051. /** 是否需要审核 (0否 1是) */
  1052. need_audit: number;
  1053. /** 默认处理人 */
  1054. default_handler_id?: number;
  1055. /** 默认完成时限(小时) */
  1056. default_deadline_hours?: number;
  1057. /** 常用语列表 */
  1058. common_phrases?: CommonPhrase[];
  1059. /** SLA配置 */
  1060. sla_config?: SLAConfig;
  1061. /** 流程配置 */
  1062. workflow_config?: WorkflowConfig;
  1063. /** 是否启用 (0否 1是) */
  1064. is_enabled?: number;
  1065. /** 是否删除 (0否 1是) */
  1066. is_deleted?: number;
  1067. /** 创建时间 */
  1068. created_at: Date;
  1069. /** 更新时间 */
  1070. updated_at: Date;
  1071. }
  1072. // 资产信息表
  1073. export interface ZichanInfo {
  1074. /** 主键ID */
  1075. id: number;
  1076. /** 资产名称 */
  1077. asset_name?: string;
  1078. /** 设备分类 */
  1079. device_category?: DeviceCategory;
  1080. /** 归属区域 */
  1081. area?: AreaType;
  1082. /** 供应商 */
  1083. supplier?: string;
  1084. /** 使用地址 */
  1085. use_address?: string;
  1086. /** 运行情况 */
  1087. operation_status?: string;
  1088. /** 是否审核 (0否 1是) */
  1089. is_audited?: number;
  1090. /** 审核状态 */
  1091. audit_status?: AuditStatus;
  1092. /** 资产状态 */
  1093. asset_status?: AssetStatus;
  1094. /** 入库数量 */
  1095. stock_quantity?: number;
  1096. /** 质保时间 */
  1097. warranty_time?: Date;
  1098. /** 品牌 */
  1099. brand?: string;
  1100. /** IP地址 */
  1101. ip_address?: string;
  1102. /** 设备状态 */
  1103. device_status?: DeviceStatus;
  1104. /** 网络状态 */
  1105. network_status?: NetworkStatus;
  1106. /** 丢包率 */
  1107. packet_loss?: number;
  1108. /** 图片 */
  1109. images?: string;
  1110. /** 是否备件 (0否 1是) */
  1111. is_spare?: number;
  1112. /** 是否被禁用 (0否 1是) */
  1113. is_disabled?: number;
  1114. /** 是否被删除 (0否 1是) */
  1115. is_deleted?: number;
  1116. /** 资产位置经度 */
  1117. longitude?: number;
  1118. /** 资产位置纬度 */
  1119. latitude?: number;
  1120. /** CPU信息 */
  1121. cpu?: string;
  1122. /** 内存信息 */
  1123. memory?: string;
  1124. /** 硬盘信息 */
  1125. disk?: string;
  1126. /** 创建时间 */
  1127. created_at: Date;
  1128. /** 更新时间 */
  1129. updated_at: Date;
  1130. }
  1131. // 资产分类表
  1132. export interface ZichanCategory {
  1133. /** 主键ID */
  1134. id: number;
  1135. /** 分类名称 */
  1136. name: string;
  1137. /** 分类编码 */
  1138. code: string;
  1139. /** 分类图片 */
  1140. image_url?: string;
  1141. /** 分类描述 */
  1142. description?: string;
  1143. /** 是否启用 (0否 1是) */
  1144. is_enabled?: EnableStatus;
  1145. /** 是否被删除 (0否 1是) */
  1146. is_deleted?: DeleteStatus;
  1147. /** 创建时间 */
  1148. created_at: Date;
  1149. /** 更新时间 */
  1150. updated_at: Date;
  1151. }
  1152. // 资产归属区域
  1153. export interface ZichanArea {
  1154. /** 主键ID */
  1155. id: number;
  1156. /** 区域名称 */
  1157. name: string;
  1158. /** 区域编码 */
  1159. code: string;
  1160. /** 区域图片 */
  1161. image_url?: string;
  1162. /** 区域描述 */
  1163. description?: string;
  1164. /** 是否启用 (0否 1是) */
  1165. is_enabled?: EnableStatus;
  1166. /** 是否被删除 (0否 1是) */
  1167. is_deleted?: DeleteStatus;
  1168. /** 创建时间 */
  1169. created_at: Date;
  1170. /** 更新时间 */
  1171. updated_at: Date;
  1172. }
  1173. // 资产流转记录表
  1174. export interface ZichanTransLog {
  1175. /** 主键ID */
  1176. id: number;
  1177. /** 资产流转 */
  1178. asset_transfer?: AssetTransferType;
  1179. /** 资产ID */
  1180. asset_id?: number;
  1181. /** 人员 */
  1182. person?: string;
  1183. /** 部门 */
  1184. department?: string;
  1185. /** 电话 */
  1186. phone?: string;
  1187. /** 流转事由 */
  1188. transfer_reason?: string;
  1189. /** 流转时间 */
  1190. transfer_time?: Date | string;
  1191. /** 是否被禁用 (0否 1是) */
  1192. is_disabled?: number;
  1193. /** 是否被删除 (0否 1是) */
  1194. is_deleted?: number;
  1195. /** 创建时间 */
  1196. created_at: Date;
  1197. /** 更新时间 */
  1198. updated_at: Date;
  1199. /** 关联的资产信息(查询时后端关联返回) */
  1200. asset_info?: ZichanInfo;
  1201. }
  1202. // 文件库接口
  1203. export interface FileLibrary {
  1204. /** 主键ID */
  1205. id: number;
  1206. /** 文件名称 */
  1207. file_name: string;
  1208. /** 原始文件名 */
  1209. original_filename?: string;
  1210. /** 文件路径 */
  1211. file_path: string;
  1212. /** 文件类型 */
  1213. file_type: string;
  1214. /** 文件大小(字节) */
  1215. file_size: number;
  1216. /** 上传用户ID */
  1217. uploader_id?: number;
  1218. /** 上传者名称 */
  1219. uploader_name?: string;
  1220. /** 文件分类 */
  1221. category_id?: number;
  1222. /** 文件标签 */
  1223. tags?: string;
  1224. /** 文件描述 */
  1225. description?: string;
  1226. /** 下载次数 */
  1227. download_count: number;
  1228. /** 是否禁用 (0否 1是) */
  1229. is_disabled?: EnableStatus;
  1230. /** 是否被删除 (0否 1是) */
  1231. is_deleted?: DeleteStatus;
  1232. /** 创建时间 */
  1233. created_at: string;
  1234. /** 更新时间 */
  1235. updated_at: string;
  1236. }
  1237. // 文件分类接口
  1238. export interface FileCategory {
  1239. id: number;
  1240. name: string;
  1241. code: string;
  1242. description?: string;
  1243. is_deleted?: DeleteStatus;
  1244. created_at: string;
  1245. updated_at: string;
  1246. }
  1247. // 资产流转类型枚举
  1248. export enum AssetTransferType {
  1249. STOCK = 0, // 在库
  1250. BORROW = 1, // 借用
  1251. RETURN = 2, // 归还
  1252. LOST = 3, // 遗失
  1253. MAINTAIN = 4 // 维护保养
  1254. }
  1255. // 资产流转类型名称映射
  1256. export const AssetTransferTypeNameMap: Record<AssetTransferType, string> = {
  1257. [AssetTransferType.STOCK]: '在库',
  1258. [AssetTransferType.BORROW]: '借用',
  1259. [AssetTransferType.RETURN]: '归还',
  1260. [AssetTransferType.LOST]: '遗失',
  1261. [AssetTransferType.MAINTAIN]: '维护保养'
  1262. };
  1263. // 资产流转类型颜色映射
  1264. export const AssetTransferTypeColorMap: Record<AssetTransferType, string> = {
  1265. [AssetTransferType.STOCK]: 'green',
  1266. [AssetTransferType.BORROW]: 'blue',
  1267. [AssetTransferType.RETURN]: 'cyan',
  1268. [AssetTransferType.LOST]: 'red',
  1269. [AssetTransferType.MAINTAIN]: 'orange'
  1270. };
  1271. // 添加图表类型定义(从大屏移植)
  1272. export interface CategoryChartData {
  1273. 设备分类: string;
  1274. 设备数: number;
  1275. }
  1276. export interface CategoryChartDataWithPercent extends CategoryChartData {
  1277. 百分比: string;
  1278. }
  1279. export interface OnlineRateChartData {
  1280. time_interval: string;
  1281. online_devices: number;
  1282. total_devices: number;
  1283. }
  1284. export interface StateChartData {
  1285. 资产流转: string;
  1286. 设备数: number;
  1287. }
  1288. export interface StateChartDataWithPercent extends StateChartData {
  1289. 百分比: string;
  1290. }
  1291. export interface AlarmChartData {
  1292. time_interval: string;
  1293. total_devices: number;
  1294. }
  1295. export interface AlarmDeviceData {
  1296. deviceName: string;
  1297. alarmCount: number;
  1298. rank: number;
  1299. }
  1300. // 设备与资产信息结合的接口
  1301. export interface DeviceWithAssetInfo {
  1302. id: number;
  1303. asset_name?: string;
  1304. device_category?: number;
  1305. ip_address?: string;
  1306. device_status?: DeviceStatus;
  1307. network_status?: NetworkStatus;
  1308. packet_loss?: PacketLossStatus;
  1309. cpu?: string;
  1310. memory?: string;
  1311. disk?: string;
  1312. is_deleted?: number;
  1313. }
  1314. // 地图类型
  1315. export enum MapMode {
  1316. ONLINE = 'online',
  1317. OFFLINE = 'offline'
  1318. }
  1319. // 地图标记数据接口 - 基础定义
  1320. export interface MarkerData {
  1321. /** 标记点经度 */
  1322. longitude: number;
  1323. /** 标记点纬度 */
  1324. latitude: number;
  1325. /** 标记点ID */
  1326. id?: string | number;
  1327. /** 标记点标题 */
  1328. title?: string;
  1329. /** 标记点描述 */
  1330. description?: string;
  1331. /** 标记点图标URL */
  1332. iconUrl?: string;
  1333. /** 标记点状态 */
  1334. status?: string;
  1335. /** 标记点类型 */
  1336. type?: string;
  1337. /** 标记点额外数据 */
  1338. extraData?: Record<string, any>;
  1339. }
  1340. // 设备地图监控视图设备接口
  1341. export interface MapViewDevice extends MarkerData {
  1342. id: number;
  1343. name?: string;
  1344. type_code: string;
  1345. device_category?: DeviceCategory;
  1346. device_status?: DeviceStatus;
  1347. description?: string;
  1348. address?: string;
  1349. protocol?: DeviceProtocolType;
  1350. last_update_time?: string;
  1351. area_code?: string;
  1352. area_name?: string;
  1353. image_url?: string;
  1354. }
  1355. // 设备地图筛选条件
  1356. export interface DeviceMapFilter {
  1357. type_code?: string;
  1358. device_category?: DeviceCategory[];
  1359. device_status?: DeviceStatus;
  1360. area_code?: string[];
  1361. keyword?: string;
  1362. device_id?: number;
  1363. }
  1364. // 设备地图统计数据接口
  1365. export interface DeviceMapStats {
  1366. total: number;
  1367. online: number;
  1368. offline: number;
  1369. error: number;
  1370. normal?: number;
  1371. fault?: number;
  1372. categoryStats?: {
  1373. category: DeviceCategory;
  1374. count: number;
  1375. name: string;
  1376. }[];
  1377. }
  1378. // 设备树统计数据类型
  1379. export type DeviceTreeStats = Record<string, {
  1380. total: number;
  1381. online: number;
  1382. offline: number;
  1383. error: number;
  1384. }>;
  1385. // 设备地图响应数据接口
  1386. export interface DeviceMapDataResponse {
  1387. data: MapViewDevice[];
  1388. stats: DeviceMapStats;
  1389. total?: number;
  1390. page?: number;
  1391. pageSize?: number;
  1392. }
  1393. // 设备地图统计响应接口
  1394. export interface DeviceMapStatsResponse {
  1395. data: DeviceMapStats;
  1396. }
  1397. // 设备树节点类型枚举
  1398. export enum DeviceTreeNodeType {
  1399. CATEGORY = 'category',
  1400. DEVICE = 'device'
  1401. }
  1402. // 设备树节点状态枚举
  1403. export enum DeviceTreeNodeStatus {
  1404. NORMAL = 'normal',
  1405. ERROR = 'error',
  1406. OFFLINE = 'offline',
  1407. WARNING = 'warning'
  1408. }
  1409. // 设备树节点接口
  1410. export interface DeviceTreeNode {
  1411. key: string;
  1412. title: string;
  1413. type: DeviceTreeNodeType;
  1414. status?: DeviceTreeNodeStatus;
  1415. icon?: string | null;
  1416. isLeaf?: boolean;
  1417. children?: DeviceTreeNode[];
  1418. }
  1419. // 登录位置相关类型定义
  1420. export interface LoginLocation {
  1421. id: number;
  1422. loginTime: string;
  1423. ipAddress: string;
  1424. longitude: number;
  1425. latitude: number;
  1426. location_name?: string;
  1427. user: {
  1428. id: number;
  1429. username: string;
  1430. nickname: string;
  1431. };
  1432. }
  1433. export interface LoginLocationDetail {
  1434. id: number;
  1435. user_id: number;
  1436. login_time: string;
  1437. ip_address: string;
  1438. longitude: number;
  1439. latitude: number;
  1440. location_name: string;
  1441. user_agent: string;
  1442. user: {
  1443. id: number;
  1444. username: string;
  1445. nickname: string;
  1446. };
  1447. }
  1448. // 系统设置分组
  1449. export enum SystemSettingGroup {
  1450. BASIC = 'basic', // 基础设置
  1451. FEATURE = 'feature', // 功能设置
  1452. UPLOAD = 'upload', // 上传设置
  1453. NOTIFICATION = 'notify' // 通知设置
  1454. }
  1455. // 系统设置键
  1456. export enum SystemSettingKey {
  1457. // 基础设置
  1458. SITE_NAME = 'SITE_NAME', // 站点名称
  1459. SITE_DESCRIPTION = 'SITE_DESCRIPTION', // 站点描述
  1460. SITE_KEYWORDS = 'SITE_KEYWORDS', // 站点关键词
  1461. SITE_LOGO = 'SITE_LOGO', // 站点LOGO
  1462. SITE_FAVICON = 'SITE_FAVICON', // 站点图标
  1463. // 功能设置
  1464. ENABLE_REGISTER = 'ENABLE_REGISTER', // 是否开启注册
  1465. ENABLE_CAPTCHA = 'ENABLE_CAPTCHA', // 是否开启验证码
  1466. LOGIN_ATTEMPTS = 'LOGIN_ATTEMPTS', // 登录尝试次数
  1467. SESSION_TIMEOUT = 'SESSION_TIMEOUT', // 会话超时时间(分钟)
  1468. // 上传设置
  1469. UPLOAD_MAX_SIZE = 'UPLOAD_MAX_SIZE', // 最大上传大小(MB)
  1470. ALLOWED_FILE_TYPES = 'ALLOWED_FILE_TYPES', // 允许的文件类型
  1471. IMAGE_COMPRESS = 'IMAGE_COMPRESS', // 是否压缩图片
  1472. IMAGE_MAX_WIDTH = 'IMAGE_MAX_WIDTH', // 图片最大宽度
  1473. // 通知设置
  1474. NOTIFY_ON_LOGIN = 'NOTIFY_ON_LOGIN', // 登录通知
  1475. NOTIFY_ON_UPLOAD = 'NOTIFY_ON_UPLOAD', // 上传通知
  1476. NOTIFY_ON_ERROR = 'NOTIFY_ON_ERROR', // 错误通知
  1477. // 主题设置
  1478. ENABLE_THEME_CONFIG = 'ENABLE_THEME_CONFIG' // 是否开启主题配置
  1479. }
  1480. export type SystemSettingGroupType = SystemSettingGroup;
  1481. export type SystemSettingKeyType = SystemSettingKey;
  1482. // 系统设置值类型
  1483. export type SystemSettingValue = string | number | boolean;
  1484. // 系统设置项接口
  1485. export interface SystemSetting {
  1486. id: number;
  1487. key: SystemSettingKeyType; // 设置键
  1488. value: SystemSettingValue; // 设置值
  1489. description?: string; // 设置描述
  1490. group: SystemSettingGroupType; // 设置分组
  1491. created_at?: string;
  1492. updated_at?: string;
  1493. }
  1494. // 系统设置分组类型
  1495. export interface SystemSettingGroupData {
  1496. name: string;
  1497. description: string;
  1498. settings: SystemSetting[];
  1499. }
  1500. // 系统设置记录类型
  1501. export type SystemSettingRecord = Record<SystemSettingKey, SystemSettingValue>;
  1502. // 允许的文件类型枚举
  1503. export enum AllowedFileType {
  1504. JPG = 'jpg',
  1505. JPEG = 'jpeg',
  1506. PNG = 'png',
  1507. GIF = 'gif',
  1508. DOC = 'doc',
  1509. DOCX = 'docx',
  1510. XLS = 'xls',
  1511. XLSX = 'xlsx',
  1512. PDF = 'pdf'
  1513. }
  1514. // 允许的文件类型列表(用于系统设置)
  1515. export const ALLOWED_FILE_TYPES = Object.values(AllowedFileType).join(',');