index.js 1.7 KB

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