<!--
 * @Author: chris
 * @Date: 2025-08-18 09:27:23
 * @LastEditors: chris
 * @LastEditTime: 2025-08-18 17:18:54
-->
<script setup>
const props = defineProps({
  params: {
    type: Object,
    default: () => ({
      deviceId: null,
      dateRange: []
    })
  }
})

const emits = defineEmits(['update:params'])

const queryRef = ref()
const queryParams = reactive({...props.params});
const pestOpts = ref([])

watch(() => queryParams, (newVal) => {
  emits('update:params', newVal)
})

watch(() => props.params, (newVal) => {
  Object.assign(queryParams, newVal)
})

function resetQuery() {
  emits('reset')
}

function handleQuery() {
  emits('query')
}

function exportData() {
  emits('export')
}
</script>

<template>
  <el-form :model="queryParams" ref="queryRef" :inline="true" label-width="68px">
    <el-form-item label="创建时间">
      <el-date-picker 
        style="width: 240px"
        v-model="queryParams.dateRange"
        value-format="YYYY-MM-DD"
        type="daterange"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
      ></el-date-picker>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
      <el-button type="warning" icon="Download" @click="exportData">导出</el-button>
      <el-button icon="Refresh" @click="resetQuery">重置</el-button>
    </el-form-item>
  </el-form>
</template>

<style lang="scss" scoped>
</style>
