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; // 工作流编号(历史字段,改造后不再写入)
|
reviewerId?: number; // 审核人编号
|
reviewerName?: string; // 审核人姓名
|
reviewTime?: string; // 审核时间
|
reviewRemark?: 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('/purchase/plan/create', data);
|
}
|
|
/** 更新采购计划 */
|
export function updatePurchasePlan(data: ErpPurchasePlanApi.PurchasePlan) {
|
return requestClient.put('/purchase/plan/update', data);
|
}
|
|
/**
|
* 提交采购计划审核(草稿/审核不通过 → 审批中)
|
*
|
* 提交前由后端校验审批配置已启用且配置了有效审批人,无需前端传流程定义。
|
*/
|
export function submitPurchasePlan(id: number) {
|
return requestClient.put('/purchase/plan/submit', null, {
|
params: { id },
|
});
|
}
|
|
/**
|
* 审核采购计划(审批中 → 审核通过/审核不通过)
|
*
|
* 仅审批配置中指定的审批人本人可调用;pass=false 时 reviewRemark(不通过原因)必填。
|
*/
|
export function auditPurchasePlan(
|
id: number,
|
pass: boolean,
|
reviewRemark?: string,
|
) {
|
return requestClient.put('/purchase/plan/audit', {
|
id,
|
pass,
|
reviewRemark,
|
});
|
}
|
|
/** 获取采购计划的审批人编号集合,用于判断是否展示审核按钮 */
|
export function getPurchasePlanApproverUserIds() {
|
return requestClient.get<number[]>('/purchase/plan/approver-ids');
|
}
|
|
/** 根据库存预警生成采购计划 */
|
export function generatePlanFromStockAlert(params: { name?: string; supplierId?: number }) {
|
return requestClient.post<number>('/purchase/plan/generate-from-stock-alert', null, {
|
params,
|
});
|
}
|
|
/** 获取库存预警建议采购明细(不落库,供新增弹窗回填核对) */
|
export function getStockAlertSuggestItems() {
|
return requestClient.get<ErpPurchasePlanApi.PurchasePlanItem[]>(
|
'/purchase/plan/get-stock-alert-suggest-items',
|
);
|
}
|
|
/** 生成采购申请 */
|
export function generatePurchaseRequests(id: number) {
|
return requestClient.post<number[]>('/purchase/plan/generate-requests', null, {
|
params: { id },
|
});
|
}
|
|
/** 删除采购计划 */
|
export function deletePurchasePlan(ids: number[]) {
|
return requestClient.delete('/purchase/plan/delete', { params: { ids: ids.join(',') } });
|
}
|
|
/** 获取采购计划详情 */
|
export function getPurchasePlan(id: number) {
|
return requestClient.get<ErpPurchasePlanApi.PurchasePlan>(
|
`/purchase/plan/get?id=${id}`,
|
);
|
}
|
|
/** 获取采购计划分页 */
|
export function getPurchasePlanPage(params: PageParam) {
|
return requestClient.get<PageResult<ErpPurchasePlanApi.PurchasePlan>>(
|
'/purchase/plan/page',
|
{ params },
|
);
|
}
|
|
/** 导出采购计划 Excel */
|
export function exportPurchasePlan(params: any) {
|
return requestClient.download('/purchase/plan/export-excel', { params });
|
}
|