index.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>试题管理</title>
  6. <meta name="renderer" content="webkit">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  8. <meta name="viewport"
  9. content="width=agent-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  10. <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
  11. <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
  12. <style type="text/css">
  13. .seach_items {
  14. float: right;
  15. margin-left: 10px;
  16. }
  17. </style>
  18. <style type="text/css">
  19. .LAY-btns .layui-nav {
  20. padding-left: 0;
  21. padding-right: 10px;
  22. top: -4px;
  23. margin: 0 10px;
  24. border: 0;
  25. background-color: #009688;
  26. }
  27. .LAY-btns .layui-nav .layui-nav-item {
  28. line-height: 30px;
  29. }
  30. .LAY-btns .layui-nav .layui-nav-child {
  31. top: 34px;
  32. }
  33. .LAY-btns .layui-nav .layui-nav-bar {
  34. display: none;
  35. }
  36. .LAY-btns .layui-nav .layui-nav-child dd.layui-this a {
  37. color: #333;
  38. background-color: #fff;
  39. }
  40. .LAY-btns .layui-nav .layui-nav-child dd.layui-this a:hover {
  41. background-color: #f2f2f2;
  42. color: #000;
  43. }
  44. .tableContent {
  45. width: 100%;
  46. display: flex;
  47. justify-content: space-between;
  48. flex-direction: row;
  49. }
  50. </style>
  51. </head>
  52. <body>
  53. <div class="layui-fluid">
  54. <div class="layui-card">
  55. <div class="layui-card-body" pad15>
  56. <div class="layui-row layui-col-space15">
  57. <div class="layui-col-md12">
  58. <div class="LAY-btns" style="margin-bottom: 10px;">
  59. <div style="float: left">
  60. <button class="layui-btn layui-btn-sm" id="exam_question_add">
  61. <i class="layui-icon layui-icon-add-circle"></i>添加
  62. </button>
  63. <button class="layui-nav">
  64. <div class="layui-nav-item">
  65. <a href="javascript:;" style="color:#fff;" >导入</a>
  66. <dl class="layui-nav-child"> <!-- 二级菜单 -->
  67. <dd><a href="#" id="btn_add_single">单选题</a></dd>
  68. <dd><a href="#" id="btn_add_multiple">多选题</a></dd>
  69. <dd><a href="#" id="btn_add_fill">填空题</a></dd>
  70. <dd><a href="#" id="btn_add_judgment">判断题</a></dd>
  71. <dd><a href="#" id="btn_add_discuss">论述题</a></dd>
  72. </dl>
  73. </div>
  74. </button>
  75. <button class="layui-nav">
  76. <div class="layui-nav-item">
  77. <a href="javascript:;" style="color:#fff;" >下载模版</a>
  78. <dl class="layui-nav-child"> <!-- 二级菜单 -->
  79. <dd><a href="#" id="btn_download_single">单选题模版</a></dd>
  80. <dd><a href="#" id="btn_download_multiple">多选题模版</a></dd>
  81. <dd><a href="#" id="btn_download_fill">填空题模版</a></dd>
  82. <dd><a href="#" id="btn_download_judgment">判断题模版</a></dd>
  83. <dd><a href="#" id="btn_download_discuss">论述题模版</a></dd>
  84. </dl>
  85. </div>
  86. </button>
  87. </div>
  88. <form class="layui-form" lay-filter="query-form-element">
  89. <div class="seach_items">
  90. <button class="layui-btn" lay-submit lay-filter="query-form-element"><i
  91. class="layui-icon layui-icon-search"></i>查询
  92. </button>
  93. </div>
  94. <div class="seach_items">
  95. <input type="text" name="title" autocomplete="off" class="layui-input"
  96. placeholder="名称"/>
  97. </div>
  98. </form>
  99. <div style="clear: both;"></div>
  100. </div>
  101. <table class="layui-hide" id="exam_question_datagrid" lay-filter="exam_question-operate"></table>
  102. <script type="text/html" id="exam_question-operate-bar">
  103. <div class="layui-btn-group">
  104. <a class="layui-btn layui-btn-xs" lay-event="exam_question_detail"
  105. >查看</a>
  106. </div>
  107. <div class="layui-btn-group">
  108. <a class="layui-btn layui-btn-xs" lay-event="exam_question_edit"
  109. >修改</a>
  110. </div>
  111. <div class="layui-btn-group">
  112. <a class="layui-btn layui-btn-xs" lay-event="exam_question_delete"
  113. >删除</a>
  114. </div>
  115. </script>
  116. </div>
  117. </div>
  118. </div>
  119. </div>
  120. </div>
  121. <script src="../../layuiadmin/layui/layui.js"></script>
  122. <script>
  123. layui.config({
  124. base: '../../../layuiadmin/' //静态资源所在路径
  125. }).extend({
  126. index: 'lib/index' //主入口模块
  127. }).use(['index', 'table', 'form', 'admin', 'upload', ], function () {
  128. var $ = layui.$;
  129. var table = layui.table
  130. , admin = layui.admin
  131. ,upload = layui.upload
  132. , form = layui.form;
  133. table.render({
  134. elem: '#exam_question_datagrid'
  135. , url: '/admin/examquestion/'
  136. , cols: [[
  137. {title: '编号', type: 'numbers'}
  138. , {field: 'subject_text', title: '科目', width: 150}
  139. , {field: 'chapter_text', title: '章节', width: 150}
  140. , {field: 'type_text', title: '题型', width: 100}
  141. , {field: 'title', title: '内容', width: 400}
  142. , {field: 'difficulty_text', title: '难度', width: 100}
  143. , {field: 'create_user_text', title: '录入人', width: 150}
  144. , {field: 'create_time', title: '录入时间', width: 200}
  145. , {title: '操作', width: 180, align: 'center', fixed: 'right', toolbar: '#exam_question-operate-bar'}
  146. ]]
  147. , page: true
  148. , height: 'full-108'
  149. });
  150. //监听工具条
  151. table.on('tool(exam_question-operate)', function (obj) {
  152. var data = obj.data;
  153. table.editdata = data;
  154. if (obj.event === 'exam_question_edit') {
  155. layer.open({
  156. type: 2,
  157. title: '修改试题',
  158. shadeClose: false,
  159. area: ['80%', '80%'],
  160. btn: ['保存', '取消'],
  161. yes: function (index, dom) {
  162. layui.onSubmitChild = function (res) {
  163. layer.close(index);
  164. table.reload('exam_question_datagrid', {});
  165. };
  166. layui.submitChild();
  167. },
  168. btn2: function (index, layero) {
  169. layer.close(index);//关闭当前按钮
  170. },
  171. content: 'edit.html?id=' + data.id
  172. });
  173. }
  174. else if (obj.event === 'exam_question_delete') {
  175. layer.confirm('确定要删除该试题吗?', function (index) {
  176. layer.close(index);
  177. admin.req({
  178. url: '/admin/examquestion/' + data.id + '/'
  179. , type: 'delete'
  180. , done: function (res) {
  181. table.reload('exam_question_datagrid', {});
  182. }
  183. });
  184. });
  185. } else if (obj.event === 'exam_question_detail') {
  186. layer.open({
  187. type: 2,
  188. title: '查看详情',
  189. shadeClose: false,
  190. area: ['70%', '80%'],
  191. btn: ['关闭'],
  192. yes: function (index, dom) {
  193. layer.close(index);//关闭当前按钮
  194. },
  195. content: 'details.html'
  196. });
  197. }
  198. });
  199. form.on('submit(query-form-element)', function (data) {
  200. table.reload('exam_question_datagrid', {
  201. where: data.field
  202. , page: {curr: 1}
  203. });
  204. layer.closeAll();
  205. return false
  206. });
  207. $('#exam_question_add').on('click', function () {
  208. layer.open({
  209. type: 2,
  210. title: '添加试题',
  211. area: ['80%', '90%'],
  212. btn: ['保存', '取消'],
  213. yes: function (index, dom) {
  214. layui.onSubmitChild = function (res) {
  215. layer.close(index);
  216. table.reload('exam_question_datagrid', {});
  217. };
  218. layui.submitChild();
  219. },
  220. btn2: function (index, layero) {
  221. layer.close(index);//关闭当前按钮
  222. },
  223. content: 'edit.html'
  224. });
  225. });
  226. upload.render({
  227. elem: '#btn_add_single'
  228. ,url: '/admin/examquestion/import_single/'
  229. ,accept:'file'
  230. ,acceptMime:'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
  231. ,exts:'xlsx'
  232. ,field:'excel_file'
  233. ,multiple:false
  234. ,done: function(res){
  235. if (res.code == 0) {
  236. table.reload('exam_question_datagrid',{});
  237. } else {
  238. layer.msg(res.msg);
  239. }
  240. }
  241. ,error: function(){
  242. layer.msg('导入失败');
  243. }
  244. });
  245. upload.render({
  246. elem: '#btn_add_multiple'
  247. ,url: '/admin/examquestion/import_multiple/'
  248. ,accept:'file'
  249. ,acceptMime:'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
  250. ,exts:'xlsx'
  251. ,field:'excel_file'
  252. ,multiple:false
  253. ,done: function(res){
  254. if (res.code == 0) {
  255. table.reload('exam_question_datagrid',{});
  256. } else {
  257. layer.msg(res.msg);
  258. }
  259. }
  260. ,error: function(){
  261. layer.msg('导入失败');
  262. }
  263. });
  264. upload.render({
  265. elem: '#btn_add_fill'
  266. ,url: '/admin/examquestion/import_fill/'
  267. ,accept:'file'
  268. ,acceptMime:'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
  269. ,exts:'xlsx'
  270. ,field:'excel_file'
  271. ,multiple:false
  272. ,done: function(res){
  273. if (res.code == 0) {
  274. table.reload('exam_question_datagrid',{});
  275. } else {
  276. layer.msg(res.msg);
  277. }
  278. }
  279. ,error: function(){
  280. layer.msg('导入失败');
  281. }
  282. });
  283. upload.render({
  284. elem: '#btn_add_judgment'
  285. ,url: '/admin/examquestion/import_judgment/'
  286. ,accept:'file'
  287. ,acceptMime:'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
  288. ,exts:'xlsx'
  289. ,field:'excel_file'
  290. ,multiple:false
  291. ,done: function(res){
  292. if (res.code == 0) {
  293. table.reload('exam_question_datagrid',{});
  294. } else {
  295. layer.msg(res.msg);
  296. }
  297. }
  298. ,error: function(){
  299. layer.msg('导入失败');
  300. }
  301. });
  302. upload.render({
  303. elem: '#btn_add_discuss'
  304. ,url: '/admin/examquestion/import_discuss/'
  305. ,accept:'file'
  306. ,acceptMime:'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
  307. ,exts:'xlsx'
  308. ,field:'excel_file'
  309. ,multiple:false
  310. ,done: function(res){
  311. if (res.code == 0) {
  312. table.reload('exam_question_datagrid',{});
  313. } else {
  314. layer.msg(res.msg);
  315. }
  316. }
  317. ,error: function(){
  318. layer.msg('导入失败');
  319. }
  320. });
  321. $('#btn_download_single').on('click', function () {
  322. layui.view.download("/static/xls/单选题导入模版.xlsx");
  323. });
  324. $('#btn_download_multiple').on('click', function () {
  325. layui.view.download("/static/xls/多选题导入模版.xlsx");
  326. });
  327. $('#btn_download_fill').on('click', function () {
  328. layui.view.download("/static/xls/填空题导入模版.xlsx");
  329. });
  330. $('#btn_download_judgment').on('click', function () {
  331. layui.view.download("/static/xls/判断题导入模版.xlsx");
  332. });
  333. $('#btn_download_discuss').on('click', function () {
  334. layui.view.download("/static/xls/论述题导入模版.xlsx");
  335. });
  336. });
  337. </script>
  338. </body>
  339. </html>