index.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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. let auth = [];
  94. options.auth ? auth = options.auth.split(",") : getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['营销工具'], ['销售线索'])[0].apps[0].meta.auth.forEach(v => auth.push(v.optionname));
  95. this.setData({
  96. sat_orderclueid: options.id,
  97. tagColor: options.color,
  98. auth
  99. })
  100. this.selectDetail();
  101. this.getFollowList();
  102. this.query_teamList();
  103. },
  104. /* 团队成员 */
  105. query_teamList(i = 0) {
  106. if (i == 5) return;
  107. _Http.basic({
  108. "classname": "sale.team.team",
  109. "method": "query_teamList",
  110. "content": {
  111. "pageNumber": 1,
  112. "pageSize": 99999,
  113. "where": {
  114. "condition": ""
  115. }
  116. }
  117. }).then(res => {
  118. if (res.msg != '成功') return this.selectDetail(i + 1);
  119. this.setData({
  120. teamList: res.data
  121. })
  122. })
  123. },
  124. /* 查询详情 */
  125. selectDetail(i = 0) {
  126. if (i == 5) return wx.showToast({
  127. title: '详情信息查询失败!',
  128. icon: "none"
  129. })
  130. _Http.basic({
  131. "classname": "saletool.orderclue.web.orderclue",
  132. "method": "selectDetail",
  133. "content": {
  134. "sat_orderclueid": this.data.sat_orderclueid
  135. }
  136. }).then(res => {
  137. if (res.msg != '成功') return this.selectDetail(i + 1);
  138. let data = res.data;
  139. for (let i in data) {
  140. if (data[i] === '') data[i] = '-';
  141. }
  142. this.setData({
  143. detailsData: data
  144. })
  145. })
  146. },
  147. /* 跟进列表 */
  148. getFollowList(i = 0) {
  149. if (i == 5) return wx.showToast({
  150. title: '跟进记录查询失败!',
  151. icon: "none"
  152. })
  153. _Http.basic({
  154. "classname": "saletool.orderclue.web.orderclue",
  155. "method": "getFollowList",
  156. "content": {
  157. "sat_orderclueid": this.data.sat_orderclueid,
  158. "isdesc": this.data.isdesc,
  159. where: this.data.where
  160. }
  161. }).then(res => {
  162. console.log("跟进", res)
  163. if (res.msg != '成功') return this.getFollowList(i + 1);
  164. this.setData({
  165. followList: res.data
  166. })
  167. })
  168. },
  169. /* 打开弹出 */
  170. openPoput(e) {
  171. const {
  172. name
  173. } = e.currentTarget.dataset;
  174. if (name == '跟进计划') {
  175. this.setData({
  176. sheetShow: true
  177. })
  178. } else {
  179. if (name == '线索编辑') this.selectComponent("#edit").initData()
  180. this.setData({
  181. sheetTitle: name
  182. })
  183. }
  184. },
  185. /* 结束编辑 */
  186. endEdit() {
  187. this.setData({
  188. sheetTitle: "",
  189. isEdit: true
  190. })
  191. this.selectDetail();
  192. },
  193. /* 结束跟进 */
  194. endFollow() {
  195. this.endEdit();
  196. this.getFollowList();
  197. },
  198. /* 修改排序方式 */
  199. changeIsdesc() {
  200. this.setData({
  201. isdesc: this.data.isdesc == 1 ? 0 : 1
  202. });
  203. this.getFollowList();
  204. },
  205. /* 打开选择时间 */
  206. openSelectDate() {
  207. this.setData({
  208. timeRangeShow: true
  209. })
  210. },
  211. /* 查看所有日期 */
  212. toSeeAll() {
  213. this.setData({
  214. showWhere: "所有日期"
  215. })
  216. this.timeRangeClose();
  217. this.getFollowList();
  218. },
  219. /* 关闭时间范围选择 */
  220. timeRangeClose() {
  221. this.setData({
  222. timeRangeShow: false,
  223. "where": {
  224. "start": "",
  225. "end": ""
  226. }
  227. })
  228. },
  229. /* 选择日期类型 */
  230. selectDateType(e) {
  231. const {
  232. name
  233. } = e.target.dataset;
  234. this.setData({
  235. "whereType.value": name
  236. })
  237. },
  238. /* 得到选择时间 */
  239. getDate({
  240. detail
  241. }) {
  242. let obj = this.data.whereType;
  243. obj.list[obj.value] = detail;
  244. this.setData({
  245. whereType: obj
  246. })
  247. },
  248. /* 确定时间范围 */
  249. determineScope() {
  250. const {
  251. list
  252. } = this.data.whereType;
  253. this.setData({
  254. "where": list,
  255. showWhere: list.start + '~' + list.end,
  256. timeRangeShow: false
  257. });
  258. this.getFollowList();
  259. },
  260. callOut(e) {
  261. wx.makePhoneCall({
  262. phoneNumber: e.currentTarget.dataset.phonenumber
  263. })
  264. },
  265. onUnload() {
  266. if (this.data.isEdit) {
  267. let pages = getCurrentPages();
  268. if (pages[pages.length - 2].route == 'pages/threadedTree/index') pages[pages.length - 2].getList(true);
  269. }
  270. },
  271. onShareAppMessage(res) {}
  272. })