detail.js 17 KB

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