distribution.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. list: [],
  5. params: {
  6. classname: "webmanage.saletool.orderclue.publicclue.PublicClue",
  7. "method": "getMatchAgentList",
  8. "content": {
  9. "nocache": true,
  10. "pageNumber": 1,
  11. "pageSize": 20,
  12. "sat_orderclueid": '',
  13. "where": {
  14. "condition": ""
  15. }
  16. },
  17. },
  18. detail: {}
  19. },
  20. onLoad(options) {
  21. getApp().globalData.Language.getLanguagePackage(this, '分配线索');
  22. let data = JSON.parse(options.data)
  23. this.setData({
  24. detail: data,
  25. 'params.content.sat_orderclueid': data.sat_orderclueid
  26. })
  27. this.getList();
  28. },
  29. /* 开始搜索 */
  30. onSearch({
  31. detail
  32. }) {
  33. console.log(detail);
  34. if (this.data.params.content.where.condition == detail) return;
  35. this.setData({
  36. 'params.content.where.condition': detail
  37. });
  38. this.getList(true)
  39. },
  40. onClear() {
  41. this.setData({
  42. 'params.content.where.condition': ""
  43. });
  44. this.getList(true)
  45. },
  46. /* 选中 */
  47. onChange(e) {
  48. const {
  49. item
  50. } = e.currentTarget.dataset;
  51. wx.showModal({
  52. title: getApp().globalData.Language.getMapText('提示'),
  53. content: getApp().globalData.Language.getMapText('是否将线索分配给') + ' ' + item.name + '?',
  54. cancelText: getApp().globalData.Language.getMapText('取消'),
  55. confirmText: getApp().globalData.Language.getMapText('确定'),
  56. complete: ({
  57. confirm
  58. }) => {
  59. if (confirm) _Http.basic({
  60. classname: "webmanage.saletool.orderclue.publicclue.PublicClue",
  61. "method": this.data.detail.cluetype == '经销商' ? 'matchAgent' : 'matchAgent_Sales',
  62. "content": {
  63. matchlist: [{
  64. sat_orderclueid: this.data.detail.sat_orderclueid,
  65. [this.data.detail.cluetype == '经销商' ? 'sa_agentsid' : 'hrid']: item.hrid
  66. }]
  67. }
  68. }).then(res => {
  69. console.log("分配线索", res)
  70. wx.showToast({
  71. title: res.code == '1' ? getApp().globalData.Language.getMapText('分配成功') : res.msg,
  72. icon: "none",
  73. mask: true
  74. });
  75. if (res.code != '1') return;
  76. setTimeout(() => {
  77. getCurrentPages().forEach(v => {
  78. if (v.__route__ == "packageA/publicClue/index" || v.__route__ == "packageA/saleAdmin/index") {
  79. v.getList(true)
  80. } else if (v.__route__ == "packageA/publicClue/detail" || v.__route__ == "packageA/saleAdmin/detail") {
  81. v.getDetail();
  82. }
  83. })
  84. wx.navigateBack()
  85. }, 500)
  86. })
  87. }
  88. })
  89. },
  90. //获取列表
  91. getList(init = false) {
  92. let params = this.data.params;
  93. if (init) params.content.pageNumber = 1;
  94. if (params.content.pageNumber > params.content.pageTotal) return;
  95. if (this.data.detail.cluetype == '业务员') {
  96. params.method = 'getMatchSalesList'
  97. } else {
  98. params.method = 'getMatchAgentList'
  99. }
  100. _Http.basic(params).then(res => {
  101. console.log("联系人", res)
  102. if (res.code != '1') return wx.showToast({
  103. title: res.data,
  104. icon: "none"
  105. });
  106. this.setData({
  107. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  108. "params.content.pageNumber": res.pageNumber + 1,
  109. "params.content.pageTotal": res.pageTotal,
  110. })
  111. })
  112. },
  113. onReachBottom() {
  114. this.getList();
  115. }
  116. })