detail.js 14 KB

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