index.php 9.8 KB

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