api.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. import { post, get, uploadFile as requestUploadFile } from '@/utils/request';
  2. export type RequestProps = {
  3. /**
  4. * @description 0-本月 1-本周 2-本年
  5. */
  6. dateType?: 0 | 1 | 2;
  7. /**
  8. * @description 0-仅本人 1-本人及下属 2-仅本部门 3-本部门及下属部门
  9. */
  10. queryType?: 0 | 1 | 2 | 3;
  11. startDate?: string;
  12. endDate?: string;
  13. };
  14. export type SummaryData = {
  15. code: string;
  16. data: {
  17. clueDataSummary: {
  18. changeNum: number;
  19. newNum: number;
  20. };
  21. businessOpportunityDataSummary: {
  22. winning: number;
  23. allAmountOfMoney: number;
  24. losting: number;
  25. newNum: number;
  26. };
  27. customDataSummary: {
  28. closeDealNum: number;
  29. newNum: number;
  30. };
  31. };
  32. };
  33. export async function getSummaryData(
  34. payload?: RequestProps
  35. ): Promise<SummaryData> {
  36. return await post('/order/dataSummary', payload);
  37. }
  38. export type StageData = {
  39. code: string;
  40. data: {
  41. dataMap: {
  42. stageName: string;
  43. num: number;
  44. }[];
  45. };
  46. };
  47. export async function getStageData(payload?: RequestProps): Promise<StageData> {
  48. return await post('/order/businessOpportunityStage', payload);
  49. }
  50. export type BulletinData = {
  51. code: string;
  52. data: {
  53. custom: {
  54. customPromote: string;
  55. customCount: number;
  56. };
  57. businessOpportunity: {
  58. businessOpportunityCount: number;
  59. businessOpportunityPromote: string;
  60. };
  61. contacts: {
  62. contactsCount: number;
  63. contactsPromote: string;
  64. };
  65. salesOrder: {
  66. salesOrderCount: number;
  67. salesOrderPromote: string;
  68. };
  69. salesOrdersPrice: {
  70. salesOrderPricePromote: string;
  71. salesOrdersPrice: number;
  72. };
  73. clue: {
  74. cluePromote: string;
  75. clueCount: number;
  76. };
  77. businessOpportunityPrice: {
  78. businessOpportunityPromote: string;
  79. businessOpportunityPrice: number;
  80. };
  81. };
  82. };
  83. export async function getBulletinData(
  84. payload?: RequestProps
  85. ): Promise<BulletinData> {
  86. return await post('/order/salesKit', payload);
  87. }
  88. export type AIQuestionParams = {
  89. questionDataSource: number;
  90. sourceContent: string;
  91. content: string;
  92. startDate: string;
  93. endDate: string;
  94. url?: string;
  95. };
  96. export interface ChatContent {
  97. type: 0 | 1;
  98. content: string;
  99. questionId?: number;
  100. }
  101. export interface LatestQuestionResponse {
  102. code: string;
  103. data: {
  104. contents: ChatContent[];
  105. };
  106. }
  107. export interface AIQuestionResponse {
  108. code: string;
  109. data: {
  110. queryRes: string;
  111. questionId: number;
  112. };
  113. }
  114. export async function askAIQuestion(
  115. payload: AIQuestionParams
  116. ): Promise<AIQuestionResponse> {
  117. return await post('/aiQuestion/ask', payload);
  118. }
  119. export type UploadFileResponse = {
  120. code: string;
  121. data: string;
  122. };
  123. export async function uploadFileApi(file: File): Promise<UploadFileResponse> {
  124. const formData = new FormData();
  125. formData.append('multipartFile', file);
  126. return await requestUploadFile('/common/uploadFile', formData);
  127. }
  128. export interface ChatContent {
  129. type: 0 | 1;
  130. content: string;
  131. createTime: string;
  132. questionId?: number;
  133. }
  134. export async function getLatestQuestionList(): Promise<LatestQuestionResponse> {
  135. return await post('/aiQuestion/getLatestQuestionList');
  136. }
  137. export interface CustomReport {
  138. id: string;
  139. storeName: string;
  140. relateFormId: string;
  141. }
  142. export interface CustomReportResponse {
  143. code: string;
  144. data: CustomReport[];
  145. }
  146. export async function getCustomReports(): Promise<CustomReportResponse> {
  147. return await post('/aiQuestion/getCusReportForm');
  148. }