<!--简易搜索框-->
<template>
  <search-area :need-clear="true" :need-search-more="false" type="seperate" size="small" @search="search" @clear="clearInput">
    <!--<el-form ref="searchForm" :inline="true" :model="listQuery.queryCondition" class="form-container">-->
    <!--<el-row>-->
    <search-item>
      <el-input v-model="listQuery.caseid" clearable placeholder="案卷编号"/>
    </search-item>
    <search-item>
      <el-input v-model="listQuery.description" clearable placeholder="案卷描述"/>
    </search-item>
    <search-item>
      <el-select v-model="listQuery.source" clearable placeholder="请选择信息来源">
        <el-option
          v-for="item in caseSourceList"
          :key="item.value"
          :label="item.name"
          :value="item.value"
        />
      </el-select>
    </search-item>
    <search-item>
      <el-select v-model="listQuery.eorc" clearable placeholder="请选择案卷类别">
        <el-option
          v-for="item in caseTypeList"
          :key="item.value"
          :label="item.name"
          :value="item.value"
        />
      </el-select>
    </search-item>
    <!--<el-form-item>-->
      <!--<el-button type="primary" @click="search">查询</el-button>-->
      <!--<el-button @click="openSearchMore">高级检索</el-button>-->
    <!--</el-form-item>-->
    <!--</el-row>-->
    <!--</el-form>-->
    <!--<search-more v-show="searchMoreShow" ref="searchMore" @searchMore="searchMore"/>-->
  </search-area>
</template>

<script>
import { getCaseSourceList, getCaseTypeList } from '@/api/seo/seo'
import SearchMore from './searchMore'

export default {
  name: 'SearchDiv',
  components: { SearchMore },
  props: {
    listQuery: {
      type: Object,
      default() {
        return {
          caseid: '',
          description: '',
          source: '',
          eorc: '',
          offset: 1,
          limit: 10,
          sort: '',
          order: ''
        }
      }
    }
  },
  data() {
    return {
      searchMoreShow: false, // 高级检索弹窗是否显示
      caseSourceList: [], // 信息来源列表
      caseTypeList: [] // 案卷类别列表
    }
  },
  mounted() {
    this.getCaseSource()
    this.getCaseType()
  },
  methods: {
    // 获取案卷来源列表
    getCaseSource() {
      getCaseSourceList().then(response => {
        this.caseSourceList = response.data
      })
    },
    // 获取案卷类别
    getCaseType() {
      getCaseTypeList().then(response => {
        this.caseTypeList = response.data
      })
    },
    // 查询条件
    search() {
      this.listQuery.offset = 1
      this.$emit('searchForm', this.listQuery)
    },
    clearInput() {
      this.listQuery = {
        offset: 1,
        limit: 10,
        sort: '',
        order: ''
      }
      this.$emit('searchForm', this.listQuery)
    },
    // 执行高级查询
    searchMore(listQuery) {
      this.$emit('searchForm', listQuery)
    },
    openSearchMore() {
      this.searchMoreShow = true
      this.$refs.searchMore.initDialog(this.searchMoreShow)
    }
  }
}
</script>

<style scoped>
  .search-div{
    /* padding-top: 50px; */
    /* padding-bottom: -40px; */
    /*margin-top: 20px;*/
    /*margin-left: 20px;*/
  }
  .el-form-item {
    margin-bottom: 5px !important;
  }
</style>
