averageprice.js 8.0 KB

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