officeztgl.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. layui.use(['layer', 'table', 'element', 'form'], function () {
  2. var $ = layui.jquery
  3. , layer = layui.layer //弹层
  4. , table = layui.table //表格
  5. , form = layui.form
  6. var previd = $('#previd').data('id');
  7. var tableIns = table.render({
  8. elem: '#officeztgllist',
  9. url: '/zt/officeztglform?previd='+previd,
  10. method: 'get',
  11. page: false,
  12. id: 'tablerReload',
  13. cols: [[
  14. {type: 'numbers', title: '序号'},
  15. {field: 'title', title: '地区名称', width: 400, align: "center"},
  16. {field: 'name', title: '楼盘名称', width: 400, align: "center"},
  17. {
  18. field: 'sort',
  19. title: '排序',
  20. width: 100,
  21. event: 'sortData',
  22. edit: 'text',
  23. align: 'center',
  24. sort: true,
  25. templet: "#sortBox"
  26. },
  27. {
  28. field: 'state', title: '状态', align: 'center', templet: function (d) {
  29. if (d.state == 1) {
  30. return '<input type="checkbox" checked value="' + d.id + '" data-state="2" lay-skin="switch" lay-filter="switchTest" lay-text="|">'
  31. } else {
  32. return '<input type="checkbox" value="' + d.id + '" data-state="1" lay-skin="switch" lay-filter="switchTest" lay-text="|">'
  33. }
  34. }
  35. },
  36. {title: '操作', templet: '#officeztglfunc', fixed: "right", align: "center"}
  37. ]]
  38. });
  39. table.reload('tablerReload'); //重新加载
  40. //表格头部操作菜单
  41. var $ = layui.$, active = {
  42. addData: function () {
  43. var id = $(this).data('id');
  44. var index = layui.layer.open({
  45. title: "添加湾区导航",
  46. type: 2,
  47. area: ['70%', '50%'],
  48. content: '/zt/officeztgladd?id='+id,
  49. })
  50. },
  51. };
  52. $('.demoTable .layui-btn').on('click', function () {
  53. var type = $(this).data('type');
  54. active[type] ? active[type].call(this) : '';
  55. });
  56. //监听指定开关
  57. form.on('switch(switchTest)', function (data) {
  58. var id = $(this).val();
  59. var state = $(this).data('state');
  60. layer.confirm('确定要修改此操作吗?', {btn: ['确定', '取消']}, function () {
  61. $.post('/zt/gulfcityglstate', {id: id, state: state}, function (data) {
  62. if (data.code == 200) {
  63. layer.msg(data.msg);
  64. table.reload('tablerReload');
  65. } else if (data.code == 300) {
  66. layer.msg(data.msg);
  67. }
  68. })
  69. }, function (aa) {
  70. table.reload('tablerReload'); //重新加载
  71. })
  72. });
  73. //排序
  74. table.on('edit(officeztgllist)', function (obj) {
  75. var data = obj.data;
  76. $.post('/zt/gulfcityglsort', {id: data.id, sort: data.sort}, function (data) {
  77. if (data.code == 200) {
  78. layer.msg(data.msg);
  79. } else if (data.code == 300) {
  80. layer.msg(data.msg);
  81. }
  82. })
  83. })
  84. //表格右边操作栏目
  85. table.on('tool(officeztgllist)', function (obj) {
  86. var data = obj.data;
  87. var id = data.id;
  88. if (obj.event === 'del') { //删除操作
  89. layer.confirm('确定要删除吗?', {btn: ['确定', '取消']}, function () {
  90. $.post('/zt/gulfcitygldel', {id: id}, function (data) {
  91. if (data.code == 200) {
  92. layer.msg(data.msg);
  93. table.reload('tablerReload');
  94. } else if (data.code == 300) {
  95. layer.msg(data.msg);
  96. }
  97. })
  98. })
  99. }
  100. })
  101. $('.The_house').focus(function(){
  102. indexOpen = parent.layui.layer.open({
  103. type: 2,
  104. title: '选择需要添加的楼盘',
  105. area: ['','100%'],
  106. content: '/publicuse/housename?type=1',
  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. form.on('submit(add_hainanville)', function (data) {
  119. $.post('/zt/officeztgladdform', {'data': data.field}, function (data) {
  120. if (data.code == 200) {
  121. layer.msg(data.msg);
  122. var index = parent.layer.getFrameIndex(window.name);
  123. parent.layer.close(index);
  124. window.parent.location.reload();
  125. }
  126. })
  127. return false;
  128. });
  129. // form.on('submit(edit_hainanville)', function (data) {
  130. // $.post('/zt/gulfcitygleditto', {'data': data.field}, function (data) {
  131. // if (data.code == 200) {
  132. // console.log(data.msg)
  133. // layer.msg(data.msg);
  134. // var index = parent.layer.getFrameIndex(window.name);
  135. // parent.layer.close(index);
  136. // window.parent.location.reload();
  137. // }
  138. // })
  139. // return false;
  140. // });
  141. })