1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <template>
- <el-card v-loading="loading" shadow="never" class="search-wrapper">
- <el-form ref="searchFormRef" :inline="true" :model="searchForm">
- <el-form-item :prop="item.field" :label="item.label" v-for="(item, index) in searchList" :key="index">
- <el-input v-model="searchForm[`${item.field}`]" :placeholder="item.placeholder" />
- </el-form-item>
- <el-form-item>
- <el-button type="primary" :icon="Search" @click="handleSearch">查询</el-button>
- <el-button :icon="Refresh" @click="resetSearch">重置</el-button>
- </el-form-item>
- </el-form>
- </el-card>
- </template>
- <script setup lang="ts">
- import { shallowRef, ref, watch } from "vue"
- import { Search, Refresh, CirclePlus, Delete, Download, RefreshRight } from "@element-plus/icons-vue"
- import { type FormInstance, type FormRules, ElMessage, ElMessageBox } from "element-plus"
- const loading = ref<boolean>(false)
- const props = defineProps({
- searchTerms: {
- type: Array,
- default() {
- return []
- }
- },
- ruleForm: {
- type: Object,
- default() {
- return {}
- }
- },
- })
- const searchList: any = shallowRef(props.searchTerms)
- const searchForm: any = shallowRef(props.ruleForm)
- const emit = defineEmits(['handleSearch']);
- // 搜索
- const handleSearch = () => {
- emit('handleSearch');
- }
- const searchFormRef = shallowRef<FormInstance | null>(null)
- // 重置
- const resetSearch = () => {
- searchFormRef.value?.resetFields()
- handleSearch()
- }
- </script>
- <style lang="scss" scoped>
- .search-wrapper {
- margin-bottom: 20px;
- :deep(.el-card__body) {
- padding-bottom: 2px;
- }
- }
- </style>
|