<template>
	<div class="container">
		<Button
			v-if="!hideButton"
			icon="funnel"
			@click="btnClick"
			refs="toggleBtn"
			class="fastQuerySearch-toggle-btn"
		>{{toggle?'快速查询':'高级查询'}}</Button>
		<div style="display: inline-block;width:310px;padding-left:4px;line-height: 33px;">
			<Input
				v-model="fastqueryValue"
				:placeholder="placeholder?placeholder:'没有正确的配置占位'"
				style="width:220px;"
				clearable
				@on-keydown="keydown"
			></Input>
			<Button icon="android-search" class="fastQuerySearch-search-btn" @click="search">查询</Button>
		</div>
	</div>
</template>
<script>
import columnsFormat from "./../../hongqi-table/src/columnsFormat";
import NumberRange from "./../../hongqi-table/src/numberRange";
import fastqueryFormat from "./../../hongqi-table/src/fastqueryFormat";
export default {
	name: "FastQuerySearch",
	components: {
		NumberRange
	},
	data() {
		return {
			fastqueryValue: null,
			fastqueryParams: {}
		};
	},
	computed: {},
	methods: {
		btnClick() {
			this.$emit("btn-click");
		},
		search() {
			let params = [];
			if (!this.fastqueryValue) {
				this.$emit("on-search", []);
				return;
			}
			fastqueryFormat(
				{
					title: "综合查询",
					key: this.colunmId ? this.colunmId : "combinationCondition",
					type: "string",
					fastqueryType: "lk"
				},
				this.fastqueryValue,
				params
			);
			this.$emit("on-search", params);
		},
		keydown(event) {
			if (event.key === 'Enter') {
				this.search();
			}
		}
	},
	props: ["columns", "dicts", "toggle", "placeholder", "colunmId", "hideButton"]
};
</script>
<style lang="less" scoped>
.container {
	display: inline-flex;
	width: 400px;
	padding: 10.5px 0 10.5px 0;
	line-height: 54px;
}
</style>
