(function() {

	Vue.component('device-searchbar', {
		template: '<div class="mt80 height-50 lheight-50 ml20" v-show="isShow">\
					<span class="fl c-f20 ml20 mr14 c-B5E1FC">居民/医生:</span>\
					<div class="l-text fl">\
						<input type="text" id="keyword" name="keyword" v-model="name"  placeholder="关键字搜索" class="c-f20 f-ml10 l-text-field">\
						<div class="l-trigger l-trigger-search mt10" @click="search">\
							<div class="l-trigger-icon"></div>\
						</div>\
					</div>\
				</div>',
		props: [],
		data: function() {
			return {
				name: null,
				isShow: false
			}
		},
		methods: {
			search: function() {
				if(this.name) {
					EventBus.$emit('search-patient-info', {
						keyword: this.name
					});
				} else {
					toastr.error("请输入关键字");
				}
			}
		},
		mounted: function() {
			var vm = this;
			//数据加载完成
			EventBus.$on('data-load-complete', function(arg) {
				vm.isShow = true;
			});

			$('#keyword').bind('keyup', function(event) {
				if(event.keyCode == "13") { //回车执行查询
					vm.search();
				}
			});
		}
	})

})()