Vue.component('header-prompt', {
	template: '<div class="cb-ebebf5 height-30 lheight-30 pl20 c-f12">\
					<span class="c-666">{{areaName}}</span> (\
					<span class="c-666">{{jieZhiTime}}</span>)\
					<span class="c-12b7f5 ml20 mr20">{{selectDate}}</span>\
					<span class="c-12b7f5 mr20">{{dimensionVal}}</span>\
					<span v-show="dimensionVal2" class="c-12b7f5">{{dimensionVal2}}</span>\
			</div>',
	props: [],
	data: function() {
		return {
			areaName:"",
			jieZhiTime:"",
			selectDate:"",
			dimensionVal:"",
			dimensionVal2: ""
		}
	},
	mounted: function() {
		var vm = this;
		getJieZhiTime(vm);
		
		//更新区域名称
		EventBus.$on('update-area-name', function(arg) {
			vm.areaName = arg.areaName;
		});
		
		//更新统计时间
		EventBus.$on('update-statistics-time', function(arg) {
			getJieZhiTime(vm);
		});
		
		//更新年份
		EventBus.$on('update-statistics-year', function(arg) {
			vm.selectDate = arg.selectDate;
		});
		
		//更新维度名称
		EventBus.$on('update-dimension-name', function(arg) {
			vm.dimensionVal = arg.dimensionVal;
		});
		
		//更新维度2名称
		EventBus.$on('update-dimension2-name', function(arg){
		    vm.dimensionVal2 = arg.dimensionVal2;
		});
		
		//更新所有信息
		EventBus.$on('update-all-prompt-info', function(arg) {
			vm.areaName = arg.areaName;
			getJieZhiTime(vm);
			vm.selectDate = arg.selectDate;
			vm.dimensionVal = arg.dimensionVal;
		});
	},
	methods: {
		
	}
})

//获取统计时间
function getJieZhiTime(vm){
	statisticAPI.statisticsTime({}).then(function(res) {
		if(res.status=="200"){
			var date = (res.data && res.data.substring(11,16)) || "";
			vm.jieZhiTime = date;
		}
	})
}
