<template>
  <div class="fire-search-container">
    <div class="search-row">
      <!-- 火情描述输入框 -->
      <div class="search-item" v-for="(items, index) in searchShowData" :key="index" >
        <label class="search-label">{{items.label}}</label>
        <el-input v-if="items.type === 'input'"
          v-model="items.content" 
          clearable
          :placeholder="items.placeholder"
        />
        <el-select v-else
          v-model="items.content" 
          :placeholder="items.placeholder"
          clearable
        >
          <el-option 
            v-for="building in items.options" 
            :key="building.value" 
            :label="building.label" 
            :value="building.value"
          />
        </el-select>
      </div>
    </div>
    <div class="operation-buttons">
        <!-- 操作按钮组 -->
      <div class="search-buttons">
        <el-button 
          type="default" 
          style="width: 45%;"
          @click="resetSearchForm"
        >
          重置
        </el-button>
        <el-button 
          type="primary" 
          style="width: 45%;"
          @click="submitSearch"
        >
          查询
        </el-button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { reactive, ref } from 'vue';
import { ElInput, ElSelect, ElOption, ElButton } from 'element-plus';

const props = defineProps(["searchShowData"])


// 提交搜索
const submitSearch = () => {
  // 搜索逻辑处理
  console.log('搜索参数:', props.searchShowData);
  // 这里可以添加API调用等实际搜索操作
};
// 定义一个重置搜索表单的函数
const resetSearchForm = () => {
    // 遍历props.searchShowData数组
    props.searchShowData.forEach(item => {
        // 将每个item的content属性置为空字符串
        item.content = ''
    })
}

</script>

<style scoped>
.fire-search-container {
  background-color: #fff;
  padding: 15px;
  border-radius: 8px;
  display: flex;
  flex-direction: row;
  gap: 15px;
  /* box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05); */
}

.search-row {
    /* background-color: #606266; */
  width: 80%;
  display: flex;
  align-items: center;
  justify-items: center;
  justify-content: space-between;
  gap: 15px;
  flex-wrap: wrap;
}

.search-item {
    /* background-color: #606266; */
  display: flex;
  align-items: center;
  flex: 1;
}


.search-label {
 
  width: 90px;
  margin-right: 8px;
  color: #606266;
  font-size: 14px;
}

/* 使用深度选择器覆盖Element Plus默认样式 */
:deep .el-input__wrapper,
:deep .el-select__wrapper {
  border-radius: 4px;
}

.search-buttons {
  display: flex;
  gap: 10px;
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  
}
.operation-buttons {
width: 20%;
padding-left: 5%;

  
}

/* 响应式适配 */
@media (max-width: 768px) {
  .search-row {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .search-buttons {
    margin-left: 0;
    margin-top: 10px;
    width: 100%;
    justify-content: flex-end;
  }
}
</style>