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.

57 lines
1.6 KiB

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