detail.js 18 KB

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