detail.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. isLeader: false, //是否为负责人
  5. tabsActive: 0, //tabs 选中项
  6. sat_orderclueid: "",
  7. detail: '',
  8. siteShow: false,
  9. sColors: getApp().globalData.sColors,
  10. },
  11. onLoad(options) {
  12. getApp().globalData.Language.getLanguagePackage(this, '线索详情');
  13. const appAuth = wx.getStorageSync('auth').worderclue_public;
  14. let tabsList = [{
  15. label: "详细信息",
  16. icon: "icon-tabxiangxixinxi1"
  17. }, {
  18. label: "跟进记录",
  19. icon: "icon-tabgenjinjilu"
  20. }, {
  21. label: "线索来源",
  22. icon: "icon-tabxiansuo",
  23. model: "#Clue"
  24. }, {
  25. label: "联系人",
  26. icon: "icon-tablianxiren",
  27. model: "#Contacts"
  28. }, {
  29. label: "操作",
  30. icon: "icon-tabcaozuojilu1"
  31. }]
  32. if (appAuth.isdatafollowup) tabsList.push({
  33. label: "跟进动态",
  34. icon: "icon-tabgenjinjilu"
  35. })
  36. if (appAuth.istask) tabsList.push({
  37. label: "任务",
  38. icon: "icon-tabrenwu",
  39. model: "#Work"
  40. })
  41. tabsList.push({
  42. label: "附件",
  43. icon: "icon-tabfujian1",
  44. model: "#Files"
  45. })
  46. this.setData({
  47. sat_orderclueid: options.sat_orderclueid || options.id,
  48. isAdmin: appAuth.options.some(v => v == "admin"), //是否具有管理权限
  49. tabsList,
  50. appAuth
  51. });
  52. this.getDetail();
  53. },
  54. getDetail() {
  55. _Http.basic({
  56. "classname": "webmanage.saletool.orderclue.publicclue.PublicClue",
  57. "method": "selectDetail",
  58. "version": 1,
  59. "content": {
  60. "nocache": true,
  61. "sat_orderclueid": this.data.sat_orderclueid
  62. },
  63. }).then(res => {
  64. console.log("线索详情", res)
  65. if (res.code != '1') return wx.showToast({
  66. title: res.msg,
  67. icon: "none"
  68. });
  69. let list1 = [{
  70. label: "医院名称",
  71. value: res.data.enterprisename_customer
  72. }, {
  73. label: "联系人",
  74. value: res.data.name
  75. }, {
  76. label: "联系角色",
  77. value: res.data.contactsrole
  78. }, {
  79. label: "手机号/座机号码",
  80. value: res.data.phonenumber
  81. }, {
  82. label: "微信",
  83. value: res.data.wechatnum
  84. }, {
  85. label: "省市县",
  86. value: res.data.province ? res.data.province + res.data.city + res.data.county : ''
  87. }, {
  88. label: "地址",
  89. value: res.data.address
  90. }, {
  91. label: "项目名称",
  92. value: res.data.projectname
  93. }, {
  94. label: "项目规模",
  95. value: res.data.scale ? res.data.scale + res.data.unitname : ""
  96. }, {
  97. label: "总投资额(万元)",
  98. value: res.data.totalinvestment
  99. }, {
  100. label: "造价(万元)",
  101. value: res.data.costofconstruction
  102. }, {
  103. label: "预计开工时间",
  104. value: res.data.begdate_due
  105. }, {
  106. label: "预计完工时间",
  107. value: res.data.enddate_due
  108. }, {
  109. label: "市场活动",
  110. value: res.data.campaign_name
  111. }, {
  112. label: "领域",
  113. value: res.data.tradefield
  114. }, {
  115. label: "设计院",
  116. value: res.data.institute
  117. }, {
  118. label: "设计师",
  119. value: res.data.designer
  120. }, {
  121. label: "关联项目",
  122. value: res.data.projectname1
  123. }, {
  124. label: "来源",
  125. value: res.data.cluesource
  126. }, {
  127. label: "线索概况",
  128. value: res.data.notes
  129. }, {
  130. label: '所属业务员',
  131. value: res.data.salename
  132. }, {
  133. label: '负责人',
  134. value: res.data.leader && res.data.leader.length > 0 ? res.data.leader[0].name : ''
  135. }, {
  136. label: '上图员',
  137. value: res.data.uppictured
  138. }, {
  139. label: '分配状态',
  140. value: res.data.allocationstatus,
  141. style: `color:${this.data.sColors[res.data.allocationstatus]}`
  142. }, {
  143. label: '跟进状态',
  144. value: getApp().globalData.Language.getMapText(res.data.status),
  145. style: `color:${this.data.sColors[res.data.status]}`
  146. }];
  147. if (wx.getStorageSync('userMsg').siteid == 'HY') list1 = list1.filter(v => !["项目预算(万元)", "总投资额(万元)", "造价(万元)"].includes(v.label))
  148. this.setData({
  149. isLeader: res.data.createuserid == wx.getStorageSync('userMsg').userid,
  150. detail: res.data,
  151. briefs: [{
  152. label: "联系人",
  153. value: res.data.name
  154. }, {
  155. label: "手机号/座机号码",
  156. value: res.data.phonenumber
  157. }, {
  158. label: "市场活动",
  159. value: res.data.campaign_name
  160. }, {
  161. label: "领域",
  162. value: res.data.tradefield
  163. }, {
  164. label: '负责人',
  165. value: res.data.leader && res.data.leader.length > 0 ? res.data.leader[0].name : ''
  166. },
  167. {
  168. label: '分配状态',
  169. value: res.data.allocationstatus,
  170. style: `color:${this.data.sColors[res.data.allocationstatus]}`
  171. },
  172. {
  173. label: '跟进状态',
  174. value: getApp().globalData.Language.getMapText(res.data.status),
  175. style: `color:${this.data.sColors[res.data.status]}`
  176. },
  177. {
  178. label: '跟进次数',
  179. value: res.data.followcount || '0'
  180. },
  181. ],
  182. list1,
  183. list2: [{
  184. label: "创建人",
  185. value: res.data.createBy
  186. }, {
  187. label: "创建时间",
  188. value: res.data.createDate
  189. }, {
  190. label: "分配人",
  191. value: res.data.assignedBy
  192. }, {
  193. label: "分配时间",
  194. value: res.data.assignedDate
  195. }, {
  196. label: "最近跟进人",
  197. value: res.data.followBy
  198. }, {
  199. label: "最近跟进时间",
  200. value: res.data.followDate
  201. }, {
  202. label: "最近编辑人",
  203. value: res.data.editBy
  204. }, {
  205. label: "最近编辑时间",
  206. value: res.data.editDate
  207. }, {
  208. label: "无效原因",
  209. value: res.data.invalidreason
  210. }, {
  211. label: "作废原因",
  212. value: res.data.deletereason
  213. }, {
  214. label: "跟进次数",
  215. value: res.data.followcount
  216. }]
  217. });
  218. /* 更新列表中状态 */
  219. let page = getCurrentPages().find(v => v.__route__ == 'packageA/publicClue/index');
  220. if (page) {
  221. let index = page.data.list.findIndex(v => v.sat_orderclueid == res.data.sat_orderclueid);
  222. if (index != -1) page.setData({
  223. [`list[${index}].status`]: res.data.status
  224. })
  225. }
  226. this.setTabbarList(res.data.status)
  227. if (this.data.appAuth.isdatatag) this.getTags();
  228. if (this.data.appAuth.isdatateam) this.getGroup();
  229. this.partialRenewal();
  230. })
  231. },
  232. setTabbarList(status) {
  233. let tabbarList = [];
  234. if (this.data.isAdmin) {
  235. if (this.data.detail.isprivate == 0 && this.data.detail.allocationstatus == '待分配') tabbarList.push({
  236. icon: "color-genghuanfuzeren",
  237. label: "分配"
  238. })
  239. tabbarList.push({
  240. icon: "icon-dibu-jieshu",
  241. label: "删除"
  242. })
  243. tabbarList.unshift({
  244. icon: "color-bianji",
  245. label: "编辑"
  246. })
  247. }
  248. if (status == '已过期' && wx.getStorageSync('auth').worderclue_public.options.some(v => v == "recover")) tabbarList.unshift({
  249. icon: "icon-dibu-chehui",
  250. label: "恢复"
  251. })
  252. if (wx.getStorageSync('auth').worderclue_public.options.some(v => v == "shiftSite")) {
  253. tabbarList.unshift({
  254. icon: "icon-CRM",
  255. label: "转站点"
  256. })
  257. this.setData({
  258. siteShow: true
  259. })
  260. }
  261. this.setData({
  262. tabbarList
  263. })
  264. },
  265. //tabs 切换
  266. tabsChange({
  267. detail
  268. }) {
  269. this.setData({
  270. tabsActive: detail
  271. });
  272. this.partialRenewal();
  273. }, //更新标签
  274. getTags() {
  275. if (this.data.appAuth.isdatatag) this.selectComponent("#Tags").getTags();
  276. }, //更新团队成员
  277. getGroup() {
  278. if (this.data.appAuth.isdatateam) this.selectComponent("#Group").getList();
  279. },
  280. //局部数据更新 tabs
  281. partialRenewal(init = false) {
  282. let id = this.data.detail.sat_orderclueid,
  283. item = this.data.tabsList[this.data.tabsActive]
  284. let model = item.model;
  285. let name = item.label;
  286. if (!model) switch (name) {
  287. case "任务":
  288. model = "#Work"
  289. break;
  290. case "跟进记录":
  291. model = "#follow"
  292. break;
  293. case "线索来源":
  294. model = "#Clue"
  295. break;
  296. case "操作":
  297. model = "#Record"
  298. break;
  299. case "跟进动态":
  300. model = "#Trace"
  301. break;
  302. case "附件":
  303. model = "#Files"
  304. break;
  305. };
  306. if (model) {
  307. // 确定好模块ID total = null 是第一次加载 加载数据
  308. // init是新增或修改需要清数据
  309. let Component = this.selectComponent(model);
  310. console.log("Component", Component)
  311. const {
  312. total,
  313. pageNumber,
  314. pageTotal
  315. } = Component.data.content;
  316. if (total == null || init) {
  317. Component.getList(id, init);
  318. } else if (pageNumber <= pageTotal) {
  319. Component.getList(id, false);
  320. } else {
  321. //用来判断 在搜索页面修改,与tabs选项不一致 但是切换到该选项 重置数据
  322. }
  323. }
  324. },
  325. onReachBottom() {
  326. this.partialRenewal();
  327. },
  328. //详情按钮回调
  329. tabbarOnClick({
  330. detail
  331. }) {
  332. let data = this.data.detail,
  333. that = this;
  334. switch (detail.label) {
  335. case "编辑":
  336. wx.navigateTo({
  337. url: `/packageA/publicClue/addClue?rowData=${JSON.stringify(this.data.detail)}`,
  338. })
  339. break;
  340. case "分配":
  341. wx.navigateTo({
  342. url: `/packageA/publicClue/distribution?data=${JSON.stringify(this.data.detail)}`,
  343. })
  344. break;
  345. case "恢复":
  346. wx.showModal({
  347. title: getApp().globalData.Language.getMapText('提示'),
  348. content: getApp().globalData.Language.getMapText('是否确定恢复该线索'),
  349. cancelText: getApp().globalData.Language.getMapText('取消'),
  350. confirmText: getApp().globalData.Language.getMapText('确定'),
  351. complete: (res) => {
  352. if (res.confirm) _Http.basic({
  353. "id": "20230907142004",
  354. "content": {
  355. "sat_orderclueid": data.sat_orderclueid
  356. }
  357. }).then(res => {
  358. console.log("恢复线索", res)
  359. wx.showToast({
  360. title: res.code == '1' ? "恢复成功" : res.msg,
  361. icon: "none"
  362. });
  363. that.getDetail();
  364. })
  365. }
  366. })
  367. break;
  368. case "转站点":
  369. that.selectComponent("#ShiftSite").showSite()
  370. break;
  371. case "删除":
  372. wx.showModal({
  373. title: getApp().globalData.Language.getMapText('提示'),
  374. content: getApp().globalData.Language.getMapText('是否确认删除该线索?'),
  375. cancelText: getApp().globalData.Language.getMapText('取消'),
  376. confirmText: getApp().globalData.Language.getMapText('确定'),
  377. complete: ({
  378. confirm
  379. }) => {
  380. if (confirm) _Http.basic({
  381. "id": 20221101100502,
  382. "content": {
  383. "sat_orderclueids": [this.data.detail.sat_orderclueid]
  384. }
  385. }).then(res => {
  386. wx.showToast({
  387. title: res.code == '1' ? getApp().globalData.Language.getMapText('操作成功') : res.msg,
  388. icon: "none"
  389. });
  390. setTimeout(() => {
  391. wx.navigateBack()
  392. getCurrentPages().forEach(v => {
  393. if (v.__route__ == "packageA/publicClue/index") {
  394. v.getList(true)
  395. }
  396. })
  397. }, 300)
  398. })
  399. }
  400. })
  401. break;
  402. case "撤回":
  403. wx.showModal({
  404. title: getApp().globalData.Language.getMapText('提示'),
  405. content: getApp().globalData.Language.getMapText('是否确认撤回该线索?'),
  406. cancelText: getApp().globalData.Language.getMapText('取消'),
  407. confirmText: getApp().globalData.Language.getMapText('确定'),
  408. complete: ({
  409. confirm
  410. }) => {
  411. if (confirm) _Http.basic({
  412. classname: "webmanage.saletool.orderclue.publicclue.PublicClue",
  413. method: "revoke",
  414. "content": {
  415. "sat_orderclueid": this.data.detail.sat_orderclueid
  416. }
  417. }).then(res => {
  418. setTimeout(() => {
  419. wx.showToast({
  420. title: res.code == '1' ? getApp().globalData.Language.getMapText('操作成功') : res.msg,
  421. icon: "none"
  422. });
  423. }, 1000)
  424. if (res.code == '1') this.getDetail()
  425. })
  426. }
  427. })
  428. break;
  429. }
  430. },
  431. onUnload() {
  432. const page = getCurrentPages().find(v => v.__route__ == 'packageA/publicClue/index');
  433. if (!page) return;
  434. let content = JSON.parse(JSON.stringify(page.data.content));
  435. content.pageSize = (content.pageNumber - 1) * content.pageSize;
  436. content.pageNumber = 1;
  437. _Http.basic({
  438. id: '20221101094402',
  439. content
  440. }).then(res => {
  441. console.log("更新公海线索列表", res);
  442. if (res.code == '1') {
  443. page.setData({
  444. list: res.data,
  445. "content.total": res.total
  446. })
  447. page.getTags()
  448. }
  449. })
  450. }
  451. })