index.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. const _Http = getApp().globalData.http,
  2. MFT = require("../../../utils/matchingFeilType"),
  3. checkFile = require("../../../utils/checkFile");
  4. Component({
  5. options: {
  6. addGlobalClass: true
  7. },
  8. properties: {
  9. ownertable: String,
  10. ownerid: String,
  11. },
  12. data: {
  13. content: {
  14. nocache: true,
  15. pageNumber: 1,
  16. pageSize: 10,
  17. pageTotal: 1,
  18. total: null,
  19. usetype: ""
  20. },
  21. list: []
  22. },
  23. methods: {
  24. getList(id, init = false) {
  25. let content = {
  26. ...this.data.content,
  27. "ownertable": this.data.ownertable,
  28. "ownerid": this.data.ownerid,
  29. nocache: true,
  30. };
  31. if (init) content.pageNumber = 1
  32. _Http.basic({
  33. "classname": "system.attachment.Attachment",
  34. "method": "queryFileLink",
  35. content
  36. }).then(res => {
  37. console.log("附件列表", res)
  38. if (res.msg != '成功') return wx.showToast({
  39. title: res.data,
  40. icon: "none"
  41. });
  42. res.data = MFT.fileList(res.data)
  43. this.setData({
  44. "content.pageNumber": res.pageNumber + 1,
  45. "content.pageTotal": res.pageTotal,
  46. "content.total": res.total,
  47. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  48. })
  49. })
  50. },
  51. addFiles({
  52. detail
  53. }) {
  54. _Http.basic({
  55. "classname": "system.attachment.Attachment",
  56. "method": "createFileLink",
  57. "content": {
  58. "ownertable": this.data.ownertable,
  59. "ownerid": this.data.ownerid,
  60. "usetype": "default",
  61. "attachmentids": detail
  62. }
  63. }).then(res => {
  64. console.log('上传附件', res)
  65. if (res.msg != '成功') return wx.showToast({
  66. title: res.msg,
  67. icon: "none"
  68. });
  69. this.getList(1, true);
  70. })
  71. },
  72. openFile(e) {
  73. const {
  74. item
  75. } = e.currentTarget.dataset;
  76. checkFile.checkFile(item)
  77. }
  78. }
  79. })