123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>试题管理</title>
- <meta name="renderer" content="webkit">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta name="viewport"
- content="width=agent-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
- <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
- <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
- <style type="text/css">
- .seach_items {
- float: right;
- margin-left: 10px;
- }
- </style>
- <style type="text/css">
- .LAY-btns .layui-nav {
- padding-left: 0;
- padding-right: 10px;
- top: -4px;
- margin: 0 10px;
- border: 0;
- background-color: #009688;
- }
- .LAY-btns .layui-nav .layui-nav-item {
- line-height: 30px;
- }
- .LAY-btns .layui-nav .layui-nav-child {
- top: 34px;
- }
- .LAY-btns .layui-nav .layui-nav-bar {
- display: none;
- }
- .LAY-btns .layui-nav .layui-nav-child dd.layui-this a {
- color: #333;
- background-color: #fff;
- }
- .LAY-btns .layui-nav .layui-nav-child dd.layui-this a:hover {
- background-color: #f2f2f2;
- color: #000;
- }
- .tableContent {
- width: 100%;
- display: flex;
- justify-content: space-between;
- flex-direction: row;
- }
- </style>
- </head>
- <body>
- <div class="layui-fluid">
- <div class="layui-card">
- <div class="layui-card-body" pad15>
- <div class="layui-row layui-col-space15">
- <div class="layui-col-md12">
- <div class="LAY-btns" style="margin-bottom: 10px;">
- <div style="float: left">
- <button class="layui-btn layui-btn-sm" id="exam_question_add">
- <i class="layui-icon layui-icon-add-circle"></i>添加
- </button>
- <button class="layui-nav">
- <div class="layui-nav-item">
- <a href="javascript:;" style="color:#fff;" >导入</a>
- <dl class="layui-nav-child"> <!-- 二级菜单 -->
- <dd><a href="#" id="btn_add_single">单选题</a></dd>
- <dd><a href="#" id="btn_add_multiple">多选题</a></dd>
- <dd><a href="#" id="btn_add_fill">填空题</a></dd>
- <dd><a href="#" id="btn_add_judgment">判断题</a></dd>
- <dd><a href="#" id="btn_add_discuss">论述题</a></dd>
- <dd><a href="#" id="btn_import_word">多题型导入(Word)</a></dd>
- </dl>
- </div>
- </button>
- <button class="layui-nav">
- <div class="layui-nav-item">
- <a href="javascript:;" style="color:#fff;" >下载模版</a>
- <dl class="layui-nav-child"> <!-- 二级菜单 -->
- <dd><a href="#" id="btn_download_single">单选题模版</a></dd>
- <dd><a href="#" id="btn_download_multiple">多选题模版</a></dd>
- <dd><a href="#" id="btn_download_fill">填空题模版</a></dd>
- <dd><a href="#" id="btn_download_judgment">判断题模版</a></dd>
- <dd><a href="#" id="btn_download_discuss">论述题模版</a></dd>
- </dl>
- </div>
- </button>
- <button class="layui-btn layui-btn-sm" id="btn_download">
- <i class="layui-icon layui-icon-download-circle"></i>导出
- </button>
- <button class="layui-btn layui-btn-sm" id="exam_question_del">
- <i class="layui-icon layui-icon-delete"></i>批量删除
- </button>
- </div>
- <form class="layui-form" lay-filter="query-form-element">
- <div class="seach_items">
- <button class="layui-btn" lay-submit lay-filter="query-form-element"><i
- class="layui-icon layui-icon-search"></i>查询
- </button>
- </div>
- <div class="seach_items">
- <input type="text" name="title" autocomplete="off" class="layui-input"
- placeholder="名称"/>
- </div>
- <div class="seach_items">
- <select name="type">
- <option value="" selected>题型</option>
- <option value="1">单选题</option>
- <option value="2">多选题</option>
- <option value="3">填空题</option>
- <option value="4">判断题</option>
- <option value="5">论述题</option>
- </select>
- </div>
- </form>
- <div style="clear: both;"></div>
- </div>
- <table class="layui-hide" id="exam_question_datagrid" lay-filter="exam_question-operate"></table>
- <script type="text/html" id="exam_question-operate-bar">
- <div class="layui-btn-group">
- <a class="layui-btn layui-btn-xs" lay-event="exam_question_detail"
- >查看</a>
- </div>
- <div class="layui-btn-group">
- <a class="layui-btn layui-btn-xs" lay-event="exam_question_edit"
- >修改</a>
- </div>
- <div class="layui-btn-group">
- <a class="layui-btn layui-btn-xs" lay-event="exam_question_delete"
- >删除</a>
- </div>
- </script>
- </div>
- </div>
- </div>
- </div>
- </div>
- <script src="../../layuiadmin/layui/layui.js"></script>
- <script>
- var _params = '';
- layui.config({
- base: '../../../layuiadmin/' //静态资源所在路径
- }).extend({
- index: 'lib/index' //主入口模块
- }).use(['index', 'table', 'form', 'admin', 'upload', ], function () {
- var $ = layui.$;
- var table = layui.table
- , admin = layui.admin
- ,upload = layui.upload
- , form = layui.form;
- table.render({
- elem: '#exam_question_datagrid'
- , url: '/admin/examquestion/'
- , cols: [[
- {type: 'checkbox', fixed: 'left'}
- , {title: '编号', type: 'numbers'}
- , {field: 'subject_text', title: '科目', width: 150}
- , {field: 'chapter_text', title: '章节', width: 150}
- , {field: 'type_text', title: '题型', width: 100}
- , {field: 'title', title: '内容', width: 400}
- , {field: 'difficulty_text', title: '难度', width: 100}
- , {field: 'create_user_text', title: '录入人', width: 150}
- , {field: 'create_time', title: '录入时间', width: 200}
- , {title: '操作', width: 180, align: 'center', fixed: 'right', toolbar: '#exam_question-operate-bar'}
- ]]
- , page: true
- , height: 'full-108'
- });
- //监听工具条
- table.on('tool(exam_question-operate)', function (obj) {
- var data = obj.data;
- table.editdata = data;
- if (obj.event === 'exam_question_edit') {
- layer.open({
- type: 2,
- title: '修改试题',
- shadeClose: false,
- area: ['80%', '80%'],
- btn: ['保存', '取消'],
- yes: function (index, dom) {
- layui.onSubmitChild = function (res) {
- layer.close(index);
- table.reload('exam_question_datagrid', {});
- };
- layui.submitChild();
- },
- btn2: function (index, layero) {
- layer.close(index);//关闭当前按钮
- },
- content: 'edit.html?id=' + data.id
- });
- }
- else if (obj.event === 'exam_question_delete') {
- layer.confirm('确定要删除该试题吗?', function (index) {
- layer.close(index);
- admin.req({
- url: '/admin/examquestion/' + data.id + '/'
- , type: 'delete'
- , done: function (res) {
- table.reload('exam_question_datagrid', {});
- }
- });
- });
- } else if (obj.event === 'exam_question_detail') {
- layer.open({
- type: 2,
- title: '查看详情',
- shadeClose: false,
- area: ['70%', '80%'],
- btn: ['关闭'],
- yes: function (index, dom) {
- layer.close(index);//关闭当前按钮
- },
- content: 'details.html'
- });
- }
- });
- form.on('submit(query-form-element)', function (data) {
- table.reload('exam_question_datagrid', {
- where: data.field
- , page: {curr: 1}
- });
- _params = data.field;
- layer.closeAll();
- return false
- });
- $('#exam_question_add').on('click', function () {
- layer.open({
- type: 2,
- title: '添加试题',
- area: ['80%', '90%'],
- btn: ['保存', '取消'],
- yes: function (index, dom) {
- layui.onSubmitChild = function (res) {
- layer.close(index);
- table.reload('exam_question_datagrid', {});
- };
- layui.submitChild();
- },
- btn2: function (index, layero) {
- layer.close(index);//关闭当前按钮
- },
- content: 'edit.html'
- });
- });
- $('#exam_question_del').on('click', function () {
- layer.confirm('确定要删除选中试题吗?', function (index) {
- layer.close(index);
- var checkStatus = table.checkStatus('exam_question_datagrid');
- var item = [];
- for (var i = 0; i < checkStatus.data.length; i++) {
- item.push(checkStatus.data[i].id);
- }
- if (item.length <= 0) {
- return;
- }
- admin.req({
- url: '/admin/examquestion/batch_del/'
- , type: 'post'
- , data: JSON.stringify(item)
- , dataType: 'json'
- , contentType: 'application/json'
- , done: function (res) {
- table.reload('exam_question_datagrid', {});
- }
- });
- });
- });
- $('#btn_import_word').on('click', function () {
- layer.open({
- type: 2,
- title: '导入Word试题',
- area: ['450px', '505px'],
- btn: ['选择文件并执行', '取消'],
- yes: function (index, dom) {
- layui.onSubmitChild = function (res) {
- layer.close(index);
- table.reload('exam_question_datagrid', {});
- };
- layui.uploadFile();
- },
- btn2: function (index, layero) {
- layer.close(index);//关闭当前按钮
- },
- content: 'import.html'
- });
- });
- upload.render({
- elem: '#btn_add_single'
- ,url: '/admin/examquestion/import_single/'
- ,accept:'file'
- ,acceptMime:'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
- ,exts:'xlsx'
- ,field:'excel_file'
- ,multiple:false
- ,done: function(res){
- if (res.code == 0) {
- table.reload('exam_question_datagrid',{});
- } else {
- layer.msg(res.msg);
- }
- }
- ,error: function(){
- layer.msg('导入失败');
- }
- });
- upload.render({
- elem: '#btn_add_multiple'
- ,url: '/admin/examquestion/import_multiple/'
- ,accept:'file'
- ,acceptMime:'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
- ,exts:'xlsx'
- ,field:'excel_file'
- ,multiple:false
- ,done: function(res){
- if (res.code == 0) {
- table.reload('exam_question_datagrid',{});
- } else {
- layer.msg(res.msg);
- }
- }
- ,error: function(){
- layer.msg('导入失败');
- }
- });
- upload.render({
- elem: '#btn_add_fill'
- ,url: '/admin/examquestion/import_fill/'
- ,accept:'file'
- ,acceptMime:'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
- ,exts:'xlsx'
- ,field:'excel_file'
- ,multiple:false
- ,done: function(res){
- if (res.code == 0) {
- table.reload('exam_question_datagrid',{});
- } else {
- layer.msg(res.msg);
- }
- }
- ,error: function(){
- layer.msg('导入失败');
- }
- });
- upload.render({
- elem: '#btn_add_judgment'
- ,url: '/admin/examquestion/import_judgment/'
- ,accept:'file'
- ,acceptMime:'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
- ,exts:'xlsx'
- ,field:'excel_file'
- ,multiple:false
- ,done: function(res){
- if (res.code == 0) {
- table.reload('exam_question_datagrid',{});
- } else {
- layer.msg(res.msg);
- }
- }
- ,error: function(){
- layer.msg('导入失败');
- }
- });
- upload.render({
- elem: '#btn_add_discuss'
- ,url: '/admin/examquestion/import_discuss/'
- ,accept:'file'
- ,acceptMime:'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
- ,exts:'xlsx'
- ,field:'excel_file'
- ,multiple:false
- ,done: function(res){
- if (res.code == 0) {
- table.reload('exam_question_datagrid',{});
- } else {
- layer.msg(res.msg);
- }
- }
- ,error: function(){
- layer.msg('导入失败');
- }
- });
- $('#btn_download_single').on('click', function () {
- layui.view.download("/static/xls/单选题导入模版.xlsx");
- });
- $('#btn_download_multiple').on('click', function () {
- layui.view.download("/static/xls/多选题导入模版.xlsx");
- });
- $('#btn_download_fill').on('click', function () {
- layui.view.download("/static/xls/填空题导入模版.xlsx");
- });
- $('#btn_download_judgment').on('click', function () {
- layui.view.download("/static/xls/判断题导入模版.xlsx");
- });
- $('#btn_download_discuss').on('click', function () {
- layui.view.download("/static/xls/论述题导入模版.xlsx");
- });
- $('#btn_download').on('click', function(){
- $.get({
- url: '/admin/examquestion/export/',
- dataType: 'json',
- data: _params,
- success: function (res) {
- // var title = ['题型', '试题内容', '科目', '章节', '难度', '分数', '单选选项', '多选选项', '正确答案', '判断答案', '填空答案', '解析'];
- // var data = [];
- // for (var i = 0; i < res.data.length; i++) {
- // var res_item = res.data[i];
- // var data_item = [
- // res_item.type_text,
- // res_item.title,
- // res_item.subject_text,
- // res_item.chapter_text,
- // res_item.difficulty_text,
- // res_item.scores,
- // ];
- // if (res_item.type == 1 || res_item.type == 2) {
- // data_item.push('');
- // data_item.push('');
- // data_item.push('');
- // data_item.push('');
- // data_item.push('');
- // } else if (res_item.type == 3) {
- // data_item.push('');
- // data_item.push('');
- // data_item.push('');
- // data_item.push('');
- // if ( res_item.items.length >= 1) {
- // var option = res_item.items[0];
- // data_item.push(option.content);
- // }
- // } else if (res_item.type == 4) {
- // data_item.push('');
- // data_item.push('');
- // data_item.push('');
- // if (res_item.judgment == '1') {
- // data_item.push('正确');
- // } else {
- // data_item.push('错误');
- // }
- // data_item.push('');
- // } else if (res_item.type == 5) {
- // data_item.push('');
- // data_item.push('');
- // data_item.push(res_item.discuss_answer);
- // data_item.push('');
- // data_item.push('');
- // } else {
- // data_item.push('');
- // data_item.push('');
- // data_item.push('');
- // data_item.push('');
- // data_item.push('');
- // }
- // data_item.push(res_item.analysis);
- // data.push(data_item);
- // if (res_item.type == 1 || res_item.type == 2) {
- // for (var n = 0; n < res_item.items.length; n++) {
- // var option = res_item.items[n];
- // var option_item = ['', '', '', '', '', ''];
- // if (res_item.type == 1) {
- // option_item.push(option.content);
- // option_item.push('');
- // } else {
- // option_item.push('');
- // option_item.push(option.content);
- // }
- // if (option.right == true) {
- // option_item.push('正确');
- // } else {
- // option_item.push('');
- // }
- // option_item.push('');
- // option_item.push('');
- // option_item.push('');
- // data.push(option_item);
- // }
- // } else if (res_item.type == 3) {
- // for (var n = 1; n < res_item.items.length; n++) {
- // var option = res_item.items[n];
- // var option_item = ['', '', '', '', '', '', '', '', '', ''];
- // option_item.push(option.content);
- // option_item.push('');
- // data.push(option_item);
- // }
- // }
- // }
- // table.exportFile(
- // title,
- // data,
- // '试题.xls'
- // );
- }
- })
- });
- });
- </script>
- </body>
- </html>
|