<template>
  <div class="search">
    <el-form :inline="true" :model="searchParams" size="small">
      <el-form-item label="产业链名称">
        <el-select v-model="searchParams.categoryId">
          <el-option
            v-for="(item, index) of dataList"
            :key="index"
            :label="item.name"
            :value="item.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="类型">
        <el-select v-model="searchParams.type ">
          <el-option
            v-for="(item, index) of quotaList"
            :key="index"
            :label="item.quota"
            :value="item.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="考核内容:">
        <el-input
          placeholder="请输入考核内容"
          clearable
          v-model="searchParams.content"
        ></el-input>
      </el-form-item>
      <el-button type="primary" size="small" @click="search">查询</el-button>
      <el-button
        type="default"
        size="small"
        @click="
          clear();
          search();
        "
        >清空</el-button
      >
      <el-button style="margin-left: 20px" size="small" type="warning" v-if="showExport" @click="emitExport">导出</el-button>
    </el-form>
    
  </div>
</template>

<script>
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import Treeselect from "@riophae/vue-treeselect"; // 下拉树
import { mapGetters, mapActions } from "vuex";
import api from '@/api/chain/assessmentContent'
export default {
  props: {
    showExport:{
      type:Boolean,
      default(){
        return false;
      }
    }
  },
  components: {
    Treeselect,
  },
  data() {
    return {
      searchParams: {
        categoryId: "",
        type: "",
        content: "",
      },
      quotaList: [
        { id: 1, quota: "重点指标" },
        { id: 2, quota: "重点任务" },
        { id: 3, quota: "加减分考核" },
      ],
      dataList: []
    };
  },
  created() {
    this.getDepartment(1);
    this.getDataList();
  },
  methods: {
    ...mapActions({
      getDepartment: "base/getDepartment",
    }),
    clear() {
      this.searchParams = {
        quota: "",
        content: "",
        department: "",
      };
    },
    search() {
      this.$emit("search:task", this.searchParams);
    },
    emitExport(){
      this.$emit('export',this.searchParams)
    },
    getDataList() {
      api.getList(Object.assign({},this.searchParams)).then(res=>{
        let data = res.data.data
        this.dataList = data
      }).catch(e=>{
        this.dataList=[];
      }).finally(()=>{
        this.loading=false;
      })
    },
  },
  computed: {
    ...mapGetters(["formatDep"]),
  },
};
</script>

<style scoped>
</style>