Pop-upMulti-select.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // pages/teams/modules/Pop-upMulti-select.js
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. properties: {
  7. showText: {
  8. type: String,
  9. value: ""
  10. },
  11. title: {
  12. type: String,
  13. value: "标题"
  14. },
  15. list: {
  16. type: Array,
  17. value: []
  18. },
  19. result: {
  20. type: Array,
  21. value: []
  22. },
  23. getResult: {
  24. type: Function
  25. }
  26. },
  27. options: {
  28. addGlobalClass: true
  29. },
  30. /**
  31. * 组件的初始数据
  32. */
  33. data: {
  34. show: false
  35. },
  36. /**
  37. * 组件的方法列表
  38. */
  39. methods: {
  40. openSelete() {
  41. this.setData({
  42. show: true
  43. })
  44. },
  45. closeSelete() {
  46. this.setData({
  47. show: false
  48. })
  49. },
  50. onChange(event) {
  51. this.setData({
  52. result: event.detail,
  53. });
  54. },
  55. confirm() {
  56. let obj = {
  57. roleids: this.data.result,
  58. rolenames: []
  59. };
  60. this.data.list.forEach(v => (this.data.result.some(value => value == v.roleid)) ? obj.rolenames.push(v.rolename) : '');
  61. this.closeSelete();
  62. this.triggerEvent("getResult", obj)
  63. },
  64. toggle(event) {
  65. const {
  66. index
  67. } = event.currentTarget.dataset;
  68. const checkbox = this.selectComponent(`.checkboxes-${index}`);
  69. checkbox.toggle();
  70. },
  71. }
  72. })