insert.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. const _Http = getApp().globalData.http;
  2. let sys_workreportmodelid = null;
  3. import {
  4. formatTime
  5. } from "../../utils/getTime"
  6. Page({
  7. data: {
  8. date: formatTime(new Date(), "-").split(" ")[0],
  9. loading: true,
  10. loading1: false
  11. },
  12. onLoad(options) {
  13. let model = JSON.parse(options.model)
  14. sys_workreportmodelid = model.sys_workreportmodelid;
  15. wx.setNavigationBarTitle({
  16. title: model.reportname,
  17. })
  18. _Http.basic({
  19. "id": "20230523131702",
  20. "content": {
  21. sys_workreportmodelid
  22. }
  23. }).then(res => {
  24. console.log("查询模板数据", res)
  25. if (res.msg != '成功') {
  26. wx.showToast({
  27. title: res.msg,
  28. icon: "none",
  29. mask: true
  30. })
  31. setTimeout(() => {
  32. wx.navigateBack()
  33. }, 500)
  34. } else {
  35. this.setData({
  36. reportname: model.reportname,
  37. list: res.data.map(v => {
  38. v.content = v.content.map(s => {
  39. return v.editable == 1 && s.content != "" ? `${s.rowindex}、${s.content}` : s.content
  40. }).join('\n\n');
  41. return v
  42. }),
  43. loading: false
  44. })
  45. }
  46. })
  47. },
  48. /* 绑定媒体 */
  49. insertImgEdit({
  50. detail
  51. }) {
  52. _Http.basic({
  53. "classname": "system.attachment.Attachment",
  54. "method": "createFileLink",
  55. "content": {
  56. "ownertable": "sys_workreport",
  57. "ownerid": 0,
  58. "usetype": "default",
  59. "attachmentids": detail
  60. }
  61. }).then(res => {
  62. console.log('跟进记录绑定附件', res)
  63. if (res.msg != '成功') return wx.showToast({
  64. title: res.msg,
  65. icon: "none"
  66. })
  67. this.selectComponent("#Yl_Files").handleFiles(res.data)
  68. })
  69. },
  70. onInput(e) {
  71. let {
  72. item,
  73. index
  74. } = e.currentTarget.dataset;
  75. item.content = e.detail.value;
  76. this.setData({
  77. [`list[${index}]`]: item
  78. })
  79. },
  80. onVoiceInput(e) {
  81. let {
  82. item,
  83. index
  84. } = e.currentTarget.dataset;
  85. item.content = e.detail;
  86. this.setData({
  87. [`list[${index}]`]: item
  88. })
  89. },
  90. /* 取消汇报 */
  91. onCancel() {
  92. wx.showModal({
  93. title: '提示',
  94. content: '是否确定取消汇报,确认后将丢失填写/修改进度',
  95. complete: (res) => {
  96. if (res.confirm) wx.navigateBack()
  97. }
  98. })
  99. },
  100. /* 提交汇报 */
  101. submit() {
  102. console.log()
  103. const that = this;
  104. wx.showModal({
  105. title: '提示',
  106. content: '是否确认提交汇报?',
  107. complete: ({
  108. confirm
  109. }) => {
  110. if (confirm) {
  111. this.setData({
  112. loading1: true
  113. })
  114. _Http.basic({
  115. "id": "20230523094702",
  116. "content": {
  117. sys_workreportmodelid,
  118. "items": that.data.list.map(v => {
  119. v.content = [{
  120. rouindex: 1,
  121. content: v.content
  122. }]
  123. return v
  124. })
  125. },
  126. }).then(res => {
  127. console.log("提交汇报", res)
  128. that.setData({
  129. loading1: false
  130. })
  131. wx.showToast({
  132. title: res.msg == '成功' ? '提交成功' : res.msg,
  133. icon: "none",
  134. mask: true
  135. });
  136. let {
  137. attachmentids
  138. } = this.selectComponent("#Yl_Files").getFiles();
  139. if (attachmentids.length == 0) return setTimeout(() => {
  140. wx.redirectTo({
  141. url: '/packageA/report/detail?id=' + res.data.sys_workreportid,
  142. })
  143. }, 500)
  144. _Http.basic({
  145. "classname": "system.attachment.Attachment",
  146. "method": "createFileLink",
  147. "content": {
  148. "ownertable": "sys_workreport",
  149. "ownerid": res.data.sys_workreportid,
  150. "usetype": "default",
  151. attachmentids
  152. }
  153. }).then(s => {
  154. console.log('附件改绑', s)
  155. if (s.msg != '成功') wx.showToast({
  156. title: s.msg,
  157. icon: "none",
  158. mask: true
  159. });
  160. setTimeout(() => {
  161. wx.redirectTo({
  162. url: '/packageA/report/detail?id=' + res.data.sys_workreportid,
  163. })
  164. }, 300)
  165. })
  166. })
  167. }
  168. }
  169. })
  170. }
  171. })