cache.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. layui.use(['form','layer','laydate','table','laytpl','layedit','upload'],function(){
  2. var form = layui.form,
  3. // layer = parent.layer === undefined ? layui.layer : top.layer,
  4. layer = layui.layer,
  5. $ = layui.jquery,
  6. table = layui.table,
  7. layedit = layui.layedit
  8. //表格头部操作菜单
  9. var $ = layui.$, active = {
  10. mobile: function(){ //获取选中数据
  11. alert(0)
  12. },
  13. pc:function () {
  14. alert(1)
  15. },
  16. backend:function () {
  17. alert(2)
  18. }
  19. };
  20. function cacheClear(type) {
  21. layer.confirm('确定要删除吗?',{btn: ['确定', '取消']},function () {
  22. $.post('/news/newsdel',{id:data.id},function (data) {
  23. if(data.code == 200)
  24. {
  25. layer.msg(data.msg);
  26. table.reload('tablerReload');
  27. } else if(data.code == 300 ) {
  28. layer.msg(data.msg);
  29. }
  30. })
  31. })
  32. }
  33. //监听指定开关
  34. form.on('switch(switchTest)', function(data){
  35. layer.confirm('确定要修改此操作吗?',{btn: ['确定', '取消']},function () {
  36. $.post('/house/housesortedit',{id:data.value,examineid:1},function (data) {
  37. if(data.code == 200)
  38. {
  39. layer.msg(data.msg);
  40. table.reload('tablerReload');
  41. } else if(data.code == 300 ) {
  42. layer.msg(data.msg);
  43. }
  44. })
  45. },function (aa) {
  46. table.reload('tablerReload'); //重新加载
  47. })
  48. });
  49. $('.demoTable .layui-btn').on('click', function(){
  50. var type = $(this).data('type');
  51. active[type] ? active[type].call(this) : '';
  52. });
  53. //表格右边操作栏目
  54. table.on('tool('+tableIds+')', function(obj){
  55. var data = obj.data;
  56. if(obj.event === 'del'){ //删除操作
  57. layer.confirm('确定要删除吗?',{btn: ['确定', '取消']},function () {
  58. $.post('/news/newsdel',{id:data.id},function (data) {
  59. if(data.code == 200)
  60. {
  61. layer.msg(data.msg);
  62. table.reload('tablerReload');
  63. } else if(data.code == 300 ) {
  64. layer.msg(data.msg);
  65. }
  66. })
  67. })
  68. } else if(obj.event === 'edit'){ //编辑操作
  69. var index = layui.layer.open({
  70. title : "编辑资讯",
  71. type : 2,
  72. area:['','100%'],
  73. maxmin: true,
  74. content : "/news/newsedit?id="+data.id
  75. })
  76. layui.layer.full(index);
  77. //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  78. $(window).on("resize",function(){
  79. layui.layer.full(index);
  80. })
  81. }
  82. });
  83. });