distribution.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. const {
  2. getCurrentPage
  3. } = require("../../miniprogram_npm/@vant/weapp/common/utils");
  4. const _Http = getApp().globalData.http;
  5. Page({
  6. data: {
  7. list: [],
  8. params: {
  9. classname: "webmanage.saletool.orderclue.publicclue.PublicClue",
  10. "method": "getMatchAgentList",
  11. "content": {
  12. "nocache": true,
  13. "pageNumber": 1,
  14. "pageSize": 20,
  15. "sat_orderclueid": '',
  16. "where": {
  17. "condition": ""
  18. }
  19. },
  20. },
  21. detail: {}
  22. },
  23. onLoad(options) {
  24. let data = JSON.parse(options.data)
  25. this.setData({
  26. detail: data,
  27. 'params.content.sat_orderclueid': data.sat_orderclueid
  28. })
  29. this.getList();
  30. },
  31. /* 开始搜索 */
  32. onSearch({
  33. detail
  34. }) {
  35. console.log(detail);
  36. if (this.data.params.content.where.condition == detail) return;
  37. this.setData({
  38. 'params.content.where.condition': detail
  39. });
  40. this.getList(true)
  41. },
  42. onClear() {
  43. this.setData({
  44. 'params.content.where.condition': ""
  45. });
  46. this.getList(true)
  47. },
  48. /* 选中 */
  49. onChange(e) {
  50. const {
  51. item
  52. } = e.currentTarget.dataset;
  53. wx.showModal({
  54. title: '提示',
  55. content: `是否将线索分配给"${item.name}"?`,
  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.msg == '成功' ? '分配成功' : res.msg,
  72. icon: "none",
  73. mask: true
  74. });
  75. if (res.msg != '成功') return;
  76. setTimeout(() => {
  77. getCurrentPages().forEach(v => {
  78. if (v.__route__ == "packageA/publicClue/index") {
  79. v.getList(true)
  80. } else if (v.__route__ == "packageA/publicClue/detail") {
  81. wx.navigateBack()
  82. getCurrentPages().forEach(v => {
  83. if (v.__route__ == "packageA/publicClue/index") {
  84. v.getList(true)
  85. }
  86. })
  87. }
  88. })
  89. wx.navigateBack()
  90. }, 500)
  91. })
  92. }
  93. })
  94. },
  95. //获取列表
  96. getList(init = false) {
  97. let params = this.data.params;
  98. console.log(this.data.detail);
  99. if (init) params.content.pageNumber = 1;
  100. if (params.content.pageNumber > params.content.pageTotal) return;
  101. if (this.data.detail.cluetype == '业务员') {
  102. params.method = 'getMatchSalesList'
  103. } else {
  104. params.method = 'getMatchAgentList'
  105. }
  106. _Http.basic(params).then(res => {
  107. console.log("联系人", res)
  108. if (res.msg != '成功') return wx.showToast({
  109. title: res.data,
  110. icon: "none"
  111. });
  112. res.data = res.data.filter(v => v.userid != wx.getStorageSync('userMsg').userid)
  113. this.setData({
  114. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  115. "params.content.pageNumber": res.pageNumber + 1,
  116. "params.content.pageTotal": res.pageTotal,
  117. })
  118. })
  119. },
  120. onReachBottom() {
  121. this.getList();
  122. }
  123. })