<template>
    <ie-page>
        <z-paging ref="paging" v-model="list" bg-color="#F6F8FA" safe-area-inset-bottom :scrollable="!isSorting"
                  :refresher-enabled="!isSorting" @query="handleQuery">
            <template #top>
                <ie-navbar title="志愿表"/>
            </template>
            <view class="mt-20 bg-warning-light p-28 text-23 leading-38 text-fore-title">
                <text class="font-bold">说明：</text>
                目前志愿计划为2025年，排序前两个为第一、二志愿，可通过修改排序重新选择第一、二志愿
            </view>
            <view class="p-28 flex flex-col gap-28">
                <voluntary-item v-for="(item,i) in list" :key="i" :data="item" :index="i"/>
            </view>
        </z-paging>
    </ie-page>
</template>

<script setup lang="ts">
import {VoluntaryRecord} from "@/types/voluntary";
import VoluntaryItem from "@/pagesOther/pages/voluntary/list/components/voluntary-item.vue";
import {sleep} from "@/uni_modules/uv-ui-tools/libs/function";
import {ApiResponseList} from "@/types";
import {VOLUNTARY_SORTING} from "@/types/injectionSymbols";

const list = ref<VoluntaryRecord>([])
const paging = ref<ZPagingInstance>()
const isSorting = ref<boolean>(false)

const handleQuery = async () => {
    await sleep()
    const res: ApiResponseList<VoluntaryRecord> = {
        code: 200,
        msg: '',
        total: 2,
        rows: [{
            id: 1,
            universityId: "20949",
            universityLogo: "https://mingxuejingbang.oss-cn-beijing.aliyuncs.com/ie/universityLog/23b6da550a584ea6b60886c6ae97b610.jpg",
            universityName: "湖南铁道职业技术学院",
            majors: [{
                majorAncestors: "交通运输大类>铁道运输类",
                majorId: "68526",
                majorName: "铁道交通运营管理1",
                majorGroup: '专业组一',
            }, {
                majorAncestors: "交通运输大类>铁道运输类",
                majorId: "68527",
                majorName: "铁道交通运营管理2",
                majorGroup: '专业组一',
            }, {
                majorAncestors: "交通运输大类>铁道运输类",
                majorId: "68528",
                majorName: "铁道交通运营管理3",
                majorGroup: '专业组一',
            }, {
                majorAncestors: "交通运输大类>铁道运输类",
                majorId: "68529",
                majorName: "铁道交通运营管理4",
                majorGroup: '专业组一',
            }, {
                majorAncestors: "交通运输大类>铁道运输类",
                majorId: "68530",
                majorName: "铁道交通运营管理5",
                majorGroup: '专业组一',
            }, {
                majorAncestors: "交通运输大类>铁道运输类",
                majorId: "68531",
                majorName: "铁道交通运营管理6",
                majorGroup: '专业组一',
            }, {
                majorAncestors: "交通运输大类>铁道运输类",
                majorId: "68532",
                majorName: "铁道交通运营管理7",
                majorGroup: '专业组一',
            }]
        }, {
            id: 2,
            universityId: "20949",
            universityLogo: "https://mingxuejingbang.oss-cn-beijing.aliyuncs.com/ie/universityLog/23b6da550a584ea6b60886c6ae97b610.jpg",
            universityName: "湖南铁道职业技术学院",
            majors: [{
                majorAncestors: "交通运输大类>铁道运输类",
                majorId: "68526",
                majorName: "铁道交通运营管理1",
                majorGroup: '专业组一',
            }, {
                majorAncestors: "交通运输大类>铁道运输类",
                majorId: "68527",
                majorName: "铁道交通运营管理2",
                majorGroup: '专业组一',
            }, {
                majorAncestors: "交通运输大类>铁道运输类",
                majorId: "68528",
                majorName: "铁道交通运营管理3",
                majorGroup: '专业组一',
            }, {
                majorAncestors: "交通运输大类>铁道运输类",
                majorId: "68529",
                majorName: "铁道交通运营管理4",
                majorGroup: '专业组一',
            }, {
                majorAncestors: "交通运输大类>铁道运输类",
                majorId: "68530",
                majorName: "铁道交通运营管理5",
                majorGroup: '专业组一',
            }, {
                majorAncestors: "交通运输大类>铁道运输类",
                majorId: "68531",
                majorName: "铁道交通运营管理6",
                majorGroup: '专业组一',
            }, {
                majorAncestors: "交通运输大类>铁道运输类",
                majorId: "68532",
                majorName: "铁道交通运营管理7",
                majorGroup: '专业组一',
            }]
        }, {
            id: 3,
            universityId: "20949",
            universityLogo: "https://mingxuejingbang.oss-cn-beijing.aliyuncs.com/ie/universityLog/23b6da550a584ea6b60886c6ae97b610.jpg",
            universityName: "湖南铁道职业技术学院",
            majors: [{
                majorAncestors: "交通运输大类>铁道运输类",
                majorId: "68526",
                majorName: "铁道交通运营管理1",
                majorGroup: '专业组一',
            }, {
                majorAncestors: "交通运输大类>铁道运输类",
                majorId: "68527",
                majorName: "铁道交通运营管理2",
                majorGroup: '专业组一',
            }, {
                majorAncestors: "交通运输大类>铁道运输类",
                majorId: "68528",
                majorName: "铁道交通运营管理3",
                majorGroup: '专业组一',
            }, {
                majorAncestors: "交通运输大类>铁道运输类",
                majorId: "68529",
                majorName: "铁道交通运营管理4",
                majorGroup: '专业组一',
            }, {
                majorAncestors: "交通运输大类>铁道运输类",
                majorId: "68530",
                majorName: "铁道交通运营管理5",
                majorGroup: '专业组一',
            }, {
                majorAncestors: "交通运输大类>铁道运输类",
                majorId: "68531",
                majorName: "铁道交通运营管理6",
                majorGroup: '专业组一',
            }, {
                majorAncestors: "交通运输大类>铁道运输类",
                majorId: "68532",
                majorName: "铁道交通运营管理7",
                majorGroup: '专业组一',
            }]
        }]
    }
    paging.value?.completeByTotal(res.rows, res.total)
}

provide(VOLUNTARY_SORTING, isSorting)
</script>

<style lang="scss">

</style>
