From 5c7728e3db80af9705ea81aa465ceef7f4338699 Mon Sep 17 00:00:00 2001 From: chiguyong Date: Tue, 24 Mar 2026 00:48:16 +0800 Subject: [PATCH] feat: add spare part management frontend pages --- src/api/sparepart.ts | 148 ++++++++ src/router/index.ts | 24 ++ src/views/Layout.vue | 53 +-- src/views/sparepart/SparePartDetail.vue | 206 +++++++++++ src/views/sparepart/SparePartList.vue | 445 ++++++++++++++++++++++++ src/views/sparepart/StockOperation.vue | 226 ++++++++++++ 6 files changed, 1078 insertions(+), 24 deletions(-) create mode 100644 src/api/sparepart.ts create mode 100644 src/views/sparepart/SparePartDetail.vue create mode 100644 src/views/sparepart/SparePartList.vue create mode 100644 src/views/sparepart/StockOperation.vue diff --git a/src/api/sparepart.ts b/src/api/sparepart.ts new file mode 100644 index 00000000..34bdaabe --- /dev/null +++ b/src/api/sparepart.ts @@ -0,0 +1,148 @@ +import request from '@/utils/request' + +// ==================== 备件相关类型 ==================== + +// 备件分类 +export interface SparePartCategory { + id: string + name: string + description?: string + createdAt?: string + updatedAt?: string +} + +// 备件 +export interface SparePart { + id: string + name: string + code: string + categoryId?: string + categoryName?: string + projectId: string + projectName?: string + unit?: string + currentStock?: number + safeStock?: number + lowStockWarning?: boolean + description?: string + createdAt?: string + updatedAt?: string +} + +// 备件表单 +export interface SparePartForm { + id?: string + name: string + code: string + categoryId?: string + projectId: string + unit?: string + currentStock?: number + safeStock?: number + description?: string +} + +// 库存记录 +export interface StockRecord { + id: string + sparePartId: string + sparePartName?: string + operationType: 'IN' | 'OUT' + quantity: number + beforeStock?: number + afterStock?: number + relatedOrderId?: string + relatedOrderNo?: string + operatorId?: string + operatorName?: string + remark?: string + createdAt?: string +} + +// 入库请求 +export interface InStockRequest { + sparePartId: string + quantity: number + remark?: string +} + +// 出库请求 +export interface OutStockRequest { + sparePartId: string + quantity: number + relatedOrderId?: string + relatedOrderNo?: string + remark?: string +} + +// 分页响应 +export interface PageResponse { + content: T[] + totalElements: number + totalPages: number + size: number + number: number +} + +// ==================== 备件分类 API ==================== + +// 获取分类列表 +export function getSparePartCategories() { + return request.get('/api/v1/ops/spare-parts/categories') +} + +// 创建分类 +export function createSparePartCategory(data: { name: string; description?: string }) { + return request.post('/api/v1/ops/spare-parts/categories', data) +} + +// ==================== 备件 API ==================== + +// 获取备件列表 +export function getSparePartList(projectId: string, categoryId?: string) { + return request.get>('/api/v1/ops/spare-parts', { + params: { projectId, categoryId } + }) +} + +// 获取备件详情 +export function getSparePartDetail(id: string) { + return request.get(`/api/v1/ops/spare-parts/${id}`) +} + +// 创建备件 +export function createSparePart(data: SparePartForm) { + return request.post('/api/v1/ops/spare-parts', data) +} + +// 更新备件 +export function updateSparePart(id: string, data: SparePartForm) { + return request.put(`/api/v1/ops/spare-parts/${id}`, data) +} + +// 删除备件 +export function deleteSparePart(id: string) { + return request.delete(`/api/v1/ops/spare-parts/${id}`) +} + +// 获取低库存备件 +export function getLowStockSpareParts(projectId: string) { + return request.get('/api/v1/ops/spare-parts/low-stock', { + params: { projectId } + }) +} + +// 入库 +export function inStock(data: InStockRequest) { + return request.post('/api/v1/ops/spare-parts/in-stock', data) +} + +// 出库 +export function outStock(data: OutStockRequest) { + return request.post('/api/v1/ops/spare-parts/out-stock', data) +} + +// 获取备件记录 +export function getSparePartRecords(id: string) { + return request.get(`/api/v1/ops/spare-parts/${id}/records`) +} diff --git a/src/router/index.ts b/src/router/index.ts index c1545a89..1e456a03 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -110,6 +110,30 @@ const router = createRouter({ name: 'EnergyStatistics', component: () => import('@/views/energy/EnergyStatistics.vue'), meta: { title: '能耗统计' } + }, + { + path: 'sparepart/list', + name: 'SparePartList', + component: () => import('@/views/sparepart/SparePartList.vue'), + meta: { title: '备件管理' } + }, + { + path: 'sparepart/detail/:id', + name: 'SparePartDetail', + component: () => import('@/views/sparepart/SparePartDetail.vue'), + meta: { title: '备件详情' } + }, + { + path: 'sparepart/stock/in', + name: 'SparePartInStock', + component: () => import('@/views/sparepart/StockOperation.vue'), + meta: { title: '备件入库' } + }, + { + path: 'sparepart/stock/out', + name: 'SparePartOutStock', + component: () => import('@/views/sparepart/StockOperation.vue'), + meta: { title: '备件出库' } } ] } diff --git a/src/views/Layout.vue b/src/views/Layout.vue index b3e84a78..6926b25a 100644 --- a/src/views/Layout.vue +++ b/src/views/Layout.vue @@ -43,32 +43,37 @@ const menuItems: MenuProps['items'] = [ ] }, { - key: 'operation', - label: '运营管理', - type: 'group', - children: [ - { - key: '/maintenance/plans', - icon: () => h(ToolOutlined), - label: '维保计划' - }, - { - key: '/maintenance/tasks', - icon: () => h(ToolOutlined), - label: '维保任务' - }, - { - key: 'energy', - icon: () => h(HeatMapOutlined), - label: '能耗管理', + key: 'operation', + label: '运营管理', + type: 'group', children: [ - { key: '/energy/meters', label: '计量点管理' }, - { key: '/energy/consumption', label: '能耗录入' }, - { key: '/energy/statistics', label: '能耗统计' } + { + key: '/sparepart/list', + icon: () => h(ToolOutlined), + label: '备件管理' + }, + { + key: '/maintenance/plans', + icon: () => h(ToolOutlined), + label: '维保计划' + }, + { + key: '/maintenance/tasks', + icon: () => h(ToolOutlined), + label: '维保任务' + }, + { + key: 'energy', + icon: () => h(HeatMapOutlined), + label: '能耗管理', + children: [ + { key: '/energy/meters', label: '计量点管理' }, + { key: '/energy/consumption', label: '能耗录入' }, + { key: '/energy/statistics', label: '能耗统计' } + ] + } ] - } - ] - }, + }, { key: 'system', label: '系统管理', diff --git a/src/views/sparepart/SparePartDetail.vue b/src/views/sparepart/SparePartDetail.vue new file mode 100644 index 00000000..656839d7 --- /dev/null +++ b/src/views/sparepart/SparePartDetail.vue @@ -0,0 +1,206 @@ + + + + + diff --git a/src/views/sparepart/SparePartList.vue b/src/views/sparepart/SparePartList.vue new file mode 100644 index 00000000..859ad715 --- /dev/null +++ b/src/views/sparepart/SparePartList.vue @@ -0,0 +1,445 @@ + + + + + diff --git a/src/views/sparepart/StockOperation.vue b/src/views/sparepart/StockOperation.vue new file mode 100644 index 00000000..e189b0da --- /dev/null +++ b/src/views/sparepart/StockOperation.vue @@ -0,0 +1,226 @@ + + + + +