add.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. detail: null,
  5. isFollow: false,
  6. isSubmit: true, //是否可以提交
  7. files: {
  8. images: [],
  9. viewImages: [],
  10. videos: [],
  11. viewVideos: [],
  12. files: []
  13. },
  14. },
  15. onLoad(options) {
  16. this.setData({
  17. detail: JSON.parse(options.data),
  18. isFollow: options.isFollow == 'true'
  19. });
  20. if (this.data.detail.attinfos.length != 0) this.selectComponent("#Yl_files").handleFiles(res.data)
  21. if (this.data.detail.notes != '' && this.data.isFollow) this.setData({
  22. isSubmit: false
  23. })
  24. },
  25. //文本域输入
  26. onInput(e) {
  27. this.setData({
  28. "detail.notes": e.detail.value
  29. })
  30. },
  31. /* 绑定媒体 */
  32. insertImgEdit({
  33. detail
  34. }) {
  35. _Http.basic({
  36. "classname": "system.attachment.Attachment",
  37. "method": "createFileLink",
  38. "content": {
  39. "ownertable": "sa_project_stagework",
  40. "ownerid": this.data.detail.sa_project_stageworkid,
  41. "usetype": "default",
  42. "attachmentids": detail
  43. }
  44. }).then(res => {
  45. console.log('跟进记录绑定附件', res)
  46. if (res.msg != '成功') return wx.showToast({
  47. title: res.data,
  48. icon: "none"
  49. })
  50. this.selectComponent("#Yl_files").handleFiles(res.data)
  51. this.data.detail.attinfos.push(res.data[0])
  52. this.changeFile();
  53. })
  54. },
  55. /* 修改源文件附件 */
  56. changeFile() {
  57. let pages = getCurrentPages(),
  58. page = pages[pages.length - 2].selectComponent("#Task"),
  59. i = page.data.list[page.data.viewIndex].work.findIndex(v => v.sa_project_stageworkid == this.data.detail.sa_project_stageworkid);
  60. page.setData({
  61. [`list[${page.data.viewIndex}].work[${i}].attinfos`]: this.data.detail.attinfos
  62. })
  63. },
  64. /* 保存 */
  65. save() {
  66. _Http.basic({
  67. "id": 20221024160202,
  68. "content": {
  69. sa_project_stageworkid: this.data.detail.sa_project_stageworkid,
  70. notes: this.data.detail.notes,
  71. }
  72. }).then(res => {
  73. wx.showToast({
  74. title: res.msg == '成功' ? '保存成功' : res.data,
  75. icon: "none"
  76. });
  77. if (res.msg != '成功') return;
  78. this.setData({
  79. isSubmit: false
  80. })
  81. let pages = getCurrentPages(),
  82. page = pages[pages.length - 2].selectComponent("#Task"),
  83. i = page.data.list[page.data.viewIndex].work.findIndex(v => v.sa_project_stageworkid == this.data.detail.sa_project_stageworkid);
  84. page.setData({
  85. [`list[${page.data.viewIndex}].work[${i}].notes`]: this.data.detail.notes
  86. })
  87. })
  88. },
  89. /* 提交 */
  90. submit() {
  91. let that = this;
  92. wx.showModal({
  93. title: '提示',
  94. content: `是否提交该任务,提交后将计算分值(仅可提交一次)`,
  95. complete: ({
  96. confirm
  97. }) => {
  98. if (confirm) _Http.basic({
  99. "id": 20221024160302,
  100. "content": {
  101. "sa_project_stageworkid": that.data.detail.sa_project_stageworkid
  102. }
  103. }).then(res => {
  104. console.log("任务提交", res)
  105. if (res.msg != '成功') return wx.showToast({
  106. title: res.data,
  107. icon: "none"
  108. });
  109. let pages = getCurrentPages(),
  110. page = pages[pages.length - 2].selectComponent("#Task");
  111. pages[pages.length - 2].getDetail();
  112. page.getList();
  113. wx.showToast({
  114. title: '提交成功',
  115. icon: "none"
  116. });
  117. that.setData({
  118. "detail.finished": 1
  119. })
  120. })
  121. }
  122. })
  123. }
  124. })