architecture.js 4.0 KB

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