const _Http = getApp().globalData.http
Component({
    options: {
        addGlobalClass: true
    },
    data: {
        sat_orderclueid: null,
        content: {
            nocache: true,
            pageNumber: 1,
            pageTotal: 1,
            total: null,
            where: {},
            sort: [{
                reversed: 1,
                sorted: 1,
                sortid: 84,
                sortname: "默认"
            }]
        },
        poputShow: false,
        showWhere: '所有日期',
        followList: [],
        timeRangeShow: false,
        whereType: {
            value: "start",
            list: {
                "start": "",
                "end": ""
            }
        }
    },
    methods: {
        getList(id, init = false) {
            let content = this.data.content;
            if (init) content.pageNumber = 1;
            content.sat_orderclueid = id;
            _Http.basic({
                id: 20221101094602,
                content
            }).then(res => {
                console.log('线索跟进', res);
                this.setData({
                    followList: res.data,
                    "content.pageNumber": res.pageNumber + 1,
                    "content.pageTotal": res.pageTotal,
                    "content.total": res.total,
                    sat_orderclueid: id
                })
            })
        },
        viewFiles(e) {
            const {
                item
            } = e.currentTarget.dataset;
            console.log(item)
            this.setData({
                poputShow: true
            })
            this.selectComponent("#Yl_Files").handleFiles(item.attinfo,true)
        },
        onClosePoput() {
            this.setData({
                poputShow: false
            })
            this.selectComponent("#Yl_Files").initData()
        },
        changeIsdesc() {
            this.setData({
                "content.sort[0].reversed": this.data.content.sort[0].reversed == 1 ? 0 : 1
            });
            this.getList(this.data.sat_orderclueid, true)
        },
        /* 打开选择时间 */
        openSelectDate() {
            this.setData({
                timeRangeShow: true
            })
        },
        /* 确定时间范围 */
        determineScope() {
            const {
                list
            } = this.data.whereType;
            this.setData({
                "content.where": list,
                showWhere: list.start + '~' + list.end,
                timeRangeShow: false
            });
            this.getList(this.data.sat_orderclueid, true);
        },
        /* 得到选择时间 */
        getDate({
            detail
        }) {
            let obj = this.data.whereType;
            obj.list[obj.value] = detail;
            this.setData({
                whereType: obj
            })
        },
        /* 选择日期类型 */
        selectDateType(e) {
            const {
                name
            } = e.target.dataset;
            this.setData({
                "whereType.value": name
            })
        },
        /* 查看所有日期 */
        toSeeAll() {
            this.setData({
                showWhere: "所有日期"
            })
            this.timeRangeClose();
            this.getList(this.data.sat_orderclueid, true);
        },
        /* 关闭时间范围选择 */
        timeRangeClose() {
            this.setData({
                timeRangeShow: false,
                "content.where": {
                    "start": "",
                    "end": ""
                }
            })
        },
    }
})