index.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. {php}
  2. $name_label = $json_config['config_option']['name']['label']??'';
  3. $value_label = $json_config['config_option']['value']['label']??'';
  4. $desc_label = $json_config['config_option']['description']['label']??'';
  5. $image_label = $json_config['config_option']['image']['label']??'';
  6. $image_show = $json_config['config_option']['image']['show']??'';
  7. {/php}
  8. <!DOCTYPE html>
  9. <html>
  10. <head>
  11. <meta charset="utf-8">
  12. <title>layui</title>
  13. <meta name="renderer" content="webkit">
  14. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  15. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  16. <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all">
  17. <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all"/>
  18. <link rel="stylesheet" href="__CSS__/admin.css" media="all">
  19. <style type="text/css">
  20. /* tooltip */
  21. #tooltip {
  22. position: absolute;
  23. border: 1px solid #ccc;
  24. background: #333;
  25. padding: 2px;
  26. display: none;
  27. color: #fff;
  28. }
  29. </style>
  30. </head>
  31. <body style="padding:10px;">
  32. <div class="tplay-body-div">
  33. <div class="layui-tab">
  34. <ul class="layui-tab-title">
  35. <li class="layui-this">配置项</li>
  36. <li><a href="{:url('publish',['pid'=>$Request.param.pid])}" class="a_menu">新增</a>
  37. </ul>
  38. </div>
  39. <form class="layui-form serch" action="{:url('index')}" method="post">
  40. <div class="layui-form-item" style="float: left;">
  41. <div class="layui-input-inline">
  42. <input type="text" name="keywords" lay-verify="title" autocomplete="off" placeholder="请输入名称"
  43. class="layui-input layui-btn-sm">
  44. </div>
  45. <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="serch">立即提交</button>
  46. </div>
  47. </form>
  48. <script type="text/html" id="toolbarDemo">
  49. <div class="layui-btn-container">
  50. <button class="layui-btn layui-btn-sm" lay-submit lay-filter="admin">排序</button>
  51. <button class="layui-btn layui-btn-danger layui-btn-sm" lay-event="deletes">批量删除</button>
  52. </div>
  53. </script>
  54. <script type="text/html" id="barDemo">
  55. <div class="layui-btn-group">
  56. <a class="layui-btn layui-btn-xs" lay-event="edit"><i class="layui-icon"
  57. style="margin-right: 0;"></i></a>
  58. <a class="layui-btn layui-btn-xs delete" lay-event="del"><i class="layui-icon"
  59. style="margin-right: 0;"></i></a>
  60. </div>
  61. </script>
  62. <table class="layui-table" id="table" lay-filter="table"></table>
  63. {include file="public/foot"}
  64. <script type="text/javascript">
  65. layui.use(['table', 'layer', 'form'], function () {
  66. var table = layui.table,
  67. form = layui.form,
  68. layer = layui.layer;
  69. //第一个实例
  70. table.render({
  71. id: 'table'
  72. , elem: '#table'
  73. , size: 'sm' //小尺寸的表格
  74. , toolbar: '#toolbarDemo'
  75. , defaultToolbar: []
  76. , limit: 15
  77. , limits: [15, 20, 30, 40, 50, 100]
  78. , url: "{:url('index',['pid'=>$Request.param.pid])}" //数据接口
  79. , page: true //开启分页
  80. , cols: [[ //表头
  81. {
  82. key: 'sort', title: '排序', align: 'center', width: 60, templet: function (row) {
  83. return '<input type="text" name="sorts[]" value="' + row.sort + '" style="width: 20px;" class="sort"><input type="hidden" name="ids[]" value="' + row.id + '">';
  84. }
  85. },
  86. {type: 'checkbox'},
  87. {field: 'id', title: 'ID', width: 60, align: 'center'},
  88. {field: 'name', title: '{if condition="!empty($name_label)"}{$name_label}{else/}名称{/if}', minWidth: 150},
  89. {field: 'value', title: '{if condition="!empty($value_label)"}{$value_label}{else/}配置值{/if}', align: 'center',minWidth:150},
  90. {field: 'description', title: '{if condition="!empty($desc_label)"}{$desc_label}{else/}备注{/if}', minWidth:150},
  91. //{if condition="$image_show==true"}
  92. {
  93. field: 'image', title: '{if condition="!empty($image_label)"}{$image_label}{else/}配图{/if}', minWidth: 80, align: 'center', templet: function (row) {
  94. return (row.thumb_url == '') ? '' : '<a href="' + row.thumb_url + '" class="tooltip" target="_blank"><img src="' + row.thumb_url + '" width="20" height="20"></a>';
  95. }
  96. },
  97. //{/if}
  98. {
  99. field: 'status', title: '状态', align: 'center', width: 100, templet: function (row) {
  100. if (row.group_type == 2) {
  101. return '<a style="font-size:18px;color: #009688" lay-event="single_status">' + (row.single_status == 1 ? '<i class="layui-icon layui-icon-radio"></i>' : '<i class="layui-icon layui-icon-circle"></i>') + '</a>';
  102. }
  103. return '<a href="javascript:;" style="font-size:18px;" class="status" data-id="' + row.id + '" data-val="' + row.status + '">' + (row.status == 1 ? '<i class="fa fa-toggle-on"></i>' : '<i class="fa fa-toggle-off"></i>') + '</a>';
  104. }
  105. },
  106. {field: 'action', title: '操作', toolbar: '#barDemo', align: 'center',fixed: 'right',minWidth:80}
  107. ]],
  108. done: function () {
  109. showThumb();
  110. switchStatus('.status', "{:url('status')}");
  111. }
  112. });
  113. form.on('submit(serch)', function (data) {
  114. table.reload('table', {
  115. where: data.field
  116. , page: {
  117. curr: 1 //重新从第 1 页开始
  118. }
  119. });
  120. return false;
  121. });
  122. table.on('tool(table)', function (obj) {
  123. if (obj.event == 'edit') {
  124. location.href = "{:url('publish',['pid'=>$Request.param.pid])}?id=" + obj.data.id;
  125. }
  126. else if (obj.event == 'del') {
  127. layer.confirm('确定要删除?', function (index) {
  128. $.ajax({
  129. url: "{:url('delete')}",
  130. dataType: 'json',
  131. data: {id: obj.data.id},
  132. success: function (res) {
  133. layer.msg(res.msg);
  134. if (res.code == 1) {
  135. table.reload('table');
  136. }
  137. }
  138. })
  139. })
  140. }
  141. else if (obj.event == 'single_status') {
  142. var status = obj.data.single_status == 1 ? 0 : 1;
  143. $.ajax({
  144. type: "post",
  145. url: '{:url("single_status")}',
  146. data: {status: status, id: obj.data.id , pid:'{$Request.param.pid}'},
  147. dataType: 'json',
  148. success: function (res) {
  149. if (res.code == 1) {
  150. table.reload('table');
  151. } else {
  152. layer.msg(res.msg);
  153. }
  154. }
  155. })
  156. }
  157. });
  158. //监听事件
  159. table.on('toolbar(table)', function (obj) {
  160. if (obj.event == 'deletes') {
  161. var checkStatus = table.checkStatus(obj.config.id);//获取选中的数据
  162. var data = checkStatus.data;
  163. if (data.length > 0) {
  164. var ids = [];//数组
  165. data.forEach(function (item, key) {
  166. ids[key] = item.id;
  167. })
  168. layer.confirm('是否删除?', function (index, layero) {
  169. $.ajax({
  170. url: "{:url('deletes')}",
  171. dataType: 'json',
  172. data: {"ids": ids},
  173. type: 'post',
  174. success: function (res) {
  175. layer.msg(res.msg);
  176. if (res.code == 1) {
  177. table.reload('table');
  178. }
  179. }
  180. })
  181. layer.close(index)
  182. });
  183. } else {
  184. layer.msg('请先勾选需要操作的记录');
  185. }
  186. }
  187. });
  188. });
  189. </script>
  190. <script>
  191. // 排序
  192. layui.use(['layer', 'form'], function () {
  193. var layer = layui.layer,
  194. $ = layui.jquery,
  195. form = layui.form;
  196. $(window).on('load', function () {
  197. form.on('submit(admin)', function (data) {
  198. $sort_eles = $('.sort');
  199. $data = {};
  200. if ($sort_eles.length > 0) {
  201. for (var i = 0; i < $sort_eles.length; i++) {
  202. $data['sorts[' + i + ']'] = $sort_eles[i].value;
  203. $data['ids[' + i + ']'] = $sort_eles[i].nextSibling.value;
  204. }
  205. }
  206. console.log($data)
  207. $.ajax({
  208. url: "{:url('sort')}",
  209. data: $data,
  210. type: 'post',
  211. async: false,
  212. success: function (res) {
  213. if (res.code == 1) {
  214. layer.alert(res.msg, function (index) {
  215. location.reload();
  216. })
  217. } else {
  218. layer.msg(res.msg);
  219. }
  220. }
  221. })
  222. return false;
  223. });
  224. });
  225. });
  226. </script>
  227. </div>
  228. </body>
  229. </html>