index.js 2.7 KB

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