diff --git a/inventory-web/src/api/purchase.ts b/inventory-web/src/api/purchase.ts new file mode 100644 index 0000000..610577f --- /dev/null +++ b/inventory-web/src/api/purchase.ts @@ -0,0 +1,91 @@ +import request from '@/utils/request' + +export interface PurchaseItem { + id?: number + request_no?: string + name: string + spec_model?: string + quantity: number + purchase_date: string + supplier_link?: string + remark?: string + images?: string[] + unit_price?: number + total_price?: number + status: number + status_text?: string + requester_id?: number + requester_name?: string + approver_id?: number + approver_name?: string + approved_at?: string + reject_reason?: string + created_at?: string + updated_at?: string +} + +export interface Approver { + id: number + username: string + email: string + role: string +} + +// 获取采购申请列表 +export function getPurchaseList(params: { + page?: number + limit?: number + status?: number +}) { + return request({ + url: '/purchase', + method: 'get', + params + }) +} + +// 创建采购申请 +export function createPurchase(data: PurchaseItem) { + return request({ + url: '/purchase', + method: 'post', + data + }) +} + +// 获取采购申请详情 +export function getPurchaseDetail(id: number) { + return request({ + url: `/purchase/${id}`, + method: 'get' + }) +} + +// 审批采购申请 +export function approvePurchase(id: number, data: { + action: 'approve' | 'reject' + reject_reason?: string +}) { + return request({ + url: `/purchase/${id}/approve`, + method: 'patch', + data + }) +} + +// 获取可选审批人列表 +export function getPurchaseApprovers() { + return request({ + url: '/purchase/approvers', + method: 'get' + }) +} + +// 根据名称/规格自动补全 +export function autoFillPurchase(keyword: string) { + return request({ + url: '/purchase/auto-fill', + method: 'get', + params: { keyword } + }) +} diff --git a/inventory-web/src/router/index.ts b/inventory-web/src/router/index.ts index fd87421..a69da78 100644 --- a/inventory-web/src/router/index.ts +++ b/inventory-web/src/router/index.ts @@ -180,6 +180,21 @@ const routes: Array = [ ] }, + // 5.1 采购管理 + { + path: '/purchase', + component: Layout, + meta: { title: '采购管理', icon: 'ShoppingCart' }, + children: [ + { + path: '', + name: 'PurchaseList', + component: () => import('@/views/purchase/index.vue'), + meta: { title: '采购申请' } + } + ] + }, + // 6. 借库管理 { path: '/operation', diff --git a/inventory-web/src/views/purchase/index.vue b/inventory-web/src/views/purchase/index.vue new file mode 100644 index 0000000..499f90a --- /dev/null +++ b/inventory-web/src/views/purchase/index.vue @@ -0,0 +1,502 @@ + + + + +