<template>
    <LeftNav />
    <div class="main-container wrap main-fullScreen main-div" style="height: unset;">
        <el-row :gutter="20">
            <!--  左侧 院校列表-->
            <el-col :xs="12" :sm="12">
                <el-card class="box-card">
                    <div class="filterTable">
                        <div class="filterTitle flexWrap">
                            <div class="flex-item-75">
                                <div class="searchSchool">
                                    <el-input v-model="state.selectForm.schoolName" maxlength="24" show-word-limit
                                        style="max-width: 230px;height: 40px;line-height: 40px;"
                                        placeholder="请输入院校或专业名称" class="input-with-select" />
                                    <el-button :icon="Search" @click="reloadSchoolList"
                                        style="border-left: none;height: 40px;line-height: 40px;" />
                                </div>
                            </div>
                        </div>
                    </div>
                    <el-divider />
                    <!--clearable-->
                    <div class="schoolList">
                        <div class="schoolItem" v-for="item in state.schoolList"
                            @click="showSchoolInfo(item.schoolCode)">
                            <div class="schoolLogo">
                                <img :src="item.schoolIcon"
                                    v-if="item.schoolIcon != null && item.schoolIcon != undefined" />
                                <img v-else src="@/assets/images/school/school_default.png">
                            </div>
                            <div class="schoolInfo">
                                <div class="schoolTitle">
                                    <h3 class="schoolName">
                                        {{ item.schoolName }}
                                        <span class="province" v-if="item.province">{{ item.province }}{{ item.city }}{{
                                            item.area }}</span>
                                    </h3>
                                </div>
                                <div class="schoolTags">
                                    <span v-for="tag in item.tagsList">{{ tag }}</span>
                                </div>
                            </div>
                        </div>
                    </div>
                    <el-skeleton :loading="state.loading" style="padding-top: 25px;"></el-skeleton>
                    <div class="page">
                        <el-pagination background @current-change="handlePage" :current-page="state.current"
                            :page-size="state.size" :total="state.total" layout="total, prev, pager, next,jumper" />
                    </div>
                </el-card>
            </el-col>
            <!--  右侧 功能广告-->
            <el-col :xs="12" :sm="12">
                <div class="page-right" style="width: 300px">
                    选择左侧院校
                </div>
            </el-col>
        </el-row>

    </div>
</template>

<script setup lang="ts">
import { reactive } from 'vue'
import apiConstant from "@/utils/ApiConstant";
import axiosInstance from '@/utils/http';
import { SchoolEntity } from "@/types";
import { Search } from '@element-plus/icons-vue';
import LeftNav from "@/components/LeftNav.vue";
import StaticConstant from '@/utils/StaticConstant';
document.title = '找大学|' + import.meta.env.VITE_PROGRAM_TYPE;
//激活的tabs页
const state = reactive({
    selectForm: {
        schoolName: '',
        current: 1,
        pageSize: 10,
    } as any,
    schoolList: [] as Array<SchoolEntity>,
    size: 10,
    total: 0,
    current: 1,
    loading: false,//加载中? true 加载/false 关闭
})


getSchoolList()

//获取学校列表
function getSchoolList() {
    state.loading = true;
    state.schoolList = []
    axiosInstance({
        url: apiConstant.School.searchSchoolList,
        method: 'get',
        params: {
            schoolName: state.selectForm.schoolName,
            pageNum: state.selectForm.current,
            pageSize: state.selectForm.pageSize,
            addressList: state.selectForm.addressList,
            tagsList: state.selectForm.tagsList,
            schoolNatureList: state.selectForm.schoolNatureList
        },
        showLoading: false,//是否显示加载图标
    }).then((response) => {
        return response?.data
    }).then((data) => {
        state.loading = false;
        if (data.success) {

            let dataResult = data.result
            console.log(dataResult)
            let tags = []
            if (dataResult.records != null && dataResult.records != undefined) {
                for (let i = 0; i < dataResult.records.length; i++) {
                    tags = []
                    let dre = dataResult.records[i]
                    if (dataResult.records[i].tagsList != null && dataResult.records[i].tagsList != undefined) {
                        tags.push(...dre.tagsList)
                    }
                    dataResult.records[i].tagsList = tags
                }
            }
            state.schoolList = dataResult.records
            state.selectForm.current = data.result.current
            state.selectForm.pageSize = data.result.size
            state.total = data.result.total
        }
    }).catch((error: any) => {
        console.log(error);
    }).finally(() => {
    });
}

function reloadSchoolList() {
    state.selectForm.current = 1
    state.schoolList = []
    getSchoolList()
}

const handlePage = (page: number) => {
    if (page) {
        state.selectForm.current = page
        getSchoolList()
    }
}

const showSchoolInfo = (schoolCode: string) => {
    window.open(schoolCode, '_self')
}

</script>

<style scoped lang="scss">
//标签页样式
.demo-tabs>.el-tabs__content {
    padding: 32px;
    color: #6b778c;
    font-size: 32px;
    font-weight: 600;
}

//自定义输入框 样式
/** 默认样式 */
.input-border-style {
    border: 1px solid #eee !important;
    border-radius: 6px !important;
}

:deep(.el-input__wrapper) {
    background: none !important;
}
</style>

<!--学校列表-->
<style scoped lang="scss">
.schoolList {
    .schoolItem:hover {
        color: #3491FA
    }

    .schoolItem:last-child {
        border-bottom: none;
    }

    .schoolItem {
        display: flex;
        justify-content: flex-start;
        align-items: center;
        padding: 20px;
        cursor: pointer;
        border-bottom: 1px solid #eee;
        position: relative;

        .schoolLogo {
            margin-right: 20px;

            img {
                width: 60px;
                height: 60px;
            }
        }

        .schoolInfo {
            .schoolTitle {
                margin-bottom: 18px;

                .schoolName {
                    color: #333;
                    font-size: 18px;
                    height: 25px;
                    line-height: 25px;
                    margin: 0 20px 0 0;
                    transition: all .3s;
                    display: flex;
                    align-items: center;

                    .province {
                        height: 26px;
                        line-height: 24px;
                        font-size: 12px;
                        border: 1px solid #eee;
                        color: #555;
                        display: inline-block;
                        padding: 0 10px;
                        margin: 0 20px 0 15px;
                    }
                }

                .schoolName:hover {
                    color: #3491FA
                }
            }

            .schoolTags {
                span {
                    display: inline-block;
                    color: #555;
                    padding-right: 10px;
                    margin-right: 10px;
                    border-right: 1px solid #c5c5c5;
                    line-height: 15px;
                }

                span:last-child {
                    border: none;
                }
            }
        }
    }
}

.page-right {
    .box-card {
        border-radius: 12px;
    }

    .card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        color: red;
    }

    :deep(.el-card__header) {
        padding: 6px 12px 12px 12px;
        background-color: #4cc8ff;
        height: 30px;

        span {
            width: 100px;
            height: 16px;
            background-size: cover;
            background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALMAAAAfCAYAAACsyvxmAAAAAXNSR0IArs4c6QAADYhJREFUeF7lnOuxJMURhbssEFggsEDCArEWSGuBWAsEFggsEFggsIDFAoEFLBZosUB4UIqvIrPidHbWo2fuD0VoIjb2xkxPPbJOnnzWlCN51Vo/Oo7jX8dx8P+bUsq38bFa61+O4/jncRwfHMfxqpTyoz9Ta/37cRxfHsfx/jiOT0opv2XzJGPqvD+WUl7JmMzD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oEhP02JxilaU/pq3tXnAczLtdn5qsLNblL7rX/qGC2HnsQapxjG3Al89yHepK0UMF/vALo/+kyFaSW4//fPvRflf00Oj7S3PvKdhc8+/YXXlcz+C9FpdooHgy/tAAAAAElFTkSuQmCC);
        }
    }

    .item {
        border-radius: 12px;

    }

    :deep(.el-card__body) {
        padding: 0;
    }
}
</style>