batch_index.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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-body">
  8. <div class="layui-row layui-col-space15">
  9. <div class="layui-col-md12">
  10. <div class="layui-tab layui-tab-brief" lay-filter="tab">
  11. <ul class="layui-tab-title">
  12. <li lay-id="list" {eq name='activity_type' value='1'}class="layui-this" {/eq} >
  13. <a href="{eq name='activity_type' value='1'}javascript:;{else}{:Url('batch_index',['activity_type'=>1])}{/eq}">批次列表</a>
  14. </li>
  15. <li lay-id="list" {eq name='activity_type' value='2'}class="layui-this" {/eq}>
  16. <a href="{eq name='activity_type' value='2'}javascript:;{else}{:Url('card_index',['activity_type'=>2])}{/eq}">会员卡列表</a>
  17. </li>
  18. </ul>
  19. </div>
  20. </div>
  21. <div class="layui-col-md12">
  22. <form class="layui-form layui-form-pane" action="">
  23. <div class="layui-form-item">
  24. <div class="layui-inline">
  25. <label class="layui-form-label">批次名称</label>
  26. <div class="layui-input-inline">
  27. <input type="text" name="title" class="layui-input" placeholder="请输入批次名称">
  28. <input type="hidden" name="activity_type" value="{$activity_type}">
  29. </div>
  30. </div>
  31. <div class="layui-inline">
  32. <div class="layui-input-inline">
  33. <button class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="search" lay-filter="search">
  34. <i class="layui-icon">&#xe615;</i> 搜索</button>
  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="action.open_add('{:Url('add_batch',['id'=>''])}','新增批次')"><i class="layui-icon">&#xe608;</i> 添加批次</button>
  43. <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" onclick="window.location.reload()"><i class="layui-icon">&#xe669;</i> 刷新</button>
  44. </div>
  45. <table class="layui-hide" id="List" lay-filter="List"></table>
  46. <script type="text/html" id="is_status">
  47. <input type='checkbox' name='id' lay-skin='switch' value="{{d.id}}" lay-filter='is_status' lay-text='激活|冻结' {{ d.status == 1 ? 'checked' : '' }}>
  48. </script>
  49. <script type="text/html" id="recommend">
  50. {{# layui.each(d.recommend, function(index, item){ }}
  51. <span class="layui-badge layui-bg-blue">{{item}}</span>
  52. {{# }); }}
  53. </script>
  54. <script type="text/html" id="qrcode">
  55. <img style="cursor: pointer;" height="50" lay-event='qrcode_image' src="{{d.qrcode}}">
  56. </script>
  57. <script type="text/html" id="act">
  58. <button type="button" class="layui-btn layui-btn-normal layui-btn-xs" lay-event='export' style="margin:5px 0;"><i class="layui-icon">&#xe67d;</i> 导出</button>
  59. <button type="button" class="layui-btn layui-btn-normal layui-btn-xs" onclick="dropdown(this)" style="margin:5px 0;"><i class="layui-icon">&#xe625;</i> 操作</button>
  60. <ul class="layui-nav-child layui-anim layui-anim-upbit">
  61. <li>
  62. <a href="{:Url('card_index')}?card_batch_id={{d.id}}&activity_type=2" >
  63. <i class="fa fa-street-view"></i> 查看卡列表
  64. </a>
  65. </li>
  66. </ul>
  67. </script>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. </div>
  75. <script src="{__ADMIN_PATH}js/layuiList.js"></script>
  76. {/block}
  77. {block name="script"}
  78. <script>
  79. //实例化form
  80. layList.form.render();
  81. //加载列表
  82. layList.tableList({o:'List', done:function () {}},"{:Url('batch_list',[])}",function (){
  83. return [
  84. {field: 'id', title: '编号', width:60,align: 'center'},
  85. {field: 'title', title: '批次名称',edit:'title',align: 'center'},
  86. {field: 'use_day', title: '体验天数', edit:'use_day',align: 'center'},
  87. {field: 'total_num', title: '发卡总数量',align: 'center'},
  88. {field: 'use_num', title: '使用数量',align: 'center'},
  89. {field: 'create_time', title: '制卡时间',align: 'center'},
  90. {field: 'qrcode', title: '二维码', templet:'#qrcode',align: 'center'},
  91. {field: 'status', title: '状态', templet:'#is_status',align: 'center'},
  92. {field: 'remark', title: '备注', edit:"remark",align: 'center'},
  93. {field: 'right', title: '操作',align:'center',toolbar:'#act'},
  94. ];
  95. });
  96. //下拉框
  97. $(document).click(function (e) {
  98. $('.layui-nav-child').hide();
  99. })
  100. function dropdown(that){
  101. var oEvent = arguments.callee.caller.arguments[0] || event;
  102. oEvent.stopPropagation();
  103. var offset = $(that).offset();
  104. var top=offset.top-$(window).scrollTop();
  105. var index = $(that).parents('tr').data('index');
  106. $('.layui-nav-child').each(function (key) {
  107. if (key != index) {
  108. $(this).hide();
  109. }
  110. })
  111. if($(document).height() < top+$(that).next('ul').height()){
  112. $(that).next('ul').css({
  113. 'padding': 10,
  114. 'top': - ($(that).parent('td').height() / 2 + $(that).height() + $(that).next('ul').height()/2),
  115. 'min-width': 'inherit',
  116. 'position': 'absolute'
  117. }).toggle();
  118. }else{
  119. $(that).next('ul').css({
  120. 'padding': 10,
  121. 'top':$(that).parent('td').height() / 2 + $(that).height(),
  122. 'min-width': 'inherit',
  123. 'position': 'absolute'
  124. }).toggle();
  125. }
  126. }
  127. //自定义方法
  128. var action= {
  129. set_value: function (field, id, value, model_type) {
  130. layList.baseGet(layList.Url({
  131. a: 'set_value',
  132. q: {field: field, id: id, value: value, model_type:model_type}
  133. }), function (res) {
  134. console.log(res);
  135. layList.msg(res.msg);
  136. }, function (err) {
  137. layList.msg(err.msg);
  138. });
  139. },
  140. //打开新添加页面
  141. open_add: function (url,title) {
  142. layer.open({
  143. type: 2 //Page层类型
  144. ,area: ['100%', '100%']
  145. ,title: title
  146. ,shade: 0.6 //遮罩透明度
  147. ,maxmin: true //允许全屏最小化
  148. ,anim: 1 //0-6的动画形式,-1不开启
  149. ,content: url
  150. ,end:function() {
  151. location.reload();
  152. }
  153. });
  154. }
  155. }
  156. //查询
  157. layList.search('search',function(where){
  158. layList.reload(where,true);
  159. });
  160. layList.switch('is_status',function (odj,value) {
  161. var is_status_value = 0
  162. if(odj.elem.checked==true){
  163. var is_status_value = 1
  164. }
  165. action.set_value('status',value,is_status_value,'member_card_batch');
  166. });
  167. //快速编辑
  168. layList.edit(function (obj) {
  169. var id=obj.data.id,value=obj.value;
  170. switch (obj.field) {
  171. case 'title':
  172. action.set_value('title',id,value,'member_card_batch');
  173. break;
  174. case 'remark':
  175. action.set_value('remark',id,value,'member_card_batch');
  176. break;
  177. case 'use_day':
  178. action.set_value('use_day',id,value,'member_card_batch');
  179. break;
  180. }
  181. });
  182. //监听并执行排序
  183. layList.sort(['id','sort'],true);
  184. //点击事件绑定
  185. layList.tool(function (event,data,obj) {
  186. switch (event) {
  187. case 'delect':
  188. var url=layList.U({a:'delete',q:{id:data.id, model_type:'special'}});
  189. $eb.$swal('delete',function(){
  190. $eb.axios.get(url).then(function(res){
  191. if(res.status == 200 && res.data.code == 200) {
  192. $eb.$swal('success',res.data.msg);
  193. obj.del();
  194. }else
  195. return Promise.reject(res.data.msg || '删除失败')
  196. }).catch(function(err){
  197. $eb.$swal('error',err);
  198. });
  199. })
  200. break;
  201. case 'open_image':
  202. $eb.openImage(data.image);
  203. break;
  204. case 'qrcode_image':
  205. $eb.openImage(data.qrcode);
  206. break;
  207. case 'export':
  208. location.href=layList.U({c:'user.member_card',a:'card_list',q:{card_batch_id:data.id,excel:1}});
  209. break;
  210. }
  211. })
  212. </script>
  213. {/block}