detail.js 13 KB

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