insert.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. const _Http = getApp().globalData.http,
  2. {
  3. formatTime
  4. } = require("../../../../utils/getTime");
  5. import {
  6. tianditu
  7. } from "../../../../utils/tianditu.js";
  8. const api = new tianditu();
  9. Page({
  10. data: {
  11. disabled: true,
  12. loading: false,
  13. form: [],
  14. "content": {
  15. sat_orderclueid: null,
  16. sat_ordercluefollowuplogid: 0,
  17. "logtype": "跟进",
  18. "competitor": "",
  19. latitude: "", //经度
  20. longitude: "", //纬度
  21. address: "", //逆解析位置
  22. }
  23. },
  24. changeState({
  25. detail
  26. }) {
  27. this.setData({
  28. loading: detail
  29. })
  30. },
  31. async onLoad(options) {
  32. getApp().globalData.Language.getLanguagePackage(this, '跟进');
  33. let date = formatTime(new Date(), '-').split(' '),
  34. time = date[1].split(":"),
  35. that = this;
  36. time.pop()
  37. let form = [{
  38. label: "跟进日期",
  39. error: false,
  40. errMsg: "",
  41. type: "date",
  42. value: date[0],
  43. placeholder: "跟进日期",
  44. valueName: "createdate",
  45. checking: "base",
  46. required: true
  47. }, {
  48. label: "跟进时间",
  49. error: false,
  50. errMsg: "",
  51. type: "time",
  52. value: time.join(":"),
  53. placeholder: "跟进时间",
  54. valueName: "time",
  55. checking: "base",
  56. required: true
  57. }, {
  58. label: "跟进类型",
  59. error: false,
  60. errMsg: "",
  61. type: "option",
  62. optionNmae: "followupmode",
  63. optionType: "radio", //复选 radio 单选
  64. value: "",
  65. placeholder: "选择跟进方式",
  66. valueName: "followupmode",
  67. checking: "base",
  68. required: true
  69. }, {
  70. label: "跟进内容",
  71. error: false,
  72. errMsg: "",
  73. type: "textarea",
  74. value: "",
  75. placeholder: "跟进内容",
  76. valueName: "content",
  77. checking: "base",
  78. required: false
  79. }]
  80. if (options.sat_orderclueid) {
  81. this.data.content.sat_orderclueid = options.sat_orderclueid;
  82. wx.getLocation({
  83. type: 'wgs84',
  84. altitude: true,
  85. isHighAccuracy: true,
  86. highAccuracyExpireTime: 5000,
  87. success({
  88. latitude,
  89. longitude
  90. }) {
  91. api.getPlace(longitude, latitude).then((place) => {
  92. console.log("获取逆解析地址", place)
  93. that.setData({
  94. "content.address": place.result.formatted_address,
  95. "content.latitude": latitude,
  96. "content.longitude": longitude
  97. })
  98. })
  99. },
  100. fail(err) {
  101. console.log(err)
  102. }
  103. })
  104. } else if (options.data) {
  105. let data = JSON.parse(options.data);
  106. date = data.createdate.split(' ');
  107. time = date[1].split(":");
  108. time.pop()
  109. form[0].value = date[0];
  110. form[1].value = time.join(":");
  111. form[2].value = data.followupmode;
  112. form[3].value = data.content;
  113. this.data.content = data;
  114. if (data.attinfo.length) this.selectComponent("#Yl_files").handleFiles(data.attinfo)
  115. }
  116. this.selectComponent("#Form").confirm()
  117. this.setData({
  118. form
  119. })
  120. },
  121. /* 绑定媒体 */
  122. insertImgEdit({
  123. detail
  124. }) {
  125. this.handleFileLink(detail)
  126. },
  127. handleFileLink(attachmentids, ownertable = "temporary", ownerid = 1, data) {
  128. _Http.basic({
  129. "classname": "system.attachment.Attachment",
  130. "method": "createFileLink",
  131. "content": {
  132. ownertable,
  133. ownerid,
  134. usetype: 'default',
  135. attachmentids
  136. }
  137. }).then(res => {
  138. console.log('跟进记录绑定附件', res)
  139. if (res.code != '1') return wx.showToast({
  140. title: res.msg,
  141. icon: "none"
  142. })
  143. if (ownertable == 'temporary') {
  144. this.selectComponent("#Yl_files").handleFiles(res.data)
  145. } else {
  146. if (res.data.length) data.attinfos = res.data;
  147. this.changeItem(data)
  148. setTimeout(() => {
  149. wx.navigateBack()
  150. }, 500)
  151. }
  152. })
  153. },
  154. changeItem(data) {
  155. this.setData({
  156. loading: false
  157. })
  158. if (_Http.changeItem) _Http.changeItem(data)
  159. },
  160. submit() {
  161. this.setData({
  162. loading: true
  163. })
  164. let content = Object.assign(this.data.content, this.selectComponent("#Form").submit())
  165. content.createdate = content.createdate + ' ' + content.time + ':00';
  166. delete(content.time)
  167. _Http.basic({
  168. "id": 20221208100602,
  169. content
  170. }).then(res => {
  171. console.log("保存跟进内容", res)
  172. wx.showToast({
  173. title: res.code != '1' ? res.msg : content.sat_ordercluefollowuplogid == 0 ? getApp().globalData.Language.getMapText('保存成功') : getApp().globalData.Language.getMapText('修改成功'),
  174. icon: "none",
  175. mask: res.code == '1'
  176. });
  177. if (res.code != '1') return;
  178. let attachmentids = this.selectComponent("#Yl_files").getFiles().attachmentids;
  179. if (attachmentids.length) return this.handleFileLink(attachmentids, 'sat_ordercluefollowuplog', res.data.sat_ordercluefollowuplogid, res.data);
  180. this.changeItem()
  181. setTimeout(() => {
  182. wx.navigateBack()
  183. }, 500)
  184. })
  185. },
  186. onConfirm({
  187. detail
  188. }) {
  189. this.setData({
  190. disabled: detail
  191. })
  192. },
  193. onUnload() {
  194. if (this.data.content.sat_ordercluefollowuplogid == 0) this.selectComponent("#Yl_files").deleteAll()
  195. }
  196. })