index.js 2.8 KB

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