<!-- 搜索表单 -->
<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, computed } from 'vue';
    import ProSearch from '@/components/CommonPage/ProSearch2.vue';

    const emit = defineEmits(['search']);

    const formItems = computed(() => {
        return [
            {
                type: 'input',
                label: '审核员',
                prop: 'userName'
            },
            {
                type: 'daterange',
                label: ' ',
                prop: 'time',
                props: {
                    format: 'YYYY-MM-DD',
                    valueFormat: 'YYYY-MM-DD',
                    onChange: (value) => {
                        searchRef.value?.setData({
                            statDateStart: value ? value[0] : '',
                            statDateEnd: value ? value[1] : ''
                        });
                    }
                },
                colProps: {
                    span: 6
                }
            }
        ];
    });

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

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