index.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. ownertable: null,
  5. ownerid: null,
  6. copyTeams: [], //用来本地搜索
  7. keyword: "", //搜索关键字
  8. activeNames: [0],
  9. userid: null
  10. },
  11. onLoad(options) {
  12. if (options.item) {
  13. this.setData({
  14. ...JSON.parse(options.item),
  15. userid: wx.getStorageSync('userMsg').userid
  16. });
  17. this.getList()
  18. };
  19. },
  20. onInput(e) {
  21. let {
  22. value
  23. } = e.detail;
  24. let index = this.data.teams.findIndex(v => v.ismyteam == 1);
  25. let copyTeams = JSON.parse(JSON.stringify(this.data.copyTeams[0]));
  26. this.setData({
  27. keyword: value,
  28. [`teams[${index}].team`]: value ? copyTeams.filter(v => v.name.includes(value) || v.position.includes(value)) : copyTeams
  29. });
  30. },
  31. cancelTheSearch() {
  32. let index = this.data.teams.findIndex(v => v.ismyteam == 1);
  33. let copyTeams = JSON.parse(JSON.stringify(this.data.copyTeams[0]));
  34. this.setData({
  35. keyword: "",
  36. [`teams[${index}].team`]: copyTeams
  37. });
  38. },
  39. onChange(event) {
  40. this.setData({
  41. activeNames: event.detail,
  42. });
  43. },
  44. toAdd() {
  45. wx.navigateTo({
  46. url: `/pages/group/select?data=${
  47. JSON.stringify({
  48. ownertable:this.data.ownertable,
  49. ownerid:this.data.ownerid
  50. })
  51. }`,
  52. })
  53. },
  54. /* 处理添加 */
  55. handelSubmit(userids) {
  56. const that = this;
  57. wx.showModal({
  58. title: '提示',
  59. content: '是否确认添加成员',
  60. success: ({
  61. confirm
  62. }) => {
  63. if (confirm) _Http.basic({
  64. "id": 20220930103601,
  65. "content": {
  66. "ownertable": that.data.ownertable,
  67. "ownerid": that.data.ownerid,
  68. userids
  69. }
  70. }).then(res => {
  71. console.log("添加团队成员", res)
  72. if (res.msg != '成功') return wx.showToast({
  73. title: res.data,
  74. icon: "none"
  75. });
  76. that.getList();
  77. wx.showToast({
  78. title: '添加成功',
  79. icon: "none"
  80. })
  81. getCurrentPages().forEach(v => {
  82. if (v.getGroup) v.getGroup();
  83. })
  84. setTimeout(wx.navigateBack, 300);
  85. })
  86. }
  87. })
  88. },
  89. //获取列表
  90. getList() {
  91. _Http.basic({
  92. "id": 20220930103501,
  93. "content": {
  94. "nocache": true,
  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. onUnload() {
  114. let page = getCurrentPages()[getCurrentPages().length-2];
  115. page.getGroup && page.getGroup();
  116. }
  117. })