index.php 8.5 KB

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