detail.js 22 KB

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