import type { PageParam, PageResult } from '@vben/request';
|
|
import { requestClient } from '#/api/request';
|
|
export namespace ErpPurchasePlanApi {
|
/** 采购计划信息 */
|
export interface PurchasePlan {
|
id?: number; // 编号
|
no?: string; // 计划单号
|
name?: string; // 计划名称
|
status?: number; // 状态:0未提交 10审批中 20审核通过 30审核不通过 40已取消
|
processInstanceId?: string; // 工作流编号
|
demandSource?: number; // 需求来源:1库存预警 2运维/生产计划
|
demandSourceName?: string; // 需求来源名称
|
planDate?: string; // 计划日期
|
planUserId?: number; // 编制人编号
|
planUserName?: string; // 编制人姓名
|
planDeptId?: number; // 编制部门编号
|
planDeptName?: string; // 编制部门名称
|
supplierId?: number; // 供应商编号
|
supplierName?: string; // 供应商名称
|
totalCount?: number; // 合计数量
|
generatedFlag?: boolean; // 是否已生成采购申请
|
remark?: string; // 备注
|
productNames?: string; // 产品名称列表
|
items?: PurchasePlanItem[]; // 计划明细
|
createTime?: string; // 创建时间
|
}
|
|
/** 采购计划明细 */
|
export interface PurchasePlanItem {
|
id?: number; // 编号
|
productId: number; // 产品编号
|
productName?: string; // 产品名称
|
productUnitId?: number; // 产品单位编号
|
productUnitName?: string; // 产品单位名称
|
count: number; // 计划采购数量
|
demandTime?: string; // 需求日期
|
remark?: string; // 备注
|
}
|
}
|
|
/** 创建采购计划 */
|
export function createPurchasePlan(data: ErpPurchasePlanApi.PurchasePlan) {
|
return requestClient.post('/erp/purchase-plan/create', data);
|
}
|
|
/** 更新采购计划 */
|
export function updatePurchasePlan(data: ErpPurchasePlanApi.PurchasePlan) {
|
return requestClient.put('/erp/purchase-plan/update', data);
|
}
|
|
/** 提交采购计划审批 */
|
export function submitPurchasePlan(id: number, processDefinitionKey: string) {
|
return requestClient.put('/erp/purchase-plan/submit', null, {
|
params: { id, processDefinitionKey },
|
});
|
}
|
|
/** 根据库存预警生成采购计划 */
|
export function generatePlanFromStockAlert(params: { name?: string; supplierId?: number }) {
|
return requestClient.post<number>('/erp/purchase-plan/generate-from-stock-alert', null, {
|
params,
|
});
|
}
|
|
/** 生成采购申请 */
|
export function generatePurchaseRequests(id: number) {
|
return requestClient.post<number[]>('/erp/purchase-plan/generate-requests', null, {
|
params: { id },
|
});
|
}
|
|
/** 删除采购计划 */
|
export function deletePurchasePlan(ids: number[]) {
|
return requestClient.delete('/erp/purchase-plan/delete', { params: { ids: ids.join(',') } });
|
}
|
|
/** 获取采购计划详情 */
|
export function getPurchasePlan(id: number) {
|
return requestClient.get<ErpPurchasePlanApi.PurchasePlan>(
|
`/erp/purchase-plan/get?id=${id}`,
|
);
|
}
|
|
/** 获取采购计划分页 */
|
export function getPurchasePlanPage(params: PageParam) {
|
return requestClient.get<PageResult<ErpPurchasePlanApi.PurchasePlan>>(
|
'/erp/purchase-plan/page',
|
{ params },
|
);
|
}
|
|
/** 导出采购计划 Excel */
|
export function exportPurchasePlan(params: any) {
|
return requestClient.download('/erp/purchase-plan/export-excel', { params });
|
}
|
|
/** 获取审批流程列表 */
|
export function getApproveProcessList(id: number) {
|
return requestClient.get(`/erp/purchase-plan/approve-process-list`, { params: { id } });
|
}
|