common.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. import axios from '../utils/request'
  2. import qs from 'qs'
  3. import CONFIG from '../utils/config'
  4. interface LoginParams {
  5. userName: string
  6. password: string
  7. clientId: string
  8. }
  9. interface DmsTypesParams {
  10. cName?: string
  11. aType?: string
  12. }
  13. interface UpdatePasswordParams {
  14. oldPassword: string
  15. newPassword: string
  16. userId?: string
  17. }
  18. interface UpdateContentParams {
  19. id: string
  20. content: string
  21. [key: string]: unknown
  22. }
  23. interface AddContentParams {
  24. content: string,
  25. columnId: number
  26. modelId: number
  27. }
  28. interface DmsDataListParams {
  29. pageNum?: number
  30. pageSize?: number
  31. [key: string]: unknown
  32. }
  33. interface ModelByIdParams {
  34. modelId: number
  35. }
  36. interface UpdateAuditParams {
  37. id: string
  38. columnId: number
  39. state: number
  40. }
  41. interface UploadFileParams {
  42. columnId: string
  43. contentId?: string
  44. paraName: string
  45. type: number
  46. file: File
  47. }
  48. const login = (params: LoginParams) => {
  49. return axios.post(CONFIG.OAUTH_URL + '/user/pwd/login', qs.stringify(params), {
  50. headers: {
  51. 'Content-Type': 'application/x-www-form-urlencoded',
  52. },
  53. })
  54. }
  55. const updatePassword = (params: UpdatePasswordParams) => {
  56. return axios.post(CONFIG.OAUTH_URL + '/user/updatePassword', qs.stringify(params), {
  57. headers: {
  58. 'Content-Type': 'application/x-www-form-urlencoded',
  59. },
  60. })
  61. }
  62. const getDmsTypes = (params: DmsTypesParams) => {
  63. return axios.post(CONFIG.DMS_URL + '/category/selectByCNameAType', qs.stringify(params))
  64. }
  65. const updateContent = (params: UpdateContentParams) => {
  66. return axios.post(CONFIG.DMS_URL + '/content/updateContent', qs.stringify(params))
  67. }
  68. const addContent = (params: AddContentParams) => {
  69. return axios.post(CONFIG.DMS_URL + '/content/addContent', qs.stringify(params))
  70. }
  71. const getDmsDataList = (params: DmsDataListParams) => {
  72. return axios.post(CONFIG.DMS_URL + '/content/selectContentList', qs.stringify(params))
  73. }
  74. const getMultipleFormsOfJointInvestigation = (params: DmsDataListParams) => {
  75. return axios.post(CONFIG.DMS_URL + '/content/multipleFormsOfJointInvestigation', qs.stringify(params))
  76. }
  77. const getModelById = (params: ModelByIdParams) => {
  78. return axios.post(CONFIG.DMS_URL + '/model/getModelById', qs.stringify(params))
  79. }
  80. const updateAudit = (params: UpdateAuditParams) => {
  81. return axios.post(CONFIG.DMS_URL + '/content/updateAudit', qs.stringify(params))
  82. }
  83. const uploadFile = (params: UploadFileParams) => {
  84. const formData = new FormData()
  85. formData.append('columnId', params.columnId)
  86. formData.append('contentId', params.contentId || '')
  87. formData.append('paraName', params.paraName)
  88. formData.append('type', String(params.type))
  89. formData.append('file', params.file)
  90. return axios.post(CONFIG.DMS_URL + '/file/uploadFile', formData, {
  91. headers: { 'Content-Type': 'multipart/form-data' }
  92. })
  93. }
  94. const getBasicCount = () => {
  95. return axios.get(CONFIG.SQ_URL + '/count/basic')
  96. }
  97. const getHistoryPartner = () => {
  98. return axios.get(CONFIG.SQ_URL + '/count/history_partner')
  99. }
  100. const getGenerateTender = (params: any) => {
  101. return axios.post(CONFIG.SQ_URL + '/tender/generate', qs.stringify(params))
  102. }
  103. /** 查询标书生成步骤进度;path 参数为投续标内容 ID */
  104. const getTenderProgress = (txbId: string | number) => {
  105. return axios.get(`${CONFIG.SQ_URL}/tender/api/v1/jobs/${txbId}/progress`, {
  106. headers: { Accept: 'application/json' },
  107. })
  108. }
  109. export default {
  110. login,
  111. updatePassword,
  112. getDmsTypes,
  113. updateContent,
  114. addContent,
  115. getDmsDataList,
  116. getMultipleFormsOfJointInvestigation,
  117. getModelById,
  118. updateAudit,
  119. uploadFile,
  120. getBasicCount,
  121. getHistoryPartner,
  122. getGenerateTender,
  123. getTenderProgress
  124. }