index.js 3.2 KB

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