insert.js 6.2 KB

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