<template>
  <el-row>
    <!-- 搜索用表单 -->
    <search-fold-form ref="searchForm" :model="searchParams" class="search" @search="searchClick">
      <el-form-item label="企业名称" prop="name">
        <el-input v-model.trim="searchParams.name" placeholder="请输入企业名称" clearable size="small" />
      </el-form-item>
      <el-form-item label="企业账号" prop="userName">
        <el-input v-model.trim="searchParams.userName" placeholder="请输入企业账号" clearable size="small" />
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-select v-model.trim="searchParams.status">
          <el-option value="" label="全部" />
          <el-option v-for="(item, index) in Object.entries(global.dict.status).map(([id, name]) => ({ id, name }))" :key="index" :label="item.name" :value="item.id" />
        </el-select>
      </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 SearchFoldForm from '@/components/SearchFoldForm/index.vue'
import { deepClone } from '@/utils'
const defaultSearchParams = { // 搜索栏初始值
  name: '',
  userName: '',
  status: ''
}
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>
