<template>
  <el-row>
    <!-- 搜索用表单 -->
    <search-fold-form ref="searchForm" :model="searchParams" class="search" @search="searchClick">
      <el-form-item label="操作时间" prop="timeRange">
        <el-date-picker v-model.trim="searchParams.timeRange" type="daterange" value-format="yyyy-MM-dd" align="right" range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" />
      </el-form-item>
      <el-form-item label="账号" prop="createName">
        <el-input v-model.trim="searchParams.createName" placeholder="请输入账号" clearable size="small" />
      </el-form-item>
      <el-form-item label="姓名" prop="operatorName">
        <el-input v-model.trim="searchParams.operatorName" placeholder="请输入姓名" clearable size="small" />
      </el-form-item>
      <el-form-item>
        <el-button :loading="global.loading" type="primary" @click="search"> 查询 </el-button>
        <el-button :loading="global.loading" @click="reset">重置</el-button>
      </el-form-item>
    </search-fold-form>
  </el-row>
</template>

<script>
import { deepClone } from '@/utils'
import SearchFoldForm from '@/components/SearchFoldForm/index.vue'
const defaultSearchParams = { // 搜索栏初始值
  createName: '',
  operatorName: '',
  timeRange: []
}
export default {
  inject: ['global'],
  components: { SearchFoldForm },
  props: {
    searchParams: {
      require: true,
      type: Object,
      default: () => deepClone(defaultSearchParams)
    }
  },
  data() {
    return {
    }
  },
  created() {
  },
  mounted() {
    this.$emit('search', deepClone(defaultSearchParams))
  },
  methods: {
    search() {
      this.$emit('search', this.searchParams)
    },
    reset() {
      this.$refs.searchForm.resetFields()
      this.$emit('search', deepClone(defaultSearchParams))
    }
  }
}
</script>

<style scoped>
</style>
