<!--
	作者：yangzhijie1488@163.com
	时间：2017-12-07
	描述：查询组件
-->
<template>
	 <div class="m-container">
	    <div class="input-group">
	      <input type="text" v-model="searchText" class="form-control" @keyup.enter="search" :placeholder="placeholderText">
	      <span class="input-group-btn">
	        <button style="width:100%;"  @click="search()" type="button" class="btn btn-blue search-button">
				查询
			</button>
	      </span>
	    </div>
	  </div>
</template>

<script>
	export default {
		props: ["placeholderText"],
		
		data: function(){
			return {
				"searchText": undefined
			}
		},
		
		methods: {
			/**
			 * 查询
			 */
			search: function(){
				this.$emit("search", this.searchText);
			},
			
			/**
			 * 获取查询的文字
			 */
			getSearchText: function(){
				return this.searchText;
			},
			
			/**
			 * 设置查询的文字
			 * @param {Object} value
			 */
			setSearchText: function(value){
				this.searchText = value;
			}
		},
		
		watch: {
			"searchText" : function(curVal, oldVal){
				this.$emit("valueChanged", curVal);
			}
		}
	}
</script>

<style scoped>
	button{
		background-color: #007aff;
		color: white;
	}
</style>