developers_house.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. layui.use([ 'laypage', 'layer', 'table', 'element','form'], function(){
  2. var laypage = layui.laypage //分页
  3. ,$ = layui.jquery
  4. ,layer = layui.layer //弹层
  5. ,table = layui.table //表格
  6. ,element = layui.element //元素操作
  7. ,form = layui.form;
  8. var tableIds = 'videolist'; //表格ID
  9. //第一个实例
  10. table.render({
  11. elem: '#'+tableIds
  12. ,url: '/pushma/developers_houseform' //数据接口
  13. ,where:{token:csrfToken,did:$('input[name=developers_id]').val()}
  14. ,method:'post'
  15. ,page: true //开启分页
  16. ,text:'数据加载中'
  17. ,id:'tablerReload'
  18. ,cols: [[ //表头
  19. {type:'numbers',title:'序号',width:50},
  20. {field: 'name', title: '楼盘名称', align:'center'},
  21. {field: 'city_name', title: '区域', align:'center',width: 200,}
  22. ,{field: 'create_at', title: '添加时间',width:150, align:'center'}
  23. ,{field: 'sort', title: '排序',width:100, edit: 'text',align:'center',sort: true}
  24. // ,{field: 'is_show', title: '审核',align:'center',width:100, templet:function (d) {
  25. // if(d.is_show == 2){
  26. // return '<input type="checkbox" value="'+d.id+'" name="open" lay-skin="switch" lay-filter="switchTest" lay-text="|">'
  27. // } else {
  28. // return '<input type="checkbox" checked value="'+d.id+'" name="open" lay-skin="switch" lay-filter="switchTest" lay-text="|">'
  29. // }
  30. // }}
  31. ,{fixed: 'right',title:'操作', width: 200, align:'center', toolbar: '#operate'}
  32. ]]
  33. });
  34. table.on('edit('+tableIds+')', function(obj){
  35. var data = obj.data;
  36. switch (obj.field){
  37. case 'sort':
  38. $.post('/pushma/cloumn_house_sort',{id:data.id,sort:data.sort},function (data) {
  39. if(data.code == 200)
  40. {
  41. layer.msg(data.msg);
  42. } else if(data.code == 300 ) {
  43. layer.msg(data.msg);
  44. }
  45. })
  46. break;
  47. }
  48. })
  49. //列表操作
  50. table.on('tool('+tableIds+')', function(obj){
  51. var layEvent = obj.event,
  52. data = obj.data;
  53. if(layEvent === 'del') {
  54. layer.confirm('您确定要删除吗?',{ btn: ['确定', '取消']},function () {
  55. $.post('/pushma/developers_housedelform',{id:data.id,type:'del'},function (data) {
  56. layer.msg(data.msg);
  57. table.reload('tablerReload');
  58. })
  59. })
  60. }
  61. });
  62. // 新增
  63. var $ = layui.$, active = {
  64. addData: function(){ //获取选中数据
  65. var index = layui.layer.open({
  66. type: 2,
  67. title: '添加本周精选',
  68. closeBtn: 1, //不显示关闭按钮
  69. area: ['800px','500px'],
  70. content: '/pushma/developers_houseadd?did='+$('input[name=developers_id]').val() //iframe的url,no代表不显示滚动条
  71. ,success:function (layero, index) {
  72. },
  73. end:function () {
  74. table.reload('tablerReload');
  75. }
  76. });
  77. },
  78. reload:function(){//搜索
  79. var form = pfgs_serialize($('form'));
  80. var name = '';
  81. var house_name = '';
  82. if(form.input_house == 'name'){
  83. name = form.input_house_text;
  84. } else if(form.input_house == 'house_name'){
  85. house_name = form.input_house_text;
  86. }
  87. table.reload('tablerReload',{
  88. where:{
  89. title:name,
  90. house_name:form.input_house_text,
  91. city:form.input_city,
  92. type_name:form.type_name
  93. }
  94. })
  95. },
  96. };
  97. $('.demoTable .layui-btn').on('click', function(){
  98. var type = $(this).data('type');
  99. active[type] ? active[type].call(this) : '';
  100. });
  101. $('.The_house').click(function(){
  102. var indexOpen = parent.layui.layer.open({
  103. type: 2,
  104. title: '选择需要添加的楼盘',
  105. area: ['','100%'],
  106. content: '/publicuse/housename',
  107. success:function (layero, index) {
  108. },
  109. end:function(){
  110. }
  111. });
  112. parent.layui.layer.full(indexOpen);
  113. //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  114. $(window).on("resize",function(){
  115. parent.layui.layer.full(indexOpen);
  116. })
  117. })
  118. //添加页面提交数据
  119. form.on('submit(add_choice)', function(data){
  120. var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); //数据提交提示
  121. $.ajax({
  122. cache : false,
  123. type : "post",
  124. url : "/pushma/developers_houseaddform",
  125. data : data.field, // 你的formid
  126. // contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
  127. // processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
  128. error : function(request) {
  129. layer.close(index);
  130. layer.msg("请联系管理员");
  131. },
  132. success : function(data) {
  133. if(data.data != null){
  134. layer.msg(ReturnInfo(data.data),{icon:5});
  135. return ;
  136. }
  137. layer.msg(data.msg);
  138. }
  139. });
  140. return false;
  141. });
  142. form.on('submit(edit_choice)', function(data){
  143. var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); //数据提交提示
  144. var formData = new FormData($('form')[0]);
  145. $.ajax({
  146. type : "post",
  147. url : "/pushma/house_developers_editform",
  148. data : formData,
  149. contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
  150. processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
  151. error : function(request) {
  152. layer.close(index);
  153. layer.msg("请联系管理员");
  154. },
  155. success : function(data) {
  156. if(data.data != null){
  157. layer.msg(ReturnInfo(data.data),{icon:5});
  158. return ;
  159. }
  160. layer.msg(data.msg);
  161. parent.layer.close(oindex); //再执行关闭
  162. }
  163. });
  164. return false;
  165. });
  166. })