index.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. lifetimes: {
  18. attached: function () {
  19. getApp().globalData.Language.getLanguagePackage(this)
  20. }
  21. },
  22. data: {
  23. content: {
  24. nocache: true,
  25. pageNumber: 1,
  26. pageSize: 999,
  27. pageTotal: 1,
  28. total: null,
  29. usetype: ""
  30. },
  31. list: []
  32. },
  33. methods: {
  34. getList(id, init = false) {
  35. let content = {
  36. ...this.data.content,
  37. "ownertable": this.data.ownertable,
  38. "ownerid": this.data.ownerid,
  39. };
  40. if (init) content.pageNumber = 1
  41. _Http.basic({
  42. "classname": "system.attachment.Attachment",
  43. "method": "queryFileLink",
  44. content
  45. }).then(res => {
  46. console.log("附件列表", res)
  47. if (res.code != '1') return wx.showToast({
  48. title: res.msg,
  49. icon: "none"
  50. });
  51. this.setData({
  52. "content.pageNumber": res.pageNumber + 1,
  53. "content.pageTotal": res.pageTotal,
  54. "content.total": res.total
  55. })
  56. this.selectComponent("#Yl_Files").handleFiles(res.data, true)
  57. })
  58. },
  59. addFiles({
  60. detail
  61. }) {
  62. _Http.basic({
  63. "classname": "system.attachment.Attachment",
  64. "method": "createFileLink",
  65. "content": {
  66. "ownertable": this.data.ownertable,
  67. "ownerid": this.data.ownerid,
  68. "usetype": "default",
  69. "attachmentids": detail
  70. }
  71. }).then(res => {
  72. console.log('上传附件', res)
  73. if (res.code != '1') return wx.showToast({
  74. title: res.msg,
  75. icon: "none"
  76. });
  77. this.selectComponent("#Yl_Files").handleFiles(res.data);
  78. this.setData({
  79. "content.total": this.data.content.total + res.total
  80. })
  81. })
  82. },
  83. deleteFiles() {
  84. this.setData({
  85. "content.total": this.data.content.total - 1
  86. })
  87. }
  88. }
  89. })