distribution.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. const { getCurrentPage } = require("../../miniprogram_npm/@vant/weapp/common/utils");
  2. const _Http = getApp().globalData.http;
  3. Page({
  4. data: {
  5. list: [],
  6. params: {
  7. classname: "webmanage.saletool.orderclue.publicclue.PublicClue",
  8. "method": "getMatchAgentList",
  9. "content": {
  10. "nocache": true,
  11. "pageNumber": 1,
  12. "pageSize": 20,
  13. "sat_orderclueid":'',
  14. "where": {
  15. "condition": ""
  16. }
  17. },
  18. },
  19. detail:{}
  20. },
  21. onLoad(options) {
  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: '提示',
  53. content: `是否将线索分配给"${item.enterprisename}"?`,
  54. complete: ({
  55. confirm
  56. }) => {
  57. if (confirm) _Http.basic({
  58. classname: "webmanage.saletool.orderclue.publicclue.PublicClue",
  59. "method": this.data.detail.cluetype == '经销商' ? 'matchAgent' : 'matchAgent_Sales',
  60. "content": {
  61. matchlist: [
  62. {
  63. sat_orderclueid: this.data.detail.sat_orderclueid,
  64. [this.data.detail.cluetype == '经销商' ? 'sa_agentsid' : 'hrid']:item.sa_agentsid
  65. }
  66. ]
  67. }
  68. }).then(res => {
  69. console.log(res)
  70. wx.showToast({
  71. title: res.msg == '成功' ? '分配成功' : res.msg,
  72. icon: "none"
  73. });
  74. if (res.msg != '成功') return;
  75. wx.navigateBack()
  76. getCurrentPages().forEach(v => {
  77. console.log(v.__route__);
  78. if(v.__route__=="packageA/publicClue/index") {
  79. console.log('触发路由');
  80. v.getList(true)
  81. }
  82. })
  83. })
  84. }
  85. })
  86. },
  87. //获取列表
  88. getList(init = false) {
  89. let params = this.data.params;
  90. if (init) params.content.pageNumber = 1;
  91. if (params.content.pageNumber > params.content.pageTotal) return;
  92. _Http.basic(params).then(res => {
  93. console.log("联系人", res)
  94. if (res.msg != '成功') return wx.showToast({
  95. title: res.data,
  96. icon: "none"
  97. });
  98. res.data = res.data.filter(v => v.userid != wx.getStorageSync('userMsg').userid)
  99. this.setData({
  100. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  101. "params.content.pageNumber": res.pageNumber + 1,
  102. "params.content.pageTotal": res.pageTotal,
  103. })
  104. })
  105. },
  106. onReachBottom() {
  107. this.getList();
  108. }
  109. })