import type { PageParam, PageResult } from '@vben/request';
|
|
import { requestClient } from '#/api/request';
|
|
export namespace CrmInvoiceApi {
|
/** 合同信息 */
|
export interface Contract {
|
id?: number;
|
name?: string;
|
no: string;
|
}
|
|
/** 附件信息 */
|
export interface Attachment {
|
id: number;
|
url?: string;
|
name?: string;
|
}
|
|
/** 开票信息 */
|
export interface Invoice {
|
id?: number;
|
no?: string;
|
contractId?: number;
|
contract?: Contract;
|
customerId?: number;
|
customerName?: string;
|
invoiceType?: number;
|
invoiceNo?: string;
|
invoiceTitle?: string;
|
price?: number;
|
invoiceTime?: string;
|
auditStatus?: number;
|
// 以下为审核派生字段,由后端在审核时写入,前端只读展示
|
reviewerId?: number; // 审核人ID(实际执行审核的用户)
|
reviewerName?: string; // 审核人姓名
|
reviewTime?: string; // 审核时间
|
reviewRemark?: string; // 审核意见(审核通过时的意见 / 审核不通过时的原因)
|
remark?: string;
|
ownerUserId?: number;
|
ownerUserName?: string;
|
ownerUserDeptName?: string;
|
attachmentList?: Attachment[];
|
blobIds?: number[];
|
hasAttachment?: boolean;
|
remainingInvoicePrice?: number;
|
creator?: string;
|
creatorName?: string;
|
createTime?: string;
|
updateTime?: string;
|
}
|
|
/** 开票简要信息(用于回款关联选择) */
|
export interface InvoiceSimple {
|
id: number;
|
no: string;
|
invoiceNo?: string;
|
invoiceTitle?: string;
|
price?: number;
|
customerId?: number;
|
contractId?: number;
|
auditStatus?: number;
|
hasAttachment?: boolean;
|
remainingInvoicePrice?: number;
|
}
|
}
|
|
/** 查询开票分页 */
|
export function getInvoicePage(params: PageParam) {
|
return requestClient.get<PageResult<CrmInvoiceApi.Invoice>>(
|
'/crm/invoice/page',
|
{ params },
|
);
|
}
|
|
/** 查询开票分页,基于指定客户 */
|
export function getInvoicePageByCustomer(params: PageParam) {
|
return requestClient.get<PageResult<CrmInvoiceApi.Invoice>>(
|
'/crm/invoice/page-by-customer',
|
{ params },
|
);
|
}
|
|
/** 查询开票详情 */
|
export function getInvoice(id: number) {
|
return requestClient.get<CrmInvoiceApi.Invoice>(
|
`/crm/invoice/get?id=${id}`,
|
);
|
}
|
|
/** 新增开票 */
|
export function createInvoice(data: CrmInvoiceApi.Invoice) {
|
return requestClient.post('/crm/invoice/create', data);
|
}
|
|
/** 修改开票 */
|
export function updateInvoice(data: CrmInvoiceApi.Invoice) {
|
return requestClient.put('/crm/invoice/update', data);
|
}
|
|
/** 删除开票 */
|
export function deleteInvoice(id: number) {
|
return requestClient.delete(`/crm/invoice/delete?id=${id}`);
|
}
|
|
/** 导出开票 */
|
export function exportInvoice(params: Record<string, unknown>) {
|
return requestClient.download('/crm/invoice/export-excel', { params });
|
}
|
|
/**
|
* 提交审批(草稿 / 审核不通过 → 审批中)
|
* 审批人由「系统管理 - 审批配置」统一配置,提交时无需指定。
|
*/
|
export function submitInvoice(id: number) {
|
return requestClient.put('/crm/invoice/submit', null, { params: { id } });
|
}
|
|
/** 获得开票的审批人编号集合,供列表页判断是否展示审核按钮 */
|
export function getInvoiceApproverIds() {
|
return requestClient.get<number[]>('/crm/invoice/approver-ids');
|
}
|
|
/**
|
* 审核开票(审批中 → 审核通过 / 审核不通过)
|
*
|
* 仅审批配置中的审批人可调用(多人时或签);pass=false 时 reviewRemark(不通过原因)必填。
|
*/
|
export function auditInvoice(
|
id: number,
|
pass: boolean,
|
reviewRemark?: string,
|
) {
|
return requestClient.put('/crm/invoice/audit', { id, pass, reviewRemark });
|
}
|
|
/** 获得待审核开票数量 */
|
export function getAuditInvoiceCount() {
|
return requestClient.get<number>('/crm/invoice/audit-count');
|
}
|
|
/** 查询开票下拉列表(按合同查可选开票) */
|
export function getInvoiceSimpleList(contractId: number) {
|
return requestClient.get<CrmInvoiceApi.InvoiceSimple[]>(
|
`/crm/invoice/simple-list?contractId=${contractId}`,
|
);
|
}
|