Pop-upMulti-select.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. Component({
  2. properties: {
  3. showText: {
  4. type: String,
  5. value: ""
  6. },
  7. title: {
  8. type: String,
  9. value: "标题"
  10. },
  11. list: {
  12. type: Array,
  13. value: []
  14. },
  15. result: {
  16. type: Array,
  17. value: []
  18. },
  19. getResult: {
  20. type: Function
  21. }
  22. },
  23. observers: {
  24. "result": function (params) {
  25. console.log(params)
  26. }
  27. },
  28. options: {
  29. addGlobalClass: true
  30. },
  31. data: {
  32. show: false,
  33. count: 0,
  34. },
  35. lifetimes: {
  36. attached: function () {
  37. getApp().globalData.Language.getLanguagePackage(this)
  38. }
  39. },
  40. methods: {
  41. openSelete() {
  42. this.setData({
  43. show: true
  44. })
  45. },
  46. closeSelete() {
  47. this.setData({
  48. show: false
  49. })
  50. },
  51. onChange(event) {
  52. this.setData({
  53. result: event.detail,
  54. });
  55. },
  56. confirm() {
  57. let obj = {
  58. roleids: this.data.result,
  59. rolenames: []
  60. };
  61. this.data.list.forEach(v => (this.data.result.some(value => value == v.roleid)) ? obj.rolenames.push(v.rolename) : '');
  62. this.closeSelete();
  63. this.triggerEvent("getResult", obj)
  64. },
  65. toggle(event) {
  66. const {
  67. index
  68. } = event.currentTarget.dataset;
  69. const checkbox = this.selectComponent(`.checkboxes-${index}`);
  70. checkbox.toggle();
  71. },
  72. }
  73. })