diff --git a/src/main/resources/web/src/api/request.ts b/src/main/resources/web/src/api/request.ts index 4f80b6f..8ef72c2 100644 --- a/src/main/resources/web/src/api/request.ts +++ b/src/main/resources/web/src/api/request.ts @@ -6,11 +6,19 @@ export async function request( url: string, options: RequestInit = {} ): Promise { - console.log(`🌐 发送请求: ${API_BASE_URL}${url}`, { - method: options.method || 'GET', + // 处理日志数据,GET/HEAD 方法不显示 body + const method = options.method?.toUpperCase() || 'GET'; + const logData: Record = { + method, headers: options.headers, - body: options.body ? JSON.parse(options.body as string) : undefined, - }) + }; + + // 只对非 GET/HEAD 方法显示 body + if (!['GET', 'HEAD'].includes(method)) { + logData.body = options.body ? JSON.parse(options.body as string) : undefined; + } + + console.log(`🌐 发送请求: ${API_BASE_URL}${url}`, logData) const defaultOptions: RequestInit = { headers: { @@ -39,10 +47,13 @@ export async function request( } try { - const response = await fetch(`${API_BASE_URL}${url}`, { - ...defaultOptions, - ...options, - }) + // 确保 GET/HEAD 请求不包含 body + const fetchOptions = { ...defaultOptions, ...options }; + if (['GET', 'HEAD'].includes(method)) { + delete fetchOptions.body; + } + + const response = await fetch(`${API_BASE_URL}${url}`, fetchOptions) console.log('📥 响应状态:', response.status, response.statusText) diff --git a/src/main/resources/web/src/api/types/repairman.ts b/src/main/resources/web/src/api/types/repairman.ts new file mode 100644 index 0000000..3f7636f --- /dev/null +++ b/src/main/resources/web/src/api/types/repairman.ts @@ -0,0 +1,2 @@ + // src/api/types/repairman.ts + export type RepairmanStatus = 'idle' | 'busy' | 'vacation' diff --git a/src/main/resources/web/src/api/types/workorder.ts b/src/main/resources/web/src/api/types/workorder.ts new file mode 100644 index 0000000..a91c25c --- /dev/null +++ b/src/main/resources/web/src/api/types/workorder.ts @@ -0,0 +1,10 @@ +// src/api/types/workorder.ts +export interface WorkOrder { + orderId: string + deviceId: string + areaId: string + description: string + status: 'pending' | 'processing' | 'reviewing' | 'completed' | 'timeout' + createdTime?: string + assignedRepairmanId?: string +} diff --git a/src/main/resources/web/src/router/index.ts b/src/main/resources/web/src/router/index.ts index ae82459..70d20ac 100644 --- a/src/main/resources/web/src/router/index.ts +++ b/src/main/resources/web/src/router/index.ts @@ -4,6 +4,7 @@ import LoginView from '../views/LoginView.vue' import MainLayout from '../components/layout/MainLayout.vue' import { useAuthStore } from '@/stores/auth' + const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), routes: [ @@ -122,22 +123,42 @@ const router = createRouter({ } }, // 人员管理相关路由 + // 在 personnel/admin 路由下添加子路由 { - path: 'personnel/admin', - name: 'personnel-admin', - component: () => import('../views/personnel/Admin.vue'), - meta: { - title: '管理员管理' - } + path: 'personnel/admin', + name: 'personnel-admin', + component: () => import('../views/personnel/Admin.vue'), + meta: { + title: '管理员管理' }, + children: [ + { + path: 'add', + name: 'admin-add', + component: () => import('../views/personnel/addAdmin.vue'), + meta: { + title: '新增管理员' + } + } + ] +}, { path: 'personnel/maintenance', name: 'personnel-maintenance', - component: () => import('../views/personnel/Maintenance.vue'), + component: () => import('@/views/personnel/Maintenance.vue'), meta: { - title: '运维人员管理' + title: '维修人员管理' } }, + { + path: 'personnel/maintenance/records/:id', + name: 'MaintenanceRecord', + component: () => import('@/views/personnel/MaintenanceRecord.vue'), + meta: { + title: '维修记录详情' + } + } +, { path: 'personnel/user', name: 'personnel-user', diff --git a/src/main/resources/web/src/stores/auth.ts b/src/main/resources/web/src/stores/auth.ts index cff9364..6042893 100644 --- a/src/main/resources/web/src/stores/auth.ts +++ b/src/main/resources/web/src/stores/auth.ts @@ -7,9 +7,10 @@ import type { LoginRequest, LoginVO, ResultVO } from '@/api/types/auth' interface UserInfo { id: number username: string - realName: string - role: string + realName?: string + role?: string avatar?: string + areaId?: string } export const useAuthStore = defineStore('auth', () => { diff --git a/src/main/resources/web/src/views/equipment/WaterMaker.vue b/src/main/resources/web/src/views/equipment/WaterMaker.vue index 13bc42c..aadfa19 100644 --- a/src/main/resources/web/src/views/equipment/WaterMaker.vue +++ b/src/main/resources/web/src/views/equipment/WaterMaker.vue @@ -15,19 +15,19 @@ @@ -53,57 +53,57 @@
- - - - - - - - - + + + + + + + + + - - - - - - + + + + + - - + - - - - + + + + +
设备ID设备机型 所属片区详细位置状态最后上传时间操作
设备ID设备机型 所属片区详细位置状态最后上传时间操作
{{ device.deviceId }}{{ device.deviceType === 'WATER_MAKER' ? '制水机' : device.deviceType }}{{ device.areaId }}{{ device.installLocation }} +
{{ device.deviceId }}{{ device.deviceType === 'WATER_MAKER' ? '制水机' : device.deviceType }}{{ device.areaId }}{{ device.installLocation }} {{ formatStatus(device.status) }} - {{ formatDate(device.lastHeartbeatTime) }} - - {{ formatDate(device.lastHeartbeatTime) }} + + - + - + + -
暂无设备数据
暂无设备数据
@@ -111,9 +111,9 @@ @@ -170,7 +170,8 @@ \ No newline at end of file + diff --git a/src/main/resources/web/vite.config.ts b/src/main/resources/web/vite.config.ts index 2c67947..c68830d 100644 --- a/src/main/resources/web/vite.config.ts +++ b/src/main/resources/web/vite.config.ts @@ -3,12 +3,33 @@ import vue from '@vitejs/plugin-vue' // https://vite.dev/config/ export default defineConfig({ - plugins: [ - vue(), - ], - resolve: { - alias: { - '@': '/src' + plugins: [ + vue(), + ], + resolve: { + alias: { + '@': '/src' + }, }, - }, -}) + server: { + proxy: { + // 代理所有以 /api 开头的请求到后端 + '/api': { + target: 'http://localhost:8080', // Spring Boot 后端地址 + changeOrigin: true, // 改变请求来源 + secure: false, // 如果是https,可能需要设置为false + // 如果需要重写路径,可以取消下面的注释 + // rewrite: (path) => path.replace(/^\/api/, '') + }, + // 如果需要代理其他路径,可以继续添加 + // '/ws': { + // target: 'ws://localhost:8080', + // ws: true + // } + }, + // 可选:设置端口 + port: 5173, // Vite默认端口 + // 可选:自动打开浏览器 + open: true + } +}) \ No newline at end of file