const _Http = getApp().globalData.http;
Component({
    properties: {
        list: Array,
        ownertable: String,
        ownerid: Number,
        teamleaderId: String
    },
    options: {
        addGlobalClass: true
    },
    data: {
        userid: wx.getStorageSync('userMsg').userid
    },
    methods: {
        /* 处理删除 */
        handleDelete(e) {
            const {
                item
            } = e.currentTarget.dataset;
            wx.showModal({
                title: '提示',
                content: `是否确认移除${item.name}?`,
                complete: ({
                    confirm
                }) => {
                    if (confirm) _Http.basic({
                        "accesstoken": "7eb155cb0a9ed5895056afc151af7d7f",
                        "id": 20220930103801,
                        "content": {
                            "ownertable": item.ownertable,
                            "ownerid": item.ownerid,
                            "userids": [item.userid]
                        }
                    }).then(s => {
                        wx.showToast({
                            title: s.msg == '成功' ? '移除成功!' : s.msg,
                            icon: "none"
                        });
                        if (s.msg == '成功') getCurrentPages().find(v => v.__route__ == "pages/group/index").getList();
                    })
                }
            })
        },
        /* 更换负责人 */
        changeUser() {
            wx.navigateTo({
                url: `/pages/group/select?data=${JSON.stringify({
                     ownertable:this.data.ownertable,
                     ownerid:this.data.ownerid,
                })}&radio=true&model=List&principal=true`,
            })
        },
        /* 更换负责人 */
        handelSubmit(arr) {
            const that = this;
            wx.showModal({
                title: '提示',
                content: '是否确认更换负责人',
                complete: ({
                    confirm
                }) => {
                    if (confirm) _Http.basic({
                        "id": 20220930103701,
                        "content": {
                            ownertable: that.data.ownertable,
                            ownerid: that.data.ownerid,
                            userid: arr[0]
                        }
                    }).then(res => {
                        console.log("更换负责人", res)
                        if (res.msg != '成功') return wx.showToast({
                            title: res.data,
                            icon: "none"
                        });
                        wx.showToast({
                            title: '更换成功！',
                            icon: "none"
                        });
                        setTimeout(() => {
                            getCurrentPages().forEach(v => {
                                if (["packageA/project/index", "ackageA/setclient/index", "pages/group/index"].includes(v.__route__)) {
                                    v.getList(true);
                                } else if (["packageA/setclient/detail", "packageA/project/detail"].includes(v.__route__)) {
                                    v.getDetail()
                                }
                            })
                            wx.navigateBack();
                        }, 300)
                    })
                }
            })
        },
    }
})