dialogAccount.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. define(function (require) {
  2. return function (context) {
  3. var $dlg, $form;
  4. var widgets = {
  5. // 人员搜索
  6. selectHrUserWidget: {
  7. url: '/app/sys/widget/selectHrUser.js',
  8. bind: {
  9. userId: 'userId',
  10. userName: 'name'
  11. }
  12. },
  13. // 机构搜索
  14. selectOrgWidget: {
  15. url: '/app/hr/widget/selectOrg.js',
  16. bind: {
  17. deptId: 'orgId',
  18. orgName: 'orgName'
  19. }
  20. }
  21. };
  22. return {
  23. xtype: 'dialog',
  24. dialogId: 'dialogAccount',
  25. title: '用户名信息',
  26. width: 650,
  27. height: 350,
  28. onOpen: function () {
  29. loadingMask: false,
  30. $dlg = $(this);
  31. if (context.isEdit) {
  32. $.yvan.ajax({
  33. type: 'GET',
  34. url: api('/sys/account/getById'),
  35. data: {
  36. accId: context.accId
  37. },
  38. success: function (data) {
  39. $dlg.find('form');
  40. $form.formSet(data.data);
  41. }
  42. });
  43. } else {
  44. // 点击新增按钮时操作:
  45. /*$(this).up('power').down('formgroup').formSet({
  46. // bcuId: context.bcuId,
  47. userId: context.userId,
  48. userName: context.userName
  49. });*/
  50. }
  51. },
  52. center: {
  53. items: {
  54. xtype: 'formgroup',
  55. subLabelWidth: '100',
  56. subControlWidth: '200',
  57. onRender: function () {
  58. $form = $(this);
  59. },
  60. items: [[
  61. {name: 'accId', xtype: 'hidden'},
  62. {label: '登录用户名', name: 'account', required: true, ff: 500},
  63. {
  64. label: '类型',
  65. name: 'accType',
  66. xtype: 'yvselect',
  67. required: true,
  68. data: $.yvan.sysDict('accType').combo()
  69. },// 需要在字典管理菜单设置值
  70. {label: '登录密码', name: 'pwd', xtype: 'passwordbox', required: true},
  71. {label: '姓名ID', name: 'userId', xtype: 'hidden', widget: widgets.selectHrUserWidget},
  72. {
  73. label: '人员',
  74. name: 'userName',
  75. xtype: 'searchbox', /*required: true, editable: false,*/
  76. widget: widgets.selectHrUserWidget
  77. },
  78. {label: '部门ID', name: 'deptId', xtype: 'hidden', widget: widgets.selectOrgWidget},
  79. {label: '部门', name: 'orgName', xtype: 'searchbox', /*editable: false,*/ widget: widgets.selectOrgWidget},
  80. {
  81. label: '启用状态',
  82. name: 'status',
  83. xtype: 'yvselect',
  84. required: true,
  85. value: 1,
  86. data: $.yvan.sysDict('accountStatus').combo()
  87. }// 通过value赋值提供下拉框默认值
  88. ]]
  89. }
  90. },
  91. buttons: [
  92. {
  93. text: "提交", iconCls: "fa fa-save", onClick: function () {
  94. var userId = $form.formGet().userId;
  95. var deptId = $form.formGet().deptId;
  96. if (('' == userId || null == userId || undefined == userId) && ('' == deptId || null == deptId || undefined == deptId)) {
  97. $.yvan.msg('帐号必须关联一个人员或者部门');
  98. return;
  99. }
  100. $.yvan.postForm($form, {
  101. url: (context.isEdit ? api('/sys/account/update') : api('/sys/account/insert')),
  102. success: function () {
  103. $.yvan.msg('操作成功');
  104. if (context.isEdit) {
  105. $dlg.window('close');
  106. }
  107. if ($.type(context.confirm) === 'function') {
  108. context.confirm();
  109. }
  110. },
  111. error: function (data) {
  112. }
  113. });
  114. }
  115. }, {
  116. text: "关闭", iconCls: "fa fa-times", onClick: function () {
  117. $dlg.dialog('close');
  118. }
  119. }
  120. ]
  121. };
  122. };
  123. });