123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336 |
- <%@ page contentType="text/html;charset=UTF-8" %>
- <script>
- $(document).ready(function() {
- $('#eduQuestionTable').bootstrapTable({
-
- //请求方法
- method: 'post',
- //类型json
- dataType: "json",
- contentType: "application/x-www-form-urlencoded",
- //显示检索按钮
- showSearch: true,
- //显示刷新按钮
- showRefresh: true,
- //显示切换手机试图按钮
- showToggle: true,
- //显示 内容列下拉框
- showColumns: true,
- //显示到处按钮
- showExport: false,
- //显示切换分页按钮
- showPaginationSwitch: true,
- //显示详情按钮
- detailView: true,
- //显示详细内容函数
- detailFormatter: "detailFormatter",
- //最低显示2行
- minimumCountColumns: 2,
- //是否显示行间隔色
- striped: true,
- //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
- cache: false,
- //是否显示分页(*)
- pagination: true,
- //排序方式
- sortOrder: "asc",
- //初始化加载第一页,默认第一页
- pageNumber:1,
- //每页的记录行数(*)
- pageSize: 10,
- //可供选择的每页的行数(*)
- pageList: [10, 25, 50, 100],
- //这个接口需要处理bootstrap table传递的固定参数,并返回特定格式的json数据
- url: "${ctx}/exam/eduQuestion/data",
- //默认值为 'limit',传给服务端的参数为:limit, offset, search, sort, order Else
- //queryParamsType:'',
- ////查询参数,每次调用是会带上这个参数,可自定义
- queryParams : function(params) {
- var searchParam = $("#searchForm").serializeJSON();
- searchParam.pageNo = params.limit === undefined? "1" :params.offset/params.limit+1;
- searchParam.pageSize = params.limit === undefined? -1 : params.limit;
- searchParam.orderBy = params.sort === undefined? "" : params.sort+ " "+ params.order;
- return searchParam;
- },
- //分页方式:client客户端分页,server服务端分页(*)
- sidePagination: "server",
- contextMenuTrigger:"right",//pc端 按右键弹出菜单
- contextMenuTriggerMobile:"press",//手机端 弹出菜单,click:单击, press:长按。
- contextMenu: '#context-menu',
- onContextMenuItem: function(row, $el){
- if($el.data("item") == "view"){
- view(row.id);
- } else if($el.data("item") == "delete"){
- jp.confirm('确认要删除该试题记录吗?', function(){
- jp.loading();
- jp.get("${ctx}/exam/eduQuestion/delete?id="+row.id, function(data){
- if(data.success){
- $('#eduQuestionTable').bootstrapTable('refresh');
- jp.success(data.msg);
- }else{
- jp.error(data.msg);
- }
- })
-
- });
-
- }
- },
-
- onClickRow: function(row, $el){
- },
- onShowSearch: function () {
- $("#search-collapse").slideToggle();
- },
- columns: [{
- checkbox: true
-
- }
- ,{
- field: 'title',
- title: '题干',
- sortable: true,
- sortName: 'title'
- ,formatter:function(value, row , index){
- value = jp.unescapeHTML(value);
- <c:choose>
- <c:when test="${fns:hasPermission('exam:eduQuestion:edit')}">
- return "<a href='javascript:view(\""+row.id+"\")'>"+value+"</a>";
- </c:when>
- <c:when test="${fns:hasPermission('exam:eduQuestion:view')}">
- return "<a href='javascript:view(\""+row.id+"\")'>"+value+"</a>";
- </c:when>
- <c:otherwise>
- return value;
- </c:otherwise>
- </c:choose>
- }
-
- }
- ,{
- field: 'types',
- title: '题型',
- sortable: true,
- sortName: 'types',
- formatter:function(value, row , index){
- if(value == '1'){
- return '单选'
- }else if (value == '2'){
- return '多选'
- }else if (value == '3'){
- return '判断'
- }
- }
-
- },
- {
- field: 'isFix',
- title: '固定试题',
- sortable: true,
- sortName: 'isFix'
- ,formatter:function(value, row , index){
- value = jp.unescapeHTML(value);
- return jp.getDictLabel(${fns:toJson(fns:getDictList('yes_no'))}, value, "-");
- }
- }
- ,{
- field: 'points',
- title: '分值',
- sortable: true,
- sortName: 'points',
- formatter:function(value, row , index){
- return value === '' ? '0' : value;
- }
-
- }
- ]
-
- });
-
-
- if(navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)){//如果是移动端
-
- $('#eduQuestionTable').bootstrapTable("toggleView");
- }
-
- $('#eduQuestionTable').on('check.bs.table uncheck.bs.table load-success.bs.table ' +
- 'check-all.bs.table uncheck-all.bs.table', function () {
- $('#remove').prop('disabled', !isEditable());
- $('#view').prop('disabled', $('#eduQuestionTable').bootstrapTable('getSelections').length!=1);
- $('#edit').prop('disabled',!isEditable())
- });
-
- $("#btnImport").click(function(){
- jp.open({
- type: 2,
- area: [500, 200],
- auto: true,
- title:"导入数据",
- content: "${ctx}/tag/importExcel" ,
- btn: ['下载模板','确定', '关闭'],
- btn1: function(index, layero){
- jp.downloadFile('${ctx}/exam/eduQuestion/import/template');
- },
- btn2: function(index, layero){
- var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method();
- iframeWin.contentWindow.importExcel('${ctx}/exam/eduQuestion/import', function (data) {
- if(data.success){
- jp.success(data.msg);
- refresh();
- }else{
- jp.error(data.msg);
- }
- });//调用保存事件
- jp.close(index);
- },
- btn3: function(index){
- jp.close(index);
- }
- });
- });
- $("#export").click(function(){//导出Excel文件
- jp.downloadFile('${ctx}/exam/eduQuestion/export');
- });
- $("#search").click("click", function() {// 绑定查询按扭
- $('#eduQuestionTable').bootstrapTable('refresh');
- });
-
- $("#reset").click("click", function() {// 绑定查询按扭
- $("#searchForm input").val("");
- $("#searchForm select").val("");
- $("#searchForm .select-item").html("");
- $('#eduQuestionTable').bootstrapTable('refresh');
- });
-
-
- });
- function getIdSelections() {
- return $.map($("#eduQuestionTable").bootstrapTable('getSelections'), function (row) {
- return row.id
- });
- }
-
- function deleteAll(){
- jp.confirm('确认要删除该试题记录吗?', function(){
- jp.loading();
- jp.get("${ctx}/exam/eduQuestion/deleteAll?ids=" + getIdSelections(), function(data){
- if(data.success){
- $('#eduQuestionTable').bootstrapTable('refresh');
- jp.success(data.msg);
- }else{
- jp.error(data.msg);
- }
- })
-
- })
- }
-
- //刷新列表
- function refresh() {
- $('#eduQuestionTable').bootstrapTable('refresh');
- }
- function add(){
- jp.openSaveDialog('新增试题', "${ctx}/exam/eduQuestion/form",'900px', '550px');
- }
-
- function edit(id){//没有权限时,不显示确定按钮
- if(id == undefined){
- id = getIdSelections();
- }
- jp.openSaveDialog('编辑试题', "${ctx}/exam/eduQuestion/form?id=" + id, '900px', '550px');
- }
-
- function view(id){//没有权限时,不显示确定按钮
- if(id == undefined){
- id = getIdSelections();
- }
- jp.openViewDialog('查看试题', "${ctx}/exam/eduQuestion/form?id=" + id, '900px', '550px');
- }
- //是否可编辑 可编辑返回true 不可编辑返回false
- function isEditable() {
- debugger;
- var rows = $('#eduQuestionTable').bootstrapTable('getSelections');
- //校验选择数量 num为1
- var num = rows.length;
- if(num !== 1){
- return false;
- }else {
- //校验是否回答 回答了就不可编辑
- return !rows[0].isAnswered;
- }
- }
-
-
-
-
-
- function detailFormatter(index, row) {
- var htmltpl = $("#eduQuestionChildrenTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
- var html = Mustache.render(htmltpl, {
- idx:row.id
- });
- $.get("${ctx}/exam/eduQuestion/detail?id="+row.id, function(eduQuestion){
- var eduQuestionChild1RowIdx = 0, eduQuestionChild1Tpl = $("#eduQuestionChild1Tpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
- var data1 = eduQuestion.eduQuestionOptionList;
- console.log(data1);
- for (var i=0; i<data1.length; i++){
- data1[i].dict = {};
- if(data1[i].isAnswer === '1'){
- data1[i].isAnswer = "√"
- }else{
- data1[i].isAnswer = ""
- }
- addRow('#eduQuestionChild-'+row.id+'-1-List', eduQuestionChild1RowIdx, eduQuestionChild1Tpl, data1[i]);
- eduQuestionChild1RowIdx = eduQuestionChild1RowIdx + 1;
- }
-
-
- })
-
- return html;
- }
-
- function addRow(list, idx, tpl, row){
- $(list).append(Mustache.render(tpl, {
- idx: idx, delBtn: true, row: row
- }));
- }
-
- </script>
- <script type="text/template" id="eduQuestionChildrenTpl">//<!--
- <div class="tabs-container">
- <ul class="nav nav-tabs">
- <li class="active"><a data-toggle="tab" href="#tab-{{idx}}-1" aria-expanded="true">试题选项</a></li>
- </ul>
- <div class="tab-content">
- <div id="tab-{{idx}}-1" class="tab-pane fade in active">
- <table class="ani table">
- <thead>
- <tr>
- <th width="800">选项</th>
- <th>正确答案</th>
- </tr>
- </thead>
- <tbody id="eduQuestionChild-{{idx}}-1-List">
- </tbody>
- </table>
- </div>
- </div>//-->
- </script>
- <script type="text/template" id="eduQuestionChild1Tpl">//<!--
- <tr style="height: 40px;">
- <td>
- {{row.title}}
- </td>
- <td style="font-size: 20px; color: red;text-align: center;">
- {{row.isAnswer}}
- </td>
- </tr>//-->
- </script>
|