index.php 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. {extend name="public/container"}
  2. {block name="content"}
  3. <div class="layui-fluid">
  4. <div class="layui-row layui-col-space15" id="app">
  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. <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-block">
  14. <select name="is_show">
  15. <option value="">是否显示</option>
  16. <option value="1">显示</option>
  17. <option value="0">不显示</option>
  18. </select>
  19. </div>
  20. </div>
  21. <div class="layui-inline">
  22. <label class="layui-form-label">等级名称</label>
  23. <div class="layui-input-block">
  24. <input type="text" name="title" class="layui-input" placeholder="请输入等级名称">
  25. </div>
  26. </div>
  27. <div class="layui-inline">
  28. <div class="layui-input-inline">
  29. <button class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="search" lay-filter="search">
  30. <i class="layui-icon layui-icon-search"></i>搜索</button>
  31. </div>
  32. </div>
  33. </div>
  34. </form>
  35. </div>
  36. </div>
  37. </div>
  38. <!--产品列表-->
  39. <div class="layui-col-md12">
  40. <div class="layui-card">
  41. <div class="layui-card-header">等级列表</div>
  42. <div class="layui-card-body">
  43. <div class="layui-btn-container">
  44. <button class="layui-btn layui-btn-sm" onclick="$eb.createModalFrame(this.innerText,'{:Url('create')}')">添加会员等级</button>
  45. </div>
  46. <table class="layui-hide" id="List" lay-filter="List"></table>
  47. <script type="text/html" id="icon">
  48. <img style="cursor: pointer;max-width: 50px;" lay-event='open_image' src="{{d.icon}}">
  49. </script>
  50. <script type="text/html" id="is_forever">
  51. <input type='checkbox' name='id' disabled lay-skin='switch' value="{{d.id}}" lay-filter='is_forever' lay-text='永久|非永久' {{ d.is_forever == 1 ? 'checked' : '' }}>
  52. </script>
  53. <script type="text/html" id="is_show">
  54. <input type='checkbox' name='id' lay-skin='switch' value="{{d.id}}" lay-filter='is_show' lay-text='开启|关闭' {{ d.is_show == 1 ? 'checked' : '' }}>
  55. </script>
  56. <script type="text/html" id="is_pay">
  57. <input type='checkbox' name='id' disabled lay-skin='switch' value="{{d.id}}" lay-filter='is_pay' lay-text='付费|免费' {{ d.is_pay == 1 ? 'checked' : '' }}>
  58. </script>
  59. <script type="text/html" id="act">
  60. <button type="button" class="layui-btn layui-btn-xs" onclick="dropdown(this)">操作 <span class="caret"></span></button>
  61. <ul class="layui-nav-child layui-anim layui-anim-upbit">
  62. <li>
  63. <a href="javascript:void(0)" onclick="$eb.createModalFrame(this.innerText,'{:Url(\'tash\')}?level_id={{d.id}}',{w:1000})">
  64. <i class="fa fa-wrench"></i> 等级任务
  65. </a>
  66. </li>
  67. <li>
  68. <a href="javascript:void(0)" onclick="$eb.createModalFrame(this.innerText,'{:Url(\'create\')}?id={{d.id}}')">
  69. <i class="fa fa-edit"></i> 编辑等级
  70. </a>
  71. </li>
  72. <li>
  73. <a lay-event='delete' href="javascript:void(0)" >
  74. <i class="fa fa-times"></i> 删除等级
  75. </a>
  76. </li>
  77. </ul>
  78. </script>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. <script src="{__ADMIN_PATH}js/layuiList.js"></script>
  85. {/block}
  86. {block name="script"}
  87. <script>
  88. //实例化form
  89. layList.form.render();
  90. //加载列表
  91. layList.tableList('List',"{:Url('get_system_vip_list')}",function (){
  92. return [
  93. {field: 'id', title: '编号', sort: true,event:'id',width:'6%',align:"center"},
  94. {field: 'icon', title: '等级图标',templet:'#icon',align:"center",width:'10%'},
  95. {field: 'name', title: '等级名称',edit:'name',width:'6%',align:"center"},
  96. {field: 'grade', title: '等级',edit:'grade',width:'6%',align:"center"},
  97. {field: 'discount', title: '享受折扣',edit:'discount',width:'8%',align:"center"},
  98. {field: 'valid_date', title: '有效时间',width:'12%',align:"center"},
  99. {field: 'is_forever', title: '是否永久',templet:'#is_forever',width:'8%',align:"center"},
  100. {field: 'is_show', title: '是否使用',templet:'#is_show',width:'8%',align:"center"},
  101. {field: 'explain', title: '等级说明',align:"center"},
  102. {field: 'right', title: '操作',align:'center',toolbar:'#act',width:'8%'},
  103. ];
  104. });
  105. //自定义方法
  106. var action= {
  107. set_value: function (field, id, value) {
  108. layList.baseGet(layList.Url({
  109. a: 'set_value',
  110. q: {field: field, id: id, value: value}
  111. }), function (res) {
  112. layList.msg(res.msg);
  113. });
  114. },
  115. }
  116. //查询
  117. layList.search('search',function(where){
  118. layList.reload(where,true);
  119. });
  120. layList.switch('is_show',function (odj,value) {
  121. if(odj.elem.checked==true){
  122. layList.baseGet(layList.Url({a:'set_show',p:{is_show:1,id:value}}),function (res) {
  123. layList.msg(res.msg);
  124. });
  125. }else{
  126. layList.baseGet(layList.Url({a:'set_show',p:{is_show:0,id:value}}),function (res) {
  127. layList.msg(res.msg);
  128. });
  129. }
  130. });
  131. //快速编辑
  132. layList.edit(function (obj) {
  133. var id=obj.data.id,value=obj.value;
  134. switch (obj.field) {
  135. case 'name':
  136. action.set_value('name',id,value);
  137. break;
  138. case 'grade':
  139. action.set_value('grade',id,value);
  140. break;
  141. case 'discount':
  142. action.set_value('discount',id,value);
  143. break;
  144. }
  145. });
  146. //监听并执行排序
  147. layList.sort(['id','sort'],true);
  148. //点击事件绑定
  149. layList.tool(function (event,data,obj) {
  150. switch (event) {
  151. case 'delete':
  152. var url=layList.U({a:'delete',q:{id:data.id}});
  153. $eb.$swal('delete',function(){
  154. $eb.axios.get(url).then(function(res){
  155. if(res.status == 200 && res.data.code == 200) {
  156. $eb.$swal('success',res.data.msg);
  157. obj.del();
  158. }else
  159. return Promise.reject(res.data.msg || '删除失败')
  160. }).catch(function(err){
  161. $eb.$swal('error',err);
  162. });
  163. })
  164. break;
  165. case 'open_image':
  166. $eb.openImage(data.icon);
  167. break;
  168. }
  169. })
  170. //下拉框
  171. $(document).click(function (e) {
  172. $('.layui-nav-child').hide();
  173. })
  174. function dropdown(that){
  175. var oEvent = arguments.callee.caller.arguments[0] || event;
  176. oEvent.stopPropagation();
  177. var offset = $(that).offset();
  178. var top=offset.top-$(window).scrollTop();
  179. var index = $(that).parents('tr').data('index');
  180. $('.layui-nav-child').each(function (key) {
  181. if (key != index) {
  182. $(this).hide();
  183. }
  184. })
  185. if($(document).height() < top+$(that).next('ul').height()){
  186. $(that).next('ul').css({
  187. 'padding': 10,
  188. 'top': - ($(that).parent('td').height() / 2 + $(that).height() + $(that).next('ul').height()/2),
  189. 'min-width': 'inherit',
  190. 'position': 'absolute'
  191. }).toggle();
  192. }else{
  193. $(that).next('ul').css({
  194. 'padding': 10,
  195. 'top':$(that).parent('td').height() / 2 + $(that).height(),
  196. 'min-width': 'inherit',
  197. 'position': 'absolute'
  198. }).toggle();
  199. }
  200. }
  201. </script>
  202. {/block}