examine.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. {extend name="public/container"}
  2. {block name="head_top"}
  3. <style>
  4. .layui-table-cell img{max-width: 100%;height: 50px;cursor: pointer;}
  5. </style>
  6. {/block}
  7. {block name="content"}
  8. <div class="layui-fluid">
  9. <div class="layui-card">
  10. <div class="layui-card-header">{$type==1 ? '练习列表':'考试列表'}</div>
  11. <div class="layui-card-body">
  12. <form class="layui-form layui-form-pane" action="">
  13. <div class="layui-form-item">
  14. <div class="layui-inline">
  15. <label class="layui-form-label">{$type==1 ? '练习搜索':'考试搜索'}</label>
  16. <div class="layui-input-inline">
  17. <input type="text" name="title" class="layui-input" placeholder="{$type==1 ? '练习':'考试'}标题">
  18. </div>
  19. </div>
  20. <div class="layui-inline">
  21. <label class="layui-form-label">讲师</label>
  22. <div class="layui-input-inline">
  23. <select name="mer_id" lay-search="">
  24. <option value="">全部</option>
  25. {volist name='mer_list' id='vc'}
  26. <option value="{$vc.id}">{$vc.mer_name}</option>
  27. {/volist}
  28. </select>
  29. </div>
  30. </div>
  31. <div class="layui-inline">
  32. <label class="layui-form-label">{$type==1 ? '练习分类':'考试分类'}</label>
  33. <div class="layui-input-inline">
  34. <select name="pid" lay-search="">
  35. <option value="0">全部</option>
  36. {volist name='category' id='vc'}
  37. <option {if $vc.pid==0}disabled{/if} value="{$vc.id}">{$vc.html}{$vc.title}</option>
  38. {/volist}
  39. </select>
  40. </div>
  41. </div>
  42. <div class="layui-inline">
  43. <div class="layui-input-inline">
  44. <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit="search" lay-filter="search">
  45. <i class="layui-icon layui-icon-search"></i>搜索
  46. </button>
  47. </div>
  48. </div>
  49. </div>
  50. </form>
  51. <div class="layui-btn-container">
  52. <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" data-type="refresh" onclick="window.location.reload()">
  53. <i class="layui-icon layui-icon-refresh-1"></i>刷新
  54. </button>
  55. </div>
  56. <table id="List" lay-filter="List"></table>
  57. <input type="hidden" id="check_source_tmp" name="check_source_tmp"/>
  58. <script type="text/html" id="status">
  59. {{# if(d.status==0){ }}
  60. <button lay-event='fail' class="layui-btn layui-btn-danger layui-btn-xs zsff-fail" type="button"><i class="layui-icon">&#x1006;</i>不通过</button>
  61. <button lay-event='succ' class="layui-btn layui-btn-normal layui-btn-xs zsff-success" type="button"><i class="layui-icon">&#xe605;</i>通过</button>
  62. {{# }else if(d.status==-1){ }}
  63. <button class="layui-btn layui-btn-danger layui-btn-xs zsff-fail" type="button"><i class="layui-icon">&#x1006;</i>不通过</button>
  64. <br>
  65. 原因:{{d.fail_message}}
  66. <br>
  67. 时间:{{d.fail_time}}
  68. {{# } }}
  69. </script>
  70. <script type="text/html" id="is_show">
  71. <input type='checkbox' name='id' lay-skin='switch' value="{{d.id}}" lay-filter='is_show' lay-text='显示|隐藏' {{ d.is_show == 1 ? 'checked' : '' }}>
  72. </script>
  73. <script type="text/html" id="image">
  74. <img width="89" height="50" lay-event='open_image' src="{{d.image}}">
  75. </script>
  76. <script type="text/html" id="recommend">
  77. {{# layui.each(d.recommend, function(index, item){ }}
  78. <span class="layui-badge layui-bg-blue recom-item" data-id="{{index}}" data-pid="{{d.id}}" style="margin-bottom: 5px;">{{item}}</span>
  79. {{# }); }}
  80. </script>
  81. <script type="text/html" id="act">
  82. {{# if (d.status) { }}
  83. <a class="layui-btn layui-btn-xs layui-btn-disabled">审核</a>
  84. {{# } else { }}
  85. <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="detail">审核</a>
  86. {{# } }}
  87. </script>
  88. </div>
  89. </div>
  90. </div>
  91. <script src="{__ADMIN_PATH}js/layuiList.js"></script>
  92. {/block}
  93. {block name="script"}
  94. <script>
  95. var $ = layui.jquery;
  96. var layer = layui.layer;
  97. var type=<?=$type?>;
  98. var types=type==1 ? '添加练习' : '添加考试';
  99. //实例化form
  100. layList.form.render();
  101. layList.date({elem: '#datetime', type: 'datetime', range: '~'});
  102. //加载列表
  103. layList.tableList({o:'List', done:function () {}},"{:Url('get_test_paper_examine_list',['type'=>$type])}",function (){
  104. var join=new Array();
  105. switch (parseInt(type)) {
  106. case 1:
  107. join = [
  108. {field: 'id', title: '编号', width: '4%', align: 'center'},
  109. {field: 'cate', title: '分类', width: '6%'},
  110. {field: 'mer_name', title: '讲师',align: 'center',width:'6%'},
  111. {field: 'title', title: '练习标题'},
  112. {field: 'item_number', title: '题目数量', align: 'center', width: '7%'},
  113. {field: 'single_number', title: '单选题数量', align: 'center', width: '7%'},
  114. {field: 'many_number', title: '多选题数量', align: 'center', width: '7%'},
  115. {field: 'judge_number', title: '判断题数量', align: 'center', width: '7%'},
  116. {field: 'answer', title: '答题人数', align: 'center', width: '6%'},
  117. {field: 'status', title: '状态',templet:'#status',align: 'center',width:'18%'},
  118. {title: '操作', align: 'center', toolbar: '#act', width: '7%'}
  119. ];
  120. break;
  121. case 2:
  122. join = [
  123. {field: 'id', title: '编号', width: '4%', align: 'center'},
  124. {field: 'cate', title: '分类', width: '5%'},
  125. {field: 'mer_name', title: '讲师',align: 'center',width:'6%'},
  126. {field: 'title', title: '考试标题'},
  127. {field: 'image', title: '封面图', templet: '#image',align: 'center', width: '7%'},
  128. {field: 'item_number', title: '题目数量', align: 'center', width: '5%'},
  129. {field: 'single_number', title: '单选题数量', align: 'center', width: '5%'},
  130. {field: 'many_number', title: '多选题数量', align: 'center', width: '5%'},
  131. {field: 'judge_number', title: '判断题数量', align: 'center', width: '5%'},
  132. {field: 'answer', title: '答题人数', align: 'center', width: '5%'},
  133. {field: 'txamination_time', title: '考试时长/分', align: 'center', width: '5%'},
  134. {field: 'money', title: '价格', align: 'center', width: '5%'},
  135. {field: 'member_money', title: '会员价', align: 'center', width: '5%'},
  136. {field: 'status', title: '状态',templet:'#status',align: 'center',width:'18%'},
  137. {title: '操作', align: 'center', toolbar: '#act', width: '7%'}
  138. ];
  139. break;
  140. }
  141. return join;
  142. });
  143. $(function () {
  144. $(document).on('mouseover', '.recom-item', function () {
  145. var that = this;
  146. layui.use('layer', function () {
  147. var layer = layui.layer;
  148. layer.tips('点击即可取消此推荐', that, {
  149. tips: [1, '#0093dd']
  150. });
  151. });
  152. });
  153. $(document).on('mouseout', '.recom-item', function () {
  154. var that = this;
  155. layui.use('layer', function () {
  156. var layer = layui.layer;
  157. layer.closeAll();
  158. });
  159. });
  160. $(document).on('click', '.recom-item', function () {
  161. var that = this;
  162. var url = layList.U({ a: 'cancel_recommendation', q: { id: that.dataset.id, test_id: that.dataset.pid } });
  163. $eb.$swal(
  164. 'delete',
  165. function () {
  166. $eb.axios
  167. .get(url)
  168. .then(function (res) {
  169. if (res.data.code == 200) {
  170. $eb.$swal('success', res.data.msg);
  171. window.location.reload();
  172. } else {
  173. return Promise.reject(res.data.msg || '删除失败');
  174. }
  175. })
  176. .catch(function (err) {
  177. $eb.$swal('error', err);
  178. });
  179. },
  180. {
  181. title: '确定取消此推荐?',
  182. text: '取消后无法撤销,请谨慎操作!',
  183. confirm: '确定取消'
  184. }
  185. );
  186. });
  187. });
  188. //自定义方法
  189. var action= {
  190. set_value: function (field, id, value) {
  191. layList.baseGet(layList.Url({
  192. a: 'set_value',
  193. q: {field: field, id: id, value: value}
  194. }), function (res) {
  195. layList.msg(res.msg);
  196. });
  197. },
  198. //打开新添加页面
  199. open_add: function (url,title) {
  200. layer.open({
  201. type: 2 //Page层类型
  202. ,area: ['100%', '100%']
  203. ,title: title
  204. ,shade: 0.6 //遮罩透明度
  205. ,maxmin: true //允许全屏最小化
  206. ,anim: 1 //0-6的动画形式,-1不开启
  207. ,content: url
  208. ,end:function() {
  209. location.reload();
  210. }
  211. });
  212. }
  213. };
  214. //查询
  215. layList.search('search',function(where){
  216. layList.reload({
  217. pid: where.pid,
  218. mer_id: where.mer_id,
  219. title: where.title
  220. },true);
  221. });
  222. //快速编辑
  223. layList.edit(function (obj) {
  224. var id=obj.data.id,value=obj.value;
  225. switch (obj.field) {
  226. case 'sort':
  227. if (value.trim()) {
  228. if (isNaN(value.trim())) {
  229. layList.msg('请输入正确的数字');
  230. } else {
  231. if (value.trim() < 0) {
  232. layList.msg('排序不能小于0');
  233. } else if (value.trim() > 9999) {
  234. layList.msg('排序不能大于9999');
  235. } else if (parseInt(value.trim()) != value.trim()) {
  236. layList.msg('排序不能为小数');
  237. } else {
  238. action.set_value('sort', id, value.trim());
  239. }
  240. }
  241. } else {
  242. layList.msg('排序不能为空');
  243. }
  244. break;
  245. }
  246. });
  247. //监听并执行排序
  248. layList.sort(['id','sort'],true);
  249. //点击事件绑定
  250. layList.tool(function (event,data,obj) {
  251. switch (event) {
  252. case 'delect':
  253. var url=layList.U({a:'delete',q:{id:data.id}});
  254. $eb.$swal('delete',function(){
  255. $eb.axios.get(url).then(function(res){
  256. if(res.status == 200 && res.data.code == 200) {
  257. $eb.$swal('success',res.data.msg);
  258. obj.del();
  259. }else
  260. return Promise.reject(res.data.msg || '删除失败')
  261. }).catch(function(err){
  262. $eb.$swal('error',err);
  263. });
  264. });
  265. break;
  266. case 'open_image':
  267. $eb.openImage(data.image);
  268. break;
  269. case 'succ':
  270. var url=layList.U({a:'succ',q:{id:data.id}});
  271. $eb.$swal('delete',function(){
  272. $eb.axios.get(url).then(function(res){
  273. if(res.status == 200 && res.data.code == 200) {
  274. window.location.reload();
  275. $eb.$swal('success',res.data.msg);
  276. }else
  277. return Promise.reject(res.data.msg || '删除失败')
  278. }).catch(function(err){
  279. $eb.$swal('error',err);
  280. });
  281. },{
  282. title:'确定审核通过?',
  283. text:'通过后无法撤销,请谨慎操作!',
  284. confirm:'审核通过'
  285. });
  286. break;
  287. case 'fail':
  288. var url=layList.U({a:'fail',q:{id:data.id}});
  289. $eb.$alert('textarea',{
  290. title:'请输入未通过愿意',
  291. value:'输入信息不完整或有误!',
  292. },function(value){
  293. $eb.axios.post(url,{message:value}).then(function(res){
  294. if(res.data.code == 200) {
  295. window.location.reload();
  296. $eb.$swal('success', res.data.msg);
  297. }else
  298. $eb.$swal('error',res.data.msg||'操作失败!');
  299. });
  300. });
  301. break;
  302. case 'detail':
  303. action.open_add('{:Url('examineDetails')}?id=' + data.id + '&type=' + data.type, '审核');
  304. break;
  305. }
  306. })
  307. </script>
  308. {/block}