index.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. if (content.pageNumber > content.pageTotal) return;
  46. _Http.basic({
  47. "classname": "system.attachment.Attachment",
  48. "method": "queryFileLink",
  49. content
  50. }).then(res => {
  51. console.log("附件列表", res)
  52. if (res.code != '1') return wx.showToast({
  53. title: res.data,
  54. icon: "none"
  55. });
  56. res.data = MFT.fileList(res.data)
  57. this.setData({
  58. "content.pageNumber": res.pageNumber + 1,
  59. "content.pageTotal": res.pageTotal,
  60. "content.total": res.total,
  61. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  62. })
  63. })
  64. },
  65. addFiles({
  66. detail
  67. }) {
  68. _Http.basic({
  69. "classname": "system.attachment.Attachment",
  70. "method": "createFileLink",
  71. "content": {
  72. "ownertable": this.data.ownertable,
  73. "ownerid": this.data.ownerid,
  74. "usetype": "default",
  75. "attachmentids": detail
  76. }
  77. }).then(res => {
  78. console.log('上传附件', res)
  79. if (res.code != '1') return wx.showToast({
  80. title: res.msg,
  81. icon: "none"
  82. });
  83. this.getList(1, true);
  84. })
  85. },
  86. openFile(e) {
  87. const {
  88. item
  89. } = e.currentTarget.dataset;
  90. checkFile.checkFile(item)
  91. }
  92. }
  93. })