const _Http = getApp().globalData.http;

Page({
    data: {
        ownertable: null,
        ownerid: null,
        sys_datafollowupid: null,
        detail: {},
        tabbarList: [{
            icon: "color-bianji",
            label: "编辑"
        }, {
            icon: "icon-shanchu",
            label: "删除"
        }],
    },
    onLoad(options) {
        if (options.data) {
            this.setData({
                ...JSON.parse(options.data),
                userid: wx.getStorageSync('userMsg').userid
            })
            this.getDetail();
            getApp().globalData.Language.getLanguagePackage(this, '跟进动态详情');
        }
    },
    getDetail() {
        _Http.basic({
            "id": 20221026085601,
            "content": {
                "sys_datafollowupid": this.data.sys_datafollowupid
            }
        }).then(res => {
            console.log("跟进详情", res)
            if (res.code != '1') return wx.showToast({
                title: res.data,
                icon: "none"
            })
            this.selectComponent("#Yl_files").initData()
            this.selectComponent("#Yl_files").handleFiles(res.data.attinfos)
            this.setData({
                detail: res.data,
                briefs: [{
                    label: "跟进类型",
                    value: res.data.type
                }, {
                    label: "跟进内容",
                    value: res.data.content
                }]
            })
        })
    },
    /* tab 切换回调 */
    tabbarOnClick({
        detail
    }) {
        const item = this.data.detail;
        switch (detail.label) {
            case "编辑":
                wx.navigateTo({
                    url: `/prsx/trace/add/index?ownertable=${this.data.ownertable}&ownerid=${this.data.ownerid}&sys_datafollowupid=${item.sys_datafollowupid}`
                });
                break;
            case "删除":
                _Http.traceHandleDelete(item).then(res => {
                    if (res) setTimeout(() => {
                        wx.navigateBack()
                    }, 300)
                })
                break;
        }
    }
})