index.js 3.3 KB

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