<!-- 搜索表单 -->
<template>
  <ele-card :body-style="{ paddingBottom: '8px' }">
    <ProSearch
      :items="formItems"
      ref="searchRef"
      @search="search"
      :initKeys="initKeys"
      :offset="1"
    ></ProSearch>
  </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 godownList = ref([]);
  const formItems = computed(() => {
    return [
      { type: 'input', label: 'ISBN', prop: 'isbn' },
      { type: 'input', label: '审核员', prop: 'auditName' },
      { type: 'input', label: '录入员', prop: 'auditName' },
      {
        type: 'datetimerange',
        label: ' ',
        prop: 'time',
        props: {
          format: 'YYYY-MM-DD HH:mm:ss',
          valueFormat: 'YYYY-MM-DD HH:mm:ss',
          onChange: (value) => {
            initKeys.startTime = value ? value[0] : '';
            initKeys.endTime = value ? value[1] : '';
            searchRef.value?.setData(initKeys);
          }
        },
        colProps: {
          span: 6
        }
      }
    ];
  });

  const initKeys = reactive({
    startTime: '',
    endTime: '',
    godownId: ''
  });

  function getStoreList(name = '') {
    return proxy.$http.post(`/baseinfo/godown/searchGodown?name=${name}`);
  }
  getStoreList().then((res) => {
    godownList.value = res.data.data;
  });

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