234 lines
4.8 KiB
TypeScript
234 lines
4.8 KiB
TypeScript
import request from '@/utils/http'
|
|
|
|
type PageList<T> = {
|
|
list: T[]
|
|
total: number
|
|
page: number
|
|
pageSize: number
|
|
totalPages: number
|
|
}
|
|
|
|
export type QcMaterial = {
|
|
id: string
|
|
materialCode: string
|
|
materialName: string
|
|
specModel: string
|
|
unit: string
|
|
stockQty: number
|
|
warningQty: number
|
|
status: string
|
|
tenantNo: string
|
|
orderNum: number
|
|
remark: string
|
|
createBy: string
|
|
createTime: string
|
|
updateTime: string
|
|
}
|
|
|
|
/** 入库批次列表行 */
|
|
export type QcMaterialBatch = {
|
|
id: string
|
|
batchId: string
|
|
materialId: string
|
|
materialCode: string
|
|
materialName: string
|
|
specModel: string
|
|
unit: string
|
|
stockInNo: string
|
|
stockInDate: string
|
|
expireDate: string
|
|
catalogNo: string
|
|
batchNo: string
|
|
manufacturer: string
|
|
unitPrice: number
|
|
amount: number
|
|
inQty: number
|
|
remainingQty: number
|
|
outTotal?: number
|
|
outCount?: number
|
|
qcAttachmentUrls?: string
|
|
stockQty: number
|
|
warningQty: number
|
|
status: string
|
|
remark: string
|
|
createTime: string
|
|
updateTime: string
|
|
}
|
|
|
|
export type QcMaterialOption = {
|
|
id: string
|
|
label: string
|
|
materialCode: string
|
|
materialName: string
|
|
specModel: string
|
|
unit: string
|
|
stockQty: number
|
|
}
|
|
|
|
export type QcMaterialBatchOption = {
|
|
id: string
|
|
batchId: string
|
|
stockInNo: string
|
|
stockInDate?: string
|
|
expireDate?: string
|
|
materialId: string
|
|
materialCode: string
|
|
materialName: string
|
|
specModel: string
|
|
unit: string
|
|
batchNo: string
|
|
catalogNo: string
|
|
manufacturer: string
|
|
unitPrice?: number
|
|
amount?: number
|
|
remainingQty: number
|
|
label: string
|
|
}
|
|
|
|
export type StockInPayload = {
|
|
stockInNo: string
|
|
stockInDate: string
|
|
expireDate: string
|
|
catalogNo: string
|
|
batchNo: string
|
|
manufacturer: string
|
|
unitPrice: number
|
|
amount: number
|
|
qty: number
|
|
remark?: string
|
|
stockInTime?: string
|
|
}
|
|
|
|
export type BatchStockInLine = StockInPayload & {
|
|
materialId: string
|
|
materialCode?: string
|
|
materialName?: string
|
|
specModel?: string
|
|
unit?: string
|
|
}
|
|
|
|
export function fetchQcMaterialBatchList(params?: {
|
|
page?: number
|
|
pageSize?: number
|
|
keyword?: string
|
|
materialId?: string
|
|
status?: string
|
|
stockStatus?: 'all' | 'available' | 'exhausted'
|
|
}) {
|
|
return request.get<PageList<QcMaterialBatch>>({
|
|
url: '/web/admin/qc-material-batches',
|
|
params
|
|
})
|
|
}
|
|
|
|
export function fetchQcMaterialBatchDetail(batchId: string) {
|
|
return request.get<QcMaterialBatch>({
|
|
url: `/web/admin/qc-material-batches/${batchId}`
|
|
})
|
|
}
|
|
|
|
export function fetchQcMaterialBatchOptions(params?: {
|
|
keyword?: string
|
|
materialId?: string
|
|
onlyAvailable?: boolean
|
|
}) {
|
|
return request.get<QcMaterialBatchOption[]>({
|
|
url: '/web/admin/qc-material-batches/options',
|
|
params
|
|
})
|
|
}
|
|
|
|
export function fetchQcMaterialList(params?: {
|
|
page?: number
|
|
pageSize?: number
|
|
keyword?: string
|
|
status?: string
|
|
}) {
|
|
return request.get<PageList<QcMaterial>>({
|
|
url: '/web/admin/qc-materials',
|
|
params
|
|
})
|
|
}
|
|
|
|
export function fetchQcMaterialOptions() {
|
|
return request.get<QcMaterialOption[]>({
|
|
url: '/web/admin/qc-materials/options'
|
|
})
|
|
}
|
|
|
|
export function fetchCreateQcMaterial(data: Record<string, any>) {
|
|
return request.post<QcMaterial>({
|
|
url: '/web/admin/qc-materials',
|
|
data
|
|
})
|
|
}
|
|
|
|
export function fetchUpdateQcMaterial(id: string, data: Record<string, any>) {
|
|
return request.put<QcMaterial>({
|
|
url: `/web/admin/qc-materials/${id}`,
|
|
data
|
|
})
|
|
}
|
|
|
|
export function fetchDeleteQcMaterial(id: string) {
|
|
return request.delete<void>({
|
|
url: `/web/admin/qc-materials/${id}`
|
|
})
|
|
}
|
|
|
|
export function fetchStockInQcMaterial(materialId: string, data: StockInPayload) {
|
|
return request.post<QcMaterialBatch>({
|
|
url: `/web/admin/qc-materials/${materialId}/stock-in`,
|
|
data
|
|
})
|
|
}
|
|
|
|
export function fetchBatchStockInQcMaterial(data: {
|
|
items: BatchStockInLine[]
|
|
remark?: string
|
|
stockInTime?: string
|
|
}) {
|
|
return request.post<{ count: number }>({
|
|
url: '/web/admin/qc-material-batches/batch-stock-in',
|
|
data
|
|
})
|
|
}
|
|
|
|
export function fetchUpdateQcMaterialBatch(id: string, data: Record<string, any>) {
|
|
return request.put<QcMaterialBatch>({
|
|
url: `/web/admin/qc-material-batches/${id}`,
|
|
data
|
|
})
|
|
}
|
|
|
|
export function fetchDeleteQcMaterialBatch(id: string) {
|
|
return request.delete<void>({
|
|
url: `/web/admin/qc-material-batches/${id}`
|
|
})
|
|
}
|
|
|
|
export function fetchBatchStockOutQcMaterial(data: {
|
|
items: { batchId: string; qty: number; remark?: string }[]
|
|
receiver?: string
|
|
purpose?: string
|
|
remark?: string
|
|
stockOutTime?: string
|
|
}) {
|
|
return request.post<{ count: number }>({
|
|
url: '/web/admin/qc-material-batches/batch-stock-out',
|
|
data
|
|
})
|
|
}
|
|
|
|
export function fetchBatchDiscardQcMaterial(data: {
|
|
items: { batchId: string; qty: number; usageUnit?: string; remark?: string }[]
|
|
discardReason: string
|
|
remark?: string
|
|
discardTime?: string
|
|
}) {
|
|
return request.post<{ count: number }>({
|
|
url: '/web/admin/qc-material-batches/batch-discard',
|
|
data
|
|
})
|
|
}
|