| | |
| | | var pageCurr; |
| | | var roleId; |
| | | var powerTreeData; |
| | | |
| | | function getCols() { |
| | | var t = typeof I18n !== 'undefined' ? I18n.t : function(k) { return k; }; |
| | | return [[ |
| | | {type: 'checkbox', fixed: 'left'} |
| | | ,{field: 'id', title: 'ID', sort: true,align: 'center', fixed: 'left', width: 80} |
| | | ,{field: 'code', align: 'center',title: t('role_code')} |
| | | ,{field: 'name', align: 'center',title: t('role_name')} |
| | | ,{field: 'leader$', align: 'center',title: t('leader')} |
| | | // ,{field: 'level$', align: 'center',title: '角色等级'} |
| | | |
| | | ,{fixed: 'right', title: t('operation'), align: 'center', toolbar: '#operate', width:150} |
| | | ]]; |
| | | } |
| | | |
| | | $(function (){ |
| | | $.ajax({ |
| | | url: baseUrl+"/power/list/auth", |
| | |
| | | var layDate = layui.laydate; |
| | | var form = layui.form; |
| | | |
| | | // 数据渲染 |
| | | tableIns = table.render({ |
| | | elem: '#role', |
| | | headers: {token: localStorage.getItem('token')}, |
| | | url: baseUrl+'/role/list/auth', |
| | | page: true, |
| | | limit: 16, |
| | | limits: [16, 30, 50, 100, 200, 500], |
| | | toolbar: '#toolbar', |
| | | cellMinWidth: 50, |
| | | cols: [[ |
| | | {type: 'checkbox', fixed: 'left'} |
| | | ,{field: 'id', title: 'ID', sort: true,align: 'center', fixed: 'left', width: 80} |
| | | ,{field: 'code', align: 'center',title: '编码'} |
| | | ,{field: 'name', align: 'center',title: '名称'} |
| | | ,{field: 'leader$', align: 'center',title: '上级'} |
| | | // ,{field: 'level$', align: 'center',title: '角色等级'} |
| | | // Local translation helper |
| | | var t = typeof I18n !== 'undefined' ? I18n.t : function(k) { return k; }; |
| | | |
| | | ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:150} |
| | | ]], |
| | | request: { |
| | | pageName: 'curr', |
| | | pageSize: 'limit' |
| | | }, |
| | | parseData: function (res) { |
| | | return { |
| | | 'code': res.code, |
| | | 'msg': res.msg, |
| | | 'count': res.data.total, |
| | | 'data': res.data.records |
| | | form.verify({ |
| | | required: function (value) { |
| | | if (!value || $.trim(value) === '') { |
| | | return typeof I18n !== 'undefined' |
| | | ? I18n.t('form_required') |
| | | : '必填项不能为空'; |
| | | } |
| | | }, |
| | | response: { |
| | | statusCode: 200 |
| | | }, |
| | | done: function(res, curr, count) { |
| | | if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | } |
| | | pageCurr=curr; |
| | | limit(); |
| | | } |
| | | }); |
| | | |
| | | // 数据渲染 |
| | | var initTable = function() { |
| | | tableIns = table.render({ |
| | | elem: '#role', |
| | | headers: {token: localStorage.getItem('token')}, |
| | | url: baseUrl+'/role/list/auth', |
| | | page: true, |
| | | limit: 16, |
| | | limits: [16, 30, 50, 100, 200, 500], |
| | | toolbar: '#toolbar', |
| | | cellMinWidth: 50, |
| | | cols: getCols(), |
| | | request: { |
| | | pageName: 'curr', |
| | | pageSize: 'limit' |
| | | }, |
| | | parseData: function (res) { |
| | | return { |
| | | 'code': res.code, |
| | | 'msg': res.msg, |
| | | 'count': res.data.total, |
| | | 'data': res.data.records |
| | | } |
| | | }, |
| | | response: { |
| | | statusCode: 200 |
| | | }, |
| | | done: function(res, curr, count) { |
| | | if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | } |
| | | pageCurr=curr; |
| | | limit(); |
| | | if (typeof I18n !== 'undefined') { |
| | | I18n.updateLayuiPagination(); |
| | | } else { |
| | | $(document).one('i18n:ready', function() { |
| | | I18n.updateLayuiPagination(); |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | if (typeof I18n !== 'undefined' && I18n.isReady()) { |
| | | initTable(); |
| | | } else { |
| | | $(document).one('i18n:ready', initTable); |
| | | } |
| | | |
| | | // Listen for language change |
| | | $(document).on('i18n:languageChanged', function() { |
| | | tableIns.reload({ |
| | | cols: getCols() |
| | | }); |
| | | }); |
| | | |
| | | // 监听排序事件 |
| | |
| | | case 'addData': |
| | | layer.open({ |
| | | type: 2, |
| | | title: '新增', |
| | | title: t('add'), |
| | | maxmin: true, |
| | | area: [top.detailWidth, top.detailHeight], |
| | | shadeClose: false, |
| | | content: 'role_detail.html', |
| | | success: function(layero, index){ |
| | | if (typeof I18n !== 'undefined') I18n.updatePage(layero); |
| | | clearFormVal(layer.getChildFrame('#detail', index)); |
| | | layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"}); |
| | | } |
| | |
| | | ids.push(track.id); |
| | | }); |
| | | if (ids.length === 0){ |
| | | layer.msg('请选择数据'); |
| | | layer.msg(t('please_select_data')); |
| | | } else { |
| | | layer.confirm('确定删除'+(ids.length===1?'此':ids.length)+'条数据吗', function(){ |
| | | layer.confirm(t('confirm_delete_prefix')+(ids.length===1?t('this'):ids.length)+t('confirm_delete_suffix'), function(){ |
| | | $.ajax({ |
| | | url: baseUrl+"/role/delete/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | |
| | | } |
| | | break; |
| | | case 'exportData': |
| | | layer.confirm('确定导出Excel吗', {shadeClose: true}, function(){ |
| | | layer.confirm(t('confirm_export_excel'), {shadeClose: true}, function(){ |
| | | var titles=[]; |
| | | var fields=[]; |
| | | obj.config.cols[0].map(function (col) { |
| | |
| | | case 'detail': |
| | | layer.open({ |
| | | type: 2, |
| | | title: '详情', |
| | | title: t('detail'), |
| | | maxmin: true, |
| | | area: [top.detailWidth, top.detailHeight], |
| | | shadeClose: false, |
| | | content: 'role_detail.html', |
| | | success: function(layero, index){ |
| | | if (typeof I18n !== 'undefined') I18n.updatePage(layero); |
| | | setFormVal(layer.getChildFrame('#detail', index), data, true); |
| | | top.convertDisabled(layer.getChildFrame('#data-detail :input', index), true); |
| | | layer.getChildFrame('#data-detail-submit,#prompt', index).hide(); |
| | |
| | | case 'edit': |
| | | layer.open({ |
| | | type: 2, |
| | | title: '修改', |
| | | title: t('modify'), |
| | | maxmin: true, |
| | | area: [top.detailWidth, top.detailHeight], |
| | | shadeClose: false, |
| | | content: 'role_detail.html', |
| | | success: function(layero, index){ |
| | | if (typeof I18n !== 'undefined') I18n.updatePage(layero); |
| | | setFormVal(layer.getChildFrame('#detail', index), data, false); |
| | | top.convertDisabled(layer.getChildFrame('#data-detail :input', index), false); |
| | | layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"}); |
| | |
| | | case 'leader': |
| | | var param = top.reObject(data).leader; |
| | | if (param === undefined) { |
| | | layer.msg("无数据"); |
| | | layer.msg(t('no_data')); |
| | | } else { |
| | | layer.open({ |
| | | type: 2, |
| | | title: '详情', |
| | | title: t('detail'), |
| | | maxmin: true, |
| | | area: [top.detailHeight, top.detailWidth], |
| | | shadeClose: false, |
| | | content: '../role/role_detail.html', |
| | | success: function(layero, index){ |
| | | if (typeof I18n !== 'undefined') I18n.updatePage(layero); |
| | | $.ajax({ |
| | | url: baseUrl+"/role/"+ param +"/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | |
| | | roleId = data.id; |
| | | layer.open({ |
| | | type: 2, |
| | | title: data.name + ' 权限分配', |
| | | title: data.name + ' ' + t('permission_assignment'), |
| | | maxmin: true, |
| | | area: [top.detailWidth/2, '85%'], |
| | | shadeClose: false, |
| | | content: 'role_power_detail.html', |
| | | success: function(layero, index){ |
| | | if (typeof I18n !== 'undefined') I18n.updatePage(layero); |
| | | } |
| | | }); |
| | | break; |