|
@@ -0,0 +1,129 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<html lang="en">
|
|
|
+
|
|
|
+<head>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <title>云阅卷本地代理工具</title>
|
|
|
+ <meta name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
|
|
|
+ <link rel="stylesheet" href="css/style.css">
|
|
|
+</head>
|
|
|
+
|
|
|
+<body>
|
|
|
+ <div class="wp">
|
|
|
+ <div class="hd">
|
|
|
+ <div class="logo"><img src="img/logo.png" /></div>
|
|
|
+ <span class="y"> 欢迎您,<span id="user-name"></span>
|
|
|
+ <span class="pipe">|</span><a href="login.html">退出</a>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ <div class="cont">
|
|
|
+ <div class="title cl" style="background:#FFF;">
|
|
|
+ <span class="y">共有<b id="total-count">0</b>所学校,请选择</span>
|
|
|
+ <h2>学校列表</h2>
|
|
|
+ </div>
|
|
|
+ <table cellpadding="0" cellspacing="0" width="100%" class="tablelist">
|
|
|
+ <thead>
|
|
|
+ <th>ID</th>
|
|
|
+ <th>学校名称</th>
|
|
|
+ <th>操作</th>
|
|
|
+ </thead>
|
|
|
+ <tbody id="school-list">
|
|
|
+ </tbody>
|
|
|
+ </table>
|
|
|
+ <div class="page">
|
|
|
+ <span class="back" id="previous-button">上页</span>
|
|
|
+ <div id="page-list">
|
|
|
+ </div>
|
|
|
+ <span class="next" id="next-button">下页</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="ft">Copyright © 2011-2020 www.qmth.com.cn, All Rights Reserved</div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <script>
|
|
|
+ const $ = require('jquery')
|
|
|
+ const env = require('../lib/env.js')
|
|
|
+ const api = require('../lib/api.js')
|
|
|
+ const mustache = require('mustache')
|
|
|
+ const schoolTemplate = '<tr><td>{{id}}</td><td>{{name}}</td>\
|
|
|
+ <td><a href="##" data-index="{{index}}">切换学校</a></td></tr>'
|
|
|
+ const pageTemplate = '<a href="##" data-number="{{number}}">{{number}}</a>'
|
|
|
+ const pageSize = 10
|
|
|
+
|
|
|
+ let schoolList = []
|
|
|
+ let currentPage
|
|
|
+ let pageCount
|
|
|
+ $(document).ready(() => {
|
|
|
+ env.merge(JSON.parse(window.localStorage.getItem('env')))
|
|
|
+ $('#user-name').html(env.user.userName)
|
|
|
+
|
|
|
+ schoolList = env.user.schoolList
|
|
|
+ initPage()
|
|
|
+ })
|
|
|
+
|
|
|
+ function initPage() {
|
|
|
+ let totalCount = schoolList.length
|
|
|
+ if (totalCount > 0) {
|
|
|
+ pageCount = totalCount % pageSize == 0 ? parseInt(totalCount / pageSize) : parseInt(totalCount / pageSize) + 1
|
|
|
+ } else {
|
|
|
+ pageCount = 0
|
|
|
+ }
|
|
|
+ $('#total-count').html(totalCount)
|
|
|
+
|
|
|
+ $('#page-list').empty()
|
|
|
+ for (let i = 1; i <= pageCount; i++) {
|
|
|
+ let dom = $(mustache.render(pageTemplate, {
|
|
|
+ number: i
|
|
|
+ }))
|
|
|
+ $('#page-list').append(dom)
|
|
|
+
|
|
|
+ dom.click(function() {
|
|
|
+ changePage(parseInt($(this).attr('data-number')))
|
|
|
+ })
|
|
|
+ }
|
|
|
+ $('#previous-button').click(() => {
|
|
|
+ if (currentPage > 1) {
|
|
|
+ changePage(currentPage - 1)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ $('#next-button').click(() => {
|
|
|
+ if (currentPage < pageCount) {
|
|
|
+ changePage(currentPage + 1)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (pageCount > 0) {
|
|
|
+ changePage(1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function render() {
|
|
|
+ $('#page-list').find('a').removeClass('on')
|
|
|
+ $('#page-list').find('a[data-number="' + currentPage + '"]').addClass('on')
|
|
|
+
|
|
|
+ $('#school-list').empty()
|
|
|
+ let start = (currentPage - 1) * pageSize
|
|
|
+ let end = start + pageSize
|
|
|
+ for (let i = start; i < end && i < schoolList.length; i++) {
|
|
|
+ schoolList[i].index = i
|
|
|
+ let dom = $(mustache.render(schoolTemplate, schoolList[i]))
|
|
|
+ $('#school-list').append(dom)
|
|
|
+
|
|
|
+ dom.find('a').click(selectSchool)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function selectSchool() {
|
|
|
+ let school = schoolList[parseInt($(this).attr('data-index'))]
|
|
|
+ env.user.schoolId = school.id
|
|
|
+ window.localStorage.setItem('env', JSON.stringify(env))
|
|
|
+ window.location.href = 'exam-list.html'
|
|
|
+ }
|
|
|
+
|
|
|
+ function changePage(pageNumber) {
|
|
|
+ currentPage = pageNumber
|
|
|
+ render()
|
|
|
+ }
|
|
|
+ </script>
|
|
|
+</body>
|
|
|
+
|
|
|
+</html>
|