/*
 *@description:查询
 *@author: hudw
 *@date: 2022-03-14 11:45:54
*/
<template>
  <a-page-header class="page-header" :title="$route.meta.title" :bordered="false" style="background-color: #fff; margin-bottom: 10px">
    <p-grid-form ref="gird" :span="6" :layout="$attrs.layout" style="font-weight: normal" :labelCol="{ span: 9 }" :wrapperCol="{ span: 14 }" @submit="submit" :items="mx_queryFromItems" />
    <a-space v-if="count != 3" slot="extra">
      <p-button type="primary" icon="search" @clickSync="submit">查询</p-button>
      <p-button type="primary" @clickSync="mx_reset">重置</p-button>
      <!-- <p-button type="primary" @click="adQueryClick">高级查询</p-button> -->
    </a-space>
    <!-- <advancedQueryModel :fieldOptions="fieldOptions||[]" :bizType="bizType" :adQueryUrl="adQueryUrl" :visible.sync="visible" /> -->
  </a-page-header>
</template>
<script>
import { setQueryFormItmes, bizTypeObj } from './formConfig'
// import advancedQueryModel from '@/blocks/components/advancedQueryModel/index.vue'
export default {
  components: {
   // advancedQueryModel,
  },
  name: 'search-bar',
  props: {
    adQueryUrl: {
      type: String,
    },

    options: {
      //字典
      type: Object,
    },
    count: {
      type: null,
      default: 0,
    },
    fromItems: {
      type: Array,
    },
  },
  data() {
    let bizType = this.$route.meta.title
    bizType = bizTypeObj[bizType]
    return {
      fieldOptions: null,
      bizType,
      visible: false,
      mx_queryFromItems:this.fromItems?this.fromItems: setQueryFormItmes(this, this.count),
    }
  },
  mounted() {},
  computed: {

  },
  watch: {
    fromItems(arr) {
      this.mx_queryFromItems=arr
    },
    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)
      }
    },

    count(value) {
      this.mx_queryFromItems =this.fromItems?this.fromItems: setQueryFormItmes(this, value)
    },
  },
  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;
  }
}
</style>


