index.html 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. {extend name="public/layout"/}
  2. {block name="title"}楼盘进度标签{/block}
  3. {block name="head"}
  4. {include file="public/head"}
  5. <style>
  6. html {
  7. width: 100%;
  8. height: 100%;
  9. background-color: white;
  10. }
  11. .data-table {
  12. margin: 0 10px;
  13. }
  14. </style>
  15. {/block}
  16. {block name="body"}
  17. <body>
  18. <div class="data-table">
  19. <table class="layui-table" id="layui-table" lay-filter="building-label"></table>
  20. </div>
  21. </body>
  22. {/block}
  23. {block name="js"}
  24. <script type="text/html" id="toolbar">
  25. <div class="layui-btn-container">
  26. <button class="layui-btn layui-btn-sm" lay-event="add">添加</button>
  27. </div>
  28. </script>
  29. <script type="text/html" id="op">
  30. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
  31. </script>
  32. <script>
  33. layui.use('table', function () {
  34. var $ = layui.jquery,
  35. table = layui.table;
  36. let labeltable = table.render({
  37. elem: '#layui-table'
  38. , url: '{:url("buildingLabel/index")}'
  39. , page: false
  40. , toolbar: '#toolbar'
  41. , defaultToolbar: []
  42. , cols: [[
  43. { type: 'numbers', title: '序号', field: 'id' },
  44. { title: '标签名', field: 'name', edit: 'text' },
  45. { title: '操作', templet: '#op', width: 100 }
  46. ]]
  47. });
  48. table.on('edit(building-label)', function (obj) {
  49. $.post('{:url("buildingLabel/update")}', { id: obj.data.id, name: obj.value }, function () {
  50. layer.msg('修改成功', {
  51. anim: 0,
  52. time: 1000
  53. });
  54. });
  55. });
  56. table.on('tool(building-label)', function (obj) {
  57. if (obj.event == 'del') {
  58. layer.confirm('确定删除该标签?', function () {
  59. $.post('{:url("buildingLabel/delete")}', { id: obj.data.id }, function () {
  60. obj.del();
  61. layer.msg('删除成功', {
  62. anim: 0,
  63. time: 1000
  64. });
  65. })
  66. })
  67. }
  68. });
  69. table.on('toolbar(building-label)', function (obj) {
  70. console.log(obj);
  71. if (obj.event == 'add') {
  72. layer.prompt({
  73. title: '添加标签'
  74. }, function (value, index) {
  75. $.post('{:url("buildingLabel/save")}', { name: value }, function () {
  76. table.reload('layui-table');
  77. layer.close(index);
  78. });
  79. });
  80. }
  81. });
  82. });
  83. </script>
  84. {/block}