const _Http = getApp().globalData.http,
    currency = require("../../utils/currency"),
    CNY = (value, symbol = "￥", precision = 2) => currency(value, {
        symbol,
        precision
    }).format();
Component({
    options: {
        addGlobalClass: true
    },
    lifetimes: {
        attached: function () {
            getApp().globalData.Language.getLanguagePackage(this)
        }
    },
    data: {
        dateTypes: ["全部", "本年"],
        dateType: "本年",
        showList: false,
        list: [],
        "isAll": 0, //1全部 0本年
        allsumscore: 0,
        "content": {
            "nocache": true,
            "pageNumber": 1,
            "pageTotal": 1,
            "total": null,
            "where": {
                begdate: "",
                enddate: "",
            }
        }
    },
    methods: {
        getList(id, init) {
            let content = this.data.content;
            content.sa_projectid = id;
            content.isAll = this.data.isAll;
            if (init) {
                content.pageNumber = 1;
                content.total = null;
            }
            if (!this.data.showList && content.total != null) return;
            if (content.pageNumber > content.pageTotal) return;
            _Http.basic({
                "id": 20230715112504,
                content
            }).then(res => {
                console.log("项目评估", res)
                if (res.code != '1') return wx.showToast({
                    title: res.data,
                    icon: "none"
                })
                content.pageNumber = res.pageNumber + 1;
                content.pageSize = res.pageSize;
                content.pageTotal = res.pageTotal;
                content.total = res.total;
                this.setData({
                    list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
                    content,
                    id: id,
                });
                try {
                    this.selectComponent("#TimeRange").onCancel()
                } catch (error) {

                }
            })
            _Http.basic({
                "id": 20230715111704,
                content
            }).then(res => {
                this.setData({
                    allsumscore: res.data[0].allsumscore || 0,
                })
            })
        },
        changeDate({
            detail
        }) {
            this.setData({
                dateType: detail.dateType,
                isAll: detail.isAll === "" ? 99 : detail.isAll,
                "content.where.begdate": detail.begdate || "",
                "content.where.enddate": detail.enddate || ""
            })
            this.getList(this.data.id, true)
        },
        shrinkChange({
            detail
        }) {
            this.setData({
                showList: detail
            })
        }
    }
})