| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <template>
- <div class="search-box">
- <section class="select-box">
- <div class="select-box--item" v-for="item in searchConfig" :key="item.prop">
- <span>{{ item.label }}</span>
- <template v-if="item.slot">
- <slot :name="item.slot" />
- </template>
- <template v-else>
- <component :is="item.component" v-model="searchData[item.prop]" v-bind="item.componentProps">
- <el-option
- v-for="option in item.selectOptions"
- :key="option.value"
- :label="option.label"
- :value="option.value"
- />
- </component>
- </template>
- </div>
- </section>
- <section class="search-btn">
- <el-button type="primary" @click="handleSearch">查询</el-button>
- <el-button @click="handleReset">重置</el-button>
- </section>
- </div>
- </template>
- <script lang="ts" setup>
- import type { SearchConfig } from '@/types/basic-search';
- const props = defineProps<{
- searchConfig: SearchConfig[];
- searchData: any;
- customReset?: boolean;
- }>();
- const emits = defineEmits<{
- (e: 'update:searchData'): void;
- (e: 'custom-reset'): void;
- }>();
- const handleSearch = () => {
- emits('update:searchData');
- };
- const handleReset = () => {
- if (props.customReset) {
- emits('custom-reset');
- return;
- }
- for (const key in props.searchData) {
- props.searchData[key] = null;
- }
- emits('update:searchData');
- };
- </script>
- <style lang="scss" scoped>
- .search-box {
- @include flex-center;
- justify-content: space-between;
- width: 100%;
- }
- .select-box {
- display: flex;
- align-items: center;
- flex-wrap: wrap;
- gap: 32px;
- &--item {
- @include flex-center;
- white-space: nowrap;
- }
- span {
- color: rgba(0, 0, 0, 0.85);
- font-size: 14px;
- }
- .el-select {
- width: 200px;
- }
- }
- .search-btn {
- display: flex;
- }
- </style>
|