From fa4f3037fbaffc4122cfb5818656fe3111e73e25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9A=E4=B8=B9ab?= <1421553879@qq.com> Date: Fri, 14 Oct 2022 13:06:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=95=E9=A2=98=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../static/js/jlw/resourcesQuestion/index.js | 196 +++++++++--------- .../jlw/resourcesQuestion/importPage.html | 41 ++-- .../jlw/resourcesQuestion/index.html | 68 ++++-- 3 files changed, 171 insertions(+), 134 deletions(-) diff --git a/web/src/main/resources/static/js/jlw/resourcesQuestion/index.js b/web/src/main/resources/static/js/jlw/resourcesQuestion/index.js index 3713eb2c..97d0fb9a 100644 --- a/web/src/main/resources/static/js/jlw/resourcesQuestion/index.js +++ b/web/src/main/resources/static/js/jlw/resourcesQuestion/index.js @@ -1,163 +1,169 @@ -layui.define([ 'form', 'laydate', 'table' ], function(exports) { +layui.define(['form', 'laydate', 'table'], function (exports) { var form = layui.form; var laydate = layui.laydate; var table = layui.table; var resourcesQuestionTable = null; - var view ={ - init:function(){ + var view = { + init: function () { this.initTable(); this.initSearchForm(); this.initToolBar(); - window.dataReload = function(){ - Lib.doSearchForm($("#searchForm"),resourcesQuestionTable) + window.dataReload = function () { + Lib.doSearchForm($("#searchForm"), resourcesQuestionTable) } }, - initTable:function(){ + initTable: function () { resourcesQuestionTable = table.render({ - elem : '#resourcesQuestionTable', - height : Lib.getTableHeight(), + elem: '#resourcesQuestionTable', + height: Lib.getTableHeight(), cellMinWidth: 100, - method : 'post', - even:true, - size:"lg", - url : Common.ctxPath + '/jlw/resourcesQuestion/list.json' // 数据接口 - ,page : Lib.tablePage // 开启分页 - ,limit : 10, - cols : [ [ // 表头 + method: 'post', + even: true, + size: "lg", + url: Common.ctxPath + '/jlw/resourcesQuestion/list.json' // 数据接口 + , page: Lib.tablePage // 开启分页 + , limit: 10, + cols: [[ // 表头 { - type : 'checkbox',align:"center" + type: 'checkbox', align: "center" }, - { - field : 'questionStem', - title : '题干',align:"center" - }, - { - field : 'questionType',align:"center",width:150, - title : '题型', templet: function (d) {//(1单选 2多选 3判断) - return d.questionType == 1?'单选':d.questionType == 2?'多选':d.questionType == 3?'判断':'-'; - } - }, - { - field : 'courseInfoParentName',width:200, - title : '归属课程',align:"center" - }, - { - field : 'courseInfoName',width:200, - title : '归属章节',align:"center" - }, - { - field : 'questionStatus',width:200, - title : '状态',align:"center", templet(d) { - return d.questionStatus === 1 - ? `上架` - : '下架'} - }, - { - field : 'userId',title : '操作',align:"center",width:260, templet: function (d) { - // TODO 上下架前端逻辑待开发 - return ` - - - - - `; + { + field: 'questionStem', width: 320, + title: '题干', align: "center" + }, + { + field: 'questionType', align: "center", width: 80, + title: '题型', templet: function (d) {//(1单选 2多选 3判断) + return d.questionType == 1 ? '单选' : d.questionType == 2 ? '多选' : d.questionType == 3 ? '判断' : '-'; + } + }, + { + field: 'courseInfoParentName', + title: '归属课程', align: "center" + }, + { + field: 'courseInfoName', + title: '归属章节', align: "center" + }, + { + field: 'undefinedYD', + title: '上传院校', align: "center" + }, + { + field: 'questionStatus', width: 80, + title: '状态', align: "center", templet: function (d) { + return d.questionStatus === 1 + ? '已上架' + : '已下架' + } + }, + { + field: 'userId', title: '操作', align: "center", width: 220, templet: function (d) { + // TODO 上下架前端逻辑待开发 + return '上架\n' + + '下架\n' + + '编辑\n' + + '删除'; + } } - } - ] ] + ]] - }); + }); - table.on('checkbox(resourcesQuestionTable)', function(obj){ + table.on('checkbox(resourcesQuestionTable)', function (obj) { var resourcesQuestion = obj.data; - if(obj.checked){ + if (obj.checked) { //按钮逻辑Lib.buttonEnable() - }else{ + } else { } }) }, - initSearchForm:function(){ - Lib.initSearchForm( $("#searchForm"),resourcesQuestionTable,form); + initSearchForm: function () { + Lib.initSearchForm($("#searchForm"), resourcesQuestionTable, form); }, - initToolBar:function(){ + initToolBar: function () { toolbar = { - add : function() { // 获取选中数据 + add: function () { // 获取选中数据 var url = "/jlw/resourcesQuestion/add.do"; - Common.openDlg(url,"题库管理/新增题目"); + Common.openDlg(url, "题库管理/新增题目"); }, refresh: function () {//刷新 searchForm.reset(); Lib.doSearchForm($("#searchForm"), resourcesQuestionTable, 1); }, - up: function() { + up: function () { alert('up') }, - down: function() { + down: function () { alert('down') }, - search:function () { + search: function () { Lib.doSearchForm($("#searchForm"), resourcesQuestionTable, 1); - },import:function (){ + }, import: function () { var url = "/jlw/resourcesQuestion/importPage.do"; - Common.openDlg(url,""); - },allDel:function (){ + Common.openDlg(url, ""); + }, allDel: function () { var checkStatus = table.checkStatus('resourcesQuestionTable').data; - if(checkStatus.length <= 0){ + if (checkStatus.length <= 0) { layer.msg("请选择需要删除的题目!", { offset: ['50%'], icon: 2, time: 2000 //2秒关闭(如果不配置,默认是3秒) }); - return ; + return; } var ids = ""; - for(var i = 0; i < checkStatus.length;i++){ + for (var i = 0; i < checkStatus.length; i++) { ids += checkStatus[i].resourcesQuestionId; - if(i < checkStatus.length - 1){ + if (i < checkStatus.length - 1) { ids += ","; } } allDelete(ids); - },chapter:function (){ //批量章节调整 + }, chapter: function () { //批量章节调整 $("select[name='courseInfoIds_1'],select[name='courseInfoIds_2']").val(""); $("select[name='courseInfoId_1'],select[name='courseInfoId_2']").html(""); form.render(); layer.open({ type: 1, offset: 'auto', - title:'批量章节调整', - shadeClose:'true', + title: '批量章节调整', + shadeClose: 'true', area: ['800px', '300px'], - scrollbar:'false', + scrollbar: 'false', btnAlign: 'c', content: $("#chapter_dialog"), btn: ['确定', '取消'], - yes: function(index,layero){ + yes: function (index, layero) { var oldCourseInfoId = $("#chapter_dialog select[name='courseInfoId_1']").val(), - newCourseInfoId= $("#chapter_dialog select[name='courseInfoId_2']").val(); - if($.isEmpty(oldCourseInfoId)){ + newCourseInfoId = $("#chapter_dialog select[name='courseInfoId_2']").val(); + if ($.isEmpty(oldCourseInfoId)) { layer.msg("请选择题目来源章节!", { offset: ['50%'], icon: 2, time: 1500 //2秒关闭(如果不配置,默认是3秒) }); - return ; + return; } - if($.isEmpty(newCourseInfoId)){ + if ($.isEmpty(newCourseInfoId)) { layer.msg("请选择题去向源章节!", { offset: ['50%'], icon: 2, time: 1500 //2秒关闭(如果不配置,默认是3秒) }); - return ; + return; } layer.confirm('是否确定调整该章节信息?', function (index1) { layer.close(index1); layer.load(3); - setTimeout(function (){ - var ret = Common.postAjax("/jlw/resourcesQuestion/changAll.json",{oldCourseInfoId:oldCourseInfoId,newCourseInfoId:newCourseInfoId}) + setTimeout(function () { + var ret = Common.postAjax("/jlw/resourcesQuestion/changAll.json", { + oldCourseInfoId: oldCourseInfoId, + newCourseInfoId: newCourseInfoId + }) layer.closeAll("loading"); layer.msg(ret.msg, { offset: ['50%'], @@ -169,29 +175,33 @@ layui.define([ 'form', 'laydate', 'table' ], function(exports) { Lib.tableRefresh(); } }); - },200); + }, 200); }); } }); } - }; - $('.ext-toolbar').on('click', function() { + }; + $('.ext-toolbar').on('click', function () { var type = $(this).data('type'); toolbar[type] ? toolbar[type].call(this) : ''; }); }, initTableTool: table.on('tool(resourcesQuestionTable)', function (obj) { var data = obj.data; if (obj.event === 'edit') { - var url = "/jlw/resourcesQuestion/add.do?resourcesQuestionId="+data.resourcesQuestionId; - Common.openDlg(url,"题库管理/编辑题目"); - }else if(obj.event === "del"){ + var url = "/jlw/resourcesQuestion/add.do?resourcesQuestionId=" + data.resourcesQuestionId; + Common.openDlg(url, "题库管理/编辑题目"); + } else if (obj.event === "del") { allDelete(data.resourcesQuestionId); + } else if (obj.event === "up") { + alert('up') + } else if (obj.event === "down") { + alert('down') } }) } //删除 - function allDelete(ids){ + function allDelete(ids) { layer.confirm('是否确定删除该信息?', function (index) { var ret = Common.postAjax("/jlw/resourcesQuestion/delete.json", {ids: ids}); layer.msg(ret.code == 0 ? "删除成功!" : ret.msg, { @@ -208,14 +218,14 @@ layui.define([ 'form', 'laydate', 'table' ], function(exports) { //选择归属课程 并且根据选择的课程查询章节 resourcesQuestionIdsIsNotNull:查询题目不为空的章节 form.on('select(select_courseInfoIds)', function (obj) { - Lib.getCourseInfo($("select[name='courseInfoId_1']"),obj.value,1); + Lib.getCourseInfo($("select[name='courseInfoId_1']"), obj.value, 1); }); //选择归属课程 并且根据选择的课程查询章节 form.on('select(select_courseInfoIds_)', function (obj) { - Lib.getCourseInfo($("select[name='courseInfoId_2']"),obj.value); + Lib.getCourseInfo($("select[name='courseInfoId_2']"), obj.value); }); - exports('index',view); + exports('index', view); }); \ No newline at end of file diff --git a/web/src/main/resources/templates/jlw/resourcesQuestion/importPage.html b/web/src/main/resources/templates/jlw/resourcesQuestion/importPage.html index ce9f694b..3916e2b1 100644 --- a/web/src/main/resources/templates/jlw/resourcesQuestion/importPage.html +++ b/web/src/main/resources/templates/jlw/resourcesQuestion/importPage.html @@ -2,7 +2,7 @@
- +
@@ -17,7 +17,7 @@
@@ -25,7 +25,7 @@
@@ -48,10 +48,10 @@ 序号 提示信息 - + - +
@@ -60,25 +60,25 @@ {{index + 1}} {{item[0]}} - - - - - + + + + + {{# }); }}