house.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. var indexOpen;
  2. layui.use([ 'laypage', 'layer', 'table', 'element','form','upload'], function(){
  3. var laypage = layui.laypage //分页
  4. ,$ = layui.jquery
  5. ,table = layui.table //表格
  6. var tableIds = 'videolist'; //表格ID
  7. var $ = layui.$, active = {
  8. house_reload:function(){
  9. var form = pfgs_serialize($('form'));
  10. console.log(form);
  11. table.reload('houseReload',{
  12. where:{
  13. name:form.input_house_text
  14. }
  15. })
  16. }
  17. };
  18. $('.demoTable .layui-btn').on('click', function(){
  19. var type = $(this).data('type');
  20. active[type] ? active[type].call(this) : '';
  21. });
  22. $('.The_house').focus(function(){
  23. indexOpen = parent.layui.layer.open({
  24. type: 2,
  25. title: '选择需要添加的楼盘',
  26. area: ['','100%'],
  27. content: '/routinevideo/allhouse',
  28. success:function (layero, index) {
  29. },
  30. end:function(){
  31. }
  32. });
  33. parent.layui.layer.full(indexOpen);
  34. //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  35. $(window).on("resize",function(){
  36. parent.layui.layer.full(indexOpen);
  37. })
  38. })
  39. var indexO = table.render({
  40. elem: '#houselist'
  41. ,url: '/publicuse/allhouseform' //数据接口
  42. ,where:{token:csrfToken}
  43. ,method:'post'
  44. ,page: true //开启分页
  45. ,text:'数据加载中'
  46. ,id:'houseReload'
  47. ,cols: [[ //表头
  48. {title:'选择',event:'check',width:60,align:'center',templet:"#checkBox",templet:function(d){
  49. return '<div class="layui-inline"><input type="radio" name="sex" ></div>'
  50. }},
  51. {type:'numbers',title:'序号'},
  52. {field: 'name', title: '楼盘名称', align:'center'},
  53. ]]
  54. });
  55. table.reload('houseReload'); //重新加载
  56. //选择所属楼盘添加
  57. var _data;
  58. table.on('tool(houselist)', function(obj){
  59. var layEvent = obj.event,
  60. data = obj.data;
  61. if(layEvent === 'check'){
  62. _data = data;
  63. }
  64. });
  65. // 提交按钮
  66. $('.xuanzhouse').click(function () {
  67. var a = parent.layer.getChildFrame('body', indexOpen);
  68. // var _length = a.find('input#hiddenBox[type="hidden"]');
  69. // if(_length.length > 0){
  70. // _length.remove();
  71. // }
  72. // if(typeof _data == 'object'){
  73. // a.find('#house_name').val(_data.name)
  74. // a.find('form').append('<input type="hidden" id="hiddenBox" name="hid" value="'+_data.id+'" />');
  75. // TableClose();
  76. // }
  77. if(a.find('#feng_houseall').length<=0){
  78. // var a = parent.layer.getChildFrame('body', indexOpen);
  79. var _length = a.find('input#hiddenBox[type="hidden"]');
  80. if(_length.length > 0){
  81. _length.remove();
  82. }
  83. if(typeof _data == 'object'){
  84. a.find('#house_name').val(_data.name)
  85. a.find('form').append('<input type="hidden" id="hiddenBox" name="hid" value="'+_data.id+'" />');
  86. TableClose();
  87. }
  88. }else{
  89. // var checkStatus = table.checkStatus('houseReload');
  90. // var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); //数据提交提示
  91. // var a = parent.layer.getChildFrame('body', indexOpen);
  92. var _length = a.find('input#hiddenBox[type="hidden"]');
  93. if(_length.length > 0){
  94. _length.remove();
  95. }
  96. if(typeof _data == 'object'){
  97. var formdat = new FormData();
  98. var htmlStr = '';
  99. var tong = false;
  100. htmlStr += '<tr><td>'+_data.name+' <input type="hidden" name="hid[]" class="hids" value="'+_data.id+'" ></td><td class="feng_houseallnamedel"> <a class="layui-btn layui-btn-danger layui-btn-xs" >删除</a></td></tr>';
  101. a.find('.hids').each(function (key,val) {
  102. if(_data.id == $(val).val()){
  103. layer.msg('该楼盘已选择')
  104. tong = true;
  105. return false;
  106. }
  107. })
  108. if(tong){
  109. return false;
  110. }
  111. var tb = $('.layui-table').length;
  112. var html = '';
  113. if(a.find('.layui-table').length<=0){
  114. html += ' <table class="layui-table">\n' +
  115. ' <colgroup>\n' +
  116. ' <col width="150">\n' +
  117. ' <col width="50">\n' +
  118. ' <col>\n' +
  119. ' </colgroup>\n' +
  120. ' <thead>\n' +
  121. ' <tr>\n' +
  122. ' <th>楼盘名称</th>\n' +
  123. ' <th>操作</th>\n' +
  124. ' </tr>\n' +
  125. ' </thead>\n' +
  126. ' <tbody>\n'+
  127. htmlStr +
  128. ' </tbody>\n'+
  129. ' \n' +
  130. ' </table>';
  131. }
  132. if(a.find('.layui-table').length>0){
  133. a.find('.layui-table').append(htmlStr);
  134. }else{
  135. a.find('#feng_houseall').append(html);
  136. }
  137. TableClose();
  138. return false;
  139. }
  140. layer.msg('请选择楼盘',{icon:5});
  141. return false;
  142. var _length = a.find('input#hiddenBox[type="hidden"]');
  143. if(_length.length > 0){
  144. _length.remove();
  145. }
  146. if(typeof _data == 'object'){
  147. a.find('#house_name').val(_data.name)
  148. a.find('form').append('<input type="hidden" id="hiddenBox" name="hid" value="'+_data.id+'" />');
  149. TableClose();
  150. }
  151. }
  152. })
  153. });