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

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

    const formItems = reactive([
        { type: 'input', label: '订单编号', prop: 'orderId' },
        { type: 'input', label: '投诉编号', prop: 'id' },
        {
            type: 'datetimerange',
            label: '投诉时间',
            prop: 'time',
            props: {
                format: 'YYYY-MM-DD HH:mm:ss',
                valueFormat: 'YYYY-MM-DD HH:mm:ss',
                onChange: (value) => {
                    searchRef.value?.setData({
                        createTimeStart: value ? value[0] : '',
                        createTimeEnd: value ? value[1] : ''
                    });
                }
            },
            colProps: { span: 6 }
        },
        {
            type: 'dictSelect',
            label: '投诉原因',
            prop: 'reason',
            props: { code: 'optimization_content' },
            colProps: { span: 3 }
        },
        {
            type: 'dictSelect',
            label: '投诉状态',
            prop: 'status',
            props: { code: 'complain_status' },
            colProps: { span: 3 }
        }
    ]);

    const initKeys = reactive({
        id: '',
        orderId: '',
        reason: '',
        time: [],
        createTimeStart: '',
        createTimeEnd: '',
        status: ''
    });

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