index.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. ownertable: null,
  5. ownerid: null,
  6. active: 0,
  7. copyTeams: [], //用来本地搜索
  8. keyword: "", //搜索关键字
  9. },
  10. handelSubmit(userids) {
  11. const that = this;
  12. wx.showModal({
  13. title: '提示',
  14. content: '是否确认添加成员',
  15. success: ({
  16. confirm
  17. }) => {
  18. if (confirm) _Http.basic({
  19. "id": 20220930103601,
  20. "content": {
  21. "ownertable": that.data.ownertable,
  22. "ownerid": that.data.ownerid,
  23. userids
  24. }
  25. }).then(res => {
  26. console.log("添加团队成员", res)
  27. if (res.msg != '成功') return wx.showToast({
  28. title: res.data,
  29. icon: "none"
  30. });
  31. that.getList();
  32. wx.showToast({
  33. title: '添加成功',
  34. icon: "none"
  35. })
  36. getCurrentPages().forEach(v => {
  37. switch (v.__route__) {
  38. case "packageA/setclient/detail":
  39. v.getGroup();
  40. break;
  41. }
  42. })
  43. setTimeout(wx.navigateBack, 300);
  44. })
  45. }
  46. })
  47. },
  48. onLoad(options) {
  49. if (options.item) {
  50. let item = JSON.parse(options.item);
  51. this.setData({
  52. ...item
  53. });
  54. this.getList()
  55. }
  56. },
  57. onInput({
  58. detail
  59. }) {
  60. let list = this.data.copyTeams[this.data.active];
  61. if (detail.value) list = list.filter(v => v.position.includes(detail.value) || v.name.includes(detail.value));
  62. this.setData({
  63. [`teams[${this.data.active}].team`]: list
  64. })
  65. },
  66. toAdd() {
  67. wx.navigateTo({
  68. url: `/packageA/group/select?data=${
  69. JSON.stringify({
  70. ownertable:this.data.ownertable,
  71. ownerid:this.data.ownerid
  72. })
  73. }`,
  74. })
  75. },
  76. /* 取消搜索 */
  77. cancelTheSearch() {
  78. this.setData({
  79. keyword: "",
  80. [`teams[${this.data.active}].team`]: this.data.copyTeams[this.data.active]
  81. })
  82. },
  83. /* 切换tabs */
  84. onChange({
  85. detail
  86. }) {
  87. this.setData({
  88. active: detail.index
  89. })
  90. },
  91. //获取列表
  92. getList() {
  93. _Http.basic({
  94. "id": 20220930103501,
  95. "content": {
  96. "ownertable": this.data.ownertable,
  97. "ownerid": this.data.ownerid
  98. }
  99. }).then(res => {
  100. console.log("团队成员列表", res)
  101. if (res.msg != '成功') return wx.showToast({
  102. title: res.data,
  103. icon: "none"
  104. })
  105. this.setData({
  106. teams: res.data,
  107. copyTeams: res.data.map(v => v.team)
  108. })
  109. })
  110. },
  111. onReachBottom() {
  112. this.getList();
  113. }
  114. })