feat(inspection): 新增巡检模块 API 接口和区域树接口

- 新增 src/api/ops/inspection:巡检表单、提交、记录分页、详情、统计接口
- 新增 src/api/ops/area:运维区域树接口(getOpsAreaTree)
- 新增 src/utils/qrcode.ts:从 mock 提取二维码解析工具函数
- 新增 mock/inspection-data.ts:检查项类型定义和快捷标签常量

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
lzh
2026-03-21 10:17:54 +08:00
parent bd14ad2cb8
commit 7a11887c27
4 changed files with 200 additions and 0 deletions

21
src/api/ops/area/index.ts Normal file
View File

@@ -0,0 +1,21 @@
import { http } from '@/http/http'
/** 运维业务区域 VO */
export interface OpsBusAreaVO {
id: number
parentId: number
areaName: string
areaCode: string
/** PARK | BUILDING | FLOOR | FUNCTION */
areaType: string
functionType?: string
floorNo?: number
isActive: boolean
sort: number
children?: OpsBusAreaVO[]
}
/** 获取运维区域树(平铺列表,前端用 parentId 组装树) */
export function getOpsAreaTree(params?: { areaType?: string, isActive?: boolean, name?: string }) {
return http.get<OpsBusAreaVO[]>('/ops/area/tree', params)
}

View File

@@ -0,0 +1,143 @@
import type { PageParam, PageResult } from '@/http/types'
import { http } from '@/http/http'
// ========== 请求 VO ==========
/** 提交巡检请求 */
export interface InspectionSubmitReqVO {
areaId: number
/** 0=正常 1=异常 */
isLocationException: number
remark: string
tags?: string[]
photos?: string[]
items: {
templateId: number
isPassed: boolean
remark: string
tags?: string[]
}[]
}
/** 巡检记录分页请求 */
export interface InspectionRecordPageReqVO extends PageParam {
areaId?: number
inspectorId?: number
/** 0=不合格 1=合格 */
resultStatus?: number
createTime?: string[]
}
// ========== 响应 VO ==========
/** 绑定的信标 */
export interface InspectionBoundBeaconVO {
major: number
minor: number
}
/** 信标配置 */
export interface InspectionBeaconConfigVO {
uuid: string
boundBeacons: InspectionBoundBeaconVO[]
rssiThreshold: number
timeoutMs: number
}
/** 检查项模板响应 */
export interface InspectionTemplateRespVO {
id: number
functionType: string
itemTitle: string
itemDescription?: string
sortOrder: number
isActive: boolean
}
/** 巡检表单响应list-by-area 返回) */
export interface InspectionFormRespVO {
areaId: number
areaName: string
areaFullName?: string
functionType: string
items: InspectionTemplateRespVO[]
/** 为 null 时表示该区域无需蓝牙定位 */
beaconConfig: InspectionBeaconConfigVO | null
}
/** 巡检记录(列表项,对应 InspectionRecordRespVO */
export interface InspectionRecordRespVO {
id: number
areaId: number
areaFullName?: string
inspectorId: number
inspectorName?: string
/** 0=正常 1=异常 */
isLocationException: number
/** 0=不合格 1=合格 */
resultStatus: number
/** 1=个人责任 2=突发状况 3=正常 */
attributionResult?: number
generatedOrderId?: number
createTime: string
}
/** 巡检明细项(对应 InspectionRecordItemRespVO */
export interface InspectionRecordItemRespVO {
id: number
templateId: number
itemTitle?: string
itemDescription?: string
isPassed: boolean
remark?: string
tags?: string[]
}
/** 巡检记录详情(对应 InspectionRecordDetailRespVO */
export interface InspectionRecordDetailRespVO extends InspectionRecordRespVO {
remark?: string
tags?: string[]
photos?: string[]
items?: InspectionRecordItemRespVO[]
}
/** 巡检统计查询参数 */
export interface InspectionStatsReqVO {
areaId?: number
createTime?: string[]
}
/** 巡检统计数据 */
export interface InspectionStatsRespVO {
totalCount: number
passedCount: number
failedCount: number
passRate: number
}
// ========== API 函数 ==========
/** 按区域获取巡检表单(检查项 + 信标配置) */
export function getInspectionForm(areaId: number) {
return http.get<InspectionFormRespVO>('/ops/inspection/template/list-by-area', { areaId })
}
/** 提交巡检结果 */
export function submitInspection(data: InspectionSubmitReqVO) {
return http.post<number>('/ops/inspection/submit', data)
}
/** 巡检记录分页 */
export function getInspectionRecordPage(params: InspectionRecordPageReqVO) {
return http.get<PageResult<InspectionRecordRespVO>>('/ops/inspection/record/page', params)
}
/** 巡检记录详情 */
export function getInspectionRecord(id: number) {
return http.get<InspectionRecordDetailRespVO>('/ops/inspection/record/get', { id })
}
/** 巡检统计数据 */
export function getInspectionStats(params?: InspectionStatsReqVO) {
return http.get<InspectionStatsRespVO>('/ops/inspection/record/stats', params)
}

View File

@@ -0,0 +1,23 @@
/** 检查项(运行时状态) */
export interface CheckItem {
templateId: number
title: string
/** 检查项描述/说明 */
description: string
/** null=未选择 true=合格 false=不合格 */
isPassed: boolean | null
remark: string
/** 已选的快捷标签 */
tags: string[]
}
/** 检测到的信标 */
export interface DetectedBeacon {
mac: string
rssi: number
}
/** 快捷标签 */
export const QUICK_TAGS = ['水渍', '异味', '堵塞', '损坏', '缺耗材', '其他']
// parseQrCode 已提取到 @/utils/qrcode.ts

13
src/utils/qrcode.ts Normal file
View File

@@ -0,0 +1,13 @@
/**
* 解析区域二维码内容
* 二维码 JSON 格式:{ "type": "AREA", "id": 123, "code": "A001", "name": "一楼大厅" }
*/
export function parseQrCode(code: string): { areaId: number, areaName: string } | null {
try {
const data = JSON.parse(code)
if (data.type === 'AREA' && data.id && data.name) {
return { areaId: data.id, areaName: data.name }
}
} catch { /* invalid QR code JSON */ }
return null
}