distribution.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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" || 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. console.log(this.data.detail);
  94. if (init) params.content.pageNumber = 1;
  95. if (params.content.pageNumber > params.content.pageTotal) return;
  96. if (this.data.detail.cluetype == '业务员') {
  97. params.method = 'getMatchSalesList'
  98. } else {
  99. params.method = 'getMatchAgentList'
  100. }
  101. _Http.basic(params).then(res => {
  102. console.log("联系人", res)
  103. if (res.msg != '成功') return wx.showToast({
  104. title: res.data,
  105. icon: "none"
  106. });
  107. res.data = res.data.filter(v => v.userid != wx.getStorageSync('userMsg').userid)
  108. this.setData({
  109. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  110. "params.content.pageNumber": res.pageNumber + 1,
  111. "params.content.pageTotal": res.pageTotal,
  112. })
  113. })
  114. },
  115. onReachBottom() {
  116. this.getList();
  117. }
  118. })