/*
 *@description:查询
 *@author: hudw
 *@date: 2022-03-14 11:45:54
*/
<template>
  <a-page-header class="page-header" :bordered="false" style="background-color: #fff; margin-bottom: 10px">
    <a-space slot="title">
      <span>{{ $route.meta.title }}</span>
      <p-grid-form ref="gird" layout="inline" style="font-weight: normal" @submit="submit" :items="formItems">
        <p-grid-form-item>
          <a-space>
            <p-button type="primary" icon="search" @clickSync="submit">查询</p-button>
            <p-button type="primary" @clickSync="mx_reset">重置</p-button>
          </a-space>
        </p-grid-form-item>
      </p-grid-form>
    </a-space>
    <slot />
  </a-page-header>
</template>
<script>
export default {

  name: 'search-bar',
  props: {
    adQueryUrl: {
      type: String,
    },

    options: {
      //字典
      type: Object,
    },
    count: {
      type: null,
      default: 0,
    },
    formItems: {
      type: Array,
    },
  },
  data() {
    return {
      fieldOptions: null,
      visible: false,
    }
  },
  mounted() {},
  computed: {},
  watch: {
    visible(value) {
      let mx_columns = this.$parent.$refs?.mainTable?.mx_columns
      if (value && mx_columns && !this.fieldOptions) {
        this.fieldOptions = []
        mx_columns.forEach((item) => {
          if (item.dataIndex && typeof item.title === 'string') {
            this.fieldOptions.push({ label: item.title, value: item.dataIndex })
          }
        }, this)
      }
    },
  },
  methods: {
    adQueryClick() {
      this.visible = true
    },
    getFieldsValue() {
      return this.$refs.gird.form.getFieldsValue()
    },
    mx_reset() {
      this.$refs.gird.form.resetFields()
    },
    submit(e) {
      e.preventDefault()
      let form = this.$refs.gird.form
      form.validateFields((error, value) => {
        if (error) return
        this.$emit('submit', value)
      })
    },
  },
}
</script>
<style lang="less">
.page-header {
  .ant-page-header-heading-title {
    font-size: 16px;
  }
  .ant-page-header-heading {
    height: auto;
    display: inline-block;
    overflow: visible;
  }
}
</style>


