api.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 type AIQuestionResponse = {
  97. code: string;
  98. data: string;
  99. };
  100. export async function askAIQuestion(
  101. payload: AIQuestionParams
  102. ): Promise<AIQuestionResponse> {
  103. return await post('/aiQuestion/ask', payload);
  104. }
  105. export type UploadFileResponse = {
  106. code: string;
  107. data: string;
  108. };
  109. export async function uploadFileApi(file: File): Promise<UploadFileResponse> {
  110. const formData = new FormData();
  111. formData.append('multipartFile', file);
  112. return await requestUploadFile('/common/uploadFile', formData);
  113. }