前三年日月季年

var list = [];
                this.set("timePointData", []);
                var date = new Date();
                var month = date.getMonth();
                var year = date.getFullYear();
                switch(type) {
                    case "day":
                        this.set("isDayTime", false);
                        break;
                    case "month":
                        this.set("isDayTime", true);
                        for(var i = 0; i < 36; i++) {
                            date.setMonth(date.getMonth() - 1);
                            var m = date.getMonth() + 1;
                            m = m < 10 ? "0" + m : m;
                            list.push({
                                id: date.getFullYear() + "-" + m,
                                txt: date.getFullYear() + "年" + m + '月'
                            });
                        }
                        break;
                    case "quarterly":
                        this.set("isDayTime", true);
                        var quar = null;
                        if(month < 4) {
                            quar = 4;
                        } else if(month < 7) {
                            quar = 1;
                        } else if(month < 10) {
                            quar = 2;
                        } else {
                            quar = 3;
                        }
                        for(var j = 0; j < 12; j++) {
                            if(quar === 0) {
                                year = year - 1;
                                quar = 4;
                            }
                            var q = quar * 3 - 2;
                            q = q < 10 ? "0" + q : q;
                            list.push({
                                id: year + "-" + q,
                                txt: year + "年" + quar + '季度'
                            });
                            quar = quar - 1;
                        }
                        break;
                    case "year":
                        this.set("isDayTime", true);
                        for(var k = year - 1; k > year - 6; k--) {
                            list.push({
                                id: k,
                                txt: k + "年"
                            });
                        }
                        break;
                    default:
                        break;

猜你喜欢

转载自blog.csdn.net/soldierofyou/article/details/82768940
今日推荐