<template>
  <span>
    <el-button type="text" icon="el-icon-zoom-in" @click="open">高级查询</el-button>
    <el-dialog
      v-dialogDrag
      title="高级查询"
      :visible.sync="visible"
      :width="width + 'px'"
      append-to-body
    >
      <el-form
        ref="queryForm"
        :model="queryParams"
        size="small"
        :label-width="labelWidth"
      >
        <slot :model="queryParams" />
      </el-form>

      <span slot="footer">
        <el-button @click="resetQuery">重置</el-button>
        <el-button type="primary" @click.native="advQuery">查询</el-button>
      </span>
    </el-dialog>
  </span>

</template>

<script>
export default {
  props: {
    width: {
      type: [Number],
      default: 800
    },
    labelWidth: {
      type: [Number, String],
      default: 80
    }
  },
  data() {
    return {
      visible: false,
      queryParams: {}
    }
  },
  methods: {
    open() {
      this.visible = true
    },
    resetQuery() {
      this.resetForm('queryForm')
      this.queryParams = {}
      this.$emit('advQuery', {})
      this.visible = false
    },
    advQuery() {
      this.$emit('advQuery', this.queryParams)
      this.visible = false
    }
  }
}
</script>
