let _Http = getApp().globalData.http;
Component({
    properties: {
        list: Array,
        detele: Boolean,
        edit: Boolean
    },
    options: {
        addGlobalClass: true
    },
    methods: {
        handleItem(e) {
            let {
                item
            } = e.currentTarget.dataset;
            console.log(item)
            wx.showModal({
                title: '提示',
                content: item.important ? `是否设置${item.enterprisename}为主要威胁？` : `是否取消设置${item.enterprisename}为主要威胁？`,
                complete: (res) => {
                    if (res.confirm) {
                        item.important = item.important == 0 ? 1 : 0;
                        _Http.basic({
                            id: "20221019165802",
                            content: item
                        }).then(res => {
                            wx.showToast({
                                title: res.msg == '成功' ? "设置成功" : res.msg,
                                icon: "none"
                            });
                            let page = getCurrentPages()[getCurrentPages().length - 1].selectComponent("#Opponent");
                            if (page) {
                                let i = page.data.list.findIndex(v => v.sa_competitorid == item.sa_competitorid);
                                if (i != -1) page.setData({
                                    [`list[${i}]`]: item
                                });
                            }
                        })
                    }
                }
            })
        }
    }
})