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

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

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

    const formItems = computed(() => {
        return [
            {
                type: 'select',
                label: '仓库名称',
                prop: 'godownId',
                options: godownList.value.map((d) => {
                    return { label: d.godownName, value: d.id };
                }),
                props: {
                    placeholder: '请选择或输入搜索仓库',
                    filterable: true
                }
            },
            { type: 'input', label: '员工姓名', prop: 'signUserName' },
            { type: 'input', label: '物流单号', prop: 'deliveryCode' },
            { type: 'input', label: '物流CODE', prop: 'expressCode' },
            {
                type: 'datetime',
                label: '签收时间(开始时间)',
                prop: 'createTimeStart',
                props: {
                    format: 'YYYY-MM-DD HH:mm:ss',
                    valueFormat: 'YYYY-MM-DD HH:mm:ss'
                }
            },
            {
                type: 'datetime',
                label: '签收时间(结束时间)',
                prop: 'createTimeEnd',
                props: {
                    format: 'YYYY-MM-DD HH:mm:ss',
                    valueFormat: 'YYYY-MM-DD HH:mm:ss'
                }
            }
        ];
    });

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

    const initKeys = reactive({
        godownId: '',
        signUserName: '',
        deliveryCode: '',
        createTimeStart: '',
        createTimeEnd: '',
        finalExpress: ''
    });

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