<template>
    <div class="app-container">
        <el-form v-show="showSearch" ref="queryForm" :model="queryParams" size="small" :inline="true"
            label-width="68px">
            <el-form-item label="学号" prop="stuNo">
                <el-input v-model="queryParams.stuNo" placeholder="请输入学号" clearable @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>
        <el-row :gutter="10" class="mb8">
            <el-col :span="1.5">
                <el-button v-hasPermi="['system:middle:export']" type="warning" plain icon="el-icon-download"
                    size="mini" @click="handleExport">导出</el-button>
                <el-col :span="1.5">
                    <el-button v-hasPermi="['system:middle:add']" type="primary" plain icon="el-icon-plus" size="mini"
                        @click="handleSync">同步数据</el-button>
                </el-col>
            </el-col>
            <right-toolbar :show-search.sync="showSearch" @queryTable="getList" />
        </el-row>

        <el-table v-loading="loading" :data="middleList">
            <el-table-column label="学生id" align="center" prop="xsid" />
            <el-table-column label="学号" align="center" prop="xh" />
            <el-table-column label="姓名" align="center" prop="xm" />
            <el-table-column label="性别" align="center" prop="xb" />
            <el-table-column label="学生状态代码" align="center" prop="sfzx" />
            <el-table-column label="学生状态名称" align="center" prop="status" />
            <el-table-column label="民族代码" align="center" prop="mz" />
            <el-table-column label="班级名称" align="center" prop="bjmc" />
        </el-table>

        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize" @pagination="getList" />
    </div>
</template>

<script>
import { listStudent} from '@/api/stuCQS/synchronous-data/sync-stu'

export default {
    name: 'Middle',
    data() {
        return {
            // 遮罩层
            loading: true,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            // 【请填写功能名称】表格数据
            middleList: [],
            // 弹出层标题
            title: '',
            // 是否显示弹出层
            open: false,
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                xqid: null,
                xndm: null,
                xqdm: null,
                stuNo: null,
                kcdm: null,
                xf: null,
                jd: null,
                cj: null,
                fzlx: null
            },
            // 表单参数
            form: {},
            // 表单校验
            rules: {
            }
        }
    },
    created() {
        this.getList()
    },
    methods: {
        /** 查询【请填写功能名称】列表 */
        getList() {
            this.loading = true
            listStudent(this.queryParams).then(response => {
                this.middleList =response.data
                console.log(response)
                this.total = response.total
                this.loading = false
            })
        },
        // 取消按钮
        cancel() {
            this.open = false
            this.reset()
        },
        // 表单重置
        reset() {
            this.form = {
                id: null,
                xqid: null,
                xndm: null,
                xqdm: null,
                stuNo: null,
                kcdm: null,
                xf: null,
                jd: null,
                cj: null,
                fzlx: null
            }
            this.resetForm('form')
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1
            this.getList()
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.resetForm('queryForm')
            this.handleQuery()
        },

        /** 导出按钮操作 */
        handleExport() {
            this.download('system/middle/export', {
                ...this.queryParams
            }, `middle_${new Date().getTime()}.xlsx`)
        },
        handleSync() {
            syncStuinfo().then(res => {
                this.$modal.msgSuccess(res.msg)
            })
        }
    }
}
</script>