index.php 11 KB

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