You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.5 KiB

  1. import ApiService from '@/services/api.service'
  2. class DocumentService {
  3. constructor() {
  4. this.request = ApiService
  5. }
  6. getDocumentList({ projectId, limit, offset, q = '', isChecked = '', filterName = '' }) {
  7. return this.request.get(`/projects/${projectId}/docs?limit=${limit}&offset=${offset}&q=${q}&${filterName}=${isChecked}`)
  8. }
  9. addDocument(projectId, payload) {
  10. return this.request.post(`/projects/${projectId}/docs`, payload)
  11. }
  12. deleteDocument(projectId, docId) {
  13. return this.request.delete(`/projects/${projectId}/docs/${docId}`)
  14. }
  15. updateDocument(projectId, docId, payload) {
  16. return this.request.patch(`/projects/${projectId}/docs/${docId}`, payload)
  17. }
  18. uploadFile(projectId, payload, config = {}) {
  19. return this.request.post(`/projects/${projectId}/docs/upload`, payload, config)
  20. }
  21. exportFile(projectId, format) {
  22. const headers = {}
  23. if (format === 'csv') {
  24. headers.Accept = 'text/csv; charset=utf-8'
  25. headers['Content-Type'] = 'text/csv; charset=utf-8'
  26. } else {
  27. headers.Accept = 'application/json'
  28. headers['Content-Type'] = 'application/json'
  29. }
  30. const config = {
  31. responseType: 'blob',
  32. params: {
  33. q: format
  34. },
  35. headers
  36. }
  37. return this.request.get(`/projects/${projectId}/docs/download`, config)
  38. }
  39. approveDocument(projectId, docId, payload) {
  40. return this.request.post(`/projects/${projectId}/docs/${docId}/approve-labels`, payload)
  41. }
  42. }
  43. export default new DocumentService()