define(function (require) { return function (context) { var $dlg, $form; var widgets = { // 人员搜索 selectHrUserWidget: { url: '/app/sys/widget/selectHrUser.js', bind: { userId: 'userId', userName: 'name' } }, // 机构搜索 selectOrgWidget: { url: '/app/hr/widget/selectOrg.js', bind: { deptId: 'orgId', orgName: 'orgName' } } }; return { xtype: 'dialog', dialogId: 'dialogAccount', title: '用户名信息', width: 650, height: 350, onOpen: function () { loadingMask: false, $dlg = $(this); if (context.isEdit) { $.yvan.ajax({ type: 'GET', url: api('/sys/account/getById'), data: { accId: context.accId }, success: function (data) { $dlg.find('form'); $form.formSet(data.data); } }); } else { // 点击新增按钮时操作: /*$(this).up('power').down('formgroup').formSet({ // bcuId: context.bcuId, userId: context.userId, userName: context.userName });*/ } }, center: { items: { xtype: 'formgroup', subLabelWidth: '100', subControlWidth: '200', onRender: function () { $form = $(this); }, items: [[ {name: 'accId', xtype: 'hidden'}, {label: '登录用户名', name: 'account', required: true, ff: 500}, { label: '类型', name: 'accType', xtype: 'yvselect', required: true, data: $.yvan.sysDict('accType').combo() },// 需要在字典管理菜单设置值 {label: '登录密码', name: 'pwd', xtype: 'passwordbox', required: true}, {label: '姓名ID', name: 'userId', xtype: 'hidden', widget: widgets.selectHrUserWidget}, { label: '人员', name: 'userName', xtype: 'searchbox', /*required: true, editable: false,*/ widget: widgets.selectHrUserWidget }, {label: '部门ID', name: 'deptId', xtype: 'hidden', widget: widgets.selectOrgWidget}, {label: '部门', name: 'orgName', xtype: 'searchbox', /*editable: false,*/ widget: widgets.selectOrgWidget}, { label: '启用状态', name: 'status', xtype: 'yvselect', required: true, value: 1, data: $.yvan.sysDict('accountStatus').combo() }// 通过value赋值提供下拉框默认值 ]] } }, buttons: [ { text: "提交", iconCls: "fa fa-save", onClick: function () { var userId = $form.formGet().userId; var deptId = $form.formGet().deptId; if (('' == userId || null == userId || undefined == userId) && ('' == deptId || null == deptId || undefined == deptId)) { $.yvan.msg('帐号必须关联一个人员或者部门'); return; } $.yvan.postForm($form, { url: (context.isEdit ? api('/sys/account/update') : api('/sys/account/insert')), success: function () { $.yvan.msg('操作成功'); if (context.isEdit) { $dlg.window('close'); } if ($.type(context.confirm) === 'function') { context.confirm(); } }, error: function (data) { } }); } }, { text: "关闭", iconCls: "fa fa-times", onClick: function () { $dlg.dialog('close'); } } ] }; }; });