save
This commit is contained in:
parent
50a4d4577c
commit
3a522c5999
@ -106,15 +106,15 @@ class AdminRuleController extends Crud
|
||||
*/
|
||||
public function permission(Request $request): Response
|
||||
{
|
||||
$controller = $request->get('controller');
|
||||
if (!$controller) {
|
||||
return $this->json(0, 'ok', []);
|
||||
}
|
||||
$rules = $this->getRules(admin('roles'));
|
||||
// 超级管理员
|
||||
if (in_array('*', $rules)) {
|
||||
return $this->json(0, 'ok', ['*']);
|
||||
}
|
||||
$controller = $request->get('controller');
|
||||
if (!$controller) {
|
||||
return $this->json(0, 'ok', []);
|
||||
}
|
||||
// 获取详细权限
|
||||
$controller_search = str_replace('\\', '\\\\', $controller);
|
||||
$keys = AdminRule::where('key', 'like', "$controller_search%")
|
||||
|
@ -485,7 +485,7 @@ class TableController extends Base
|
||||
$template_file_path = "$controller_path_base/app/view/$template_path";
|
||||
$model_class_with_namespace = "$model_namespace\\$model_class";
|
||||
$primary_key = (new $model_class_with_namespace)->getKeyName();
|
||||
$this->createTemplate($template_file_path, $table_name, $template_path, $url_path_base, $primary_key);
|
||||
$this->createTemplate($template_file_path, $table_name, $template_path, $url_path_base, $primary_key, "$controller_namespace\\$controller_class");
|
||||
|
||||
$reflection = new \ReflectionClass("$controller_namespace\\$controller_class");
|
||||
$controller_class_with_nsp = $reflection->getName();
|
||||
@ -696,9 +696,10 @@ EOF;
|
||||
* @param $template_path
|
||||
* @param $url_path_base
|
||||
* @param $primary_key
|
||||
* @param $controller_class_with_namespace
|
||||
* @return void
|
||||
*/
|
||||
protected function createTemplate($template_file_path, $table, $template_path, $url_path_base, $primary_key)
|
||||
protected function createTemplate($template_file_path, $table, $template_path, $url_path_base, $primary_key, $controller_class_with_namespace)
|
||||
{
|
||||
$this->mkdir($template_file_path . '/index.html');
|
||||
$form = LayuiForm::buildForm($table, 'search');
|
||||
@ -772,8 +773,9 @@ EOF
|
||||
<script src="/app/admin/admin/js/common.js"></script>
|
||||
<script>
|
||||
|
||||
// 相关接口
|
||||
// 相关常量
|
||||
const PRIMARY_KEY = '$primary_key';
|
||||
const CONTROLLER = '$controller_class_with_namespace';
|
||||
const SELECT_API = "$url_path_base/$template_path/select";
|
||||
const UPDATE_API = "$url_path_base/$template_path/update";
|
||||
const DELETE_API = "$url_path_base/$template_path/delete";
|
||||
|
@ -40,7 +40,7 @@ layui.$(function () {
|
||||
$.ajax({
|
||||
url: "/app/admin/admin-rule/permission",
|
||||
dataType: "json",
|
||||
data: {controller: CONTROLLER},
|
||||
data: {controller: window.CONTROLLER || ''},
|
||||
success: function (res) {
|
||||
let style = '';
|
||||
layui.each(res.data || [], function (k, action) {
|
||||
|
Loading…
Reference in New Issue
Block a user