2026-05-12 16:36:57 +08:00
|
|
|
import request from '@/utils/request'
|
|
|
|
|
|
|
|
|
|
export interface PurchaseItem {
|
|
|
|
|
id?: number
|
|
|
|
|
request_no?: string
|
2026-07-14 15:25:00 +08:00
|
|
|
base_id?: number
|
2026-05-12 16:36:57 +08:00
|
|
|
name: string
|
|
|
|
|
spec_model?: string
|
|
|
|
|
quantity: number
|
|
|
|
|
purchase_date: string
|
|
|
|
|
supplier_link?: string
|
|
|
|
|
remark?: string
|
|
|
|
|
images?: string[]
|
|
|
|
|
unit_price?: number
|
|
|
|
|
total_price?: number
|
2026-07-15 16:07:59 +08:00
|
|
|
tax_rate?: number
|
2026-05-12 16:36:57 +08:00
|
|
|
status: number
|
|
|
|
|
status_text?: string
|
|
|
|
|
requester_id?: number
|
|
|
|
|
requester_name?: string
|
2026-07-14 16:29:19 +08:00
|
|
|
requester_email?: string
|
2026-05-12 16:36:57 +08:00
|
|
|
approver_id?: number
|
|
|
|
|
approver_name?: string
|
|
|
|
|
approved_at?: string
|
|
|
|
|
reject_reason?: string
|
|
|
|
|
created_at?: string
|
|
|
|
|
updated_at?: string
|
2026-07-14 15:25:00 +08:00
|
|
|
// [新增] 关联物料基础信息(已审批未入库列表返回)
|
|
|
|
|
material?: {
|
|
|
|
|
id: number
|
|
|
|
|
company_name: string
|
|
|
|
|
name: string
|
|
|
|
|
spec_model: string
|
|
|
|
|
category: string
|
|
|
|
|
unit: string
|
|
|
|
|
type: string
|
|
|
|
|
is_inspection_required: boolean
|
|
|
|
|
} | null
|
2026-05-12 16:36:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-31 13:41:25 +08:00
|
|
|
// 批量审批采购申请(循环提交产生的多条记录可一次审批)
|
|
|
|
|
export function batchApprovePurchase(data: {
|
2026-08-31 13:46:46 +08:00
|
|
|
ids?: number[]
|
|
|
|
|
batch_no?: string
|
2026-08-31 13:41:25 +08:00
|
|
|
action: 'approve' | 'reject'
|
|
|
|
|
reject_reason?: string
|
|
|
|
|
}) {
|
|
|
|
|
return request({
|
|
|
|
|
url: '/purchase/batch-approve',
|
|
|
|
|
method: 'post',
|
|
|
|
|
data
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-31 13:46:46 +08:00
|
|
|
// 按批次号查询同批次的采购申请记录
|
|
|
|
|
export function getPurchaseByBatch(batchNo: string) {
|
|
|
|
|
return request({
|
|
|
|
|
url: `/purchase/batch/${encodeURIComponent(batchNo)}`,
|
|
|
|
|
method: 'get'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-12 16:36:57 +08:00
|
|
|
// 获取可选审批人列表
|
|
|
|
|
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 }
|
|
|
|
|
})
|
|
|
|
|
}
|
2026-05-12 17:48:29 +08:00
|
|
|
|
|
|
|
|
// 物料基础信息搜索(分页),用于采购申请弹窗
|
|
|
|
|
export function searchMaterialPurchase(keyword: string, page: number = 1) {
|
|
|
|
|
return request({
|
|
|
|
|
url: '/purchase/search-material',
|
|
|
|
|
method: 'get',
|
|
|
|
|
params: { keyword, page }
|
|
|
|
|
})
|
|
|
|
|
}
|
2026-07-14 15:25:00 +08:00
|
|
|
|
|
|
|
|
// [新增] 获取已审批通过且未入库的采购单列表(供库管按单入库使用)
|
|
|
|
|
export function getApprovedUnstockedRequests(params: {
|
|
|
|
|
page?: number
|
|
|
|
|
limit?: number
|
|
|
|
|
keyword?: string
|
|
|
|
|
}) {
|
|
|
|
|
return request({
|
|
|
|
|
url: '/purchase/approved-unstocked',
|
|
|
|
|
method: 'get',
|
|
|
|
|
params
|
|
|
|
|
})
|
|
|
|
|
}
|