file.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * @Description: 悟空软件
  3. * @Author: 悟空
  4. * @Date: 2020-06-03 09:10:23
  5. * @LastEditTime: 2020-07-01 10:23:57
  6. * @LastEditors: yang
  7. */
  8. import request from '@/utils/request'
  9. /**
  10. * 通过批次ID删除文件
  11. */
  12. export function adminFileDeleteByBatchIdAPI(data) {
  13. return request({
  14. url: 'adminFile/deleteByBatchId',
  15. method: 'post',
  16. data: data,
  17. headers: {
  18. 'Content-Type': 'application/json;charset=UTF-8'
  19. }
  20. })
  21. }
  22. /**
  23. * 通过ID删除文件
  24. */
  25. export function adminFileDeleteByIdAPI(id) {
  26. return request({
  27. url: `adminFile/deleteById/${id}`,
  28. method: 'post'
  29. })
  30. }
  31. /**
  32. * 下载文件接口
  33. */
  34. export function adminFileDownAPI(id) {
  35. return request({
  36. url: `adminFile/down/${id}`,
  37. method: 'post',
  38. responseType: 'blob'
  39. })
  40. }
  41. /**
  42. * 通过adminFile/down/${id}下载文件接口
  43. * 后期使用 暂用 downloadFileAPI
  44. */
  45. export function adminFileDownByUrlAPI(url) {
  46. return request({
  47. url: url,
  48. method: 'post',
  49. responseType: 'blob'
  50. })
  51. }
  52. /**
  53. * 通过ID查询文件
  54. */
  55. export function adminFileQueryByIdAPI(id) {
  56. return request({
  57. url: `adminFile/queryById/${id}`,
  58. method: 'post'
  59. })
  60. }
  61. /**
  62. * 通过批次ID查询文件列表
  63. */
  64. export function adminFileQueryFileListAPI(id) {
  65. return request({
  66. url: `adminFile/queryFileList/${id}`,
  67. method: 'post'
  68. })
  69. }
  70. /**
  71. * 通过批次ID查询单个文件
  72. */
  73. export function adminFileQueryOneByBatchIdAPI(id) {
  74. return request({
  75. url: `adminFile/queryOneByBatchId/${id}`,
  76. method: 'post'
  77. })
  78. }
  79. /**
  80. * 修改附件名称
  81. * @param {*} data
  82. */
  83. export function adminFileRenameFileAPI(data) {
  84. return request({
  85. url: 'adminFile/renameFileById',
  86. method: 'post',
  87. data: data,
  88. headers: {
  89. 'Content-Type': 'application/json;charset=UTF-8'
  90. }
  91. })
  92. }
  93. /**
  94. * 上传文件
  95. */
  96. export function adminFileUploadAPI(data) {
  97. var param = new FormData()
  98. Object.keys(data).forEach(key => {
  99. param.append(key, data[key])
  100. })
  101. return request({
  102. url: 'adminFile/upload',
  103. method: 'post',
  104. data: param,
  105. headers: {
  106. 'Content-Type': 'multipart/form-data'
  107. }
  108. })
  109. }
  110. /**
  111. * 新附件预览
  112. */
  113. export function adminFilePreviewAPI(data) {
  114. const fileUrl = data.fileUrl
  115. delete data.fileUrl
  116. data.htmlName = 'obopom - CRM'
  117. data.htmlTitle = 'obopom - CRM'
  118. return request({
  119. baseURL: '/api-file/',
  120. url: `composite/httpfile?${fileUrl}`,
  121. method: 'post',
  122. data
  123. })
  124. }