gaoluyang
9 天以前 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
import type { PageParam, PageResult } from '@vben/request';
 
import { requestClient } from '#/api/request';
 
export namespace SrmInquiryApi {
  /** 询价产品行 */
  export interface Item {
    id?: number;
    inquiryId?: number;
    productId?: number;
    productUnitId?: number;
    productCode?: string;
    productName?: string;
    productSpec?: string;
    unitName?: string;
    quantity?: number;
    estimatedPrice?: number;
    selectedSupplierId?: number;
    selectedQuoteId?: number;
    selectedPrice?: number;
    /** 新增/编辑询价单时随产品行一并提交的供应商报价 */
    quotes?: ItemQuote[];
    remark?: string;
    sort?: number;
  }
 
  /** 产品行内的供应商报价 */
  export interface ItemQuote {
    supplierId: number;
    price?: number;
    taxRate?: number;
    deliveryCycle?: number;
    paymentTerms?: string;
    remark?: string;
  }
 
  /** 参与供应商 */
  export interface Supplier {
    id?: number;
    supplierId: number;
    supplierName?: string;
    supplierCode?: string;
    quoteStatus?: number;
    quoteTime?: string;
    remark?: string;
  }
 
  /** 产品报价 */
  export interface Quote {
    id?: number;
    inquiryId?: number;
    inquiryItemId?: number;
    supplierId?: number;
    price?: number;
    taxRate?: number;
    deliveryCycle?: number;
    paymentTerms?: string;
    remark?: string;
    isSelected?: boolean;
  }
 
  /** 询价转订单记录 */
  export interface Order {
    id?: number;
    supplierId?: number;
    supplierName?: string;
    purchaseOrderId?: number;
    purchaseOrderNo?: string;
  }
 
  /** 询价单 */
  export interface Inquiry {
    id?: number;
    no?: string;
    title: string;
    status?: number;
    inquiryDate?: string;
    deadline?: string;
    purchaserUserId?: number;
    remark?: string;
    createTime?: string;
    items?: Item[];
    suppliers?: Supplier[];
    quotes?: Quote[];
    orders?: Order[];
  }
 
  /** 保存报价 */
  export interface QuoteSaveItem {
    inquiryItemId: number;
    supplierId: number;
    price?: number;
    taxRate?: number;
    deliveryCycle?: number;
    paymentTerms?: string;
    remark?: string;
  }
 
  /** 中标选择 */
  export interface Selection {
    inquiryItemId: number;
    quoteId: number;
  }
 
  /** 确认转订单结果 */
  export interface ConfirmResult {
    inquiryId: number;
    orders: {
      purchaseOrderId: number;
      purchaseOrderNo: string;
      supplierId: number;
      supplierName: string;
    }[];
  }
}
 
/** 分页查询询价单 */
export function getInquiryPage(params: PageParam) {
  return requestClient.get<PageResult<SrmInquiryApi.Inquiry>>(
    '/srm/inquiry/page',
    { params },
  );
}
 
/** 查询询价单详情 */
export function getInquiry(id: number) {
  return requestClient.get<SrmInquiryApi.Inquiry>(
    `/srm/inquiry/get?id=${id}`,
  );
}
 
/** 查询询价比价视图 */
export function getInquiryCompare(id: number) {
  return requestClient.get<SrmInquiryApi.Inquiry>(
    `/srm/inquiry/compare?id=${id}`,
  );
}
 
/** 查询询价单精简列表 */
export function getInquirySimpleList() {
  return requestClient.get<SrmInquiryApi.Inquiry[]>(
    '/srm/inquiry/simple-list',
  );
}
 
/** 创建询价单 */
export function createInquiry(data: SrmInquiryApi.Inquiry) {
  return requestClient.post<number>('/srm/inquiry/create', data);
}
 
/** 更新询价单 */
export function updateInquiry(data: SrmInquiryApi.Inquiry) {
  return requestClient.put('/srm/inquiry/update', data);
}
 
/** 删除询价单 */
export function deleteInquiry(id: number) {
  return requestClient.delete('/srm/inquiry/delete', { params: { id } });
}
 
/** 发布询价单 */
export function publishInquiry(id: number) {
  return requestClient.put('/srm/inquiry/publish', null, { params: { id } });
}
 
/** 取消询价单 */
export function cancelInquiry(id: number) {
  return requestClient.put('/srm/inquiry/cancel', null, { params: { id } });
}
 
/** 批量保存报价 */
export function saveQuotes(
  inquiryId: number,
  quotes: SrmInquiryApi.QuoteSaveItem[],
) {
  return requestClient.post('/srm/inquiry/save-quotes', {
    inquiryId,
    quotes,
  });
}
 
/** 确认中标并生成采购订单草稿 */
export function confirmInquiry(
  id: number,
  selections: SrmInquiryApi.Selection[],
) {
  return requestClient.post<SrmInquiryApi.ConfirmResult>(
    '/srm/inquiry/confirm',
    { id, selections },
  );
}