<!-- 搜索表单 -->
<template>
  <ele-card :body-style="{ paddingBottom: '8px' }">
    <ProSearch
      :items="formItems"
      ref="searchRef"
      @search="search"
      :initKeys="initKeys"
    ></ProSearch>

    <slot></slot>
  </ele-card>
</template>

<script setup>
  import { reactive, ref, defineEmits } from 'vue';
  import ProSearch from '@/components/CommonPage/ProSearch2.vue';

  let { proxy } = getCurrentInstance();
  const emit = defineEmits(['search']);

  const formItems = reactive([
    { type: 'input', label: '订单号', prop: 'code' },
    { type: 'input', label: '客户昵称', prop: 'nickName' },
    { type: 'dictSelect', label: '交易类型', prop: 'type' },
    { type: 'dictSelect', label: '交易状态', prop: 'status' },
    {
      type: 'date',
      label: '时间',
      prop: 'time',
      props: {
        format: 'YYYY-MM-DD',
        valueFormat: 'YYYY-MM-DD'
      }
    }
  ]);

  const initKeys = reactive({
    date: '',
    uid: '',
    status: ''
  });

  const searchRef = ref(null);
  /** 搜索 */
  const search = (data) => {
    emit('search', { ...data });
  };
</script>
