101 lines
1.9 KiB
TypeScript
101 lines
1.9 KiB
TypeScript
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 }
|
|
})
|
|
}
|
|
|
|
// 物料基础信息搜索(分页),用于采购申请弹窗
|
|
export function searchMaterialPurchase(keyword: string, page: number = 1) {
|
|
return request({
|
|
url: '/purchase/search-material',
|
|
method: 'get',
|
|
params: { keyword, page }
|
|
})
|
|
}
|