(function(){ Vue.component('sign-progress-filter',{ template:'
\
统计年份
\
\
\
统计维度
\
\ \
\ \ \
\
\ \
', props:['yearHtml','contentHtml'], data: function(){ return { } }, methods: { yearClick:function(){ $(event.target.closest("div")).addClass('active').siblings().removeClass('active'); }, contentClick:function(){ $(".div-content").find(".div-btn").removeClass('active'); $(event.target.closest("div")).addClass('active'); }, resetClick:function(){ $("#signYear").find(".c-33").removeClass("active"); $("#signYear").find(".c-33").eq(0).addClass("active"); $(".div-content").find(".c-33").removeClass("active"); $(".div-content").find(".c-33").eq(0).addClass("active"); }, confirmClick:function(){ var vm = this; var year = $("#signYear .c-33.active").attr("data-val"), $type = $(".div-content .div-btn.active"), typeCode = $type.attr("data-val"), lowCode = $type.attr("data-lowCode"), name = $type.find("a").html(); console.log("year:"+$("#signYear .c-33.active").attr("data-val")) console.log("id:"+typeCode) console.log("lowCode:"+lowCode) console.log("name:"+name) //触发刷新 this.$emit('vuedals:close', { chooseYear: year, id: typeCode, lowCode: lowCode, name: name, yearHtml:$("#signYear").html(), contentHtml:$(".div-content").html() }); }, formatYearData: function () { //显示年份最低是2016年 var now = new Date(), year = now.getFullYear(); var yearHtml = ""; if(now.getMonth() >= 6){ yearHtml += '
'+year+"
"; } for(i=year-1; i>=2016; i--){ if(i == (year-1) && now.getMonth() < 6){ yearHtml += '
'+i+"
"; }else{ yearHtml += '
'+i+"
"; } } this.yearHtml = yearHtml; }, }, mounted: function(){ if(this.contentHtml){ $(".div-content").html(this.contentHtml); }else{ this.formatYearData(); } } }); })()