const _Http = getApp().globalData.http;
Component({
    properties: {
        add: Boolean, //是否允许新增
        ownertable: String,
        ownerid: String
    },
    data: {
        list: [],
    },
    options: {
        addGlobalClass: true
    },
    methods: {
        getList() {
            _Http.basic({
                "id": 20220930103501,
                "content": {
                    ownertable: this.data.ownertable,
                    ownerid: this.data.ownerid
                }
            }).then(res => {
                console.log("团队列表", res)
                if (res.msg != '成功') return wx.showToast({
                    title: res.data,
                    icon: "none"
                });
                if (res.data.length == 0) return;
                let list = res.data.map(v => v.team);
                const newArr = function (arr) {
                    return arr.reduce((pre, cur) => pre.concat(Array.isArray(cur) ? newArr(cur) : cur), [])
                }
                list = newArr(list).slice(0, 5);
                this.setData({
                    list
                })
            });
        },
        addUser() {
            if (this.data.add) {
                wx.navigateTo({
                    url: '/pages/group/index?item=' + JSON.stringify({
                        ownertable: this.data.ownertable,
                        ownerid: this.data.ownerid
                    })
                })
            } else {
                wx.showToast({
                    title: '当前状态不可查询',
                    icon: "none"
                })
            }
        },
        query() {
            return this.data.list
        }
    }
})