dialogRole.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. define(function (require) {
  2. return function (context) {
  3. var $dlg, $form;
  4. return {
  5. xtype: 'dialog',
  6. dialogId: 'dialogRole',
  7. title: '角色基本属性',
  8. width: 610,
  9. height: 250,
  10. onOpen: function () {
  11. $dlg = $(this);
  12. if (context.isEdit) {
  13. $.yvan.ajax({
  14. loadingMask: false,
  15. url: api('/sys/role/getById'),
  16. type: 'GET',
  17. data: {
  18. roleId: context.roleId
  19. },
  20. success: function (data) {
  21. $dlg.find('form');
  22. $form.formSet(data.data);
  23. }
  24. });
  25. } else {
  26. $form.formSet({
  27. beActive: 'Y'
  28. });
  29. }
  30. },
  31. center: {
  32. items: {
  33. xtype: 'formgroup',
  34. onRender: function () {
  35. $form = $(this);
  36. },
  37. items: [
  38. [
  39. {name: 'roleId', xtype: 'hidden'},
  40. {name: 'roleName', label: '角色名称', required: true, ff: 500},
  41. {
  42. name: 'beActive', label: '启用状态', xtype: 'yvselect', required: true, data: [
  43. {id: 'Y', text: '启用'},
  44. {id: 'N', text: '禁用'},
  45. {id: 'D', text: '删除'}
  46. ]
  47. }
  48. ], [
  49. {name: 'roleDes', label: '角色描述', span: 2},
  50. ]
  51. ]
  52. }
  53. },
  54. buttons: [
  55. {
  56. text: "提交", iconCls: "fa fa-save", onClick: function () {
  57. $.yvan.postForm($form, {
  58. url: (context.isEdit ? api('/sys/role/update') : api('/sys/role/insert')),
  59. success: function () {
  60. $.yvan.msg('操作成功');
  61. if (context.isEdit) {
  62. $dlg.window('close');
  63. }
  64. if ($.type(context.confirm) === 'function') {
  65. context.confirm();
  66. }
  67. },
  68. error: function (data) {
  69. }
  70. });
  71. }
  72. }, {
  73. text: "关闭", iconCls: "fa fa-times", onClick: function () {
  74. $dlg.dialog('close');
  75. }
  76. }
  77. ]
  78. };
  79. };
  80. });