<!-- 搜索表单 -->
<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';

    let { proxy } = getCurrentInstance();
    const emit = defineEmits(['search']);

    const formItems = reactive([
        { type: 'input', label: '书名', prop: 'bookName' },
        { type: 'input', label: '条码', prop: 'isbn' },
        { type: 'input', label: '作者', prop: 'author' },
        { type: 'input', label: '出版社', prop: 'publish' },
        {
            type: 'dictSelect',
            label: '人工核实',
            prop: 'perCheck',
            props: { code: 'is_common_yes' }
        },
        {
            type: 'dictSelect',
            label: '是否套装',
            prop: 'suit',
            props: { code: 'is_common_yes' }
        },
        {
            type: 'select',
            label: '信息缺失',
            prop: 'emptyType',
            props: {
                multiple: true,
                clearable: true,
                collapseTags: true
            },
            options: [
                { label: '图片', value: 1 },
                { label: '书名', value: 2 },
                { label: '作者', value: 3 },
                { label: '出版社', value: 4 },
                { label: '出版时间', value: 5 }
            ]
        }
    ]);

    const initKeys = reactive({
        schoolName: '',
        provinceId: '',
        cityId: '',
        schoolLevel: '',
        departmentName: '',
        shcoolTag: '',
        emptyType: []
    });

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