index.php 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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: 'group_award_ratio', title: '团队奖比例(%)',edit:'group_award_ratio',width:'8%',align:"center"},
  99. {field: 'same_level_award_ratio', title: '平级奖比例(%)',edit:'same_level_award_ratio',width:'8%',align:"center"},
  100. // {field: 'valid_date', title: '有效时间',width:'12%',align:"center"},
  101. // {field: 'is_forever', title: '是否永久',templet:'#is_forever',width:'8%',align:"center"},
  102. {field: 'is_show', title: '是否使用',templet:'#is_show',width:'8%',align:"center"},
  103. {field: 'explain', title: '等级说明',align:"center"},
  104. {field: 'right', title: '操作',align:'center',toolbar:'#act',width:'8%'},
  105. ];
  106. });
  107. //自定义方法
  108. var action= {
  109. set_value: function (field, id, value) {
  110. layList.baseGet(layList.Url({
  111. a: 'set_value',
  112. q: {field: field, id: id, value: value}
  113. }), function (res) {
  114. layList.msg(res.msg);
  115. });
  116. },
  117. }
  118. //查询
  119. layList.search('search',function(where){
  120. layList.reload(where,true);
  121. });
  122. layList.switch('is_show',function (odj,value) {
  123. if(odj.elem.checked==true){
  124. layList.baseGet(layList.Url({a:'set_show',p:{is_show:1,id:value}}),function (res) {
  125. layList.msg(res.msg);
  126. });
  127. }else{
  128. layList.baseGet(layList.Url({a:'set_show',p:{is_show:0,id:value}}),function (res) {
  129. layList.msg(res.msg);
  130. });
  131. }
  132. });
  133. //快速编辑
  134. layList.edit(function (obj) {
  135. var id=obj.data.id,value=obj.value;
  136. switch (obj.field) {
  137. case 'name':
  138. action.set_value('name',id,value);
  139. break;
  140. case 'grade':
  141. action.set_value('grade',id,value);
  142. break;
  143. case 'discount':
  144. action.set_value('discount',id,value);
  145. break;
  146. }
  147. });
  148. //监听并执行排序
  149. layList.sort(['id','sort'],true);
  150. //点击事件绑定
  151. layList.tool(function (event,data,obj) {
  152. switch (event) {
  153. case 'delete':
  154. var url=layList.U({a:'delete',q:{id:data.id}});
  155. $eb.$swal('delete',function(){
  156. $eb.axios.get(url).then(function(res){
  157. if(res.status == 200 && res.data.code == 200) {
  158. $eb.$swal('success',res.data.msg);
  159. obj.del();
  160. }else
  161. return Promise.reject(res.data.msg || '删除失败')
  162. }).catch(function(err){
  163. $eb.$swal('error',err);
  164. });
  165. })
  166. break;
  167. case 'open_image':
  168. $eb.openImage(data.icon);
  169. break;
  170. }
  171. })
  172. //下拉框
  173. $(document).click(function (e) {
  174. $('.layui-nav-child').hide();
  175. })
  176. function dropdown(that){
  177. var oEvent = arguments.callee.caller.arguments[0] || event;
  178. oEvent.stopPropagation();
  179. var offset = $(that).offset();
  180. var top=offset.top-$(window).scrollTop();
  181. var index = $(that).parents('tr').data('index');
  182. $('.layui-nav-child').each(function (key) {
  183. if (key != index) {
  184. $(this).hide();
  185. }
  186. })
  187. if($(document).height() < top+$(that).next('ul').height()){
  188. $(that).next('ul').css({
  189. 'padding': 10,
  190. 'top': - ($(that).parent('td').height() / 2 + $(that).height() + $(that).next('ul').height()/2),
  191. 'min-width': 'inherit',
  192. 'position': 'absolute'
  193. }).toggle();
  194. }else{
  195. $(that).next('ul').css({
  196. 'padding': 10,
  197. 'top':$(that).parent('td').height() / 2 + $(that).height(),
  198. 'min-width': 'inherit',
  199. 'position': 'absolute'
  200. }).toggle();
  201. }
  202. }
  203. </script>
  204. {/block}