<!--
 * @Author: chris
 * @Date: 2026-01-06 11:50:02
 * @LastEditors: chris
 * @LastEditTime: 2026-01-15 17:52:16
-->
<script setup>
const defaultQueryParams = {
  dateRange: [],
}

const queryRef = ref(null)

const queryParams = ref({
  dateRange: [],
})

const emits = defineEmits(['export', 'query', 'reset'])

function handleQuery () {
  emits('query', {
    beginTime: queryParams.value.dateRange[0],
    endTime: queryParams.value.dateRange[1],
  })
}

function handleReset () {
  queryParams.value = {...defaultQueryParams}
  queryParams.value.dateRange = []
  emits('reset', queryRef.value)
}

function handleExport () {
  console.log('export', queryRef)
  emits('export', queryRef.value)
}
</script>

<template>
  <el-form :model="queryParams" ref="queryRef" :inline="true" label-width="68px">
    <el-form-item label="记录时间">
      <el-date-picker 
        style="width: 300px"
        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="handleExport">导出</el-button>
      <el-button icon="Refresh" @click="handleReset">重置</el-button>
    </el-form-item>
  </el-form>
</template>
