index.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. {extend name="public/container"}
  2. {block name="content"}
  3. <div class="layui-fluid">
  4. <div class="layui-row layui-col-space15">
  5. <div class="layui-col-md12">
  6. <div class="layui-card">
  7. <div class="layui-card-header">荣誉证书列表</div>
  8. <div class="layui-card-body">
  9. <div class="layui-row layui-col-space15">
  10. <div class="layui-col-md12">
  11. <form class="layui-form layui-form-pane" action="">
  12. <div class="layui-form-item">
  13. <div class="layui-inline">
  14. <label class="layui-form-label">证书搜索</label>
  15. <div class="layui-input-inline">
  16. <input type="text" name="title" class="layui-input" placeholder="证书标题">
  17. </div>
  18. </div>
  19. <div class="layui-inline">
  20. <label class="layui-form-label">获取方式</label>
  21. <div class="layui-input-inline">
  22. <select name="obtain" lay-search="">
  23. <option value="0">全部</option>
  24. <option value="1">课程</option>
  25. <option value="2">考试</option>
  26. </select>
  27. </div>
  28. </div>
  29. <div class="layui-inline">
  30. <div class="layui-input-inline">
  31. <div class="layui-btn-group">
  32. <button type="button" class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="search" lay-filter="search">
  33. <i class="layui-icon">&#xe615;</i>搜索
  34. </button>
  35. </div>
  36. </div>
  37. </div>
  38. </div>
  39. </form>
  40. </div>
  41. <div class="layui-col-md12">
  42. <div class="layui-btn-group">
  43. <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" data-type="add" onclick="action.open_add('{:Url('add')}','添加荣誉证书')">
  44. <i class="layui-icon">&#xe608;</i>添加荣誉证书
  45. </button>
  46. <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" data-type="refresh" onclick="window.location.reload()">
  47. <i class="layui-icon">&#xe669;</i>刷新
  48. </button>
  49. </div>
  50. <table class="layui-hide" id="List" lay-filter="List"></table>
  51. <input type="hidden" id="check_source_tmp" name="check_source_tmp"/>
  52. <script type="text/html" id="background">
  53. <img style="cursor: pointer;" width="35" height="50" lay-event='open_image_background' src="{{d.background}}">
  54. </script>
  55. <script type="text/html" id="qr_code">
  56. <img style="cursor: pointer;" width="50" height="50" lay-event='open_image_qr_code' src="{{d.qr_code}}">
  57. </script>
  58. <script type="text/html" id="status">
  59. {{# if(d.status==1){ }}
  60. <span class="layui-badge layui-bg-blue">通过</span>
  61. {{# }else if(d.status==0){ }}
  62. <span class="layui-badge layui-bg-blue">未审核</span>
  63. {{# }else{ }}
  64. <span class="layui-badge">未通过</span>
  65. <span class="layui-badge layui-bg-blue" lay-event='fail'>查看原因</span>
  66. {{# } }}
  67. </script>
  68. <script type="text/html" id="act">
  69. <button type="button" class="layui-btn layui-btn-normal layui-btn-xs" onclick="dropdown(this)">
  70. <i class="layui-icon">&#xe625;</i>操作
  71. </button>
  72. <ul class="layui-nav-child layui-anim layui-anim-upbit">
  73. <li>
  74. <a href="javascript:void(0)" onclick="action.open_add('{:Url('add')}?id={{d.id}}','编辑证书')">
  75. <i class="iconfont icon-bianji"></i> 编辑证书
  76. </a>
  77. </li>
  78. <li>
  79. <a lay-event='delect' href="javascript:void(0)">
  80. <i class="iconfont icon-shanchu"></i> 删除证书
  81. </a>
  82. </li>
  83. </ul>
  84. </script>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. </div>
  91. </div>
  92. <script src="{__ADMIN_PATH}js/layuiList.js"></script>
  93. {/block}
  94. {block name="script"}
  95. <script>
  96. var $ = layui.jquery;
  97. var layer = layui.layer;
  98. //实例化form
  99. layList.form.render();
  100. layList.date({elem: '#datetime', type: 'datetime', range: '~'});
  101. //加载列表
  102. layList.tableList({o:'List', done:function () {}},"{:Url('getCertificateList')}",function (){
  103. return [
  104. {field: 'id', title: '编号', width: '8%', align: 'center'},
  105. {field: 'title', title: '证书标题', align: 'center'},
  106. {field: 'background', title: '证书背景', templet: '#background',align: 'center', width: '10%'},
  107. {field: 'qr_code', title: '二维码', templet: '#qr_code',align: 'center', width: '10%'},
  108. {field: 'obtains', title: '获取方式', align: 'center', width: '10%'},
  109. {field: 'number', title: '获取人数', align: 'center', width: '10%'},
  110. {field: 'sort', title: '排序', sort: true, event: 'sort', edit: 'sort', align: 'center', width: '10%'},
  111. {field: 'status', title: '审核',templet:'#status',align: 'center',width:'8%'},
  112. {field: 'right', title: '操作', align: 'center', toolbar: '#act', width: '12%'}
  113. ];
  114. });
  115. //下拉框
  116. $(document).click(function (e) {
  117. $('.layui-nav-child').hide();
  118. });
  119. function dropdown(that){
  120. var oEvent = arguments.callee.caller.arguments[0] || event;
  121. oEvent.stopPropagation();
  122. var offset = $(that).offset();
  123. var top=offset.top-$(window).scrollTop();
  124. var index = $(that).parents('tr').data('index');
  125. $('.layui-nav-child').each(function (key) {
  126. if (key != index) {
  127. $(this).hide();
  128. }
  129. });
  130. if($(document).height() < top+$(that).next('ul').height()){
  131. $(that).next('ul').css({
  132. 'padding': 10,
  133. 'top': - ($(that).parent('td').height() / 2 + $(that).height() + $(that).next('ul').height()/2),
  134. 'min-width': 'inherit',
  135. 'position': 'absolute'
  136. }).toggle();
  137. }else{
  138. $(that).next('ul').css({
  139. 'padding': 10,
  140. 'top':$(that).parent('td').height() / 2 + $(that).height(),
  141. 'min-width': 'inherit',
  142. 'position': 'absolute'
  143. }).toggle();
  144. }
  145. }
  146. layList.switch('is_show',function (odj,value) {
  147. var is_show_value = 0
  148. if(odj.elem.checked==true){
  149. var is_show_value = 1
  150. }
  151. action.set_value('is_show',value,is_show_value);
  152. });
  153. //自定义方法
  154. var action= {
  155. set_value: function (field, id, value) {
  156. layList.baseGet(layList.Url({
  157. a: 'set_value',
  158. q: {field: field, id: id, value: value}
  159. }), function (res) {
  160. layList.msg(res.msg);
  161. });
  162. },
  163. //打开新添加页面
  164. open_add: function (url,title) {
  165. layer.open({
  166. type: 2 //Page层类型
  167. ,area: ['90%', '90%']
  168. ,title: title
  169. ,shade: 0.6 //遮罩透明度
  170. ,maxmin: true //允许全屏最小化
  171. ,anim: 1 //0-6的动画形式,-1不开启
  172. ,content: url
  173. ,end:function() {
  174. location.reload();
  175. }
  176. });
  177. }
  178. };
  179. //查询
  180. layList.search('search',function(where){
  181. layList.reload({
  182. obtain: where.obtain,
  183. title: where.title
  184. },true);
  185. });
  186. //快速编辑
  187. layList.edit(function (obj) {
  188. var id=obj.data.id,value=obj.value;
  189. switch (obj.field) {
  190. case 'sort':
  191. if (value.trim()) {
  192. if (isNaN(value.trim())) {
  193. layList.msg('请输入正确的数字');
  194. } else {
  195. if (value.trim() < 0) {
  196. layList.msg('排序不能小于0');
  197. } else if (value.trim() > 9999) {
  198. layList.msg('排序不能大于9999');
  199. } else if (parseInt(value.trim()) != value.trim()) {
  200. layList.msg('排序不能为小数');
  201. } else {
  202. action.set_value('sort', id, value.trim());
  203. }
  204. }
  205. } else {
  206. layList.msg('排序不能为空');
  207. }
  208. break;
  209. }
  210. });
  211. //监听并执行排序
  212. layList.sort(['id','sort'],true);
  213. //点击事件绑定
  214. layList.tool(function (event,data,obj) {
  215. switch (event) {
  216. case 'delect':
  217. var url=layList.U({a:'delete',q:{id:data.id}});
  218. $eb.$swal('delete',function(){
  219. $eb.axios.get(url).then(function(res){
  220. if(res.status == 200 && res.data.code == 200) {
  221. $eb.$swal('success',res.data.msg);
  222. obj.del();
  223. }else
  224. return Promise.reject(res.data.msg || '删除失败')
  225. }).catch(function(err){
  226. $eb.$swal('error',err);
  227. });
  228. });
  229. break;
  230. case 'open_image_background':
  231. $eb.openImage(data.background);
  232. break;
  233. case 'open_image_qr_code':
  234. $eb.openImage(data.qr_code);
  235. break;
  236. case 'fail':
  237. layer.open({
  238. type: 1,
  239. skin: 'layui-layer-rim', //加上边框
  240. area: ['420px', '240px'], //宽高
  241. title: '审核未通过原因',
  242. content: data.fail_message
  243. });
  244. break;
  245. }
  246. })
  247. </script>
  248. {/block}