<template>
  <div>
    <el-form label-width="80px" class="ele-form-search" @keyup.enter.native="search" @submit.native.prevent>
      <el-row :gutter="15">

        <el-col v-bind="styleResponsive ? { lg: 5, md: 12 } : { span: 5 }">
          <el-form-item label="计划名称:">
            <el-input clearable v-model="where.name" placeholder="请输入" />
          </el-form-item>
        </el-col>
<!--        <el-col></el-col>-->
        <el-col v-bind="styleResponsive ? { lg: 4, md: 12 } : { span: 4 }">
          <div class="ele-form-actions">
            <el-button type="primary" icon="el-icon-search" class="ele-btn-icon" @click="search">
              查询
            </el-button>
            <el-button @click="reset" icon="el-icon-refresh-left" type="primary">重置</el-button>
          </div>
        </el-col>

      </el-row>
    </el-form>
  </div>
</template>

<script>
export default {
  components: {

  },
  data() {
    const defaultWhere = {
      releaseTime: [],
      deliveryTime: [],
      createTime: []
    };
    return {
      where: { ...defaultWhere },
    }
  },
  computed: {
    // 是否开启响应式布局
    styleResponsive() {
      return this.$store.state.theme.styleResponsive;
    }
  },
  methods: {
    search() {
      const where = { ...this.where };

      for (const key in where) {
        if (Array.isArray(where[key]) && where[key].length) {
          where[`${key}Start`] = where[key][0];
          where[`${key}End`] = where[key][1];
        }
      }
      delete where.releaseTime;
      delete where.deliveryTime;
      delete where.createTime;

      this.$emit('search', where);
    },
    /*  重置 */
    reset() {
      this.where = { ...this.defaultWhere };
      this.search();
    }
  }
}
</script>

<style scoped lang="scss">

</style>
