new Vue({
	el: '#main',
	data: {
		roles: [{
			"code": "350205",
			"level": "3",
			"name": "海沧区",
			"isManage": "1",
			"authOperate": "1",
			"areas": "350205"
		}, {
			"code": "350200",
			"level": "2",
			"name": "厦门市卫生与计划生育委员会",
			"isManage": "1",
			"authOperate": "1",
			"areas": "350200"
		}, {
			"code": "3502050100",
			"level": "4",
			"name": "海沧区嵩屿街道社区卫生服务中心",
			"isManage": "1",
			"authOperate": "1",
			"areas": "3502050100"
		}],
		selectedRole: "",
		isopen: true,
		signAnalysis: [{
			photo: '../../images/qianyujingzhan_icon.png',
			label: '签约进展',
			url: 'sign-progress.html'
		}, {
			photo: '../../images/xuqianjingzhan_icon.png',
			label: '续签进展',
			url: ''
		}, {
			photo: '../../images/jumingfenxi_icon.png',
			label: '居民分析',
			url: 'resident-analysis.html'
		}, {
			photo: '../../images/tuigaiqian_icon.png',
			label: '退改签',
			url: ''
		}, {
			photo: '../../images/lianglvfenxi_icon.png',
			label: '两率分析',
			url: ''
		}],
		serviceAnalysis: [{
			photo: '../../images/zongtifenxi_icon.png',
			label: '总体分析',
			url: 'comprehensive-analysis.html'
		}, {
			photo: '../../images/zixunfenxi_icon.png',
			label: '咨询分析',
			url: ''
		}, {
			photo: '../../images/pijianfenxi_icon.png',
			label: '评价分析',
			url: ''
		}, {
			photo: '../../images/changcufangfenxi_icon.png',
			label: '长处方分析',
			url: ''
		}]
	},
	methods: {
		open: function() {
			EventBus.$emit('open-click', {});
		},
		showDetail: function(url) {
			window.location.href = url;
		}
	},
	mounted: function() {
		var selected = window.localStorage.getItem("selectedRole");
		if(selected) {
			this.selectedRole = JSON.parse(selected).code;
		} else {
			this.selectedRole = this.roles[0].code;
			var selected = this.roles[0];
			window.localStorage.setItem("selectedRole", JSON.stringify(selected));
		}
	},
	watch: {
		selectedRole: function(val) {
			var selected = _.findWhere(this.roles, {
				code: val
			});
			window.localStorage.setItem("selectedRole", JSON.stringify(selected));
		}
	}
})