<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('考试管理')" />
	<th:block th:include="include :: element-css" />
</head>
<body class="gray-bg">
    <div class="container-div" id="app">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="notice-form">
					<div class="select-list">
						<ul>
							<li>
								题目内容：<input type="text" name="title"/>
								<input type="hidden" name="examId" th:value="*{examId}"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>

	        <div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-danger" onclick="closeItem()">
					<i class="fa fa-reply-all"></i> 关闭
				</a>
				<a class="btn btn-success"   onclick="startTrain()">
					<i class="fa fa-plus"></i> 错题训练
				</a>
	        </div>

	        <div class="col-sm-12 select-table table-striped">
	            <table id="bootstrap-table"></table>
	        </div>
    	</div>
    </div>
    <th:block th:include="include :: footer" />
	<th:block th:include="include :: element-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/userBook";
        $(function() {
            var options = {
				uniqueId: "id",
                url: prefix + "/list",
				removeUrl: prefix + "/remove",
				queryParams: queryParams,
                modalName: "考试错题",
                columns: [
				{
					field : 'title',
					title : '题目内容',
					width: '60',
					widthUnit: '%',
					align: "left"
				},
				{
					field: 'wrongCount',
					title: '错误次数'
				},
				{
		            field: 'createTime',
		            title: '创建时间',
		            sortable: true
		        },
				{
					title: '操作',
					align: 'center',
					formatter: function(value, row, index) {
						var actions = [];
						actions.push('<a class="btn btn-success btn-xs '  + '" href="javascript:void(0)" onclick="detail(\'' + row.quId + '\')"><i class="fa fa-edit"></i>详情</a> ');
						actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');

						return actions.join('');
					}
				}]
            };
            $.table.init(options);
        });
		function detail(id) {
			var url = prefix + '/view/' + id;
			$.modal.openTab("题目详情", url);
		}
		function queryParams(params) {
			var search = $.table.queryParams(params);
			search.examId = [[${examId}]];
			return search;
		}
		function startTrain() {
			$.modal.openTab("错题训练", prefix + "/toTrain/"+[[${examId}]]);
		}

    </script>
</body>
</html>
