insert.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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. list: [{
  15. label: "目的",
  16. key: "target",
  17. value: "",
  18. }, {
  19. label: "过程",
  20. key: "content",
  21. value: "",
  22. }, {
  23. label: "结果",
  24. key: "results",
  25. value: "",
  26. }, {
  27. label: "下次跟进计划",
  28. key: "nextplan",
  29. value: "",
  30. }],
  31. "content": {
  32. dataextend: {
  33. contactsid: []
  34. },
  35. sat_orderclueid: null,
  36. sat_ordercluefollowuplogid: 0,
  37. "logtype": "跟进",
  38. "competitor": "",
  39. resource: "",
  40. latitude: "", //经度
  41. longitude: "", //纬度
  42. address: "", //逆解析位置
  43. }
  44. },
  45. changeState({
  46. detail
  47. }) {
  48. this.setData({
  49. loading: detail
  50. })
  51. },
  52. async onLoad(options) {
  53. getApp().globalData.Language.getLanguagePackage(this, '跟进');
  54. if (options.resource) this.data.content.resource = options.resource;
  55. let date = formatTime(new Date(), '-').split(' '),
  56. time = date[1].split(":"),
  57. that = this;
  58. time.pop()
  59. let form = [{
  60. label: "跟进日期",
  61. error: false,
  62. errMsg: "",
  63. type: "date",
  64. value: date[0],
  65. placeholder: "跟进日期",
  66. valueName: "createdate",
  67. checking: "base",
  68. required: true
  69. }, {
  70. label: "跟进时间",
  71. error: false,
  72. errMsg: "",
  73. type: "time",
  74. value: time.join(":"),
  75. placeholder: "跟进时间",
  76. valueName: "time",
  77. checking: "base",
  78. required: true
  79. }, {
  80. label: "跟进对象",
  81. error: false,
  82. errMsg: "",
  83. params: {
  84. "id": "2025042110014402",
  85. "content": {
  86. "nocache": true,
  87. "sat_orderclueid": options.sat_orderclueid,
  88. "pageNumbe": 1,
  89. "pageTotal": 1,
  90. "total": null,
  91. "where": {
  92. "conditino": ""
  93. }
  94. }
  95. },
  96. type: "route",
  97. url: "/packageA/select/linkman/select",
  98. value: [],
  99. placeholder: "选择跟进对象",
  100. valueName: "contactsid",
  101. checking: "base",
  102. required: true
  103. }, {
  104. label: "跟进类型",
  105. error: false,
  106. errMsg: "",
  107. type: "option",
  108. optionNmae: "followupmode",
  109. optionType: "radio", //复选 radio 单选
  110. value: "",
  111. placeholder: "选择跟进方式",
  112. valueName: "followupmode",
  113. checking: "base",
  114. required: true
  115. }]
  116. if (options.sat_orderclueid) {
  117. this.data.content.sat_orderclueid = options.sat_orderclueid;
  118. wx.getLocation({
  119. type: 'wgs84',
  120. altitude: true,
  121. isHighAccuracy: true,
  122. highAccuracyExpireTime: 5000,
  123. success({
  124. latitude,
  125. longitude
  126. }) {
  127. api.getPlace(longitude, latitude).then((place) => {
  128. console.log("获取逆解析地址", place)
  129. that.setData({
  130. "content.address": place.result.formatted_address,
  131. "content.latitude": latitude,
  132. "content.longitude": longitude
  133. })
  134. })
  135. },
  136. fail(err) {
  137. console.log(err)
  138. }
  139. })
  140. } else if (options.data) {
  141. let data = JSON.parse(options.data);
  142. date = data.createdate.split(' ');
  143. time = date[1].split(":");
  144. time.pop()
  145. form[0].value = date[0];
  146. form[1].value = time.join(":");
  147. form[2].value = [data.contactsName,data.dataextend.contactsid]
  148. console.log(" form[2].value", form[2].value)
  149. form[3].value = data.followupmode;
  150. this.setData({
  151. list: this.data.list.map(v => {
  152. v.value = data[v.key]
  153. return v
  154. })
  155. })
  156. this.data.content = data;
  157. if (data.attinfo.length) this.selectComponent("#Yl_files").handleFiles(data.attinfo)
  158. }
  159. this.selectComponent("#Form").confirm()
  160. this.setData({
  161. form
  162. })
  163. },
  164. onInput(e) {
  165. const {
  166. index
  167. } = e.target.dataset;
  168. this.data.list[index].value = e.detail.value;
  169. },
  170. onVoiceInput(e) {
  171. let {
  172. index
  173. } = e.target.dataset;
  174. this.setData({
  175. [`list[${index}].value`]: e.detail
  176. })
  177. },
  178. /* 绑定媒体 */
  179. insertImgEdit({
  180. detail
  181. }) {
  182. this.handleFileLink(detail)
  183. },
  184. handleFileLink(attachmentids, ownertable = "temporary", ownerid = 1, data) {
  185. _Http.basic({
  186. "classname": "system.attachment.Attachment",
  187. "method": "createFileLink",
  188. "content": {
  189. ownertable,
  190. ownerid,
  191. usetype: 'default',
  192. attachmentids
  193. }
  194. }).then(res => {
  195. console.log('跟进记录绑定附件', res)
  196. if (res.code != '1') return wx.showToast({
  197. title: res.msg,
  198. icon: "none"
  199. })
  200. if (ownertable == 'temporary') {
  201. this.selectComponent("#Yl_files").handleFiles(res.data)
  202. } else {
  203. _Http.basic({
  204. "classname": "system.attachment.Attachment",
  205. "method": "createFileLink",
  206. "content": {
  207. ownertable: "sat_orderclue",
  208. ownerid: this.data.content.sat_orderclueid,
  209. usetype: 'default',
  210. attachmentids
  211. }
  212. })
  213. if (res.data.length) data.attinfos = res.data;
  214. this.changeItem(data)
  215. setTimeout(() => {
  216. wx.navigateBack()
  217. }, 500)
  218. }
  219. })
  220. },
  221. changeItem(data) {
  222. this.setData({
  223. loading: false
  224. })
  225. if (_Http.changeItem) _Http.changeItem(data)
  226. },
  227. submit() {
  228. this.setData({
  229. loading: true
  230. })
  231. let content = Object.assign(this.data.content, this.selectComponent("#Form").submit())
  232. content.createdate = content.createdate + ' ' + content.time + ':00';
  233. content.dataextend = {
  234. contactsid: content.contactsid[1]
  235. }
  236. delete(content.time)
  237. this.data.list.forEach(v => {
  238. content[v.key] = v.value
  239. })
  240. _Http.basic({
  241. "id": 20221208100602,
  242. content
  243. }).then(res => {
  244. console.log("保存跟进内容", res)
  245. wx.showToast({
  246. title: res.code != '1' ? res.msg : content.sat_ordercluefollowuplogid == 0 ? getApp().globalData.Language.getMapText('保存成功') : getApp().globalData.Language.getMapText('修改成功'),
  247. icon: "none",
  248. mask: res.code == '1'
  249. });
  250. if (res.code != '1') return;
  251. let attachmentids = this.selectComponent("#Yl_files").getFiles().attachmentids;
  252. if (attachmentids.length) return this.handleFileLink(attachmentids, 'sat_ordercluefollowuplog', res.data.sat_ordercluefollowuplogid, res.data);
  253. this.changeItem()
  254. setTimeout(() => {
  255. wx.navigateBack()
  256. }, 500)
  257. })
  258. },
  259. onConfirm({
  260. detail
  261. }) {
  262. this.setData({
  263. disabled: detail
  264. })
  265. },
  266. onUnload() {
  267. if (this.data.content.sat_ordercluefollowuplogid == 0) this.selectComponent("#Yl_files").deleteAll()
  268. }
  269. })