coupon.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>优惠券</title>
  6. <meta name="renderer" content="webkit">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  8. <meta name="viewport"
  9. content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  10. <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
  11. <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
  12. <link rel="stylesheet" type="text/css" href="../../layuiadmin/style/formSelects-v4.css"/>
  13. <style type="text/css">
  14. .seach_items {
  15. display: inline-block;
  16. margin-right: 5px;
  17. margin-top: 5px;
  18. }
  19. </style>
  20. </head>
  21. <body>
  22. <div class="layui-fluid">
  23. <div class="layui-card">
  24. <div class="layui-card-body" pad15>
  25. <div class="layui-row layui-col-space15">
  26. <div class="layui-col-md12">
  27. <div class="LAY-btns" style="margin-bottom: 10px;">
  28. <div style="float:left; margin-right: 5px; margin-top: 5px;">
  29. <button class="layui-btn" id="btn_add">
  30. <i class="layui-icon layui-icon-add-circle"></i>添加
  31. </button>
  32. </div>
  33. <div style="clear: both;"></div>
  34. </div>
  35. <table class="layui-hide" id="datagrid" lay-filter="datagrid-operate"></table>
  36. <script type="text/html" id="datagrid-operate-bar">
  37. <div class="layui-btn-group">
  38. <a class="layui-btn layui-btn-xs" lay-event="edit"
  39. data-permission="account.add_user">修改</a>
  40. </div>
  41. </script>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. </div>
  47. <script src="../../layuiadmin/layui/layui.js?t=1"></script>
  48. <script>
  49. layui.config({
  50. base: '../../../layuiadmin/' //静态资源所在路径
  51. }).extend({
  52. index: 'lib/index' //主入口模块
  53. , formSelects: 'formSelects-v4'
  54. }).use(['index', 'table', 'form', 'formSelects'], function () {
  55. var $ = layui.$
  56. , table = layui.table
  57. , form = layui.form;
  58. table.render({
  59. elem: '#datagrid'
  60. , url: '/order/coupon/'
  61. , cols: [[
  62. {field: 'name', title: '优惠券名称', width: 200}
  63. , {field: 'amount', title: '优惠券金额', width: 100}
  64. , {field: 'category_text', title: '使用分类', width: 260}
  65. , {field: 'school_text', title: '使用学校', width: 260}
  66. , {field: 'begin_date', title: '开始时间', width: 120}
  67. , {field: 'end_date', title: '结束时间', width: 120}
  68. , {field: 'count', title: '已用数量', width: 100}
  69. , {field: 'enable_text', title: '是否在用', width: 100}
  70. , {field: 'create_time', title: '添加时间', width: 150}
  71. , {field: 'create_user_text', title: '添加人', width: 100}
  72. , {width: 100, align: 'center', fixed: 'right', toolbar: '#datagrid-operate-bar'}
  73. ]]
  74. , page: true
  75. , height: 'full-108'
  76. });
  77. var _params;
  78. form.on('submit(query-form-element)', function (data) {
  79. //layer.msg(JSON.stringify(data.field));
  80. _params = data.field;
  81. table.reload('datagrid', {
  82. where: data.field
  83. , page: {curr: 1}
  84. });
  85. layer.closeAll();
  86. return false;
  87. });
  88. //监听工具条
  89. table.on('tool(datagrid-operate)', function (obj) {
  90. var data = obj.data;
  91. if (obj.event === 'edit') {
  92. table.editdata = data;
  93. layer.open({
  94. type: 2,
  95. title: '修改优惠券',
  96. shadeClose: false,
  97. area: ['50%', '90%'],
  98. btn: ['保存', '取消'],
  99. yes: function (index, dom) {
  100. layui.onSubmitChild = function (res) {
  101. layer.close(index);
  102. table.reload('datagrid', {});
  103. };
  104. layui.submitChild();
  105. },
  106. btn2: function (index, layero) {
  107. layer.close(index);//关闭当前按钮
  108. },
  109. content: 'coupon_edit.html?id=' + data.id
  110. });
  111. }
  112. });
  113. $('#btn_add').on('click', function () {
  114. layer.open({
  115. type: 2,
  116. title: '添加优惠券',
  117. shadeClose: false,
  118. area: ['40%', '90%'],
  119. btn: ['保存', '取消'],
  120. yes: function (index, dom) {
  121. layui.onSubmitChild = function (res) {
  122. layer.close(index);
  123. table.reload('datagrid', {});
  124. };
  125. layui.submitChild();
  126. },
  127. btn2: function (index, layero) {
  128. layer.close(index);//关闭当前按钮
  129. },
  130. content: 'coupon_edit.html'
  131. });
  132. });
  133. });
  134. </script>
  135. </body>
  136. </html>