747 lines
17 KiB
TypeScript
747 lines
17 KiB
TypeScript
import request from '@/utils/http'
|
|
|
|
type PageList<T> = {
|
|
list: T[]
|
|
total: number
|
|
page: number
|
|
pageSize: number
|
|
totalPages: number
|
|
}
|
|
|
|
export type ProductionMaterial = {
|
|
id: string
|
|
materialCode: string
|
|
materialName: string
|
|
materialType: 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 ProductionMaterialBatch = {
|
|
id: string
|
|
batchId: string
|
|
materialId: string
|
|
materialCode: string
|
|
materialName: string
|
|
materialType: string
|
|
specModel: string
|
|
unit: string
|
|
stockInNo: string
|
|
stockInDate: string
|
|
expireDate: string
|
|
productionDate?: string
|
|
catalogNo: string
|
|
batchNo: string
|
|
manufacturer: string
|
|
storageLocation?: string
|
|
unitPrice: number
|
|
amount: number
|
|
inQty: number
|
|
remainingQty: number
|
|
stockQty: number
|
|
warningQty: number
|
|
status: string
|
|
remark: string
|
|
createTime: string
|
|
updateTime: string
|
|
}
|
|
|
|
export type ProductionMaterialOption = {
|
|
id: string
|
|
label: string
|
|
materialCode: string
|
|
materialName: string
|
|
materialType: string
|
|
specModel: string
|
|
unit: string
|
|
stockQty: number
|
|
}
|
|
|
|
export type ProductionMaterialBatchOption = {
|
|
id: string
|
|
batchId: string
|
|
stockInNo: string
|
|
stockInDate?: string
|
|
expireDate?: string
|
|
productionDate?: string
|
|
materialId: string
|
|
materialCode: string
|
|
materialName: string
|
|
materialType: string
|
|
specModel: string
|
|
unit: string
|
|
batchNo: string
|
|
catalogNo: string
|
|
manufacturer: string
|
|
storageLocation?: string
|
|
unitPrice?: number
|
|
amount?: number
|
|
remainingQty: number
|
|
label: string
|
|
}
|
|
|
|
export type StockInPayload = {
|
|
stockInNo: string
|
|
stockInDate: string
|
|
expireDate: string
|
|
productionDate?: string
|
|
catalogNo: string
|
|
batchNo: string
|
|
manufacturer: string
|
|
storageLocation?: 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 type ProductionMaterialRequisitionOption = {
|
|
id: string
|
|
label: string
|
|
materialId: string
|
|
materialName: string
|
|
materialType: string
|
|
stockInNo: string
|
|
batchNo: string
|
|
batchId: string
|
|
receiver: string
|
|
receiverName: string
|
|
requisitionQty: number
|
|
usageUnit: string
|
|
useTime: string
|
|
}
|
|
|
|
export type ProductionMaterialUsage = {
|
|
id: string
|
|
materialId: string
|
|
materialCode: string
|
|
materialName: string
|
|
materialType: string
|
|
batchId?: string
|
|
stockInNo?: string
|
|
stockInDate?: string
|
|
catalogNo?: string
|
|
batchNo?: string
|
|
manufacturer?: string
|
|
storageLocation?: string
|
|
unitPrice?: number | null
|
|
amount?: number | null
|
|
changeType: string
|
|
changeQty: number
|
|
usageUnit?: string
|
|
stockBefore?: number
|
|
stockAfter: number
|
|
parentUsageId?: string
|
|
requisitionUsageId?: string
|
|
receiverName?: string
|
|
requisitionReceiver?: string
|
|
requisitionReceiverName?: string
|
|
productionTaskId: string
|
|
productionTaskNo: string
|
|
taskNo?: string
|
|
prepId?: string
|
|
prepNo?: string
|
|
configuredMaterialName?: string
|
|
receiver?: string
|
|
purpose?: string
|
|
useTime?: string
|
|
sourceType: string
|
|
requisitionStatus?: string
|
|
remark: string
|
|
createBy: string
|
|
createByName?: string
|
|
createTime: string
|
|
}
|
|
|
|
export type ProductionMaterialStockCheck = {
|
|
id: string
|
|
title: string
|
|
checkTime: string
|
|
status: string
|
|
statusLabel: string
|
|
completeTime?: string
|
|
remark?: string
|
|
batchLineCount: number
|
|
unusedLineCount: number
|
|
createBy: string
|
|
createByName?: string
|
|
createTime: string
|
|
updateTime: string
|
|
}
|
|
|
|
export type ProductionMaterialStockCheckBatchLine = {
|
|
id: string
|
|
materialCode: string
|
|
materialName: string
|
|
materialType?: string
|
|
specModel: string
|
|
unit: string
|
|
stockInNo: string
|
|
stockInDate: string
|
|
expireDate: string
|
|
catalogNo: string
|
|
batchNo: string
|
|
manufacturer: string
|
|
unitPrice: number
|
|
amount: number
|
|
remainingQty: number
|
|
remainingAmount?: number
|
|
remark?: string
|
|
}
|
|
|
|
export type ProductionMaterialStockCheckUnusedLine = {
|
|
id?: string
|
|
usageId?: string
|
|
batchId?: string
|
|
materialCode?: string
|
|
materialName: string
|
|
materialType?: string
|
|
specModel?: string
|
|
unit?: string
|
|
stockInNo?: string
|
|
stockInDate?: string
|
|
expireDate?: string
|
|
catalogNo?: string
|
|
batchNo?: string
|
|
manufacturer?: string
|
|
unitPrice?: number | null
|
|
remainingAmount?: number | null
|
|
holder?: string
|
|
unusedQty: number
|
|
remark?: string
|
|
batchPickId?: string
|
|
fromBatch?: boolean
|
|
}
|
|
|
|
export type ProductionMaterialStockCheckRequisition = {
|
|
id: string
|
|
materialId: string
|
|
materialType: string
|
|
materialCode: string
|
|
materialName: string
|
|
specModel: string
|
|
batchId: string
|
|
stockInNo: string
|
|
stockInDate: string
|
|
expireDate: string
|
|
catalogNo: string
|
|
batchNo: string
|
|
manufacturer: string
|
|
storageLocation?: string
|
|
unitPrice: number
|
|
unit: string
|
|
requisitionQty: number
|
|
taskConsumedQty: number
|
|
receiver: string
|
|
receiverName: string
|
|
purpose: string
|
|
useTime: string
|
|
requisitionStatus: string
|
|
createByName: string
|
|
}
|
|
|
|
export type ProductionMaterialStockCheckDetail = ProductionMaterialStockCheck & {
|
|
batchLines: ProductionMaterialStockCheckBatchLine[]
|
|
unusedLines: ProductionMaterialStockCheckUnusedLine[]
|
|
}
|
|
|
|
export function fetchProductionMaterialBatchList(params?: {
|
|
page?: number
|
|
pageSize?: number
|
|
keyword?: string
|
|
materialId?: string
|
|
materialType?: string
|
|
status?: string
|
|
}) {
|
|
return request.get<PageList<ProductionMaterialBatch>>({
|
|
url: '/web/admin/production-material-batches',
|
|
params
|
|
})
|
|
}
|
|
|
|
export function fetchProductionMaterialBatchOptions(params?: {
|
|
keyword?: string
|
|
materialId?: string
|
|
materialType?: string
|
|
onlyAvailable?: boolean
|
|
}) {
|
|
return request.get<ProductionMaterialBatchOption[]>({
|
|
url: '/web/admin/production-material-batches/options',
|
|
params
|
|
})
|
|
}
|
|
|
|
export function fetchProductionMaterialList(params?: {
|
|
page?: number
|
|
pageSize?: number
|
|
keyword?: string
|
|
materialType?: string
|
|
status?: string
|
|
}) {
|
|
return request.get<PageList<ProductionMaterial>>({
|
|
url: '/web/admin/production-materials',
|
|
params
|
|
})
|
|
}
|
|
|
|
export function fetchProductionMaterialOptions(params?: { materialType?: string }) {
|
|
return request.get<ProductionMaterialOption[]>({
|
|
url: '/web/admin/production-materials/options',
|
|
params
|
|
})
|
|
}
|
|
|
|
export function fetchCreateProductionMaterial(data: Record<string, any>) {
|
|
return request.post<ProductionMaterial>({
|
|
url: '/web/admin/production-materials',
|
|
data
|
|
})
|
|
}
|
|
|
|
export function fetchUpdateProductionMaterial(id: string, data: Record<string, any>) {
|
|
return request.put<ProductionMaterial>({
|
|
url: `/web/admin/production-materials/${id}`,
|
|
data
|
|
})
|
|
}
|
|
|
|
export function fetchDeleteProductionMaterial(id: string) {
|
|
return request.delete<void>({
|
|
url: `/web/admin/production-materials/${id}`
|
|
})
|
|
}
|
|
|
|
export function fetchStockInProductionMaterial(materialId: string, data: StockInPayload) {
|
|
return request.post<ProductionMaterialBatch>({
|
|
url: `/web/admin/production-materials/${materialId}/stock-in`,
|
|
data
|
|
})
|
|
}
|
|
|
|
export function fetchBatchStockInProductionMaterial(data: {
|
|
items: BatchStockInLine[]
|
|
remark?: string
|
|
stockInTime?: string
|
|
}) {
|
|
return request.post<{ count: number }>({
|
|
url: '/web/admin/production-material-batches/batch-stock-in',
|
|
data
|
|
})
|
|
}
|
|
|
|
export function fetchUpdateProductionMaterialBatch(id: string, data: Record<string, any>) {
|
|
return request.put<ProductionMaterialBatch>({
|
|
url: `/web/admin/production-material-batches/${id}`,
|
|
data
|
|
})
|
|
}
|
|
|
|
export function fetchDeleteProductionMaterialBatch(id: string) {
|
|
return request.delete<void>({
|
|
url: `/web/admin/production-material-batches/${id}`
|
|
})
|
|
}
|
|
|
|
export function fetchBatchStockOutProductionMaterial(data: {
|
|
items: { batchId: string; qty: number; usageUnit?: string; remark?: string }[]
|
|
receiver?: string
|
|
purpose?: string
|
|
remark?: string
|
|
stockOutTime?: string
|
|
}) {
|
|
return request.post<{ count: number }>({
|
|
url: '/web/admin/production-material-batches/batch-stock-out',
|
|
data
|
|
})
|
|
}
|
|
|
|
export function fetchBatchDiscardProductionMaterial(data: {
|
|
items: { batchId: string; qty: number; usageUnit?: string; remark?: string }[]
|
|
discardReason: string
|
|
remark?: string
|
|
discardTime?: string
|
|
}) {
|
|
return request.post<{ count: number }>({
|
|
url: '/web/admin/production-material-batches/batch-discard',
|
|
data
|
|
})
|
|
}
|
|
|
|
export function fetchProductionMaterialUsageList(params?: {
|
|
page?: number
|
|
pageSize?: number
|
|
materialId?: string
|
|
materialType?: string
|
|
changeType?: string
|
|
startTime?: string
|
|
endTime?: string
|
|
keyword?: string
|
|
stockInNo?: string
|
|
}) {
|
|
return request.get<PageList<ProductionMaterialUsage>>({
|
|
url: '/web/admin/production-material-usages',
|
|
params
|
|
})
|
|
}
|
|
|
|
export function fetchMarkProductionMaterialUsageFullyUsed(usageId: string) {
|
|
return request.post<void>({
|
|
url: `/web/admin/production-material-usages/${usageId}/mark-fully-used`
|
|
})
|
|
}
|
|
|
|
export function fetchProductionMaterialRequisitionOptions(params?: {
|
|
materialType?: string
|
|
keyword?: string
|
|
limit?: number
|
|
}) {
|
|
return request.get<ProductionMaterialRequisitionOption[]>({
|
|
url: '/web/admin/production-material-requisition-options',
|
|
params
|
|
})
|
|
}
|
|
|
|
export function fetchProductionMaterialLinkedStepUsages(parentUsageId: string) {
|
|
return request.get<ProductionMaterialUsage[]>({
|
|
url: `/web/admin/production-material-usages/${parentUsageId}/linked-step-usages`
|
|
})
|
|
}
|
|
|
|
export function fetchMyProductionMaterialUsageList(params?: {
|
|
page?: number
|
|
pageSize?: number
|
|
materialId?: string
|
|
materialType?: string
|
|
changeType?: string
|
|
startTime?: string
|
|
endTime?: string
|
|
keyword?: string
|
|
stockInNo?: string
|
|
}) {
|
|
return request.get<PageList<ProductionMaterialUsage>>({
|
|
url: '/web/admin/my-production-material-usages',
|
|
params
|
|
})
|
|
}
|
|
|
|
export function fetchProductionMaterialStockCheckList(params?: {
|
|
page?: number
|
|
pageSize?: number
|
|
keyword?: string
|
|
materialType?: string
|
|
status?: string
|
|
startTime?: string
|
|
endTime?: string
|
|
}) {
|
|
return request.get<PageList<ProductionMaterialStockCheck>>({
|
|
url: '/web/admin/production-material-stock-checks',
|
|
params
|
|
})
|
|
}
|
|
|
|
export function fetchCreateProductionMaterialStockCheck(data: {
|
|
title: string
|
|
checkTime?: string
|
|
remark?: string
|
|
}) {
|
|
return request.post<{ id: string; batchLineCount: number }>({
|
|
url: '/web/admin/production-material-stock-checks',
|
|
data
|
|
})
|
|
}
|
|
|
|
export function fetchProductionMaterialStockCheckDetail(id: string) {
|
|
return request.get<ProductionMaterialStockCheckDetail>({
|
|
url: `/web/admin/production-material-stock-checks/${id}`
|
|
})
|
|
}
|
|
|
|
export function fetchSaveProductionMaterialStockCheckUnusedLines(
|
|
id: string,
|
|
items: ProductionMaterialStockCheckUnusedLine[]
|
|
) {
|
|
return request.put<{ count: number }>({
|
|
url: `/web/admin/production-material-stock-checks/${id}/unused-lines`,
|
|
data: { items }
|
|
})
|
|
}
|
|
|
|
export function fetchCompleteProductionMaterialStockCheck(id: string) {
|
|
return request.post<void>({
|
|
url: `/web/admin/production-material-stock-checks/${id}/complete`
|
|
})
|
|
}
|
|
|
|
export function fetchCancelProductionMaterialStockCheck(id: string) {
|
|
return request.post<void>({
|
|
url: `/web/admin/production-material-stock-checks/${id}/cancel`
|
|
})
|
|
}
|
|
|
|
export function fetchProductionMaterialStockCheckRequisitions(params?: {
|
|
page?: number
|
|
pageSize?: number
|
|
keyword?: string
|
|
}) {
|
|
return request.get<PageList<ProductionMaterialStockCheckRequisition>>({
|
|
url: '/web/admin/production-material-stock-check-requisitions',
|
|
params
|
|
})
|
|
}
|
|
|
|
export type ProductionMaterialFormulaLine = {
|
|
id?: string
|
|
configuredMaterialId?: string
|
|
componentMaterialId: string
|
|
componentMaterialType: string
|
|
componentMaterialCode?: string
|
|
componentMaterialName?: string
|
|
standardQty: number
|
|
usageUnit?: string
|
|
remark?: string
|
|
}
|
|
|
|
export function fetchProductionMaterialFormula(materialId: string) {
|
|
return request.get<ProductionMaterialFormulaLine[]>({
|
|
url: `/web/admin/production-materials/${materialId}/formula`
|
|
})
|
|
}
|
|
|
|
export function fetchReplaceProductionMaterialFormula(
|
|
materialId: string,
|
|
lines: ProductionMaterialFormulaLine[]
|
|
) {
|
|
return request.put<ProductionMaterialFormulaLine[]>({
|
|
url: `/web/admin/production-materials/${materialId}/formula`,
|
|
data: { lines }
|
|
})
|
|
}
|
|
|
|
export type ProductionMaterialPrepLine = {
|
|
id?: string
|
|
componentMaterialId: string
|
|
componentMaterialType: string
|
|
componentMaterialCode?: string
|
|
componentMaterialName?: string
|
|
requisitionUsageId: string
|
|
actualQty: number
|
|
usageUnit?: string
|
|
remark?: string
|
|
}
|
|
|
|
export type ProductionMaterialPrep = {
|
|
id: string
|
|
prepNo: string
|
|
configuredMaterialId: string
|
|
configuredMaterialCode: string
|
|
configuredMaterialName: string
|
|
prepTime: string
|
|
outputQty: number
|
|
outputUnit: string
|
|
batchNo: string
|
|
specModel?: string
|
|
catalogNo?: string
|
|
manufacturer?: string
|
|
stockInDate?: string
|
|
unitPrice?: number | null
|
|
amount?: number | null
|
|
storageLocation?: string
|
|
expireDate: string
|
|
stockInNo: string
|
|
outputBatchId: string
|
|
status: string
|
|
statusLabel: string
|
|
lineCount: number
|
|
remark: string
|
|
lines?: ProductionMaterialPrepLine[]
|
|
}
|
|
|
|
export function fetchProductionMaterialPrepList(params?: {
|
|
page?: number
|
|
pageSize?: number
|
|
keyword?: string
|
|
status?: string
|
|
configuredMaterialId?: string
|
|
}) {
|
|
return request.get<PageList<ProductionMaterialPrep>>({
|
|
url: '/web/admin/production-material-preps',
|
|
params
|
|
})
|
|
}
|
|
|
|
export function fetchProductionMaterialPrepDetail(id: string) {
|
|
return request.get<ProductionMaterialPrep>({
|
|
url: `/web/admin/production-material-preps/${id}`
|
|
})
|
|
}
|
|
|
|
export function fetchCreateProductionMaterialPrep(data: Record<string, any>) {
|
|
return request.post<ProductionMaterialPrep>({
|
|
url: '/web/admin/production-material-preps',
|
|
data
|
|
})
|
|
}
|
|
|
|
export function fetchUpdateProductionMaterialPrep(id: string, data: Record<string, any>) {
|
|
return request.put<ProductionMaterialPrep>({
|
|
url: `/web/admin/production-material-preps/${id}`,
|
|
data
|
|
})
|
|
}
|
|
|
|
export function fetchCompleteProductionMaterialPrep(id: string) {
|
|
return request.post<ProductionMaterialPrep>({
|
|
url: `/web/admin/production-material-preps/${id}/complete`
|
|
})
|
|
}
|
|
|
|
export function fetchCancelProductionMaterialPrep(id: string) {
|
|
return request.post<void>({
|
|
url: `/web/admin/production-material-preps/${id}/cancel`
|
|
})
|
|
}
|
|
|
|
export function fetchDeleteProductionMaterialPrep(id: string) {
|
|
return request.del<void>({
|
|
url: `/web/admin/production-material-preps/${id}`
|
|
})
|
|
}
|
|
|
|
export type QuickPrepLine = {
|
|
requisitionUsageId: string
|
|
componentMaterialId: string
|
|
componentMaterialType: string
|
|
batchId?: string
|
|
consumptionQty: number
|
|
usageUnit?: string
|
|
remark?: string
|
|
}
|
|
|
|
export type QuickPrepPayload = {
|
|
configuredMaterialName: string
|
|
outputQty: number
|
|
lines: QuickPrepLine[]
|
|
specModel?: string
|
|
outputUnit?: string
|
|
stockInNo?: string
|
|
stockInDate?: string
|
|
catalogNo?: string
|
|
batchNo?: string
|
|
manufacturer?: string
|
|
storageLocation?: string
|
|
expireDate?: string
|
|
remark?: string
|
|
}
|
|
|
|
export function fetchQuickProductionMaterialPrep(data: QuickPrepPayload) {
|
|
return request.post<ProductionMaterialPrep>({
|
|
url: '/web/admin/production-material-preps/quick',
|
|
data
|
|
})
|
|
}
|
|
|
|
export type AvailableMaterialBatch = {
|
|
requisitionUsageId: string
|
|
batchId: string
|
|
materialId: string
|
|
materialType: string
|
|
materialCode: string
|
|
materialName: string
|
|
specModel?: string
|
|
unit?: string
|
|
stockInNo: string
|
|
stockInDate?: string
|
|
expireDate?: string
|
|
catalogNo?: string
|
|
batchNo: string
|
|
manufacturer: string
|
|
storageLocation?: string
|
|
requisitionQty: number
|
|
unitPrice?: number | null
|
|
receiver?: string
|
|
receiverName?: string
|
|
useTime?: string
|
|
}
|
|
|
|
export function fetchAvailableMaterialBatches(params?: {
|
|
page?: number
|
|
pageSize?: number
|
|
keyword?: string
|
|
materialType?: string
|
|
}) {
|
|
return request.get<PageList<AvailableMaterialBatch>>({
|
|
url: '/web/admin/production-material-preps/available-materials',
|
|
params
|
|
})
|
|
}
|
|
|
|
export type MaterialConsumption = {
|
|
id: string
|
|
materialId: string
|
|
materialType: string
|
|
materialCode: string
|
|
materialName: string
|
|
batchId?: string
|
|
stockInNo?: string
|
|
batchNo?: string
|
|
manufacturer?: string
|
|
unitPrice?: number | null
|
|
changeQty: number
|
|
usageUnit?: string
|
|
prepId?: string
|
|
prepNo: string
|
|
configuredMaterialName: string
|
|
sourceType: string
|
|
remark: string
|
|
createBy: string
|
|
createByName?: string
|
|
createTime: string
|
|
}
|
|
|
|
export function fetchProductionMaterialConsumptions(params?: {
|
|
page?: number
|
|
pageSize?: number
|
|
keyword?: string
|
|
materialType?: string
|
|
startTime?: string
|
|
endTime?: string
|
|
}) {
|
|
return request.get<PageList<MaterialConsumption>>({
|
|
url: '/web/admin/production-material-consumptions',
|
|
params
|
|
})
|
|
}
|
|
|
|
export function fetchMyProductionMaterialConsumptions(params?: {
|
|
page?: number
|
|
pageSize?: number
|
|
keyword?: string
|
|
materialType?: string
|
|
startTime?: string
|
|
endTime?: string
|
|
}) {
|
|
return request.get<PageList<MaterialConsumption>>({
|
|
url: '/web/admin/my-production-material-consumptions',
|
|
params
|
|
})
|
|
}
|