detail.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. loading: true,
  5. isLeader: false, //是否为负责人
  6. tabsActive: 1, //tabs 选中项
  7. sa_customersid: 0,
  8. },
  9. onLoad(options) {
  10. const appAuth = wx.getStorageSync('auth').wCustomer;
  11. let tabsList = [{
  12. label: "跟进动态",
  13. icon: "icon-tabgenjinjilu",
  14. model: "#Trace"
  15. }, {
  16. label: "详细信息",
  17. icon: "icon-tabxiangxixinxi1"
  18. }, {
  19. label: "关联线索",
  20. icon: "icon-tabxiansuo",
  21. model: "#Clue"
  22. }, {
  23. label: "项目商机",
  24. icon: "icon-tabxiangmu",
  25. model: "#Project"
  26. }, {
  27. label: "客户地址",
  28. icon: "icon-tabdizhi",
  29. model: "#Address"
  30. }, {
  31. label: "联系人",
  32. icon: "icon-tablianxiren",
  33. model: "#Contacts"
  34. }, {
  35. label: "报价单",
  36. icon: "icon-tabbaojiadan",
  37. model: "#Offers"
  38. }, {
  39. label: "合同",
  40. icon: "icon-tabhetong",
  41. model: "#Contract"
  42. }, {
  43. label: "账户余额",
  44. icon: "icon-tabkaipiaoxinxi",
  45. model: "#Account"
  46. }, {
  47. label: "银行卡信息",
  48. icon: "icon-tabchanpin",
  49. model: "#Bankcard"
  50. }, {
  51. label: "开票信息",
  52. icon: "icon-tabbaojiadan",
  53. model: "#Financing"
  54. }];
  55. if (appAuth.istask) tabsList.push({
  56. label: "任务",
  57. icon: "icon-tabrenwu",
  58. model: "#Work"
  59. })
  60. tabsList = tabsList.concat([{
  61. label: "操作",
  62. icon: "icon-tabcaozuojilu1",
  63. model: "#Record"
  64. }, {
  65. label: "附件",
  66. icon: "icon-tabfujian1",
  67. model: "#Files"
  68. }])
  69. this.setData({
  70. sa_customersid: options.id,
  71. isAdmin: appAuth.options.some(v => v == "admin"), //是否具有管理权限
  72. options: appAuth.options, //权限列表
  73. tabsList
  74. })
  75. this.getDetail();
  76. },
  77. //详情按钮回调
  78. tabbarOnClick({
  79. detail
  80. }) {
  81. let data = this.data.detail,
  82. that = this;
  83. switch (detail.label) {
  84. case "退回":
  85. wx.showModal({
  86. title: '提示',
  87. content: `是否确定将${data.enterprisename}退回到公海客户`,
  88. complete: (res) => {
  89. console.log(data)
  90. if (res.confirm) _Http.basic({
  91. "id": 20221014102602,
  92. "content": {
  93. "sa_customerpoolid": data.sa_customerpoolid_source,
  94. "sa_customersid": data.sa_customersid
  95. }
  96. }).then(res => {
  97. console.log("公海线索退回", res)
  98. wx.showToast({
  99. title: res.msg == '成功' ? '退回成功' : res.msg,
  100. icon: "none"
  101. });
  102. if (res.msg == '成功') setTimeout(() => {
  103. let page = getCurrentPages().find(v => v.__route__ == 'packageA/setclient/index');
  104. if (page) page.setData({
  105. list: page.data.list.filter(v => v.sa_customersid != data.sa_customersid)
  106. });
  107. wx.redirectTo({
  108. url: '/packageA/publicCustomer/detail?id' + data.sa_customersid,
  109. })
  110. }, 300)
  111. })
  112. }
  113. });
  114. break;
  115. case "回收":
  116. wx.navigateTo({
  117. url: `/packageA/publicCustomer/pond/index?params=${JSON.stringify({
  118. "id": 20221206195102,
  119.                 "content": {
  120. nocache:true,
  121.                     "where": {
  122.                         "condition": ""
  123.                     }
  124.                 }
  125. })}`,
  126. })
  127. getApp().globalData.handleSelect = this.handleTransfer.bind(this);
  128. break;
  129. case "跟进":
  130. that.selectComponent("#Trace").insetr();
  131. break;
  132. case "编辑":
  133. data.parentid = data.superiorenterprisename ? [data.superiorenterprisename, [data.parentid]] : "";
  134. wx.navigateTo({
  135. url: `/packageA/setclient/addAndEditor?data=${JSON.stringify(data)}`,
  136. })
  137. break;
  138. case "作废":
  139. wx.navigateTo({
  140. url: `/packageA/setclient/delete?item=${JSON.stringify({
  141. "sa_customersids": [this.data.detail.sa_customersid],
  142. datastatus: 1, //(0:正常;1:作废;2:锁定)
  143. })}`,
  144. })
  145. break;
  146. case "更换负责人":
  147. wx.navigateTo({
  148. url: `/pages/group/select?data=${JSON.stringify({
  149. ownertable:"sa_customers",
  150. ownerid:this.data.sa_customersid,
  151. })}&radio=true&principal=true`,
  152. })
  153. break;
  154. case "查看重复":
  155. _Http.basic({
  156. "id": 20221208172002,
  157. "content": {
  158. ...data,
  159. pageSize: 999
  160. }
  161. }).then(res => {
  162. console.log("查看重复", res)
  163. if (res.msg != '成功') return wx.showToast({
  164. title: res.msg,
  165. icon: "none"
  166. });
  167. if (res.data.length == 0) return wx.showToast({
  168. title: '未查询到重复数据',
  169. icon: "none"
  170. });
  171. this.setData({
  172. repetitionList: res.data,
  173. repetitionShow: true
  174. })
  175. })
  176. break;
  177. default:
  178. console.log(detail)
  179. break;
  180. }
  181. },
  182. /* 前去重复项详情 */
  183. toRepDetail(e) {
  184. const {
  185. item
  186. } = e.currentTarget.dataset;
  187. console.log(item)
  188. wx.navigateTo({
  189. url: '/packageA/setclient/detail?id=' + item.sa_customersid,
  190. })
  191. this.repClose()
  192. },
  193. /* 关闭查重 */
  194. repClose() {
  195. this.setData({
  196. repetitionShow: false
  197. })
  198. },
  199. /* 处理回收客户 */
  200. handleTransfer({
  201. value
  202. }) {
  203. wx.showModal({
  204. title: '提示',
  205. content: `是否确定将客户回收至${value[0]}?`,
  206. complete: (res) => {
  207. if (res.confirm) _Http.basic({
  208. "id": 20221014165602,
  209. "content": {
  210. "sa_customerpoolid": value[1][0], //公海池id
  211. "sa_customersids": [this.data.detail.sa_customersid],
  212. "sa_customersid": this.data.detail.sa_customersid
  213. },
  214. }).then(res => {
  215. console.log("回收客户", res)
  216. wx.showToast({
  217. title: res.data == '成功' ? `回收成功` : res.msg,
  218. icon: "none"
  219. });
  220. if (res.data == '成功') setTimeout(() => {
  221. wx.navigateBack()
  222. let page = getCurrentPages().find(v => v.__route__ == 'packageA/setclient/index');
  223. if (page) page.setData({
  224. list: page.data.list.filter(v => v.sa_customersid != this.data.detail.sa_customersid)
  225. });
  226. wx.redirectTo({
  227. url: '/packageA/publicCustomer/detail?id=' + this.data.detail.sa_customersid,
  228. })
  229. }, 300)
  230. })
  231. }
  232. })
  233. },
  234. /* 更换负责人 */
  235. handelSubmit(arr) {
  236. const that = this;
  237. wx.showModal({
  238. title: '提示',
  239. content: '是否确认更换负责人',
  240. complete: ({
  241. confirm
  242. }) => {
  243. if (confirm) _Http.basic({
  244. "id": 20220930103701,
  245. "content": {
  246. ownertable: "sa_customers",
  247. ownerid: that.data.sa_customersid,
  248. userid: arr[0]
  249. }
  250. }).then(res => {
  251. console.log("更换负责人", res)
  252. if (res.msg != '成功') return wx.showToast({
  253. title: res.data,
  254. icon: "none"
  255. });
  256. wx.showToast({
  257. title: '更换成功!',
  258. icon: "none"
  259. });
  260. setTimeout(() => {
  261. that.getDetail();
  262. getCurrentPages().forEach(v => {
  263. if (['packageA/setclient/index'].includes(v.__route__)) v.getList(true)
  264. })
  265. wx.navigateBack();
  266. }, 300)
  267. })
  268. }
  269. })
  270. },
  271. /* 获取详情 */
  272. getDetail() {
  273. /* 基本信息 */
  274. _Http.basic({
  275. "id": 20221012164302,
  276. "content": {
  277. sa_customersid: this.data.sa_customersid
  278. },
  279. }).then(res => {
  280. console.log("详情", res)
  281. if (res.msg != '成功') return wx.showToast({
  282. title: res.data,
  283. icon: "none"
  284. })
  285. this.setPreview(res);
  286. this.setTabbar(res, res.data.leader.some(some => some.userid == wx.getStorageSync('userMsg').userid));
  287. this.setData({
  288. loading: false,
  289. detail: res.data,
  290. })
  291. //获取标签
  292. this.getTags();
  293. this.getGroup()
  294. this.partialRenewal();
  295. });
  296. },
  297. async setTabbar(res, Leader) {
  298. /* 底部功能 */
  299. let isAdmin = this.data.isAdmin,
  300. isLeader = Leader,
  301. editdataleader = true,
  302. tabbarList = [];
  303. if (!isLeader) {
  304. let s = await getApp().agentOrNot("sa_customers", this.data.sa_customersid);
  305. isLeader = s.data.editable == 1;
  306. editdataleader = s.data.editdataleader == 1;
  307. }
  308. //负责人或管理员基础功能
  309. if (isLeader || isAdmin) {
  310. tabbarList = [{
  311. icon: "icon-bianji",
  312. label: "编辑"
  313. }];
  314. if (editdataleader) tabbarList.push({
  315. icon: "icon-zhuanyi",
  316. label: "更换负责人"
  317. })
  318. tabbarList.push({
  319. icon: "icon-shanchu",
  320. label: "作废"
  321. })
  322. }
  323. //来自公海
  324. if (res.data.ispublic == 1) {
  325. //查询到回收公海客户权限
  326. if (this.data.options.some(v => v == 'recycle')) tabbarList.push({
  327. icon: "icon-dibu-chehui",
  328. label: "回收"
  329. })
  330. //负责人
  331. if (isLeader) tabbarList.push({
  332. icon: "icon-dibu-chehui",
  333. label: "退回"
  334. })
  335. }
  336. if (this.data.options.find(v => v == 'viewRepetition')) tabbarList.push({
  337. icon: "icon-a-shouyejingangquhehuoren",
  338. label: "查看重复"
  339. });
  340. this.setData({
  341. tabbarList,
  342. isLeader,
  343. editdataleader
  344. })
  345. },
  346. setPreview(res) {
  347. /* 摘要信息 */
  348. let briefs = [{
  349. label: "客户类型",
  350. value: res.data.type
  351. }, {
  352. label: "企业等级",
  353. value: res.data.grade
  354. }, {
  355. label: "上级企业",
  356. value: res.data.superiorenterprisename
  357. }, {
  358. label: "负责人",
  359. value: res.data.leader.map(v => v.name) || ""
  360. }, {
  361. label: "归属经销商",
  362. value: res.data.agentname
  363. }];
  364. /* 基本信息 */
  365. let list1 = [{
  366. label: "客户名称",
  367. value: res.data.enterprisename
  368. }, {
  369. label: "客户编号",
  370. value: res.data.sa_customersid
  371. }, {
  372. label: "erp编号",
  373. value: res.data.erpagentnum
  374. }, {
  375. label: "企业简称",
  376. value: res.data.abbreviation
  377. }, {
  378. label: "客户类型",
  379. value: res.data.type
  380. }, {
  381. label: "企业等级",
  382. value: res.data.grade
  383. }, {
  384. label: "客户分类",
  385. value: res.data.customergrade
  386. }, {
  387. label: "客户行业",
  388. value: res.data.industry
  389. }, {
  390. label: "税号",
  391. value: res.data.taxno
  392. }, {
  393. label: "法人",
  394. value: res.data.contact
  395. }, {
  396. label: "电话",
  397. value: res.data.telephone
  398. }, {
  399. label: "省市县",
  400. value: res.data.province ? [res.data.province, res.data.city, res.data.county] : ""
  401. }, {
  402. label: "详细地址",
  403. value: res.data.address
  404. }, {
  405. label: "上级企业",
  406. value: res.data.superiorenterprisename
  407. }, {
  408. label: "客户来源",
  409. value: res.data.source
  410. }, {
  411. label: "来源公海",
  412. value: res.data.sourcepoolname
  413. }, {
  414. label: "成交状态",
  415. value: res.data.tradingstatus
  416. }, {
  417. label: "成交次数",
  418. value: res.data.contact_signnum
  419. }, {
  420. label: "合作状态",
  421. value: res.data.status
  422. }, {
  423. label: "负责人",
  424. value: res.data.leader.map(v => v.name) || ""
  425. }, {
  426. label: "归属经销商",
  427. value: res.data.agentname
  428. }];
  429. /* 系统信息 */
  430. let list2 = [{
  431. label: "创建人",
  432. value: res.data.createby
  433. }, {
  434. label: "创建时间",
  435. value: res.data.createdate
  436. }, {
  437. label: "最近编辑人",
  438. value: res.data.changeby
  439. }, {
  440. label: "最近编辑时间",
  441. value: res.data.changedate
  442. }, {
  443. label: "作废原因",
  444. value: res.data.deletereason
  445. }, {
  446. label: "转手次数",
  447. value: res.data.leader[0] ? res.data.leader[0].leadernum : 0
  448. }];
  449. this.setData({
  450. briefs,
  451. list1,
  452. list2
  453. });
  454. },
  455. //tabs 切换
  456. tabsChange({
  457. detail
  458. }) {
  459. this.setData({
  460. tabsActive: detail
  461. });
  462. this.partialRenewal();
  463. },
  464. //局部数据更新 tabs
  465. partialRenewal(init = false) {
  466. let model = this.data.tabsList[this.data.tabsActive].model;
  467. if (model) {
  468. let Component = this.selectComponent(model),
  469. {
  470. total,
  471. pageNumber,
  472. pageTotal
  473. } = Component.data.content,
  474. id = model == "#Clue" ? this.data.detail.sa_customersid : this.data.detail.sys_enterpriseid;
  475. if (total == null || init) {
  476. Component.getList(id, init);
  477. } else if (pageNumber <= pageTotal) {
  478. Component.getList(id, false);
  479. }
  480. }
  481. },
  482. //更新标签
  483. getTags() {
  484. this.selectComponent("#Tags").getTags();
  485. },
  486. //更新团队成员
  487. getGroup() {
  488. this.selectComponent("#Group").getList();
  489. },
  490. onReachBottom() {
  491. this.partialRenewal();
  492. },
  493. onShareAppMessage() {}
  494. })