timelimitsgroup.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. layui.use([ 'laypage', 'layer','laydate', 'table', 'element','form','upload'], function(){
  2. var laypage = layui.laypage //分页
  3. ,$ = layui.jquery
  4. ,laydate = layui.laydate
  5. ,layer = layui.layer //弹层
  6. ,table = layui.table //表格
  7. ,element = layui.element //元素操作
  8. ,form = layui.form
  9. ,upload = layui.upload;
  10. var tableIds = 'videolist'; //表格ID
  11. var type_id = $('input[name="typeid"]').val();
  12. //第一个实例
  13. table.render({
  14. elem: '#'+tableIds
  15. ,url: '/pushm/timelimitsgroupform' //数据接口
  16. ,where:{token:csrfToken,type:type_id}
  17. ,method:'post'
  18. ,page: true //开启分页
  19. ,text:'数据加载中'
  20. ,id:'tablerReload'
  21. ,height : 600
  22. ,limit:15
  23. ,cols: [[ //表头
  24. {type:'numbers',title:'序号',width:50},
  25. {field: 'name', title: '楼盘名称', align:'center'},
  26. {field: 'province', title: '区域', align:'center'},
  27. {field: 'sort', title: '排序',width:100, event:'sortData',edit: 'text', align:'center',sort: true,templet:"#sortBox"},
  28. {field: 'create_at', title: '添加时间',width:150, align:'center'},
  29. {field: 'is_show', title: '审核',align:'center',width:100, templet:function (d) {
  30. if(d.is_show == 2){
  31. return '<input type="checkbox" value="'+d.id+'" name="open" lay-skin="switch" lay-filter="switchTest" lay-text="|">'
  32. } else {
  33. return '<input type="checkbox" checked value="'+d.id+'" name="open" title="'+d.is_show+'" lay-skin="switch" lay-filter="switchTest" lay-text="|">'
  34. }
  35. }}
  36. ,{fixed: 'right',title:'操作', width: 120, align:'center', toolbar: '#operate'}
  37. ]]
  38. });
  39. //监听指定开关
  40. form.on('switch(switchTest)', function(data){
  41. layer.confirm('确定要修改此操作吗?',{btn: ['确定', '取消']},function () {
  42. $.post('/pushm/timelimitsgroupdelandshow',{id:data.value,type:'show'},function (data) {
  43. layer.msg(data.msg);
  44. table.reload('tablerReload');
  45. })
  46. },function (aa) {
  47. table.reload('tablerReload'); //重新加载
  48. })
  49. });
  50. // 日期
  51. laydate.render({
  52. elem: '#EventDate'
  53. });
  54. laydate.render({
  55. elem: '#ModificationDate'
  56. });
  57. //列表操作
  58. table.on('tool('+tableIds+')', function(obj){
  59. var layEvent = obj.event,
  60. data = obj.data;
  61. if(layEvent === 'sortData'){ //修改排序
  62. /* 列表操作 edit 修改后执行 2018.7.24*/
  63. table.on('edit('+tableIds+')', function(obj){
  64. var data = obj.data;
  65. $.post('/pushm/timelimitsgroupdelandshow',{id:data.id,type:'sort',sort:data.sort},function (data) {
  66. if(data.code == 200)
  67. {
  68. layer.msg(data.msg);
  69. } else if(data.code == 300 ) {
  70. layer.msg(data.msg);
  71. }
  72. })
  73. })
  74. // layer.prompt({
  75. // formType: 2
  76. // ,title: '排序热销楼盘:<span style="color:red">'+data.name+'</span>'
  77. // ,value: data.sort
  78. // }, function(value, index){
  79. // $.post('/pushm/saledelshow',{id:data.id,type:'sort',sort:value},function (data) {
  80. // layer.msg(data.msg);
  81. // table.reload('tablerReload');
  82. // })pfg_pushm_hothousesort
  83. // });
  84. }
  85. if(layEvent === 'clickData'){ //修改排序
  86. /* 列表操作 edit 修改后执行 2018.7.24*/
  87. table.on('edit('+tableIds+')', function(obj){
  88. var data = obj.data;
  89. $.post('/pushm/timelimitsgroupdelandshow',{id:data.id,type:'click',click:data.click},function (data) {
  90. if(data.code == 200)
  91. {
  92. layer.msg(data.msg);
  93. } else if(data.code == 300 ) {
  94. layer.msg(data.msg);
  95. }
  96. })
  97. })
  98. // layer.prompt({
  99. // formType: 2
  100. // ,title: '排序热销楼盘:<span style="color:red">'+data.name+'</span>'
  101. // ,value: data.sort
  102. // }, function(value, index){
  103. // $.post('/pushm/saledelshow',{id:data.id,type:'sort',sort:value},function (data) {
  104. // layer.msg(data.msg);
  105. // table.reload('tablerReload');
  106. // })
  107. // });
  108. }
  109. if(layEvent === 'groupnumData'){ //修改排序
  110. /* 列表操作 edit 修改后执行 2018.7.24*/
  111. table.on('edit('+tableIds+')', function(obj){
  112. var data = obj.data;
  113. $.post('/pushm/timelimitsgroupdelandshow',{id:data.id,type:'group_num',group_num:data.group_num},function (data) {
  114. if(data.code == 200)
  115. {
  116. layer.msg(data.msg);
  117. } else if(data.code == 300 ) {
  118. layer.msg(data.msg);
  119. }
  120. })
  121. })
  122. // layer.prompt({
  123. // formType: 2
  124. // ,title: '排序热销楼盘:<span style="color:red">'+data.name+'</span>'
  125. // ,value: data.sort
  126. // }, function(value, index){
  127. // $.post('/pushm/saledelshow',{id:data.id,type:'sort',sort:value},function (data) {
  128. // layer.msg(data.msg);
  129. // table.reload('tablerReload');
  130. // })
  131. // });
  132. }
  133. if(layEvent === 'del') {
  134. layer.confirm('您确定要删除吗?',{ btn: ['确定', '取消']},function () {
  135. $.post('/pushm/timelimitsgroupdelandshow',{id:data.id,type:'del'},function (data) {
  136. layer.msg(data.msg);
  137. table.reload('tablerReload');
  138. })
  139. })
  140. }
  141. if(layEvent === 'edit') {
  142. var index = layer.open({
  143. type: 2,
  144. title: '修改限时团购',
  145. area:['800px','500px'],
  146. content: '/pushm/timelimitsgroupedit?id='+data.id+'&house_name='+data.name,
  147. end:function () {
  148. table.reload('tablerReload'); //重新加载
  149. }
  150. });
  151. }
  152. });
  153. // 新增
  154. var $ = layui.$, active = {
  155. addData: function(){ //获取选中数据
  156. var index = layui.layer.open({
  157. type: 2,
  158. title: '添加楼盘',
  159. closeBtn: 1, //不显示关闭按钮
  160. area: ['600px','345px'],
  161. content: '/pushm/timelimitsgroupadd?type='+type_id
  162. ,success:function (layero, index) {
  163. // indexOpen = layer.getChildFrame('body', index) ;
  164. // console.log(indexOpen);
  165. },
  166. end:function () {
  167. table.reload('tablerReload');
  168. }
  169. });
  170. },
  171. reload:function(){
  172. var form = pfgs_serialize($('form'));
  173. // var name = '';
  174. // var house_name = '';
  175. // if(form.input_house == 'name'){
  176. // name = form.input_house_text;
  177. // } else if(form.input_house == 'house_name'){
  178. // house_name = form.input_house_text;
  179. // }
  180. table.reload('tablerReload',{
  181. where:{
  182. house_name: form.input_house_text,
  183. province: form.province
  184. },
  185. page:{
  186. curr:1
  187. }
  188. })
  189. }
  190. };
  191. $('.demoTable .layui-btn').on('click', function(){
  192. var type = $(this).data('type');
  193. active[type] ? active[type].call(this) : '';
  194. });
  195. // select 选中
  196. form.on('select(cityname)', function(data){
  197. var city=$(this).html();
  198. $('.mt input').val(city);
  199. })
  200. $('.The_house').focus(function(){
  201. // $('form').append('<input type="hidden" name="aa" value="aaa">');
  202. indexOpen = parent.layui.layer.open({
  203. type: 2,
  204. title: '选择需要添加的楼盘',
  205. area: ['','100%'],
  206. content: '/publicuse/housename',
  207. success:function (layero, index) {
  208. },
  209. end:function(){
  210. }
  211. });
  212. parent.layui.layer.full(indexOpen);
  213. //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  214. $(window).on("resize",function(){
  215. parent.layui.layer.full(indexOpen);
  216. })
  217. })
  218. //添加页面提交数据
  219. form.on('submit(add)', function(data){
  220. var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); //数据提交提示
  221. var formData = new FormData($('form')[0]);
  222. $.ajax({
  223. cache : false,
  224. type : "post",
  225. url : "/pushm/timelimitsgroupaddform",
  226. data : formData, // 你的formid
  227. contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
  228. processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
  229. error : function(request) {
  230. layer.close(index);
  231. layer.msg("请联系管理员");
  232. },
  233. success : function(data) {
  234. if(data.data != null){
  235. layer.msg(ReturnInfo(data.data),{icon:5});
  236. return ;
  237. }
  238. layer.msg(data.msg);
  239. parent.layer.close(oindex); //再执行关闭
  240. }
  241. });
  242. return false;
  243. });
  244. //修改页面提交数据
  245. form.on('submit(edit)', function(data){
  246. var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); //数据提交提示
  247. var formData = new FormData($('form')[0]);
  248. $.ajax({
  249. cache : false,
  250. type : "post",
  251. url : "/pushm/timelimitsgroupeditform",
  252. data : formData, // 你的formid
  253. contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
  254. processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
  255. error : function(request) {
  256. layer.close(index);
  257. layer.msg("请联系管理员");
  258. },
  259. success : function(data) {
  260. if(data.data != null){
  261. layer.msg(ReturnInfo(data.data),{icon:5});
  262. return ;
  263. }
  264. layer.msg(data.msg);
  265. parent.layer.close(oindex); //再执行关闭
  266. //layer.close(index);
  267. }
  268. });
  269. return false;
  270. });
  271. })