gaoluyang
2026-11-05 f3cac4aa2db56d6017c1d1dc035bcfeaec76c3e2
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import type { PageParam, PageResult } from '@vben/request';
 
import { requestClient } from '#/api/request';
 
export namespace ErpPurchaseOrderApi {
  /** 采购订单信息 */
  export interface PurchaseOrder {
    id?: number; // 订单工单编号
    no?: string; // 采购订单号
    supplierId?: number; // 供应商编号
    supplierName?: string; // 供应商名称
    orderTime?: Date | string; // 订单时间
    totalCount?: number; // 合计数量
    totalPrice?: number; // 合计金额,单位:元
    totalProductPrice?: number; // 产品金额,单位:元
    totalTaxPrice?: number; // 合计税额,单位:元
    remainInvoicePrice?: number; // 剩余可开票金额(订单总金额-已来票金额),单位:元
    discountPercent?: number; // 优惠率,百分比
    discountPrice?: number; // 优惠金额,单位:元
    depositPrice?: number; // 定金金额,单位:元
    accountId?: number; // 结算账户编号
    purchaseType?: number; // 采购类型:1生产 2办公用品 3其他
    contractNo?: string; // 合同号(手工输入,不自动生成)
    projectName?: string; // 项目名称(非必填)
    paymentDate?: Date | string; // 付款日期
    paymentMethod?: number; // 付款方式:1电汇 2汇票 3现金 4手机支付
    sourceType?: number; // 来源类型:1生产工单 3销售订单
    sourceId?: number; // 来源单编号
    sourceNo?: string; // 来源单号
    sourceTypeName?: string; // 来源类型名称
    productCodes?: string; // 产品编号列表(MDM 物料编码,逗号拼接)
    status?: number; // 状态
    remark?: string; // 备注
    attachmentList?: { id: number; name?: string; url?: string }[]; // 附件列表
    inCount?: number; // 采购入库数量
    count?: number; // 数量
    returnCount?: number; // 采购退货数量
    inStatus?: number; // 入库状态
    returnStatus?: number; // 退货状态
    productNames?: string; // 产品名称列表
    creatorName?: string; // 创建人名称
    createTime?: Date; // 创建时间
    items?: PurchaseOrderItem[]; // 订单项列表
  }
 
  /** 采购订单项信息 */
  export interface PurchaseOrderItem {
    id?: number; // 订单项编号
    seq?: number; // 前端行号
    orderId?: number; // 采购订单编号
    productId?: number; // 产品编号
    productCode?: string; // 产品编号(MDM 物料编码快照)
    productName?: string; // 产品名称
    productBarCode?: string; // 产品条码
    productUnitId?: number; // 产品单位编号
    productUnitName?: string; // 产品单位名称
    productPrice?: number; // 产品单价,单位:元
    totalProductPrice?: number; // 产品总价,单位:元
    count?: number; // 数量
    totalPrice?: number; // 总价,单位:元
    taxPercent?: number; // 税率,百分比
    taxPrice?: number; // 税额,单位:元
    totalTaxPrice?: number; // 含税总价,单位:元
    remark?: string; // 备注
    stockCount?: number; // 库存数量(显示字段)
    qcCheckFlag?: boolean; // 是否需要来料检验
  }
}
 
/** 查询采购订单分页 */
export function getPurchaseOrderPage(params: PageParam) {
  return requestClient.get<PageResult<ErpPurchaseOrderApi.PurchaseOrder>>(
    '/erp/purchase-order/page',
    { params },
  );
}
 
/** 查询采购订单详情 */
export function getPurchaseOrder(id: number) {
  return requestClient.get<ErpPurchaseOrderApi.PurchaseOrder>(
    `/erp/purchase-order/get?id=${id}`,
  );
}
 
/** 新增采购订单 */
export function createPurchaseOrder(data: ErpPurchaseOrderApi.PurchaseOrder) {
  return requestClient.post('/erp/purchase-order/create', data);
}
 
/** 修改采购订单 */
export function updatePurchaseOrder(data: ErpPurchaseOrderApi.PurchaseOrder) {
  return requestClient.put('/erp/purchase-order/update', data);
}
 
/** 更新采购订单的状态 */
export function updatePurchaseOrderStatus(id: number, status: number) {
  return requestClient.put('/erp/purchase-order/update-status', null, {
    params: { id, status },
  });
}
 
/** 提交采购订单审批(草稿/未审核 -> 审批中) */
export function submitPurchaseOrder(
  id: number,
  processDefinitionKey = 'purchase_order_approve',
) {
  return requestClient.post('/erp/purchase-order/submit', null, {
    params: { id, processDefinitionKey },
  });
}
 
/** 删除采购订单 */
export function deletePurchaseOrder(ids: number[]) {
  return requestClient.delete('/erp/purchase-order/delete', {
    params: { ids: ids.join(',') },
  });
}
 
/** 导出采购订单 Excel */
export function exportPurchaseOrder(params: any) {
  return requestClient.download('/erp/purchase-order/export-excel', { params });
}
 
/** 获取采购审核流程列表 */
export function getPurchaseApproveProcessList() {
  return requestClient.get<any[]>('/erp/purchase-order/approve-process-list');
}
 
/** 反审批(协同办公已办任务中撤回已审核订单,回退为未审核) */
export function reverseApprove(processInstanceId: string) {
  return requestClient.post('/erp/purchase-order/reverse-approve', null, {
    params: { processInstanceId },
  });
}
 
/** 采购订单导入结果 */
export interface ImportResult {
  /** 创建成功的采购单编号 */
  createList?: string[];
  /** 更新成功的采购单编号 */
  updateList?: string[];
  /** 导入失败集合,key 为采购单编号或行号,value 为失败原因 */
  failureList?: Record<string, string>;
}
 
/** 获取采购审核流程列表响应 */
export interface ProcessDefinition {
  id: string; // 流程定义ID
  key: string; // 流程Key
  name: string; // 流程名称
  version: number; // 版本号
}
 
/** 确认收货 */
export function confirmReceipt(id: number) {
  return requestClient.post<number>('/erp/purchase-order/confirm-receipt', null, {
    params: { id },
  });
}
 
/** 下载采购订单导入模板 */
export function importPurchaseOrderTemplate() {
  return requestClient.download('/erp/purchase-order/get-import-template');
}
 
/** 导入采购订单 */
export function importPurchaseOrder(file: File, directApprove: boolean) {
  return requestClient.upload<ImportResult>(
    '/erp/purchase-order/import',
    { file, directApprove },
  );
}