index.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. options: {
  4. addGlobalClass: true
  5. },
  6. data: {
  7. sheetShow: false,
  8. sheetTitle: "",
  9. showWhere: "所有日期",
  10. timeRangeShow: false,
  11. sat_orderclueid: 0,
  12. detailsData: null,
  13. followList: null,
  14. isdesc: 1,
  15. whereType: {
  16. value: "start",
  17. list: {
  18. "start": "",
  19. "end": ""
  20. }
  21. },
  22. where: {
  23. "start": "",
  24. "end": ""
  25. },
  26. teamList: [],
  27. isEdit: false, //退出时是否重新获取列表
  28. actions: [{
  29. name: "跟进"
  30. }, {
  31. name: "成交"
  32. }, {
  33. name: "无效"
  34. }]
  35. },
  36. handleSelect({
  37. detail
  38. }) {
  39. const that = this;
  40. if (detail.name == '跟进') {
  41. this.selectComponent("#follow").updateTime();
  42. this.setData({
  43. sheetTitle: '跟进计划'
  44. })
  45. } else {
  46. wx.showModal({
  47. title: "提示",
  48. content: `是否设置该线索为"${detail.name}"状态,确定后无法撤销!`,
  49. success({
  50. confirm
  51. }) {
  52. if (!confirm) return;
  53. _Http.basic({
  54. "classname": "saletool.orderclue.web.orderclue",
  55. "method": "addFollowUpLog",
  56. "content": {
  57. sat_orderclueid: that.data.detailsData.sat_orderclueid,
  58. "content": "",
  59. "followupmode": "",
  60. "logtype": detail.name,
  61. "competitor": ""
  62. },
  63. }).then(res => {
  64. if (res.msg != '成功') return wx.showToast({
  65. title: res.msg,
  66. icon: "none"
  67. });
  68. that.selectDetail();
  69. that.getFollowList();
  70. });
  71. const pages = getCurrentPages();
  72. pages[pages.length - 2].getList();
  73. setTimeout(() => {
  74. wx.showToast({
  75. title: '操作成功',
  76. icon: "none"
  77. })
  78. }, 100)
  79. }
  80. })
  81. }
  82. this.selectCancel();
  83. },
  84. selectCancel() {
  85. this.setData({
  86. sheetShow: false
  87. })
  88. },
  89. /**
  90. * 生命周期函数--监听页面加载
  91. */
  92. onLoad(options) {
  93. this.setData({
  94. sat_orderclueid: options.id,
  95. tagColor: options.color,
  96. auth: wx.getStorageSync('authList').worderclue.optionnames
  97. })
  98. this.selectDetail();
  99. this.getFollowList();
  100. this.query_teamList();
  101. },
  102. /* 团队成员 */
  103. query_teamList(i = 0) {
  104. if (i == 5) return;
  105. _Http.basic({
  106. "classname": "sale.team.team",
  107. "method": "query_teamList",
  108. "content": {
  109. "pageNumber": 1,
  110. "pageSize": 99999,
  111. "where": {
  112. "condition": ""
  113. }
  114. }
  115. }).then(res => {
  116. if (res.msg != '成功') return this.selectDetail(i + 1);
  117. this.setData({
  118. teamList: res.data
  119. })
  120. })
  121. },
  122. /* 查询详情 */
  123. selectDetail(i = 0) {
  124. if (i == 5) return wx.showToast({
  125. title: '详情信息查询失败!',
  126. icon: "none"
  127. })
  128. _Http.basic({
  129. "classname": "saletool.orderclue.web.orderclue",
  130. "method": "selectDetail",
  131. "content": {
  132. "sat_orderclueid": this.data.sat_orderclueid
  133. }
  134. }).then(res => {
  135. if (res.msg != '成功') return this.selectDetail(i + 1);
  136. let data = res.data;
  137. for (let i in data) {
  138. if (data[i] === '') data[i] = '-';
  139. }
  140. this.setData({
  141. detailsData: data
  142. })
  143. })
  144. },
  145. /* 跟进列表 */
  146. getFollowList(i = 0) {
  147. if (i == 5) return wx.showToast({
  148. title: '跟进记录查询失败!',
  149. icon: "none"
  150. })
  151. _Http.basic({
  152. "classname": "saletool.orderclue.web.orderclue",
  153. "method": "getFollowList",
  154. "content": {
  155. "sat_orderclueid": this.data.sat_orderclueid,
  156. "isdesc": this.data.isdesc,
  157. where: this.data.where
  158. }
  159. }).then(res => {
  160. console.log("跟进", res)
  161. if (res.msg != '成功') return this.getFollowList(i + 1);
  162. this.setData({
  163. followList: res.data
  164. })
  165. })
  166. },
  167. /* 打开弹出 */
  168. openPoput(e) {
  169. const {
  170. name
  171. } = e.currentTarget.dataset;
  172. if (name == '跟进计划') {
  173. this.setData({
  174. sheetShow: true
  175. })
  176. } else {
  177. if (e.currentTarget.dataset.status == '待跟进') {
  178. wx.showToast({
  179. title: '请先执行跟进后再进行编辑!',
  180. icon: "none"
  181. });
  182. this.setData({
  183. sheetShow: true
  184. })
  185. return
  186. }
  187. if (name == '线索编辑') this.selectComponent("#edit").initData()
  188. this.setData({
  189. sheetTitle: name
  190. })
  191. }
  192. },
  193. /* 结束编辑 */
  194. endEdit() {
  195. this.setData({
  196. sheetTitle: "",
  197. isEdit: true
  198. })
  199. this.selectDetail();
  200. },
  201. /* 结束跟进 */
  202. endFollow() {
  203. this.endEdit();
  204. this.getFollowList();
  205. },
  206. /* 修改排序方式 */
  207. changeIsdesc() {
  208. this.setData({
  209. isdesc: this.data.isdesc == 1 ? 0 : 1
  210. });
  211. this.getFollowList();
  212. },
  213. /* 打开选择时间 */
  214. openSelectDate() {
  215. this.setData({
  216. timeRangeShow: true
  217. })
  218. },
  219. /* 查看所有日期 */
  220. toSeeAll() {
  221. this.setData({
  222. showWhere: "所有日期"
  223. })
  224. this.timeRangeClose();
  225. this.getFollowList();
  226. },
  227. /* 关闭时间范围选择 */
  228. timeRangeClose() {
  229. this.setData({
  230. timeRangeShow: false,
  231. "where": {
  232. "start": "",
  233. "end": ""
  234. }
  235. })
  236. },
  237. /* 选择日期类型 */
  238. selectDateType(e) {
  239. const {
  240. name
  241. } = e.target.dataset;
  242. this.setData({
  243. "whereType.value": name
  244. })
  245. },
  246. /* 得到选择时间 */
  247. getDate({
  248. detail
  249. }) {
  250. let obj = this.data.whereType;
  251. obj.list[obj.value] = detail;
  252. this.setData({
  253. whereType: obj
  254. })
  255. },
  256. /* 确定时间范围 */
  257. determineScope() {
  258. const {
  259. list
  260. } = this.data.whereType;
  261. this.setData({
  262. "where": list,
  263. showWhere: list.start + '~' + list.end,
  264. timeRangeShow: false
  265. });
  266. this.getFollowList();
  267. },
  268. callOut(e) {
  269. wx.makePhoneCall({
  270. phoneNumber: e.currentTarget.dataset.phonenumber
  271. })
  272. },
  273. onUnload() {
  274. if (this.data.isEdit) {
  275. let pages = getCurrentPages();
  276. if (pages[pages.length - 2].route == 'pages/threadedTree/index') pages[pages.length - 2].getList(true);
  277. }
  278. },
  279. onShareAppMessage(res) {}
  280. })