<!-- 搜索表单 -->
<template>
    <ele-card :body-style="{ paddingBottom: '8px' }">
        <ProSearch
            :items="formItems"
            ref="searchRef"
            @search="search"
            :initKeys="initKeys"
            :offset="1"
        />
    </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: '拆包员',
                prop: 'signUserName'
            },
            {
                type: 'daterange',
                label: ' ',
                prop: 'time',
                props: {
                    format: 'YYYY-MM-DD',
                    valueFormat: 'YYYY-MM-DD',
                    onChange: (value) => {
                        initKeys.statDateStart = value ? value[0] : '';
                        initKeys.statDateEnd = value ? value[1] : '';
                        searchRef.value?.setData(initKeys);
                    }
                },
                colProps: {
                    span: 6
                }
            }
        ];
    });

    const initKeys = reactive({
        statDateStart: '',
        statDateEnd: '',
        signUserName: ''
    });

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