main.html 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <meta name="keywords" content="">
  8. <meta name="description" content="">
  9. <title text="标签"></title>
  10. <link rel="stylesheet" href="../../../component/pear/css/pear.css" />
  11. <link rel="stylesheet" href="../../../admin/css/other/user.css" />
  12. </head>
  13. <body class="pear-container">
  14. <div class="layui-card">
  15. <div class="layui-card-body">
  16. <form class="layui-form">
  17. <div class="layui-form-item">
  18. <label class="layui-form-label"></label>
  19. <div class="layui-input-inline">
  20. <input type="text" name="" placeholder="" class="layui-input">
  21. </div>
  22. <label class="layui-form-label"></label>
  23. <div class="layui-input-inline">
  24. <input type="text" name="" placeholder="" class="layui-input">
  25. </div>
  26. <button class="pear-btn pear-btn-md-0 pear-btn-primary" lay-submit lay-filter="query">
  27. <i class="layui-icon layui-icon-search"></i> 查询
  28. </button>
  29. <button type="reset" class="pear-btn pear-btn-md-0">
  30. <i class="layui-icon layui-icon-refresh"></i> 重置
  31. </button>
  32. </div>
  33. </form>
  34. </div>
  35. </div>
  36. <div class="layui-card">
  37. <div class="layui-card-body">
  38. <table id="table" lay-filter="table"></table>
  39. </div>
  40. </div>
  41. </body>
  42. <script type="text/html" id="toolbar">
  43. <button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
  44. <i class="pear-icon pear-icon-add"></i> 新增
  45. </button>
  46. </script>
  47. <script type="text/html" id="bar">
  48. <a class="cool-line-btn cool-bg-blue" lay-event="edit">编辑</a>
  49. <div class="cool-line-divider"></div>
  50. <a class="cool-line-btn cool-bg-blue" lay-event="remove">删除</a>
  51. </script>
  52. <script src="../../../component/layui/layui.js"></script>
  53. <script src="../../../component/pear/pear.js"></script>
  54. <script>
  55. layui.use(['request', 'table', 'form', 'popup', 'common'], function () {
  56. var request = layui.request,
  57. table = layui.table,
  58. form = layui.form,
  59. popup = layui.popup,
  60. common = layui.common;
  61. var MODULE_PATH = "/system/label/v1/";
  62. request.tableRender({
  63. url: MODULE_PATH,
  64. cols: [
  65. [
  66. {type: 'checkbox'},
  67. {title: '名称', field: 'name', align: 'center'},
  68. {title: '背景色', field: 'backColor', align: 'center'},
  69. {title: '字体颜色', field: 'fontColor', align: 'center'},
  70. {title: '操作', toolbar: '#bar', align: 'center', width: 130}
  71. ]
  72. ]
  73. });
  74. table.on('tool(table)', function (obj) {
  75. if (obj.event === 'edit') {
  76. edit(obj);
  77. }
  78. else if (obj.event === 'remove') {
  79. remove(obj.data.id);
  80. }
  81. });
  82. table.on('toolbar(table)', function (obj) {
  83. if (obj.event === 'add') {
  84. add();
  85. }
  86. else if (obj.event === 'removeBatch') {
  87. remove(common.checkField(obj,'id'));
  88. }
  89. });
  90. form.on('submit(query)', function (data) {
  91. refresh(data.field);
  92. return false;
  93. });
  94. window.add = function() {
  95. layer.open({
  96. type: 2,
  97. title: '新增',
  98. shade: 0.1,
  99. area: ['480px', '500px'],
  100. content: ['add.html', 'no']
  101. });
  102. };
  103. window.edit= function(obj) {
  104. layer.open({
  105. type: 2,
  106. title: '编辑',
  107. shade: 0.1,
  108. area: ['480px', '500px'],
  109. content: ['add.html?id=' + obj.data.id, 'no']
  110. });
  111. };
  112. window.remove= function(ids) {
  113. if (ids === '' || ids === undefined) {
  114. layer.alert('请先选择删除数据!');
  115. return false;
  116. }
  117. layer.confirm("是否确认删除这些项?", function () {
  118. request.http({
  119. type: "delete",
  120. url: MODULE_PATH + ids,
  121. loading: true,
  122. success: function (result) {
  123. refresh();
  124. if (result.success) {
  125. popup.success(result.msg);
  126. } else {
  127. popup.failure(result.msg);
  128. }
  129. }
  130. })
  131. });
  132. };
  133. window.refresh = function (param) {
  134. table.reload('table', {where: param});
  135. };
  136. })
  137. </script>
  138. </html>