// pages/teams/modules/Pop-upMulti-select.js
Component({
    /**
     * 组件的属性列表
     */
    properties: {
        showText: {
            type: String,
            value: ""
        },
        title: {
            type: String,
            value: "标题"
        },
        list: {
            type: Array,
            value: []
        },
        result: {
            type: Array,
            value: []
        },
        getResult: {
            type: Function
        }
    },
    observers: {
        "result": function (params) {
            console.log(params)
            /* this.setData({

            }) */
        }
    },
    options: {
        addGlobalClass: true
    },
    /**
     * 组件的初始数据
     */
    data: {
        show: false,
        count: 0,
    },
    /**
     * 组件的方法列表
     */
    methods: {
        openSelete() {
            this.setData({
                show: true
            })
        },
        closeSelete() {
            this.setData({
                show: false
            })
        },
        onChange(event) {
            this.setData({
                result: event.detail,
            });
        },
        confirm() {
            let obj = {
                roleids: this.data.result,
                rolenames: []
            };
            this.data.list.forEach(v => (this.data.result.some(value => value == v.roleid)) ? obj.rolenames.push(v.rolename) : '');
            this.closeSelete();
            this.triggerEvent("getResult", obj)
        },
        toggle(event) {
            const {
                index
            } = event.currentTarget.dataset;
            const checkbox = this.selectComponent(`.checkboxes-${index}`);
            checkbox.toggle();
        },
    }
})