diff --git a/application/admin/controller/auth/Group.php b/application/admin/controller/auth/Group.php index 8aebd666..488bf73e 100644 --- a/application/admin/controller/auth/Group.php +++ b/application/admin/controller/auth/Group.php @@ -84,12 +84,13 @@ class Group extends Backend if (!in_array($params['pid'], $this->childrenIds)) { $this->code = -1; + $this->msg = __(''); return; } $parentmodel = model("AuthGroup")->get($params['pid']); if (!$parentmodel) { - $this->code = -1; + $this->msg = __('The parent group can not found'); return; } // 父级别的规则节点 @@ -126,10 +127,10 @@ class Group extends Backend { $this->code = -1; $params = $this->request->post("row/a"); - // 复节点不能是它自身的子节点 + // 父节点不能是它自身的子节点 if (!in_array($params['pid'], $this->childrenIds)) { - $this->code = -1; + $this->msg = __('The parent group can not be its own child'); return; } $params['rules'] = explode(',', $params['rules']); @@ -137,7 +138,7 @@ class Group extends Backend $parentmodel = model("AuthGroup")->get($params['pid']); if (!$parentmodel) { - $this->code = -1; + $this->msg = __('The parent group can not found'); return; } // 父级别的规则节点 @@ -200,6 +201,11 @@ class Group extends Backend continue; } } + if (!$ids) + { + $this->msg = __('You can not delete group that contain child group and administrators'); + return; + } $count = $this->model->where('id', 'in', $ids)->delete(); if ($count) { diff --git a/application/admin/lang/zh-cn/auth/admin.php b/application/admin/lang/zh-cn/auth/admin.php new file mode 100644 index 00000000..0a36d7ce --- /dev/null +++ b/application/admin/lang/zh-cn/auth/admin.php @@ -0,0 +1,6 @@ + '所属组别', + 'Login time' => '最后登录', +]; diff --git a/application/admin/lang/zh-cn/auth/group.php b/application/admin/lang/zh-cn/auth/group.php new file mode 100644 index 00000000..89f3a8ee --- /dev/null +++ b/application/admin/lang/zh-cn/auth/group.php @@ -0,0 +1,7 @@ + '父组别不能是自身的子组别', + 'The parent group can not found' => '父组别未找到', + 'You can not delete group that contain child group and administrators' => '你不能删除含有子组和管理员的组', +]; diff --git a/application/admin/lang/zh-cn/auth/rule.php b/application/admin/lang/zh-cn/auth/rule.php new file mode 100644 index 00000000..d173e4d5 --- /dev/null +++ b/application/admin/lang/zh-cn/auth/rule.php @@ -0,0 +1,10 @@ + '显示全部', + 'Condition' => '条件', + 'Remark' => '备注', + 'Icon' => '图标', + 'Alert' => '警告', + 'If not necessary, use the command line to build rule' => '非必要情况下请使用命令行来生成', +]; diff --git a/application/admin/view/auth/rule/add.html b/application/admin/view/auth/rule/add.html index 1ec1f98e..469289ae 100644 --- a/application/admin/view/auth/rule/add.html +++ b/application/admin/view/auth/rule/add.html @@ -1,6 +1,6 @@

{:__('Alert')}!

- {:__('If not necessary, use the rebuild node feature directly')} + {:__('If not necessary, use the command line to build rule')}
diff --git a/application/admin/view/auth/rule/index.html b/application/admin/view/auth/rule/index.html index d439dd79..0d6331f4 100644 --- a/application/admin/view/auth/rule/index.html +++ b/application/admin/view/auth/rule/index.html @@ -8,7 +8,6 @@ diff --git a/public/assets/js/backend/auth/rule.js b/public/assets/js/backend/auth/rule.js index 2ae895c6..a103402c 100755 --- a/public/assets/js/backend/auth/rule.js +++ b/public/assets/js/backend/auth/rule.js @@ -41,69 +41,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function // 为表格绑定事件 Table.api.bindevent(table);//当内容渲染完成后 - $(document).on("click", ".btn-rebuild", function () { - Backend.api.layer.confirm( - __('Are you sure you want to rebuild node?'), - {icon: 3, title: __('Warning'), offset: 0}, - function (index) { - Backend.api.layer.close(index); - Backend.api.ajax({url: "auth/rule/rebuild", data: {step: 1}}, function (content) { - table.bootstrapTable('refresh'); - var msg = '
' + __('You can change the node name if you want to') + '
'; - Backend.api.layer.open({ - type: 1, - content: msg, - area: ['600px', '400px'], - scrollbar: false, - success: function (layero, index) { - require(['jstree'], function () { - $("#treeview", $(layero)).jstree({ - "themes": {"stripes": true}, - "types": { - "menu": { - "icon": "fa fa-folder-open", - "valid_children": [] - }, - "file": { - "icon": "fa fa-file-o", - "valid_children": [] - } - }, - "plugins": ["types"], - "core": { - 'check_callback': true, - "data": content - } - }).bind("select_node.jstree", function (e, data) { - var ref = $("#treeview", layero).jstree(true); - ref.edit(data.node); - }); - }); - } - , - btn: [__('OK'), __('Cancel')], - yes: function (index, layero) { - //递归获取所有节点信息 - var get_children = function (node) { - var data = []; - $.each(node, function (i, j) { - data.push({id: j.id, name: j.text}); - data = data.concat(get_children(j.children)); - }); - return data; - }; - var data = get_children($("#treeview").jstree('get_json')); - Backend.api.ajax({url: "auth/rule/rebuild", data: {step: 2, data: data}}, function (content) { - Backend.api.layer.close(index); - top.location.reload(); - }); - } - }); - - }); - } - ); - }); //默认隐藏所有子节点 table.on('post-body.bs.table', function (e, settings, json, xhr) { $("a.btn[data-id][data-pid][data-pid!=0]").closest("tr").hide();