quote.ts 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. import request from '@/utils/request';
  2. /**
  3. * 查询参数接口
  4. */
  5. export interface QuoteQuery {
  6. pageNum?: number;
  7. pageSize?: number;
  8. quoteNo?: string;
  9. quoteTitle?: string;
  10. customerId?: number;
  11. customerName?: string;
  12. opportunityId?: number;
  13. status?: string;
  14. ownerUserId?: number;
  15. approvedByUserId?: number; // 审批人ID(用于查询某个用户已审批过的报价单)
  16. minAmount?: number;
  17. maxAmount?: number;
  18. isLatest?: number;
  19. quoteDateBegin?: string;
  20. quoteDateEnd?: string;
  21. beginTime?: string;
  22. endTime?: string;
  23. }
  24. /**
  25. * 报价单产品
  26. */
  27. export interface QuoteProduct {
  28. id?: string | number;
  29. quoteId?: string | number;
  30. productId: string | number;
  31. productName: string;
  32. productNo?: string;
  33. categoryId?: string | number;
  34. categoryName?: string;
  35. model?: string;
  36. unit?: string;
  37. quantity: number;
  38. price: number;
  39. discount?: number;
  40. subtotal?: number;
  41. description?: string;
  42. sort?: number;
  43. remark?: string;
  44. }
  45. /**
  46. * 报价单产品表单(用于新增/编辑)
  47. */
  48. export interface QuoteProductForm {
  49. id?: string | number;
  50. productId?: string | number;
  51. productName?: string;
  52. categoryId?: string | number;
  53. categoryName?: string;
  54. model?: string;
  55. unit?: string; // 单位
  56. price?: number; // 含税单价/元
  57. unitPrice?: number;
  58. quantity?: number;
  59. discount?: number;
  60. subtotal?: number; // 含税总价/元
  61. discountAmount?: number;
  62. totalPrice?: number;
  63. taxAmount?: number; // 税费/元
  64. taxRate?: number; // 税率(%)
  65. packageSpec?: string; // 包装规格
  66. deliveryMethod?: string; // 送货方式
  67. description?: string;
  68. }
  69. /**
  70. * 表单数据接口
  71. */
  72. export interface QuoteForm {
  73. id?: string | number;
  74. quoteNo?: string;
  75. title?: string;
  76. quoteTitle?: string;
  77. customerId?: string | number;
  78. customerName?: string;
  79. opportunityId?: string | number;
  80. opportunityName?: string;
  81. contactId?: string | number;
  82. contactName?: string;
  83. contactMobile?: string;
  84. contactEmail?: string;
  85. businessId?: string | number;
  86. businessName?: string;
  87. saleStage?: string;
  88. version?: string;
  89. parentId?: string | number;
  90. isLatest?: number;
  91. discountRate?: number;
  92. validityDays?: number;
  93. quoteDate?: string;
  94. expireDate?: string;
  95. status?: string;
  96. ownerUserId?: string | number;
  97. ownerUserName?: string;
  98. totalAmount?: number;
  99. discountAmount?: number;
  100. finalAmount?: number;
  101. paymentMethod?: string;
  102. paymentTerms?: string;
  103. deliveryMethod?: string;
  104. deliveryTerms?: string;
  105. deliveryCycle?: number;
  106. description?: string;
  107. serviceTerms?: string;
  108. attachments?: string;
  109. remark?: string;
  110. products?: QuoteProductForm[];
  111. }
  112. /**
  113. * 视图对象接口
  114. */
  115. export interface QuoteVO {
  116. id: string | number;
  117. quoteNo: string;
  118. quoteTitle: string;
  119. customerId: string | number;
  120. customerName: string;
  121. opportunityId?: string | number;
  122. opportunityName?: string;
  123. contactId?: string | number;
  124. contactName?: string;
  125. contactMobile?: string;
  126. contactEmail?: string;
  127. version: string;
  128. parentId: string | number;
  129. isLatest: number;
  130. totalAmount: number;
  131. discountRate?: number;
  132. discountAmount?: number;
  133. finalAmount: number;
  134. validityDays: number;
  135. quoteDate: string;
  136. expireDate: string;
  137. status: string;
  138. rejectReason?: string;
  139. pdfUrl?: string;
  140. pdfGenerated: number;
  141. shareLink?: string;
  142. shareCode?: string;
  143. shareExpireTime?: string;
  144. viewCount: number;
  145. lastViewTime?: string;
  146. ownerUserId: string | number;
  147. ownerUserName: string;
  148. contractId?: string | number;
  149. paymentTerms?: string;
  150. deliveryTerms?: string;
  151. attachments?: string;
  152. createTime: string;
  153. updateTime?: string;
  154. remark?: string;
  155. productList?: QuoteProduct[];
  156. canApprove?: boolean; // 当前用户是否可以审批
  157. }
  158. /**
  159. * 提交审批参数
  160. */
  161. export interface SubmitApprovalForm {
  162. id: string | number;
  163. approverIds: (string | number)[];
  164. remark?: string;
  165. }
  166. /**
  167. * 审批参数
  168. */
  169. export interface ApprovalForm {
  170. id: string | number;
  171. approvalResult: string;
  172. approvalOpinion?: string;
  173. remark?: string;
  174. }
  175. /**
  176. * 分享参数
  177. */
  178. export interface GenerateShareForm {
  179. id: string | number;
  180. validityDays?: number;
  181. }
  182. /**
  183. * 转合同参数
  184. */
  185. export interface ToContractForm {
  186. id: string | number;
  187. contractNo: string;
  188. contractTitle: string;
  189. signDate?: string;
  190. effectiveDate?: string;
  191. expiryDate?: string;
  192. remark?: string;
  193. }
  194. /**
  195. * 新版本参数
  196. */
  197. export interface NewVersionForm {
  198. id: string | number;
  199. version: string;
  200. remark?: string;
  201. }
  202. /**
  203. * 查询报价单列表
  204. */
  205. export function listQuote(query: QuoteQuery) {
  206. return request({
  207. url: '/crm/quote/list',
  208. method: 'get',
  209. params: query
  210. });
  211. }
  212. /**
  213. * 查询报价单详细
  214. */
  215. export function getQuote(id: string | number) {
  216. return request({
  217. url: `/crm/quote/${id}`,
  218. method: 'get'
  219. });
  220. }
  221. /**
  222. * 新增报价单
  223. */
  224. export function addQuote(data: QuoteForm) {
  225. return request({
  226. url: '/crm/quote',
  227. method: 'post',
  228. data: data
  229. });
  230. }
  231. /**
  232. * 修改报价单
  233. */
  234. export function updateQuote(data: QuoteForm) {
  235. return request({
  236. url: '/crm/quote',
  237. method: 'put',
  238. data: data
  239. });
  240. }
  241. /**
  242. * 删除报价单
  243. */
  244. export function delQuote(ids: string | number | (string | number)[]) {
  245. return request({
  246. url: `/crm/quote/${ids}`,
  247. method: 'delete'
  248. });
  249. }
  250. /**
  251. * 提交审批
  252. */
  253. export function submitQuote(data: SubmitApprovalForm) {
  254. return request({
  255. url: '/crm/quote/submit',
  256. method: 'put',
  257. data: data
  258. });
  259. }
  260. /**
  261. * 生成PDF
  262. */
  263. export function generatePdf(id: string | number) {
  264. return request({
  265. url: '/crm/quote/generatePdf',
  266. method: 'post',
  267. data: { id }
  268. });
  269. }
  270. /**
  271. * 生成分享链接
  272. */
  273. export function generateShare(data: GenerateShareForm) {
  274. return request({
  275. url: '/crm/quote/generateShare',
  276. method: 'post',
  277. data: data
  278. });
  279. }
  280. /**
  281. * 通过分享码查看报价单
  282. */
  283. export function viewByShareCode(shareCode: string) {
  284. return request({
  285. url: `/crm/quote/share/${shareCode}`,
  286. method: 'get'
  287. });
  288. }
  289. /**
  290. * 接受报价单
  291. */
  292. export function acceptQuote(id: string | number, remark?: string) {
  293. return request({
  294. url: '/crm/quote/accept',
  295. method: 'put',
  296. data: { id, remark }
  297. });
  298. }
  299. /**
  300. * 拒绝报价单
  301. */
  302. export function rejectQuote(id: string | number, rejectReason: string, remark?: string) {
  303. return request({
  304. url: '/crm/quote/reject',
  305. method: 'put',
  306. data: { id, rejectReason, remark }
  307. });
  308. }
  309. /**
  310. * 转为合同
  311. */
  312. export function toContract(data: ToContractForm) {
  313. return request({
  314. url: '/crm/quote/toContract',
  315. method: 'post',
  316. data: data
  317. });
  318. }
  319. /**
  320. * 创建新版本
  321. */
  322. export function createNewVersion(data: NewVersionForm) {
  323. return request({
  324. url: '/crm/quote/newVersion',
  325. method: 'post',
  326. data: data
  327. });
  328. }
  329. /**
  330. * 查询版本历史
  331. */
  332. export function queryVersions(quoteNo: string) {
  333. return request({
  334. url: '/crm/quote/versions',
  335. method: 'get',
  336. params: { quoteNo }
  337. });
  338. }
  339. /**
  340. * 导出报价单
  341. */
  342. export function exportQuote(query: QuoteQuery) {
  343. return request({
  344. url: '/crm/quote/export',
  345. method: 'post',
  346. data: query,
  347. responseType: 'blob'
  348. });
  349. }
  350. /**
  351. * 统计概览视图对象
  352. */
  353. export interface QuoteStatisticsVO {
  354. totalCount: number;
  355. draftCount: number;
  356. submittedCount: number;
  357. approvedCount: number;
  358. rejectedCount: number;
  359. sentCount: number;
  360. acceptedCount: number;
  361. expiredCount: number;
  362. totalAmount: number;
  363. monthAmount: number;
  364. }
  365. /**
  366. * 查询统计概览
  367. */
  368. export function statisticsOverview() {
  369. return request({
  370. url: '/crm/quote/statistics/overview',
  371. method: 'get'
  372. });
  373. }
  374. // ==================== 审批相关接口 ====================
  375. /**
  376. * 审批记录视图对象
  377. */
  378. export interface QuoteApprovalVO {
  379. id: string | number;
  380. quoteId: string | number;
  381. quoteNo: string;
  382. step: number;
  383. approverId: string | number;
  384. approverName: string;
  385. approvalResult?: string;
  386. approvalOpinion?: string;
  387. approvalTime?: string;
  388. createTime: string;
  389. remark?: string;
  390. }
  391. /**
  392. * 查询审批记录列表
  393. */
  394. export function listApproval(quoteId: string | number) {
  395. return request({
  396. url: '/crm/quote/approval/list',
  397. method: 'get',
  398. params: { quoteId }
  399. });
  400. }
  401. /**
  402. * 审批报价单
  403. */
  404. export function approveQuote(data: ApprovalForm) {
  405. return request({
  406. url: '/crm/quote/approval',
  407. method: 'post',
  408. data: data
  409. });
  410. }
  411. /**
  412. * 撤回审批
  413. */
  414. export function withdrawApproval(id: string | number, remark?: string) {
  415. return request({
  416. url: '/crm/quote/approval/withdraw',
  417. method: 'put',
  418. data: { id, remark }
  419. });
  420. }
  421. /**
  422. * 刷新审批人姓名(修复旧数据)
  423. */
  424. export function refreshApproverNames(quoteId?: string | number) {
  425. return request({
  426. url: '/crm/quote/approval/refreshNames',
  427. method: 'post',
  428. data: quoteId ? { quoteId } : {}
  429. });
  430. }
  431. // ==================== 分享日志相关接口 ====================
  432. /**
  433. * 分享访问日志视图对象
  434. */
  435. export interface ShareLogVO {
  436. id: string | number;
  437. quoteId: string | number;
  438. shareCode: string;
  439. ipAddress: string;
  440. location?: string;
  441. deviceType: string;
  442. browser?: string;
  443. visitTime: string;
  444. stayDuration?: number;
  445. remark?: string;
  446. }
  447. /**
  448. * 分享统计视图对象
  449. */
  450. export interface ShareStatisticsVO {
  451. totalVisits: number;
  452. uniqueIps: number;
  453. avgStayDuration?: number;
  454. lastVisitTime?: string;
  455. deviceStats?: Record<string, number>;
  456. }
  457. /**
  458. * 查询分享访问日志列表
  459. */
  460. export function listShareLog(quoteId: string | number) {
  461. return request({
  462. url: '/crm/quote/shareLog/list',
  463. method: 'get',
  464. params: { quoteId }
  465. });
  466. }
  467. /**
  468. * 查询分享访问统计
  469. */
  470. export function shareLogStatistics(quoteId: string | number) {
  471. return request({
  472. url: '/crm/quote/shareLog/statistics',
  473. method: 'get',
  474. params: { quoteId }
  475. });
  476. }