123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- define(function (require) {
- return function (context) {
- var $dlg, $form;
- //生成拼音
- function onblurCustomerName() {
- $('body').item('roleName').textbox('setValue', $(this).val());
- var customerName = $('body').item('roleName').textbox("getValue");
- if (null != customerName && "" != customerName && undefined != customerName) {
- $('body').item('roleNamePy').val(top.pinyin.getFullChars(customerName));
- var pinyin = $('body').item('roleNamePy').val();
- $('body').item('roleNamePy').textbox('setValue', pinyin);
- }
- }
- //获取平台列表
- function getSysList() {
- var _datas = [];
- $.yvan.ajax({
- url: api('/sys/system/query'),
- data: {status: 1},
- method: 'post',
- async: false,
- success: function (data) {
- if (data.data != null && data.data != undefined) {
- for (var i = 0; i < data.data.length; i++) {
- _datas.push({
- "id": data.data[i].sysId,
- "text": data.data[i].sysName
- })
- }
- }
- }
- });
- return _datas;
- }
- return {
- xtype: 'dialog',
- dialogId: 'dialogSysRole',
- title: '角色信息',
- width: 500,
- height: 300,
- onOpen: function () {
- $dlg = $(this);
- if (context.isEdit) {
- $.yvan.ajax({
- loadingMask: false,
- url: api('/sys/sysRole/getById'),
- type: 'GET',
- data: {
- roleId: context.roleId
- },
- success: function (data) {
- $dlg.find('form');
- $form.formSet(data.data);
- }
- });
- } else {
- $form.formSet({
- beActive: 'Y',
- status: 1,
- isBase: 0,
- sysId: context.sysId
- });
- }
- },
- center: {
- items: {
- xtype: 'formgroup',
- onRender: function () {
- $form = $(this);
- },
- items: [
- [
- {name: 'roleId', xtype: 'hidden'},
- {name: 'status', xtype: 'hidden'},
- {name: 'roleNamePy', xtype: 'hidden'},
- {
- name: 'sysId', label: '所属平台', xtype: 'yvselect', width: 400, required: true,
- disabled: context.isEdit ? "disabled" : "",
- data: getSysList()
- },
- {
- name: 'roleName',
- label: '角色名称',
- required: true,
- width: 400,
- maxlength: 50,
- events: {blur: onblurCustomerName}
- },
- {name: 'roleCode', label: '角色编码', required: true, width: 400, maxlength: 20},
- {name: 'remark', label: '备注', width: 400, maxlength: 200}
- ]
- ]
- }
- },
- buttons: [
- {
- text: "提交", iconCls: "fa fa-save", onClick: function () {
- $.yvan.postForm($form, {
- url: (context.isEdit ? api('/sys/sysRole/update') : api('/sys/sysRole/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');
- }
- }
- ]
- };
- };
- });
|