index.js 1.7 KB

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