截流自动化的商城平台
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

index.html 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. {layout name="layout1" /}
  2. <style>
  3. </style>
  4. <div class="wrapper">
  5. <div class="layui-card">
  6. <div class="layui-card-body">
  7. <!--操作提示-->
  8. <div class="layui-collapse like-layui-collapse" lay-accordion="" style="border:1px dashed #c4c4c4">
  9. <div class="layui-colla-item">
  10. <h2 class="layui-colla-title like-layui-colla-title" style="background-color: #fff">操作提示</h2>
  11. <div class="layui-colla-content layui-show">
  12. <p>*管理分销会员的等级,系统默认等级不能删除;</p>
  13. <p>*删除分销等级时,会重新调整分销会员等级为系统默认等级,请谨慎操作;</p>
  14. </div>
  15. </div>
  16. </div>
  17. </div>
  18. <div class="layui-card-body">
  19. <!--功能按钮-->
  20. <div class="btns">
  21. <buttion class="layui-btn layui-btn-sm layui-bg-blue" id="add">添加分销等级</buttion>
  22. </div>
  23. <!--数据表格-->
  24. <table id="lists" lay-filter="lists"></table>
  25. <!--工具条模板-->
  26. <script type="text/html" id="operate">
  27. <a class="layui-btn layui-btn-sm layui-bg-blue" lay-event="edit">编辑</a>
  28. {{# if(d.is_default != 1){ }}
  29. <a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a>
  30. {{# } }}
  31. </script>
  32. </div>
  33. </div>
  34. </div>
  35. <script>
  36. layui.config({
  37. version:"{$front_version}",
  38. base: '/static/lib/'
  39. }).use(['table'], function () {
  40. let $ = layui.$
  41. , table = layui.table;
  42. // 数据表格渲染
  43. table.render({
  44. elem: '#lists'
  45. ,height: 312
  46. ,url: '{:url("distribution.distribution_level/index")}' //数据接口
  47. ,method: 'post'
  48. ,page: false //开启分页
  49. ,cols: [[ //表头
  50. {field: 'weights_desc', title: '等级级别', width:150}
  51. ,{field: 'name', title: '等级名称', width:150}
  52. ,{field: 'first_ratio', title: '一级佣金比例', width:150}
  53. ,{field: 'second_ratio', title: '二级佣金比例', width: 150}
  54. ,{field: 'members_num', title: '分销会员数', width: 150}
  55. ,{title: '操作', toolbar: '#operate'}
  56. ]] , text: {none: '暂无数据!'}
  57. , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
  58. return {
  59. "code": res.code,
  60. "msg": res.msg,
  61. "count": res.data.count, //解析数据长度
  62. "data": res.data.lists, //解析数据列表
  63. };
  64. },
  65. response: {
  66. statusCode: 1
  67. }
  68. ,done: function(res, curr, count){
  69. // 解决操作栏因为内容过多换行问题
  70. $(".layui-table-main tr").each(function (index, val) {
  71. $($(".layui-table-fixed-l .layui-table-body tbody tr")[index]).height($(val).height());
  72. $($(".layui-table-fixed-r .layui-table-body tbody tr")[index]).height($(val).height());
  73. });
  74. }
  75. });
  76. // 工具条事件
  77. table.on('tool(lists)', function(obj){
  78. var layEvent = obj.event; //获得 lay-event 对应的值(也可以是表头的 event 参数对应的值)
  79. if(layEvent === 'del'){ //删除
  80. layer.confirm('确定要删除吗?', function(index){
  81. layer.close(index);
  82. like.ajax({
  83. url: "{:url('distribution.distribution_level/delete')}",
  84. data: {id: obj.data.id},
  85. type: "post",
  86. success:function(res) {
  87. if(res.code === 1) {
  88. layui.layer.msg(res.msg);
  89. layer.close(index);
  90. table.reload("lists");
  91. }
  92. }
  93. });
  94. });
  95. } else if(layEvent === 'edit'){ //编辑
  96. id = obj.data.id;
  97. // 弹窗显示添加页
  98. layer.open({
  99. type: 2
  100. ,title: "编辑分销等级"
  101. ,content: "{:url('distribution.distribution_level/edit')}?id=" + id
  102. ,area: ["90%", "90%"]
  103. ,btn: ["确定", "取消"]
  104. ,yes: function(index, layero){
  105. var iframeWindow = window["layui-layer-iframe" + index];
  106. var submit = layero.find("iframe").contents().find("#editSubmit");
  107. iframeWindow.layui.form.on("submit(editSubmit)", function(data){
  108. like.ajax({
  109. url: "{:url('distribution.distribution_level/edit')}",
  110. data: data.field,
  111. type: "post",
  112. success:function(res) {
  113. if(res.code === 1) {
  114. layui.layer.msg(res.msg);
  115. layer.close(index);
  116. table.reload("lists");
  117. }
  118. }
  119. });
  120. return false;
  121. });
  122. submit.trigger("click");
  123. }
  124. });
  125. }
  126. });
  127. // 功能按钮
  128. $('#add').click(function() {
  129. // 弹窗显示添加页
  130. layer.open({
  131. type: 2
  132. ,title: "添加分销等级"
  133. ,content: "{:url('distribution.distribution_level/add')}"
  134. ,area: ["90%", "90%"]
  135. ,btn: ["确定", "取消"]
  136. ,yes: function(index, layero){
  137. var iframeWindow = window["layui-layer-iframe" + index];
  138. var submit = layero.find("iframe").contents().find("#addSubmit");
  139. iframeWindow.layui.form.on("submit(addSubmit)", function(data){
  140. like.ajax({
  141. url: "{:url('distribution.distribution_level/add')}",
  142. data: data.field,
  143. type: "post",
  144. success:function(res) {
  145. if(res.code === 1) {
  146. layui.layer.msg(res.msg);
  147. layer.close(index);
  148. table.reload("lists");
  149. }
  150. }
  151. });
  152. return false;
  153. });
  154. submit.trigger("click");
  155. }
  156. });
  157. });
  158. });
  159. </script>