detail.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. isLeader: false, //是否为负责人
  5. tabsActive: 0, //tabs 选中项
  6. sat_orderclueid: "",
  7. detail: '',
  8. tabsList: [{
  9. label: "详细信息",
  10. icon: "icon-tabxiangxixinxi1"
  11. }, {
  12. label: "跟进记录",
  13. icon: "icon-tabgenjinjilu"
  14. }, {
  15. label: "操作",
  16. icon: "icon-tabcaozuojilu1"
  17. }, {
  18. label: "跟进动态",
  19. icon: "icon-tabgenjinjilu"
  20. }, {
  21. label: "任务",
  22. icon: "icon-tabrenwu"
  23. }],
  24. tabbarList: [],
  25. },
  26. onLoad(options) {
  27. this.setData({
  28. sat_orderclueid: options.sat_orderclueid,
  29. isAdmin: wx.getStorageSync('auth').wCustomer.options.some(v => v == "admin"), //是否具有管理权限
  30. });
  31. this.getDetail();
  32. },
  33. getDetail() {
  34. _Http.basic({
  35. "classname": "saletool.orderclue.web.orderclue",
  36. "method": "selectDetail",
  37. "version": 1,
  38. "content": {
  39. "nocache": true,
  40. "sat_orderclueid": this.data.sat_orderclueid
  41. },
  42. }).then(res => {
  43. console.log("线索详情", res)
  44. if (res.msg != '成功') return wx.showToast({
  45. title: res.msg,
  46. icon: "none"
  47. });
  48. let isLeader = res.data.leader.some(some => some.userid == wx.getStorageSync('userMsg').userid),
  49. tabbarList = [{
  50. icon: "icon-genjin",
  51. label: "跟进"
  52. }];
  53. if (this.data.isAdmin || isLeader) tabbarList = tabbarList.concat([{
  54. icon: "icon-bianji",
  55. label: "编辑"
  56. }, {
  57. icon: "icon-dibu-zhuanhuan",
  58. label: "转化项目"
  59. }, {
  60. icon: "icon-dibu-zhuanhuan",
  61. label: "转化客户"
  62. }, {
  63. icon: "icon-zhuanyi",
  64. label: "更换负责人"
  65. }, {
  66. icon: "icon-dibu-jieshu",
  67. label: "作废"
  68. }]);
  69. if (isLeader) tabbarList = tabbarList.concat([{
  70. icon: "icon-dibu-tuihui",
  71. label: "退回"
  72. }, {
  73. icon: "icon-dibu-wuxiao",
  74. label: "无效"
  75. }])
  76. this.setData({
  77. isLeader,
  78. tabbarList,
  79. detail: res.data,
  80. briefs: [{
  81. label: "联系人",
  82. value: res.data.name
  83. }, {
  84. label: "手机号",
  85. value: res.data.phonenumber
  86. }, {
  87. label: "来源",
  88. value: res.data.cluesource
  89. }, {
  90. label: "市场活动",
  91. value: res.data.campaign_name
  92. }, {
  93. label: '负责人',
  94. value: res.data.leader && res.data.leader.length > 0 ? res.data.leader[0].name : ''
  95. },
  96. {
  97. label: '分配状态',
  98. value: res.data.allocationstatus
  99. },
  100. {
  101. label: '跟进状态',
  102. value: res.data.status
  103. },
  104. {
  105. label: '跟进次数',
  106. value: res.data.followcount || '0'
  107. },
  108. ],
  109. list1: [{
  110. label: "联系人",
  111. value: res.data.name
  112. }, {
  113. label: "手机号",
  114. value: res.data.phonenumber
  115. }, {
  116. label: "来源",
  117. value: res.data.cluesource
  118. }, {
  119. label: '负责人',
  120. value: res.data.leader && res.data.leader.length > 0 ? res.data.leader[0].name : ''
  121. },
  122. {
  123. label: '分配状态',
  124. value: res.data.allocationstatus
  125. },
  126. {
  127. label: '跟进状态',
  128. value: res.data.status
  129. },
  130. {
  131. label: '跟进次数',
  132. value: res.data.followcount || '0'
  133. },
  134. ],
  135. list2: [{
  136. label: "创建人",
  137. value: res.data.createBy
  138. }, {
  139. label: "创建时间",
  140. value: res.data.createDate
  141. }, {
  142. label: "分配人",
  143. value: res.data.assignedBy
  144. }, {
  145. label: "最近跟进人",
  146. value: res.data.followBy
  147. }, {
  148. label: "最近编辑人",
  149. value: res.data.editBy
  150. }, {
  151. label: "转手次数",
  152. value: res.data.changecount
  153. }, {
  154. label: "创建时间",
  155. value: res.data.createDate
  156. }, {
  157. label: "分配时间",
  158. value: res.data.assignedDate
  159. }, {
  160. label: "最近跟进时间",
  161. value: res.data.followDate
  162. }, {
  163. label: "最近编辑时间",
  164. value: res.data.editDate
  165. }],
  166. tabsList: this.data.tabsList,
  167. });
  168. /* 更新列表中状态 */
  169. let page = getCurrentPages().find(v => v.__route__ == 'packageA/saleClue/index');
  170. if (page) {
  171. let index = page.data.list.findIndex(v => v.sat_orderclueid == res.data.sat_orderclueid);
  172. console.log("列表中位置", index)
  173. if (index != -1) page.setData({
  174. [`list[${index}].status`]: res.data.status
  175. })
  176. }
  177. if (res.data.status == '已转化') {
  178. tabbarList = tabbarList.filter(item => {
  179. return item.label == '编辑' || item.label == '跟进' || item.label == '转化客户' || item.label == '转化项目'
  180. })
  181. if (res.data.isproject == 1) {
  182. let i = tabbarList.findIndex(item => item.label == '转化项目')
  183. tabbarList.splice(i,1)
  184. console.log('触发项目');
  185. }
  186. if (res.data.iscustomer == 1) {
  187. let i = tabbarList.findIndex(item => item.label == '转化客户')
  188. tabbarList.splice(i,1)
  189. console.log('触发客户');
  190. }
  191. console.log(tabbarList);
  192. this.setData({
  193. tabbarList
  194. })
  195. }
  196. if (res.data.status != '待跟进' && res.data.status != '跟进中' && res.data.status != '已转化') this.setData({
  197. tabbarList: []
  198. })
  199. this.getTags();
  200. this.getGroup();
  201. this.partialRenewal();
  202. })
  203. },
  204. //tabs 切换
  205. tabsChange({
  206. detail
  207. }) {
  208. this.setData({
  209. tabsActive: detail
  210. });
  211. this.partialRenewal();
  212. },
  213. //更新标签
  214. getTags() {
  215. this.selectComponent("#Tags").getTags();
  216. },
  217. //更新团队成员
  218. getGroup() {
  219. this.selectComponent("#Group").getList();
  220. },
  221. //局部数据更新 tabs
  222. partialRenewal(init = false) {
  223. let id = this.data.detail.sat_orderclueid;
  224. let model = '';
  225. let name = this.data.tabsList[this.data.tabsActive].label;
  226. switch (name) {
  227. case "任务":
  228. model = "#Work"
  229. break;
  230. case "跟进记录":
  231. model = "#follow"
  232. break;
  233. case "操作":
  234. model = "#Record"
  235. break;
  236. case "跟进动态":
  237. model = "#Trace"
  238. break;
  239. };
  240. if (model) {
  241. // 确定好模块ID total = null 是第一次加载 加载数据
  242. // init是新增或修改需要清数据
  243. let Component = this.selectComponent(model);
  244. const {
  245. total,
  246. pageNumber,
  247. pageTotal
  248. } = Component.data.content;
  249. if (total == null || init) {
  250. Component.getList(id, init);
  251. } else if (pageNumber <= pageTotal) {
  252. Component.getList(id, false);
  253. } else {
  254. //用来判断 在搜索页面修改,与tabs选项不一致 但是切换到该选项 重置数据
  255. }
  256. }
  257. },
  258. onReachBottom() {
  259. this.partialRenewal();
  260. },
  261. //详情按钮回调
  262. tabbarOnClick({
  263. detail
  264. }) {
  265. let data = this.data.detail,
  266. that = this;
  267. switch (detail.label) {
  268. case "编辑":
  269. wx.navigateTo({
  270. url: `/packageA/saleClue/addClue?rowData=${JSON.stringify(this.data.detail)}`,
  271. })
  272. break;
  273. case "作废":
  274. wx.showModal({
  275. title: '提示',
  276. content: `是否确认作废该线索?`,
  277. complete: ({
  278. confirm
  279. }) => {
  280. if (confirm) _Http.basic({
  281. "id": 20221123193702,
  282. "content": {
  283. "sat_orderclueids": [that.data.detail.sat_orderclueid]
  284. }
  285. }).then(res => {
  286. wx.showToast({
  287. title: res.msg == '成功' ? `操作成功` : res.msg,
  288. icon: "none"
  289. });
  290. setTimeout(() => {
  291. let pages = getCurrentPages(),
  292. page = pages[pages.length - 2];
  293. if (page.getList) page.setData({
  294. list: page.data.list.filter(v => v.sat_orderclueid != that.data.detail.sat_orderclueid)
  295. })
  296. }, 300)
  297. })
  298. }
  299. })
  300. break;
  301. case "无效":
  302. wx.showModal({
  303. title: '提示',
  304. content: `是否设置该线索为"无效"状态,确定后无法撤销!`,
  305. complete: ({
  306. confirm
  307. }) => {
  308. if (confirm) _Http.basic({
  309. id: "20221208100602",
  310. "content": {
  311. "sat_orderclueid": that.data.detail.sat_orderclueid,
  312. sat_ordercluefollowuplogid: 0,
  313. "content": "",
  314. "followupmode": "",
  315. "logtype": "无效",
  316. "competitor": ""
  317. }
  318. }).then(res => {
  319. if (res.msg == '成功') {
  320. that.getDetail();
  321. that.selectComponent("#follow").getList(that.data.detail.sat_orderclueid, true)
  322. }
  323. setTimeout(() => {
  324. wx.showToast({
  325. title: res.msg == '成功' ? `操作成功` : res.msg,
  326. icon: "none"
  327. });
  328. }, 1000)
  329. })
  330. }
  331. })
  332. break;
  333. case "退回":
  334. wx.showModal({
  335. title: '提示',
  336. content: `是否退回该线索,确定后无法撤销!`,
  337. complete: ({
  338. confirm
  339. }) => {
  340. if (confirm) _Http.basic({
  341. "id": 20221207160802,
  342. "content": {
  343. sat_orderclueid: this.data.detail.sat_orderclueid
  344. }
  345. }).then(res => {
  346. if (res.msg == '成功') {
  347. that.getDetail();
  348. }
  349. setTimeout(() => {
  350. wx.showToast({
  351. title: res.msg == '成功' ? `操作成功` : res.msg,
  352. icon: "none"
  353. });
  354. }, 1000)
  355. })
  356. }
  357. })
  358. break;
  359. case "转化项目":
  360. wx.navigateTo({
  361. url: `/packageA/saleClue/change?rowData=${JSON.stringify(this.data.detail)}`,
  362. })
  363. break;
  364. case "转化客户":
  365. wx.navigateTo({
  366. url: `/packageA/saleClue/translate?data=${JSON.stringify(this.data.detail)}`,
  367. })
  368. break;
  369. case "跟进":
  370. wx.navigateTo({
  371. url: `/packageA/saleClue/addFollow?sat_orderclueid=` + this.data.detail.sat_orderclueid
  372. })
  373. break;
  374. case "更换负责人":
  375. wx.navigateTo({
  376. url: `/pages/group/select?data=${JSON.stringify({
  377. ownertable:"sat_orderclue",
  378. ownerid:data.sat_orderclueid,
  379. })}&radio=true&principal=true`,
  380. })
  381. break;
  382. }
  383. },
  384. /* 更换负责人 */
  385. handelSubmit(arr) {
  386. const that = this;
  387. wx.showModal({
  388. title: '提示',
  389. content: '是否确认更换负责人',
  390. complete: ({
  391. confirm
  392. }) => {
  393. if (confirm) _Http.basic({
  394. "id": 20220930103701,
  395. "content": {
  396. ownertable: "sat_orderclue",
  397. ownerid: that.data.detail.sat_orderclueid,
  398. userid: arr[0]
  399. }
  400. }).then(res => {
  401. console.log("更换负责人", res)
  402. if (res.msg != '成功') return wx.showToast({
  403. title: res.data,
  404. icon: "none"
  405. });
  406. wx.showToast({
  407. title: '更换成功!',
  408. icon: "none"
  409. });
  410. setTimeout(() => {
  411. that.getDetail();
  412. wx.navigateBack();
  413. /* getCurrentPages().forEach(v => {
  414. if (['packageA/project/index'].includes(v.__route__)) v.getList(true)
  415. }) */
  416. }, 300)
  417. })
  418. }
  419. })
  420. },
  421. onShareAppMessage() {}
  422. })