detail.js 17 KB

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