detail.js 15 KB

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