hothouse.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <?php
  2. use backend\assets\AppAsset;
  3. ?>
  4. <style>
  5. body {
  6. padding: 15px;
  7. }
  8. .layui-elem-quote {
  9. margin-bottom: 0;
  10. border-left: none;
  11. padding: 10px;
  12. }
  13. .layui-table-page .layui-laypage {
  14. float: right;
  15. margin-right: 1%;
  16. }
  17. .layui-table-view .layui-form-switch {
  18. right: 0px
  19. }
  20. </style>
  21. <form action="" class="layui-form">
  22. <fieldset class="layui-elem-field">
  23. <legend>搜索信息</legend>
  24. <div class="layui-field-box">
  25. <blockquote class="quoteBox demoTable">
  26. <div class="layui-inline">
  27. <span>楼盘:</span>
  28. <div class="layui-input-inline">
  29. <input type="text" name="input_house_text" class="layui-input searchVal"
  30. placeholder="请输入需要搜索的楼盘"/>
  31. </div>
  32. </div>
  33. <div class="layui-inline">
  34. <a class="layui-btn search_btn" data-type="reload"><i class="layui-icon layui-icon-search"></i>搜索</a>
  35. </div>
  36. <input type="hidden" name="typeid" value="<?php echo $type ?>">
  37. </blockquote>
  38. </div>
  39. </fieldset>
  40. </form>
  41. <blockquote class="layui-elem-quote quoteBox demoTable">
  42. <div class="layui-btn-group demoTable">
  43. <a class="layui-btn" data-type="addData">新增</a>
  44. </div>
  45. </blockquote>
  46. <table id="videolist" lay-filter="videolist"></table>
  47. <script type="text/html" id="operate">
  48. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
  49. </script>
  50. <!-- 排序 -->
  51. <script type="text/html" id="sortBox">
  52. {{# if(d.sort){ }}
  53. <div style="border:1px solid #E6E6E6;height:27px;line-height:27px;box-shadow:1px 1px 1px 1px rgba(224, 224, 224, 0.76);">
  54. {{ d.sort }}
  55. </div>
  56. {{# } }}
  57. </script>
  58. <script>
  59. window.onload = function(){
  60. layui.use(['laypage', 'layer', 'table', 'element', 'form', 'upload'], function () {
  61. var laypage = layui.laypage //分页
  62. , $ = layui.jquery
  63. , layer = layui.layer //弹层
  64. , table = layui.table //表格
  65. , element = layui.element //元素操作
  66. , form = layui.form
  67. , upload = layui.upload;
  68. var tableIds = 'videolist'; //表格ID
  69. var type_id = $('input[name="typeid"]').val();
  70. //第一个实例
  71. table.render({
  72. elem: '#' + tableIds
  73. , url: '/push/hothouseform' //数据接口
  74. , where: {token: csrfToken, type: type_id}
  75. , method: 'post'
  76. , page: true //开启分页
  77. , text: '数据加载中'
  78. , id: 'tablerReload'
  79. , cols: [[ //表头
  80. {type: 'numbers', title: '序号', width: 50},
  81. {field: 'name', title: '楼盘名称', align: 'center'},
  82. {
  83. field: 'sort',
  84. title: '排序',
  85. width: 100,
  86. event: 'sortData',
  87. edit: 'text',
  88. align: 'center',
  89. sort: true,
  90. templet: "#sortBox"
  91. },
  92. {field: 'create_at', title: '添加时间', width: 150, align: 'center'},
  93. {
  94. field: 'state', title: '审核', align: 'center', width: 100, templet: function (d) {
  95. if (d.state == 2) {
  96. return '<input type="checkbox" value="' + d.id + '" name="open" lay-skin="switch" lay-filter="switchTest" lay-text="|">'
  97. } else {
  98. return '<input type="checkbox" checked value="' + d.id + '" name="open" lay-skin="switch" lay-filter="switchTest" lay-text="|">'
  99. }
  100. }
  101. }
  102. , {fixed: 'right', title: '操作', width: 100, align: 'center', toolbar: '#operate'}
  103. ]]
  104. });
  105. //监听指定开关
  106. form.on('switch(switchTest)', function (data) {
  107. layer.confirm('确定要修改此操作吗?', {btn: ['确定', '取消']}, function () {
  108. $.post('/push/hothousedelshow', {id: data.value, type: 'show'}, function (data) {
  109. layer.msg(data.msg);
  110. table.reload('tablerReload');
  111. })
  112. }, function (aa) {
  113. table.reload('tablerReload'); //重新加载
  114. })
  115. });
  116. //列表操作
  117. table.on('tool(' + tableIds + ')', function (obj) {
  118. var layEvent = obj.event,
  119. data = obj.data;
  120. if (layEvent === 'sortData') { //修改排序
  121. table.on('edit(' + tableIds + ')', function (obj) {
  122. var data = obj.data;
  123. // console.log(data)
  124. $.post('/push/hothousedelshow', {
  125. id: data.id,
  126. type: 'sort',
  127. sort: data.sort
  128. }, function (data) {
  129. if (data.code == 200) {
  130. layer.msg(data.msg);
  131. } else if (data.code == 300) {
  132. layer.msg(data.msg);
  133. }
  134. })
  135. })
  136. }
  137. if (layEvent === 'del') {
  138. layer.confirm('您确定要删除吗?', {btn: ['确定', '取消']}, function () {
  139. $.post('/push/hothousedelshow', {id: data.id, type: 'del'}, function (data) {
  140. layer.msg(data.msg);
  141. table.reload('tablerReload');
  142. })
  143. })
  144. }
  145. });
  146. // 新增
  147. var $ = layui.$, active = {
  148. addData: function () { //获取选中数据
  149. var index = layui.layer.open({
  150. type: 2,
  151. title: '添加楼盘',
  152. closeBtn: 1, //不显示关闭按钮
  153. area: ['600px', '300px'],
  154. content: '/pushm/hothouseadd?type=' + type_id
  155. , success: function (layero, index) {
  156. // indexOpen = layer.getChildFrame('body', index) ;
  157. // console.log(indexOpen);
  158. },
  159. end: function () {
  160. table.reload('tablerReload');
  161. }
  162. });
  163. },
  164. reload: function () {
  165. var form = pfgs_serialize($('form'));
  166. table.reload('tablerReload', {
  167. where: {
  168. name: form.input_house_text
  169. }
  170. })
  171. }
  172. };
  173. $('.demoTable .layui-btn').on('click', function () {
  174. var type = $(this).data('type');
  175. active[type] ? active[type].call(this) : '';
  176. });
  177. })
  178. }
  179. </script>