select.js 3.4 KB

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