index.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. radio: false, //是否为单选
  5. content: {
  6. "ownertable": "sa_itemgroup",
  7. "ownerid": 11,
  8. pageSize: 20,
  9. pageNumber: 1,
  10. pageTotal: 1,
  11. "where": {
  12. "condition": ""
  13. }
  14. },
  15. list: [],
  16. result: [],
  17. },
  18. onLoad(options) {
  19. //是否为单选
  20. if (options.radio) this.setData({
  21. radio: true
  22. })
  23. if (options.ownertable) {
  24. this.setData({
  25. "content.ownertable": options.ownertable,
  26. "content.ownerid": options.ownerid,
  27. });
  28. this.getList();
  29. console.log(this.data.content)
  30. };
  31. },
  32. submit() {
  33. let result = this.data.result;
  34. if (result.length == 0) return;
  35. console.log(result)
  36. _Http.basic({
  37. "id": 20220930103601,
  38. "content": {
  39. "ownertable": this.data.content.ownertable,
  40. "ownerid": this.data.content.ownerid,
  41. "userids": result
  42. }
  43. }).then(res => {
  44. if (res.msg != '成功') return wx.showToast({
  45. title: res.data,
  46. icon: "none"
  47. });
  48. wx.showToast({
  49. title: '保存成功',
  50. icon: "none"
  51. });
  52. setTimeout(() => {
  53. const pages = getCurrentPages();
  54. pages[pages.length - 2].selectComponent("#Group").getList();
  55. wx.navigateBack();
  56. }, 300)
  57. })
  58. },
  59. /* 选中 */
  60. onChange(e) {
  61. const userid = e.currentTarget.dataset.item.userid + "";
  62. if (!userid) return;
  63. if (this.data.radio) {
  64. this.setData({
  65. result: [userid]
  66. })
  67. } else {
  68. let result = this.data.result;
  69. if (result.some(v => v == userid)) {
  70. result = result.filter(v => v != userid)
  71. } else {
  72. result.push(userid)
  73. }
  74. this.setData({
  75. result
  76. })
  77. }
  78. },
  79. //获取列表
  80. getList(init = false) {
  81. let content = this.data.content;
  82. if (init) {
  83. content.pageTotal = 1
  84. content.pageNumber = 1
  85. }
  86. if (content.pageNumber > content.pageTotal) return;
  87. _Http.basic({
  88. "id": 20221018122201,
  89. content
  90. }).then(res => {
  91. console.log("数据团队列表", res)
  92. this.setData({
  93. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  94. "content.pageTotal": res.pageTotal,
  95. "content.pageNumber": res.pageNumber + 1,
  96. })
  97. })
  98. },
  99. onReachBottom() {
  100. this.getList();
  101. }
  102. })