detail.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  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. default:
  213. console.log(detail)
  214. break;
  215. }
  216. },
  217. /* 获取详情 */
  218. getDetail() {
  219. /* 基本信息 */
  220. _Http.basic({
  221. "id": 20221012164302,
  222. "content": {
  223. nocache: true,
  224. sa_customersid: this.data.sa_customersid
  225. },
  226. }).then(res => {
  227. console.log("详情", res)
  228. if (res.msg != '成功') return wx.showToast({
  229. title: res.data,
  230. icon: "none"
  231. })
  232. this.setPreview(res);
  233. //获取标签
  234. this.getTags();
  235. this.partialRenewal();
  236. });
  237. },
  238. setPreview(res) {
  239. /* 摘要信息 */
  240. let briefs = [{
  241. label: "公海池:",
  242. value: res.data.poolname
  243. }, {
  244. label: "客户类型",
  245. value: res.data.type
  246. }, {
  247. label: "企业等级",
  248. value: res.data.grade
  249. }, {
  250. label: "上级企业",
  251. value: res.data.superiorenterprisename
  252. }];
  253. /* 基本信息 */
  254. let list1 = [{
  255. label: "客户名称",
  256. value: res.data.enterprisename
  257. }, {
  258. label: "客户编号",
  259. value: res.data.sa_customersid
  260. }, {
  261. label: "erp编号",
  262. value: res.data.erpagentnum
  263. }, {
  264. label: "公海池",
  265. value: res.data.poolname
  266. }, {
  267. label: "企业简称",
  268. value: res.data.abbreviation
  269. }, {
  270. label: "客户类型",
  271. value: res.data.type
  272. }, {
  273. label: "企业等级",
  274. value: res.data.grade
  275. }, {
  276. label: "客户分类",
  277. value: res.data.customergrade
  278. }, {
  279. label: "客户行业",
  280. value: res.data.industry
  281. }, {
  282. label: "税号",
  283. value: res.data.taxno
  284. }, {
  285. label: "法人",
  286. value: res.data.contact
  287. }, {
  288. label: "电话",
  289. value: res.data.telephone
  290. }, {
  291. label: "省市县",
  292. value: res.data.province ? [res.data.province, res.data.city, res.data.county] : ""
  293. }, {
  294. label: "详细地址",
  295. value: res.data.address
  296. }, {
  297. label: "上级企业",
  298. value: res.data.superiorenterprisename
  299. }, {
  300. label: "客户来源",
  301. value: res.data.source
  302. }, {
  303. label: "来源公海",
  304. value: res.data.sourcepoolname
  305. }, {
  306. label: "成交状态",
  307. value: res.data.tradingstatus
  308. }, {
  309. label: "成交次数",
  310. value: res.data.contact_signnum
  311. }, {
  312. label: "合作状态",
  313. value: res.data.status
  314. }];
  315. /* 系统信息 */
  316. let list2 = [{
  317. label: "创建人",
  318. value: res.data.createby
  319. }, {
  320. label: "创建时间",
  321. value: res.data.createdate
  322. }, {
  323. label: "最近编辑人",
  324. value: res.data.changeby
  325. }, {
  326. label: "最近编辑时间",
  327. value: res.data.changedate
  328. }, {
  329. label: "作废原因",
  330. value: res.data.deletereason
  331. }];
  332. let tabbarList = [{
  333. icon: "icon-genjin",
  334. label: "跟进"
  335. }];
  336. //公海客户可领取并且拥有领取客户的权限
  337. if (res.data.freeget == 1 && this.data.options.some(v => v == 'getCustomer')) tabbarList.unshift({
  338. icon: "icon-paixushaixuanxuanzhong",
  339. label: "领取"
  340. })
  341. if (this.data.isAdmin) tabbarList = tabbarList.concat([{
  342. icon: "icon-bianji",
  343. label: "编辑"
  344. }, {
  345. icon: "icon-shanchu",
  346. label: "删除"
  347. }]);
  348. //拥有分配权限或管理员权限
  349. if (this.data.options.some(v => v == 'allot') || this.data.isAdmin) tabbarList.splice(0, 0, {
  350. icon: "icon-a-tuiguangsucailaxinliang",
  351. label: "分配"
  352. })
  353. this.setData({
  354. detail: res.data,
  355. briefs,
  356. list1,
  357. list2,
  358. tabbarList
  359. });
  360. },
  361. //tabs 切换
  362. tabsChange({
  363. detail
  364. }) {
  365. this.setData({
  366. tabsActive: detail
  367. });
  368. this.partialRenewal();
  369. },
  370. //局部数据更新 tabs
  371. partialRenewal(init = false) {
  372. let model = this.data.tabsList[this.data.tabsActive].model;
  373. if (model) {
  374. let Component = this.selectComponent(model),
  375. {
  376. total,
  377. pageNumber,
  378. pageTotal
  379. } = Component.data.content,
  380. id = model == "#Clue" ? this.data.detail.sa_customersid : this.data.detail.sys_enterpriseid;
  381. if (total == null || init) {
  382. Component.getList(id, init);
  383. } else if (pageNumber < pageTotal) {
  384. Component.getList(id, false);
  385. }
  386. }
  387. },
  388. //更新标签
  389. getTags() {
  390. this.selectComponent("#Tags").getTags();
  391. },
  392. onReachBottom() {
  393. this.partialRenewal();
  394. }
  395. })