detail.js 16 KB

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