index.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. result: [],
  5. content: {
  6. "nocache": true,
  7. "pageNumber": 1,
  8. "pageSize": 20,
  9. "total": null,
  10. "where": {
  11. "condition": "",
  12. "type": 7
  13. }
  14. }
  15. },
  16. onLoad(options) {
  17. this.getList();
  18. },
  19. tabChange(e) {
  20. this.data.content.where.type = e.detail.name == '客户' ? 7 : 5;
  21. this.getList(true)
  22. },
  23. changeResult(e) {
  24. const {
  25. item
  26. } = e.currentTarget.dataset;
  27. wx.showModal({
  28. cancelText: getApp().globalData.Language.getMapText('取消'),
  29. confirmText: getApp().globalData.Language.getMapText('确定'),
  30. title: getApp().globalData.Language.getMapText('提示'),
  31. content: getApp().globalData.Language.getMapText('是否确认选择') + ` ${item.enterprisename}?`,
  32. complete: ({
  33. confirm
  34. }) => {
  35. if (confirm) getApp().globalData.handleSelect(item);
  36. }
  37. })
  38. },
  39. /* 获取列表 */
  40. getList(init = false) {
  41. //init 用于初始化分页
  42. if (init.detail != undefined) init = init.detail;
  43. let content = this.data.content;
  44. if (init) content.pageNumber = 1;
  45. if (content.pageNumber > content.pageTotal) return;
  46. _Http.basic({
  47. "id": 20220920083901,
  48. content
  49. }).then(res => {
  50. console.log("关联客户列表", res)
  51. this.selectComponent('#ListBox').RefreshToComplete();
  52. if (res.msg != '成功') return wx.showToast({
  53. title: res.data,
  54. icon: "none"
  55. })
  56. this.setData({
  57. 'content.pageNumber': res.pageNumber + 1,
  58. 'content.pageTotal': res.pageTotal,
  59. 'content.total': res.total,
  60. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  61. })
  62. this.getTags();
  63. })
  64. },
  65. /* 开始搜索 */
  66. startSearch({
  67. detail
  68. }) {
  69. if (detail == this.data.content.where.condition) return;
  70. this.setData({
  71. 'content.where.condition': detail
  72. });
  73. this.getList(true);
  74. },
  75. /* 取消搜索 */
  76. onClear() {
  77. this.setData({
  78. 'content.where.condition': ""
  79. });
  80. this.getList(true);
  81. },
  82. /* 获取标签 */
  83. getTags() {
  84. let list = this.data.list,
  85. ownerids = list.map(v => v.sa_customersid);
  86. _Http.basic({
  87. "id": 20221018102001,
  88. "content": {
  89. "ownertable": "sa_customers",
  90. ownerids
  91. }
  92. }).then(res => {
  93. console.log("标签", res)
  94. if (res.msg != '成功') return;
  95. for (let key in res.data) {
  96. let index = list.findIndex(v => v.sa_customersid == key);
  97. if (index != -1) list[index].tags = res.data[key]
  98. };
  99. this.setData({
  100. list
  101. })
  102. })
  103. },
  104. onReady() {
  105. this.selectComponent("#ListBox").setHeight(".search", this);
  106. },
  107. onUnload() {
  108. getApp().globalData.handleSelect = null;
  109. }
  110. })