<!-- 搜索表单 -->
<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: 'input',
            label: '投诉原因',
            prop: 'reason',
            colProps: { span: 4 }
        },
        {
            type: 'select',
            label: '投诉状态',
            prop: 'status',
            options: [
                { label: '待处理', value: '1' },
                { label: '处理中', value: '2' },
                { label: '已完结', value: '3' }
            ],
            colProps: { span: 4 }
        }
    ]);

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

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