liu
2 天以前 ea9d117374e44d9eac0309ea2687b439f89b07b4
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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 });
}