index.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. const _Http = getApp().globalData.http,
  2. getHeight = require("../../../../../utils/getRheRemainingHeight");
  3. Page({
  4. data: {
  5. active: 0,
  6. item: null,
  7. radio: true,
  8. content: {
  9. pageNumber: 1,
  10. pageTotal: 1,
  11. total: null,
  12. where: {
  13. condition: "",
  14. type: 5,
  15. sa_projectid: 1
  16. }
  17. }
  18. },
  19. onLoad(options) {
  20. /* 从表单组件进入进入 */
  21. if (options.item) {
  22. let item = JSON.parse(options.item);
  23. this.setData({
  24. item
  25. })
  26. };
  27. this.getList()
  28. },
  29. onChange(e) {
  30. this.setData({
  31. active: e.detail.index
  32. });
  33. this.getList(true);
  34. },
  35. getList(init = false) {
  36. //init 用于初始化分页
  37. if (init.detail != undefined) init = init.detail;
  38. let content = this.data.content;
  39. if (init) content.pageNumber = 1;
  40. if (content.pageNumber > content.pageTotal) return;
  41. content.where.type = this.data.active == 0 ? 6 : 5
  42. if (this.data)
  43. _Http.basic({
  44. id: 20220920083901,
  45. content
  46. }).then(res => {
  47. console.log("选择客户列表", res)
  48. this.selectComponent('#ListBox').RefreshToComplete();
  49. if (res.msg != '成功') return wx.showToast({
  50. title: res.data,
  51. icon: "none"
  52. })
  53. this.setData({
  54. 'content.pageNumber': res.pageNumber + 1,
  55. 'content.pageTotal': res.pageTotal,
  56. 'content.total': res.total,
  57. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  58. })
  59. this.getTags();
  60. })
  61. },
  62. /* 获取列表标签 */
  63. getTags() {
  64. let list = this.data.list,
  65. ownerids = list.map(v => v.sys_enterpriseid)
  66. _Http.basic({
  67. "id": 20221018102001,
  68. "content": {
  69. "ownertable": "sa_customers",
  70. ownerids
  71. }
  72. }).then(res => {
  73. for (let key in res.data) {
  74. let index = list.findIndex(v => v.sys_enterpriseid == key);
  75. list[index].tags = res.data[key]
  76. };
  77. this.setData({
  78. list
  79. })
  80. })
  81. },
  82. /* 选中 */
  83. changeResult(e) {
  84. const {
  85. id
  86. } = e.currentTarget.dataset;
  87. let pages = getCurrentPages();
  88. let page = pages[pages.length - 2].selectComponent("#Form"),
  89. item = this.data.item,
  90. data = this.data.list.find(v => v.sys_enterpriseid == id);
  91. item.value = [data.enterprisename, [id]];
  92. page.handleRoute(item, [data]);
  93. },
  94. /* 开始搜索 */
  95. startSearch({
  96. detail
  97. }) {
  98. let condition = this.data.content ? this.data.content.where.condition : this.data.content.where.condition;
  99. if (detail == condition) return;
  100. this.setData({
  101. 'content.where.condition': detail
  102. });
  103. this.getList(true);
  104. },
  105. /* 取消搜索 */
  106. onClear() {
  107. this.setData({
  108. 'content.where.condition': ""
  109. });
  110. this.getList(true);
  111. },
  112. onReady() {
  113. getHeight.getHeight('.total', this).then(res => this.setData({
  114. listHeight: res
  115. }));
  116. }
  117. })