<!-- 搜索表单 -->
<template>
  <el-form
    label-width="100px"
    class="ele-form-search"
    @keyup.enter.native="search(true)"
    @submit.native.prevent
  >
    <el-row :gutter="15">
      <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
        <el-form-item label="流程分类：" prop="queryParams.processTypeId">
          <ele-tree-select
            clearable
            ref="processTypeRef"
            filterable
            :data="processTypeList"
            v-model="queryParams.processTypeId"
            childrenKey="children"
            valueKey="id"
            labelKey="name"
            placeholder="请选择"
            default-expand-all
          />
        </el-form-item>
      </el-col>
      <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
        <el-form-item label="流程标识：" prop="queryParams.key">
          <el-input
            clearable
            v-model.trim="queryParams.key"
          ></el-input>
        </el-form-item>
      </el-col>
      <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
        <el-form-item label="流程名称：" prop="queryParams.name">
          <el-input
            clearable
            v-model="queryParams.name"
          ></el-input>
        </el-form-item>
      </el-col>
      <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
        <div class="ele-form-actions">
          <el-button
            type="primary"
            icon="el-icon-search"
            class="ele-btn-icon"
            @click="search(true)"
          >
            查询
          </el-button>
          <el-button @click="reset">重置</el-button>
        </div>
      </el-col>
    </el-row>
  </el-form>
</template>
<script>
  export default {
    props:{
      processTypeList:Array
    },
    data () {
      // 默认表单数据
      const defaultParams = {
        key: '',
        name: ''
      };
      return {
        defaultParams,
        // 表单数据
        queryParams: { ...defaultParams }
      };
    },
    computed: {
      // 是否开启响应式布局
      styleResponsive () {
        return this.$store.state.theme.styleResponsive;
      }
    },
    methods: {
      /* 搜索 */
      search (reset) {
        this.$emit('search', {reset: reset,
          ...this.queryParams
        });
      },
      /*  重置 */
      reset () {
        this.queryParams = { ...this.defaultParams };
        this.search(true);
      }
    }
  };
</script>
