<!-- 搜索表单 -->
<template>
    <ele-card :body-style="{ paddingBottom: '8px' }">
        <ProSearch :items="columns" ref="searchRef" :isShowLabel="false" @search="search">
            <el-col :span="6" style="min-width: 160px">
                <el-button style="width: 80px" type="primary" plain @click="search">查询</el-button>
                <el-button style="width: 80px" type="info" @click="reset">重置</el-button>
            </el-col>
        </ProSearch>
    </ele-card>
</template>

<script setup>
    import { reactive, ref, defineEmits } from 'vue';
    import { useFormData } from '@/utils/use-form-data';
    import ProSearch from '@/components/CommonPage/ProSearch2.vue';
    import request from '@/utils/request';

    const emit = defineEmits(['search']);
    const columns = ref([
        {
            type: 'select',
            label: '复审状态',
            prop: 'reviewStatus',
            options: [
                { label: '未复审', value: '1' },
                { label: '已复审', value: '2' },
                { label: '复审终止', value: '3' }
            ]
        },
        {
            type: 'input',
            label: '用户名',
            prop: 'userName'
        },
        {
            type: 'input',
            label: '订单编号(多个以中文逗号、空格或换行分割)',
            prop: 'orderIds',
            colProps: { span: 8 }
        },
        {
            type: 'input',
            label: '物流单号(多个以中文逗号、空格或换行分割)',
            prop: 'waybillCodes',
            colProps: { span: 8 }
        },
        {
            type: 'select',
            label: '收货仓库',
            prop: 'godownId',
            options: []
        },
        {
            type: 'datetime',
            label: '提交复审时间（开始时间）',
            prop: 'applyTimeStart',
            props: {
                format: 'YYYY-MM-DD HH:mm:ss',
                valueFormat: 'YYYY-MM-DD HH:mm:ss'
            }
        },
        {
            type: 'datetime',
            label: '提交复审时间（结束时间）',
            prop: 'applyTimeEnd',
            props: {
                valueFormat: 'YYYY-MM-DD HH:mm:ss'
            }
        },
    ]);

    //获取仓库数据
    function getGodownList() {
        request.post('/baseinfo/godown/searchGodown?name=').then((res) => {
            if (res.data.code === 200) {
                let item = columns.value.find(
                    (item) => item.prop === 'godownId'
                );
                item.options = res.data.data.map((item) => ({
                    label: item.godownName,
                    value: item.id
                }));
            }
        });
    }
    getGodownList();

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

    /** 重置 */
    const reset = () => {
        resetFields();
        search();
    };
</script>
