NewbieSearch

搜索组件

Version: 1.0.0

Props

Prop nameDescriptionTypeValuesDefault
columns搜索项的配置, 详见 SearchItemConfigarray|func-() => []
disableConditions是否禁用搜索条件boolean-false
autoQuery是否在搜索条件变化时自动搜索boolean-false
gutter搜索项的间距string|number-16

Events

Event namePropertiesDescription
searchqueryForm Object - 搜索栏的值点击搜索

详细参数

SearchItemConfig 配置

Prop nameDescriptionTypeValuesDefault
key检索时的关键词string-""
title检索时的关键词的显示文案string-""
type检索类型string"input""select""date""textare""number""input"
expandable是否可展项, false 不展开, true 表示展开单选,"multiple" 表示 展开多选boolean | stringtruefalse"multiple"false
options检索项的选项Array | func-[]
inputProps输入组件的属性Object-{}
disableConditions是否禁用搜索条件boolean-false
conditions搜索项的条件,可选项为不同类型的内置条件array-[]
defaultValue搜索项的默认值any--

方法

名称参数说明
getQueryForm() => Object获取搜索栏的值
setQueryForm({key: value}) => void设置搜索栏的值

示例


搜索栏
<template>
	<Card title="搜索栏">
		<NewbieSearch ref="elem" :columns="items" @search="onSearch"></NewbieSearch>
	</Card>
</template>
<script setup>
import { ref } from "vue"
import { Card } from "ant-design-vue"

const elem = ref("")

const items = ref([
	{ title: "姓名", key: "name", type: "input", disableConditions: true },
	{ title: "学号", key: "stu_num", type: "textarea", inputProps: { style: { width: "300px" } } },
	{
		title: "审核状态",
		key: "status",
		expandable: "multiple",
		options: [
			{ label: "通过", value: "pass" },
			{ label: "未通过", value: "deny" },
			{ label: "待审核", value: "waiting" },
		],
	},

	{
		title: "性别",
		key: "gender",
		type: "select",
		expandable: true,
		options: [
			{ label: "男", value: "male" },
			{ label: "女", value: "female" },
		],
	},

	{ title: "项目金额", key: "amount", type: "number", conditions: ["equal", "notEqual"], defaultValue: [20, 0] },
	{ title: "注册日期", key: "registered_at", type: "date" },
])

const onSearch = () => {
	console.log(elem.value.getQueryForm())
}
</script>
Last Updated:
Contributors: sinceow