From 7a11887c2790528f97ff1ebfbb1dd016cecf811c Mon Sep 17 00:00:00 2001 From: lzh Date: Sat, 21 Mar 2026 10:17:54 +0800 Subject: [PATCH] =?UTF-8?q?feat(inspection):=20=E6=96=B0=E5=A2=9E=E5=B7=A1?= =?UTF-8?q?=E6=A3=80=E6=A8=A1=E5=9D=97=20API=20=E6=8E=A5=E5=8F=A3=E5=92=8C?= =?UTF-8?q?=E5=8C=BA=E5=9F=9F=E6=A0=91=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 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) --- src/api/ops/area/index.ts | 21 +++ src/api/ops/inspection/index.ts | 143 ++++++++++++++++++ .../scan/inspection/mock/inspection-data.ts | 23 +++ src/utils/qrcode.ts | 13 ++ 4 files changed, 200 insertions(+) create mode 100644 src/api/ops/area/index.ts create mode 100644 src/api/ops/inspection/index.ts create mode 100644 src/pages/scan/inspection/mock/inspection-data.ts create mode 100644 src/utils/qrcode.ts diff --git a/src/api/ops/area/index.ts b/src/api/ops/area/index.ts new file mode 100644 index 0000000..6bf7fba --- /dev/null +++ b/src/api/ops/area/index.ts @@ -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('/ops/area/tree', params) +} diff --git a/src/api/ops/inspection/index.ts b/src/api/ops/inspection/index.ts new file mode 100644 index 0000000..c7885d7 --- /dev/null +++ b/src/api/ops/inspection/index.ts @@ -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('/ops/inspection/template/list-by-area', { areaId }) +} + +/** 提交巡检结果 */ +export function submitInspection(data: InspectionSubmitReqVO) { + return http.post('/ops/inspection/submit', data) +} + +/** 巡检记录分页 */ +export function getInspectionRecordPage(params: InspectionRecordPageReqVO) { + return http.get>('/ops/inspection/record/page', params) +} + +/** 巡检记录详情 */ +export function getInspectionRecord(id: number) { + return http.get('/ops/inspection/record/get', { id }) +} + +/** 巡检统计数据 */ +export function getInspectionStats(params?: InspectionStatsReqVO) { + return http.get('/ops/inspection/record/stats', params) +} diff --git a/src/pages/scan/inspection/mock/inspection-data.ts b/src/pages/scan/inspection/mock/inspection-data.ts new file mode 100644 index 0000000..259ed2b --- /dev/null +++ b/src/pages/scan/inspection/mock/inspection-data.ts @@ -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 diff --git a/src/utils/qrcode.ts b/src/utils/qrcode.ts new file mode 100644 index 0000000..06b66f1 --- /dev/null +++ b/src/utils/qrcode.ts @@ -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 +}