housecn.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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/allhousecnform' //数据接口
  42. , where: {token: csrfToken}
  43. , method: 'post'
  44. , page: true //开启分页
  45. , text: '数据加载中'
  46. , id: 'houseReload'
  47. , cols: [[ //表头
  48. {
  49. title: '选择', event: 'check', width: 60, align: 'center', templet: "#checkBox", templet: function (d) {
  50. return '<div class="layui-inline"><input type="radio" name="sex" ></div>'
  51. }
  52. },
  53. {type: 'numbers', title: '序号'},
  54. {field: 'name', title: '楼盘名称', align: 'center'},
  55. ]]
  56. });
  57. //选择所属楼盘添加
  58. var _data;
  59. table.on('tool(houselist)', function (obj) {
  60. var layEvent = obj.event,
  61. data = obj.data;
  62. if (layEvent === 'check') {
  63. _data = data;
  64. }
  65. });
  66. // 提交按钮
  67. $('.xuanzhouse').click(function () {
  68. var a = parent.layer.getChildFrame('body', indexOpen);
  69. if (a.find('#feng_houseall').length <= 0) {
  70. // var a = parent.layer.getChildFrame('body', indexOpen);
  71. var _length = a.find('input#hiddenBox[type="hidden"]');
  72. if (_length.length > 0) {
  73. _length.remove();
  74. }
  75. if (typeof _data == 'object') {
  76. a.find('#house_name').val(_data.name)
  77. a.find('form').append('<input type="hidden" id="hiddenBox" name="hid" value="' + _data.id + '" />');
  78. TableClose();
  79. }
  80. } else {
  81. ;
  82. // var checkStatus = table.checkStatus('houseReload');
  83. // var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); //数据提交提示
  84. // var a = parent.layer.getChildFrame('body', indexOpen);
  85. var _length = a.find('input#hiddenBox[type="hidden"]');
  86. if (_length.length > 0) {
  87. _length.remove();
  88. }
  89. if (typeof _data == 'object') {
  90. var formdat = new FormData();
  91. var htmlStr = '';
  92. // $.each(checkStatus.data,function (key,val) {
  93. htmlStr += '<tr><td>' + _data.name + ' <input type="hidden" name="hid[]" value="' + _data.id + '" ></td><td class="feng_houseallnamedel"> <a class="layui-btn layui-btn-danger layui-btn-xs" >删除</a></td></tr>';
  94. // })
  95. var tb = $('.layui-table').length;
  96. var html = '';
  97. if (a.find('.layui-table').length <= 0) {
  98. html += ' <table class="layui-table">\n' +
  99. ' <colgroup>\n' +
  100. ' <col width="150">\n' +
  101. ' <col width="50">\n' +
  102. ' <col>\n' +
  103. ' </colgroup>\n' +
  104. ' <thead>\n' +
  105. ' <tr>\n' +
  106. ' <th>楼盘名称</th>\n' +
  107. ' <th>操作</th>\n' +
  108. ' </tr>\n' +
  109. ' </thead>\n' +
  110. ' <tbody>\n' +
  111. htmlStr +
  112. ' </tbody>\n' +
  113. ' \n' +
  114. ' </table>';
  115. }
  116. if (a.find('.layui-table').length > 0) {
  117. a.find('.layui-table').append(htmlStr);
  118. } else {
  119. a.find('#feng_houseall').append(html);
  120. }
  121. TableClose();
  122. return false;
  123. }
  124. layer.msg('请选择楼盘', {icon: 5});
  125. return false;
  126. var _length = a.find('input#hiddenBox[type="hidden"]');
  127. if (_length.length > 0) {
  128. _length.remove();
  129. }
  130. if (typeof _data == 'object') {
  131. a.find('#house_name').val(_data.name)
  132. a.find('form').append('<input type="hidden" id="hiddenBox" name="hid" value="' + _data.id + '" />');
  133. TableClose();
  134. }
  135. }
  136. })
  137. });