architecture.js 4.0 KB

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