| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <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 '@/views/disaster/types';
- const props = defineProps<{
- searchConfig: SearchConfig[];
- searchData: any;
- }>();
- const emit = defineEmits<{
- (e: 'update:searchData'): void;
- }>();
- const handleSearch = () => {
- emit('update:searchData');
- };
- const handleReset = () => {
- for (const key in props.searchData) {
- props.searchData[key] = '';
- }
- emit('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: 10cpx;
- &--item {
- @include flex-center;
- white-space: nowrap;
- gap: 10cpx;
- }
- span {
- color: rgba(0, 0, 0, 0.85);
- font-size: 14cpx;
- }
- .el-select {
- width: 200cpx;
- }
- }
- .search-btn {
- display: flex;
- }
- </style>
|