queryRole.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. define(function (require) {
  2. return function (context) {
  3. var $grid, $form;
  4. function queryGrid1() {
  5. $grid.jqGrid("clearGridData");
  6. var obj = $form.formGet();
  7. $grid.reload({
  8. url: api('/sys/role/query'),
  9. mtype: 'POST',
  10. queryParams: obj
  11. });
  12. }
  13. //删除
  14. function deleteRow() {
  15. var row = $grid.rowData();
  16. if (!row) {
  17. $.yvan.msg('请先选择一行数据');
  18. return;
  19. }
  20. $.yvan.confirm('确定删除 [' + row.roleName + "] ?", {
  21. yes: function (index) {
  22. $.yvan.ajax({
  23. url: api('/sys/role/delete'),
  24. data: {
  25. roleId: row.roleId,
  26. },
  27. method: 'post',
  28. success: function (data) {
  29. $.yvan.msg(data.msg);
  30. $grid.reload();
  31. }
  32. });
  33. }
  34. });
  35. }
  36. return {
  37. center: {
  38. border: false,
  39. items: {
  40. onRender: function () {
  41. $grid = $(this);
  42. },
  43. xtype: 'grid',
  44. idField: "roleId",
  45. toolbar: {
  46. xtype: 'div',
  47. items: [
  48. {
  49. xtype: 'toolbar', title: '角色管理', items: [
  50. {
  51. text: '查询', iconCls: 'fa fa-search', onClick: function () {
  52. queryGrid1();
  53. }
  54. }, {
  55. text: '重置', iconCls: 'fa fa-refresh', onClick: function () {
  56. $form.formClear();
  57. queryGrid1();
  58. }
  59. }, {
  60. text: '新增', iconCls: 'fa fa-plus-circle', onClick: function () {
  61. $.yvan.showDialog(this,
  62. require('/app/sys/role/dialogRole.js')({
  63. confirm: function () {
  64. $grid.reload();
  65. },
  66. isEdit: false
  67. })
  68. );
  69. }
  70. }, {
  71. text: '编辑', iconCls: 'fa fa-pencil-square-o', onClick: function () {
  72. var row = $grid.rowData();
  73. if (!row) {
  74. $.yvan.msg('请先选择一行数据');
  75. return;
  76. }
  77. $.yvan.showDialog(this,
  78. require('/app/sys/role/dialogRole.js')({
  79. confirm: function () {
  80. $grid.reload();
  81. },
  82. isEdit: true,
  83. roleId: row.roleId
  84. })
  85. );
  86. }
  87. }, {
  88. text: '编辑权限', iconCls: 'fa fa-check-square', onClick: function () {
  89. var row = $grid.rowData();
  90. if (!row) {
  91. $.yvan.msg('请先选择一行数据');
  92. return;
  93. }
  94. $.yvan.showDialog(this,
  95. require('/app/sys/role/dialogRoleMenu.js')({
  96. isEdit: true,
  97. roleId: row.roleId
  98. })
  99. );
  100. }
  101. }, {
  102. text: '删除', iconCls: 'fa fa-trash-o fa-lg', onClick: function () {
  103. deleteRow();
  104. }
  105. }, {
  106. text: '关闭', iconCls: 'fa fa-times-circle', onClick: function () {
  107. App.closeMe();
  108. }
  109. }
  110. ]
  111. },
  112. {
  113. onRender: function () {
  114. $form = $(this);
  115. },
  116. xtype: 'form',
  117. items: [[
  118. {xtype: 'textbox', label: '角色名称', name: 'roleName', labelWidth: 'auto'},
  119. {xtype: 'textbox', label: '角色备注', name: 'roleDes', labelWidth: 'auto'}
  120. ]]
  121. },
  122. {xtype: 'toolbar', title: '角色列表'}
  123. ]
  124. },
  125. columns: [[
  126. {title: '角色ID', field: 'roleId'},
  127. {title: '角色名称', field: 'roleName'},
  128. {title: '角色描述', field: 'roleDes'},
  129. {title: '是否活动', field: 'beActive', formatter: 'ba'},
  130. {title: '建立时间', field: 'createAt', formatter: 'ts'},
  131. {title: '更新日期', field: 'updateAt', formatter: 'ts'}
  132. ]]
  133. }
  134. }
  135. };
  136. };
  137. });