define(function (require) { return function (context) { var $grid, $form; function queryGrid1() { $grid.jqGrid("clearGridData"); var obj = $form.formGet(); $grid.reload({ url: api('/sys/role/query'), mtype: 'POST', queryParams: obj }); } //删除 function deleteRow() { var row = $grid.rowData(); if (!row) { $.yvan.msg('请先选择一行数据'); return; } $.yvan.confirm('确定删除 [' + row.roleName + "] ?", { yes: function (index) { $.yvan.ajax({ url: api('/sys/role/delete'), data: { roleId: row.roleId, }, method: 'post', success: function (data) { $.yvan.msg(data.msg); $grid.reload(); } }); } }); } return { center: { border: false, items: { onRender: function () { $grid = $(this); }, xtype: 'grid', idField: "roleId", toolbar: { xtype: 'div', items: [ { xtype: 'toolbar', title: '角色管理', items: [ { text: '查询', iconCls: 'fa fa-search', onClick: function () { queryGrid1(); } }, { text: '重置', iconCls: 'fa fa-refresh', onClick: function () { $form.formClear(); queryGrid1(); } }, { text: '新增', iconCls: 'fa fa-plus-circle', onClick: function () { $.yvan.showDialog(this, require('/app/sys/role/dialogRole.js')({ confirm: function () { $grid.reload(); }, isEdit: false }) ); } }, { text: '编辑', iconCls: 'fa fa-pencil-square-o', onClick: function () { var row = $grid.rowData(); if (!row) { $.yvan.msg('请先选择一行数据'); return; } $.yvan.showDialog(this, require('/app/sys/role/dialogRole.js')({ confirm: function () { $grid.reload(); }, isEdit: true, roleId: row.roleId }) ); } }, { text: '编辑权限', iconCls: 'fa fa-check-square', onClick: function () { var row = $grid.rowData(); if (!row) { $.yvan.msg('请先选择一行数据'); return; } $.yvan.showDialog(this, require('/app/sys/role/dialogRoleMenu.js')({ isEdit: true, roleId: row.roleId }) ); } }, { text: '删除', iconCls: 'fa fa-trash-o fa-lg', onClick: function () { deleteRow(); } }, { text: '关闭', iconCls: 'fa fa-times-circle', onClick: function () { App.closeMe(); } } ] }, { onRender: function () { $form = $(this); }, xtype: 'form', items: [[ {xtype: 'textbox', label: '角色名称', name: 'roleName', labelWidth: 'auto'}, {xtype: 'textbox', label: '角色备注', name: 'roleDes', labelWidth: 'auto'} ]] }, {xtype: 'toolbar', title: '角色列表'} ] }, columns: [[ {title: '角色ID', field: 'roleId'}, {title: '角色名称', field: 'roleName'}, {title: '角色描述', field: 'roleDes'}, {title: '是否活动', field: 'beActive', formatter: 'ba'}, {title: '建立时间', field: 'createAt', formatter: 'ts'}, {title: '更新日期', field: 'updateAt', formatter: 'ts'} ]] } } }; }; });