xiaoyi
4 天以前 5c243d9d05da668a32b1bc9a4f543ea081488d11
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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 } });
}