<!-- 搜索表单 -->
<template>
  <el-form
    label-width="100px"
    class="ele-form-search"
    @keyup.enter.native="search"
    @submit.native.prevent
  >
    <el-row :gutter="15">
      <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
        <el-form-item label="工单单号:">
          <el-input clearable v-model="where.code" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="巡点检人员:">
          <el-input
            clearable
            v-model="where.executeUserName"
            placeholder="请输入"
          />
        </el-form-item>
      </el-col>
      <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
        <el-form-item label="计划单号:">
          <el-input clearable v-model="where.planCode" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="状态:">
          <DictSelection
            dictName="巡点检工单状态"
            clearable
            v-model="where.orderStatus"
          >
          </DictSelection>
        </el-form-item>
      </el-col>
      <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
        <el-form-item label="巡点检名称:">
          <el-input clearable v-model="where.planName" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="设备分类:">
          <equipmentSelect v-model="where.categoryLevelId" />
        </el-form-item>
      </el-col>
      <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
        <el-form-item label="巡点检部门:">
          <deptSelect v-model="where.groupId" />
        </el-form-item>
        <el-form-item label="规则名称:">
          <el-input clearable v-model="where.name" placeholder="请输入" />
        </el-form-item>
        <div class="ele-form-actions">
          <el-button
            type="primary"
            icon="el-icon-search"
            class="ele-btn-icon"
            @click="search"
            size="small"
          >
            查询
          </el-button>
          <el-button
            @click="reset"
            icon="el-icon-refresh-left"
            size="small"
            type="primary"
            >重置</el-button
          >
        </div>
      </el-col>
    </el-row>
  </el-form>
</template>

<script>
  import equipmentSelect from '@/components/CommomSelect/equipment-select.vue';
  import deptSelect from '@/components/CommomSelect/dept-select.vue';
  import personSelect from '@/components/CommomSelect/person-select.vue';
  export default {
    components: { equipmentSelect, deptSelect, personSelect },
    data () {
      // 默认表单数据
      const defaultWhere = {
        name: '',
        executeUserName: '',
        planCode: '',
        code: '',
        orderStatus: '',
        groupId: '',
        categoryLevelId: '',
        planName: ''
      };
      return {
        // 表单数据
        where: { ...defaultWhere },
        treeData: []
      };
    },
    computed: {
      // 是否开启响应式布局
      styleResponsive () {
        return this.$store.state.theme.styleResponsive;
      }
    },
    created () {},
    methods: {
      /* 搜索 */
      search () {
        console.log(this.where);
        this.$emit('search', this.where);
      },
      /*  重置 */
      reset () {
        this.where = { ...this.defaultWhere };
        this.search();
      }
    }
  };
</script>
<style lang="scss" scoped>
  .ele-form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }
</style>
