index.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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 (name == '线索编辑') this.selectComponent("#edit").initData()
  178. this.setData({
  179. sheetTitle: name
  180. })
  181. }
  182. },
  183. /* 结束编辑 */
  184. endEdit() {
  185. this.setData({
  186. sheetTitle: "",
  187. isEdit: true
  188. })
  189. this.selectDetail();
  190. },
  191. /* 结束跟进 */
  192. endFollow() {
  193. this.endEdit();
  194. this.getFollowList();
  195. },
  196. /* 修改排序方式 */
  197. changeIsdesc() {
  198. this.setData({
  199. isdesc: this.data.isdesc == 1 ? 0 : 1
  200. });
  201. this.getFollowList();
  202. },
  203. /* 打开选择时间 */
  204. openSelectDate() {
  205. this.setData({
  206. timeRangeShow: true
  207. })
  208. },
  209. /* 查看所有日期 */
  210. toSeeAll() {
  211. this.setData({
  212. showWhere: "所有日期"
  213. })
  214. this.timeRangeClose();
  215. this.getFollowList();
  216. },
  217. /* 关闭时间范围选择 */
  218. timeRangeClose() {
  219. this.setData({
  220. timeRangeShow: false,
  221. "where": {
  222. "start": "",
  223. "end": ""
  224. }
  225. })
  226. },
  227. /* 选择日期类型 */
  228. selectDateType(e) {
  229. const {
  230. name
  231. } = e.target.dataset;
  232. this.setData({
  233. "whereType.value": name
  234. })
  235. },
  236. /* 得到选择时间 */
  237. getDate({
  238. detail
  239. }) {
  240. let obj = this.data.whereType;
  241. obj.list[obj.value] = detail;
  242. this.setData({
  243. whereType: obj
  244. })
  245. },
  246. /* 确定时间范围 */
  247. determineScope() {
  248. const {
  249. list
  250. } = this.data.whereType;
  251. this.setData({
  252. "where": list,
  253. showWhere: list.start + '~' + list.end,
  254. timeRangeShow: false
  255. });
  256. this.getFollowList();
  257. },
  258. callOut(e) {
  259. wx.makePhoneCall({
  260. phoneNumber: e.currentTarget.dataset.phonenumber
  261. })
  262. },
  263. onUnload() {
  264. if (this.data.isEdit) {
  265. let pages = getCurrentPages();
  266. if (pages[pages.length - 2].route == 'pages/threadedTree/index') pages[pages.length - 2].getList(true);
  267. }
  268. },
  269. onShareAppMessage(res) {}
  270. })