demo-yvtreegrid.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. define(function (require) {
  2. return function (context) {
  3. var $tree1;
  4. return {
  5. center: {
  6. border: false,
  7. items: {
  8. xtype: 'yvtreegrid',
  9. onRender: function () {
  10. $tree1 = $(this);
  11. },
  12. autoSizeColumns: false,
  13. idField: 'menuId',
  14. checkbox: true,
  15. keyDataField: 'menuId',
  16. parentDataField: 'parentId',
  17. onRowClick: function () {
  18. console.log('onRowClick', this, arguments);
  19. },
  20. onRowSelect: function () {
  21. console.log('onRowSelect', this, arguments);
  22. },
  23. onRowCheck: function () {
  24. console.log('onRowCheck', this, arguments);
  25. },
  26. toolbar: {
  27. xtype: 'toolbar', title: '系统字典详情',
  28. items: [
  29. {
  30. text: '查询',
  31. onClick: function () {
  32. $.yvan.ajax({
  33. url: ('/api/menu/queryMenu'),
  34. success: function (root) {
  35. $tree1.yvtreegrid('reload', {
  36. data: root.data
  37. });
  38. }
  39. });
  40. }
  41. },
  42. {
  43. text: 'selectRow',
  44. iconCls: 'fa fa-search',
  45. onClick: function () {
  46. console.log('getSelected', $tree1.yvtreegrid('getSelected'));
  47. }
  48. },
  49. {
  50. text: 'getCheckedRows',
  51. iconCls: 'fa fa-search',
  52. onClick: function () {
  53. console.log('getCheckedRows', $tree1.yvtreegrid('getCheckedRows'));
  54. }
  55. }
  56. ]
  57. },
  58. columns: [[
  59. {field: 'menuName', title: '菜单名称', width: 200},
  60. {field: 'menuId', title: '菜单编号', width: 100},
  61. {
  62. field: 'menuIcon', title: '图标', width: 40, formatter: function (v) {
  63. return "<i class='" + v + "'></i>";
  64. }
  65. },
  66. {
  67. field: 'menuType',
  68. title: '菜单类型',
  69. width: 100,
  70. formatter: [{id: 'ent', text: '企业'}, {id: 'wms', text: '仓库'}]
  71. },
  72. {field: 'moduleId', title: '模块名称', width: 100},
  73. {field: 'sortNum', title: '序号', width: 40, hidden: true, type: 'number'},
  74. {field: 'menuUrl', title: '功能地址', width: 100},
  75. {field: 'permissionCode', title: '权限编号', hidden: true, width: 100},
  76. {field: 'clientType', title: '客户端', width: 60},
  77. {
  78. field: 'beActive',
  79. title: '状态',
  80. width: 40,
  81. formatter: [{id: 'Y', text: '启用'}, {id: 'N', text: '禁用'}, {id: 'D', text: '删除'}]
  82. },
  83. {field: 'createAt', title: '新增时间', width: 160, formatter: fmtDate},
  84. {field: 'updateAt', title: '最后更新时间', width: 160, formatter: fmtDate}
  85. ]]
  86. }
  87. }
  88. };
  89. };
  90. });