bottomlabel.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. layui.use([ 'laypage', 'layer', 'table', 'element','form'], function(){
  2. var laypage = layui.laypage //分页
  3. ,layer = layui.layer //弹层
  4. ,table = layui.table //表格
  5. ,element = layui.element //元素操作
  6. ,form = layui.form;
  7. var tableIds = 'themelist'; //表格ID
  8. var reloadId = 'tablerReload';
  9. //第一个实例
  10. table.render({
  11. elem: '#'+tableIds
  12. ,url: '/dictionarya/bottomlabelform' //数据接口
  13. ,where:{token:csrfToken}
  14. ,method:'post'
  15. ,page: true //开启分页
  16. ,height:600
  17. ,text:'数据加载中'
  18. ,id:reloadId
  19. ,cols: [[ //表头
  20. // {field: 'id', title: 'ID', width:80, sort: true, fixed: 'left',align:'center'},
  21. {type:'numbers'},
  22. {field: 'name', title: '标签名',align:'center'}
  23. ,{field: 'update_at', title: '更新时间', width:150,align:'center'}
  24. ,{field: 'create_at', title: '添加时间', width:150,align:'center'}
  25. ,{fixed: 'right',title:'操作', width: 165, align:'center', toolbar: '#operate'}
  26. ]]
  27. });
  28. table.reload('tablerReload'); //重新加载
  29. //列表操作
  30. table.on('tool('+tableIds+')', function(obj){
  31. var layEvent = obj.event,
  32. data = obj.data;
  33. if(layEvent === 'edit'){
  34. layer.open({
  35. type: 2,
  36. title: '修改标签',
  37. closeBtn: 1, //不显示关闭按钮
  38. shade: [0],
  39. area: ['600px', '500px'],
  40. anim: 2,
  41. content: '/dictionarya/bottomlabeledit?id='+data.id, //iframe的url,no代表不显示滚动条
  42. end:function(){
  43. table.reload('tablerReload');
  44. }
  45. });
  46. } else if(layEvent === 'del') {
  47. layer.confirm('您确定要删除吗?',{ btn: ['确定', '取消']},function () {
  48. $.post('/dictionarya/bottomlabeldel',{'id':data.id},function (data) {
  49. if(data.code == 200)
  50. {
  51. layer.msg(data.msg);
  52. table.reload('tablerReload');
  53. } else if(data.code == 300 ) {
  54. layer.msg(data.msg);
  55. }
  56. })
  57. })
  58. }
  59. });
  60. var $ = layui.$, active = {
  61. addData: function(){ //获取选中数据
  62. layer.open({
  63. type: 2,
  64. title: '添加底部标签',
  65. area: ['600px', '500px'],
  66. content: '/dictionarya/bottomlabeladd', //iframe的url,no代表不显示滚动条
  67. end:function(){
  68. table.reload('tablerReload');
  69. }
  70. });
  71. }
  72. };
  73. $('.demoTable .layui-btn').on('click', function(){
  74. var type = $(this).data('type');
  75. active[type] ? active[type].call(this) : '';
  76. });
  77. //修改
  78. form.on('submit(editbottomlabel)', function(data){
  79. $.post('/dictionarya/bottomlabeleditform',{'data':data.field},function (data) {
  80. if(data.code == 200)
  81. {
  82. layer.msg(data.msg);
  83. } else if(data.code == 300 ) {
  84. layer.msg(data.msg);
  85. }
  86. })
  87. return false;
  88. });
  89. //添加
  90. form.on('submit(addbottomlabel)', function(data){
  91. $.post('/dictionarya/bottomlabeladdform',{'data':data.field},function (data) {
  92. if(data.code == 200)
  93. {
  94. layer.msg(data.msg);
  95. $('input').val('');
  96. } else if(data.code == 300 ) {
  97. layer.msg(data.msg);
  98. }
  99. })
  100. return false;
  101. });
  102. });