class_index.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. {extend name="public/layout"/} {block name="title"}课程培训{/block} {block name="body"}
  2. <style type="text/css">
  3. html,
  4. body {
  5. display: block;
  6. min-width: 1100px;
  7. }
  8. .layui-table thead tr,
  9. .layui-table-header {
  10. background-color: #D8E6F1 !important;
  11. }
  12. .layui-fluid {
  13. display: block;
  14. box-shadow: 0 0 4px 0 #B6CADE;
  15. border-radius: 5px;
  16. margin: 15px;
  17. background-color: #ffffff;
  18. }
  19. .layui-form-item .layui-inline {
  20. margin-right: 0px;
  21. }
  22. .layui-form-label {
  23. width: auto;
  24. }
  25. .layui-btn-primary {
  26. color: #249EFB;
  27. border: 1px solid #249EFB;
  28. }
  29. .layui-btn-primary:hover {
  30. background-color: #E3F7FF;
  31. color: #249EFB;
  32. }
  33. /*.layui-table-cell {
  34. padding: 0px 20px;
  35. }*/
  36. .plr10 {
  37. padding: 0px 10px;
  38. }
  39. .border249EFB,
  40. .border249EFB:hover {
  41. border: 1px solid #249EFB;
  42. background-color: #fff;
  43. color: #249EFB;
  44. padding: 0px 10px;
  45. }
  46. .borderFF5722,
  47. .borderFF5722:hover {
  48. border: 1px solid #FF5722;
  49. background-color: #fff;
  50. color: #FF5722;
  51. padding: 0px 10px;
  52. }
  53. .layui-table td,
  54. .layui-table th {
  55. box-sizing: border-box;
  56. }
  57. .layui-table-view .layui-table {
  58. width: 100%;
  59. }
  60. </style>
  61. <div class="layui-fluid">
  62. <div class="layui-card">
  63. <div class="layui-form layui-card-header layuiadmin-card-header-auto">
  64. <div class="layui-form-item">
  65. <div style="float:right;">
  66. <div class="layui-inline">
  67. <label class="layui-form-label">关键字查询:</label>
  68. <div class="layui-input-inline" style="width: auto;">
  69. <input type="text" name="keyword" placeholder="请输入关键字搜索" autocomplete="off"
  70. class="layui-input keyword">
  71. </div>
  72. </div>
  73. <div class="layui-inline">
  74. <button class="layui-btn layuiadmin-btn" lay-submit lay-filter="LAY-app-contlist-search">
  75. <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
  76. </button>
  77. </div>
  78. </div>
  79. {auth:check name="train/class_add"}
  80. <div class="layui-inline" style="float: left;">
  81. <button class="layui-btn layuiadmin-btn layui-btn-primary" data-type="trainClassAdd">添加课程</button>
  82. </div>
  83. {/auth:check}
  84. <div class="layui-inline" style="float: left;margin-left:10px;">
  85. <button class="layui-btn layuiadmin-btn layui-btn-primary" data-type="trainClassCate">分类管理</button>
  86. </div>
  87. <div class="layui-inline" style="float: left;margin-left:10px;">
  88. <button class="layui-btn layuiadmin-btn layui-btn-primary" data-type="trainClassLabel">二级分类</button>
  89. </div>
  90. </div>
  91. </div>
  92. <div class="layui-card-body">
  93. <table lay-filter="datalist" id="datalist"></table>
  94. </div>
  95. </div>
  96. </div>
  97. {/block} {block name="js"}
  98. <script type="text/html" id="op">
  99. {auth:check name="train/class_add"}
  100. <a class="layui-btn layui-btn-xs layui-btn-success plr10 border249EFB" lay-event="assign">指派</a>
  101. {{# if(d.from_type == 0){ }}
  102. <a class="layui-btn layui-btn-xs layui-btn-success plr10 border249EFB" lay-event="edit">编辑</a>
  103. {{# } }}
  104. {/auth:check}
  105. <a class="layui-btn layui-btn-xs plr10 border249EFB" lay-event="comment">感悟</a>
  106. {auth:check name="train/classDel"}
  107. {{# if(d.from_type == 0){ }}
  108. <a class="layui-btn layui-btn-danger layui-btn-xs plr10 borderFF5722" lay-event="del">删除</a>
  109. {{# } }}
  110. {/auth:check}
  111. </script>
  112. <script type="text/html" id="show">
  113. <input type="checkbox" name="show" value="{{d.id}}" lay-skin="switch" lay-text="上架|下架" lay-filter="show" {{ d.publish == 1 ? 'checked' : '' }} id="clickshow">
  114. </script>
  115. <script type="text/html" id="kh">
  116. <a href="javascript:void(0)" lay-event="showOrgData" style="color:blue;">查看</a>
  117. </script>
  118. <script type="text/html" id="completeCount">
  119. <a href="javascript:void(0)" lay-event="completeList" style="color:blue;">{{d.completeCount}}</a>
  120. </script>
  121. <script type="text/html" id="noFinishCount">
  122. <a href="javascript:void(0)" lay-event="noFinishList" style="color:blue;">{{d.noFinishCount}}</a>
  123. </script>
  124. <script type="text/html" id="qrcode">
  125. <a href="javascript:void(0)" lay-event="download" style="color:blue;">查看</a>
  126. </script>
  127. <script type="text/html" id="title">
  128. {{# if(d.from_type == 2){ }}
  129. <i class="layui-icon">&#xe609;</i>&nbsp;&nbsp;{{d.title}}
  130. {{# }else{ }}
  131. {{d.title}}
  132. {{# } }}
  133. </script>
  134. <script type="text/html" id="cate">
  135. {{# if(d.cate){ }}
  136. <span>{{d.cate}}</span>
  137. {{# }else{ }}
  138. <span style="color: #cccccc;">无</span>
  139. {{# } }}
  140. </script>
  141. <script type="text/html" id="label">
  142. {{# if(d.label){ }}
  143. <span>{{d.label}}</span>
  144. {{# }else{ }}
  145. <span style="color: #cccccc;">无</span>
  146. {{# } }}
  147. </script>
  148. <script type="text/html" id="category">
  149. {{# if(d.category=='elective'){ }}
  150. <span>选修</span>
  151. {{# }else{ }}
  152. <span>必修</span>
  153. {{# } }}
  154. </script>
  155. <script type="text/html" id="view">
  156. <a href="javascript:void(0)" lay-event="view_log" style="color:blue;">{{d.view}}</a>
  157. </script>
  158. <script>
  159. layui.use(['form', 'table'], function () {
  160. var form = layui.form,
  161. table = layui.table,
  162. $ = layui.$;
  163. var field = {};
  164. form.on('submit(LAY-app-contlist-search)', function (data) {
  165. var keyword = $('.keyword').val();
  166. field['keyword'] = keyword;
  167. //执行重载
  168. table.reload('datalist', {
  169. where: field,
  170. page: {
  171. curr: 1
  172. }
  173. });
  174. });
  175. var active = {
  176. trainClassAdd: function () {
  177. layer.open({
  178. type: 2,
  179. title: ['添加课程', 'color:#333333;background-color:#D8E6F1;'],
  180. content: '{:url("train/class_add")}',
  181. resize: false,
  182. area: ['80%', '80%'],
  183. });
  184. },
  185. trainClassCate: function () {
  186. layer.open({
  187. type: 2,
  188. title: ['分类管理', 'color:#333333;background-color:#D8E6F1;'],
  189. content: '{:url("train/class_cate")}',
  190. resize: false,
  191. area: ['80%', '80%'],
  192. });
  193. },
  194. trainClassLabel: function () {
  195. layer.open({
  196. type: 2,
  197. title: ['二级分类管理', 'color:#333333;background-color:#D8E6F1;'],
  198. content: '{:url("train/class_label")}',
  199. resize: false,
  200. area: ['80%', '80%'],
  201. });
  202. }
  203. };
  204. table.render({
  205. elem: '#datalist',
  206. url: "{:url('train/class_index')}",
  207. page: true,
  208. height: 'full-160',
  209. cols: [
  210. [{
  211. type: 'numbers',
  212. field: 'id',
  213. title: '序号',
  214. width: '50',
  215. fixed: 'left'
  216. },
  217. {
  218. title: '课程名称',
  219. field: 'title',
  220. width: '200',
  221. fixed: 'left',
  222. templet: '#title',
  223. align: 'center'
  224. },
  225. {
  226. title: '分类',
  227. field: 'cate',
  228. width: '100',
  229. fixed: 'left',
  230. templet: '#cate',
  231. align: 'center'
  232. },
  233. {
  234. title: '二级分类',
  235. field: 'label',
  236. width: '100',
  237. fixed: 'left',
  238. templet: '#label',
  239. align: 'center'
  240. },
  241. {
  242. title: '添加时间',
  243. field: 'addtime',
  244. width: '160',
  245. align: 'center'
  246. },
  247. {
  248. title: '课件数',
  249. field: 'courseCount',
  250. width: '80',
  251. align: 'center'
  252. },
  253. // {
  254. // title: '培训人数',
  255. // field: 'train_employee',
  256. // width: '90',
  257. // align: 'center'
  258. // },
  259. {
  260. title: '类别',
  261. field: 'category',
  262. width: '90',
  263. align: 'center',
  264. templet: '#category',
  265. },
  266. {
  267. title: '已完成人数',
  268. templet: '#completeCount',
  269. width: '100',
  270. align: 'center'
  271. },
  272. {
  273. title: '未完成人数',
  274. templet: '#noFinishCount',
  275. width: '100',
  276. align: 'center'
  277. },
  278. {
  279. title: '未开始人数',
  280. field: 'noStartCount',
  281. width: '100',
  282. align: 'center'
  283. },
  284. {
  285. title: '完成观看感',
  286. field: 'summaryCount',
  287. width: '100',
  288. align: 'center'
  289. },
  290. {
  291. title: '量化考核',
  292. templet: '#kh',
  293. width: '90',
  294. align: 'center'
  295. },
  296. {
  297. title: '学习码',
  298. templet: '#qrcode',
  299. width: '6.2%',
  300. align: 'center'
  301. },
  302. {
  303. title: '上下架',
  304. templet: '#show',
  305. width: '10%',
  306. align: 'center'
  307. },
  308. {
  309. field: 'view',
  310. width: '90',
  311. title: '浏览次数',
  312. align: 'center',
  313. templet: '#view',
  314. },
  315. {
  316. title: '操作',
  317. templet: '#op',
  318. minWidth: '266',
  319. fixed: 'right'
  320. },
  321. ]
  322. ],
  323. done: function (res, curr, count) {
  324. fixedLayuiTable(this, count);
  325. }
  326. });
  327. table.on('tool(datalist)', function (obj) {
  328. switch (obj.event) {
  329. case 'del':
  330. layer.confirm('确定要删除该内容么', { title: ['信息', 'color:#333333;background-color:#D8E6F1;'] }, function () {
  331. $.ajax({
  332. url: '{:url("train/classDel")}',
  333. data: {
  334. id: obj.data.id
  335. },
  336. type: 'get',
  337. success: function (res) {
  338. if (res.code == 0) {
  339. layer.msg(res.msg, {
  340. icon: 1,
  341. time: 1000
  342. }, function () {
  343. layui.table.reload('datalist');
  344. });
  345. } else {
  346. layer.msg(res.msg);
  347. }
  348. }
  349. });
  350. });
  351. break;
  352. case 'publish':
  353. $.ajax({
  354. url: '{:url("train/classPublish")}',
  355. data: {
  356. id: obj.data.id
  357. },
  358. type: 'get',
  359. success: function (res) {
  360. if (res.code == 0) {
  361. layer.msg(res.msg, {
  362. icon: 1,
  363. time: 1000
  364. }, function () {
  365. layui.table.reload('datalist');
  366. });
  367. } else {
  368. layer.msg(res.msg);
  369. }
  370. }
  371. });
  372. break;
  373. case 'assign':
  374. layer.open({
  375. type: 2,
  376. title: ['指派', 'color:#333333;background-color:#D8E6F1;'],
  377. content: '{:url("train/class_assigns")}?id=' + obj.data.id,
  378. area: ['80%', '80%'],
  379. btn: ['确定', '取消'],
  380. yes: function (index, layero) {
  381. layui.table.reload('datalist');
  382. layer.close(index);
  383. //点击确认触发 iframe 内容中的按钮提交
  384. // var val = layero.find('iframe').contents().find("#departinput").val();
  385. // var arr = val?JSON.parse(val):"";
  386. // var org_arr = [];
  387. // for(var i in arr){
  388. // org_arr.push(i);
  389. // }
  390. // if(org_arr.length == 0)
  391. // {
  392. // layer.msg('请选择考核组织');
  393. // return false;
  394. // }
  395. // $.ajax({
  396. // url: '{:url("train/class_assign_edit")}',
  397. // data: {
  398. // id: obj.data.id,
  399. // org: org_arr.join(',')
  400. // },
  401. // type: 'get',
  402. // success: function(res) {
  403. // if(res.code == 0){
  404. // layer.msg(res.msg, {
  405. // icon: 1,
  406. // time: 1000
  407. // },function(){
  408. // layui.table.reload('datalist');
  409. // layer.close(index);
  410. // });
  411. // }else{
  412. // layer.msg(res.msg);
  413. // }
  414. // }
  415. // });
  416. }
  417. });
  418. break;
  419. case 'showOrgData':
  420. layer.open({
  421. type: 2,
  422. title: ['量化考核', 'color:#333333;background-color:#D8E6F1;'],
  423. content: '{:url("train/class_org_data")}?class_id=' + obj.data.id + '&trainNumber=' + obj.data.trainNumber + '&completeCount=' + obj.data.completeCount + '&summaryCount=' + obj.data.summaryCount,
  424. resize: false,
  425. area: ['80%', '80%'],
  426. });
  427. break;
  428. case 'comment':
  429. layer.open({
  430. type: 2,
  431. title: ['感悟', 'color:#333333;background-color:#D8E6F1;'],
  432. content: '{:url("train/class_comment")}?class_id=' + obj.data.id,
  433. resize: false,
  434. area: ['80%', '80%'],
  435. });
  436. break;
  437. case 'edit':
  438. layer.open({
  439. type: 2,
  440. title: ['修改课程', 'color:#333333;background-color:#D8E6F1;'],
  441. content: '{:url("train/class_edit")}?class_id=' + obj.data.id,
  442. resize: false,
  443. area: ['80%', '80%'],
  444. });
  445. break;
  446. case 'completeList':
  447. layer.open({
  448. type: 2,
  449. title: ['已完成人数', 'color:#333333;background-color:#D8E6F1;'],
  450. content: '{:url("train/doneLog")}?type=complete&class_id=' + obj.data.id,
  451. resize: false,
  452. area: ['80%', '80%'],
  453. });
  454. break;
  455. case 'noFinishList':
  456. layer.open({
  457. type: 2,
  458. title: ['未完成人数', 'color:#333333;background-color:#D8E6F1;'],
  459. content: '{:url("train/doneLog")}?type=noFinish&class_id=' + obj.data.id,
  460. resize: false,
  461. area: ['80%', '80%'],
  462. });
  463. break;
  464. case 'download':
  465. $.ajax({
  466. url: '{:url("train/qrcode")}',
  467. data: {
  468. id: obj.data.id
  469. },
  470. type: 'get',
  471. success: function (res) {
  472. if (res.code == 0) {
  473. layer.open({
  474. type: 1,
  475. title: ['学习码', 'color:#333333;background-color:#D8E6F1;'],
  476. content: '<img border="0" src="' + res.qrcode + '" alt="点击下载">',
  477. btn: ['下载', '关闭'],
  478. yes: function (index, layero) {
  479. window.open(obj.data.qrcode);
  480. //按钮【按钮一】的回调
  481. },
  482. btn2: function (index, layero) {
  483. //按钮【按钮二】的回调
  484. }
  485. })
  486. } else {
  487. layer.msg(res.msg);
  488. }
  489. }
  490. });
  491. break;
  492. case 'view_log':
  493. layer.open({
  494. type: 2,
  495. title:['浏览记录','color:#333333;background-color:#D8E6F1;'],
  496. content: '{:url("train/class_view")}?class_id=' + obj.data.id,
  497. resize: false,
  498. area: ['80%', '80%']
  499. });
  500. break;
  501. }
  502. });
  503. form.on('switch(show)', function (obj) {
  504. var id = obj.value;
  505. $.ajax({
  506. type: "post",
  507. url: '{:url("train/classPublish")}',
  508. data: {
  509. id: id
  510. },
  511. success: function (res) {
  512. layer.msg(res.msg);
  513. }
  514. });
  515. });
  516. //发布
  517. form.on('switch(show)', function (obj) {
  518. // console.log(obj)
  519. // return false;
  520. var id = obj.value;
  521. $.ajax({
  522. type: "post",
  523. url: '{:url("train/classPublish")}',
  524. data: {
  525. id: id,
  526. },
  527. success: function (res) {
  528. layer.msg(res.msg, { time: 2000 });
  529. }
  530. });
  531. });
  532. $('.layui-btn.layuiadmin-btn').on('click', function () {
  533. var type = $(this).data('type');
  534. active[type] ? active[type].call(this) : '';
  535. });
  536. });
  537. function fixedLayuiTable(tableobj, count, ifpage) {
  538. if (count == 0) {
  539. tableobj.elem.next('.layui-table-view').find('.layui-table-header').css('display', 'inline-block');
  540. var tableBox = tableobj.elem.next('.layui-table-view').find('.layui-table-box');
  541. tableBox.css('overflow-x', 'auto');
  542. //改变高度:table没有分页高度减15,否则增加25
  543. if (!ifpage) {
  544. tableBox.height(tableBox.height() - 15);
  545. } else {
  546. tableBox.height(tableBox.height() + 25);
  547. }
  548. }
  549. }
  550. </script>
  551. {/block}