Pop-upMulti-select.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. observers: {
  28. "result": function (params) {
  29. console.log(params)
  30. /* this.setData({
  31. }) */
  32. }
  33. },
  34. options: {
  35. addGlobalClass: true
  36. },
  37. /**
  38. * 组件的初始数据
  39. */
  40. data: {
  41. show: false,
  42. count: 0,
  43. },
  44. /**
  45. * 组件的方法列表
  46. */
  47. methods: {
  48. openSelete() {
  49. this.setData({
  50. show: true
  51. })
  52. },
  53. closeSelete() {
  54. this.setData({
  55. show: false
  56. })
  57. },
  58. onChange(event) {
  59. this.setData({
  60. result: event.detail,
  61. });
  62. },
  63. confirm() {
  64. let obj = {
  65. roleids: this.data.result,
  66. rolenames: []
  67. };
  68. this.data.list.forEach(v => (this.data.result.some(value => value == v.roleid)) ? obj.rolenames.push(v.rolename) : '');
  69. this.closeSelete();
  70. this.triggerEvent("getResult", obj)
  71. },
  72. toggle(event) {
  73. const {
  74. index
  75. } = event.currentTarget.dataset;
  76. const checkbox = this.selectComponent(`.checkboxes-${index}`);
  77. checkbox.toggle();
  78. },
  79. }
  80. })