liu
3 天以前 91eff4781fa4142d1f62d30a0fa1de5cae424eaf
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
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}`,
  );
}