优化系统管理模块的各个页面体验,权限删除添加限制:还在使用的权限组限制删除

This commit is contained in:
hdm 2022-07-21 09:46:28 +08:00
parent 6d083d9405
commit 87c526ae38
10 changed files with 253 additions and 237 deletions

View File

@ -106,17 +106,17 @@ class Conf extends BaseController
$module = strtolower(app('http')->getName()); $module = strtolower(app('http')->getName());
$class = strtolower(app('request')->controller()); $class = strtolower(app('request')->controller());
$action = strtolower(app('request')->action()); $action = strtolower(app('request')->action());
$template = $module . '/view/'. $class .'/'.$conf['name'].'.html'; $template = $module . '/view/' . $class . '/' . $conf['name'] . '.html';
$config = []; $config = [];
if ($conf['content']) { if ($conf['content']) {
$config = unserialize($conf['content']); $config = unserialize($conf['content']);
} }
View::assign('id', $id); View::assign('id', $id);
View::assign('config', $config); View::assign('config', $config);
if(isTemplate($template)){ if (isTemplate($template)) {
return view($conf['name']); return view($conf['name']);
}else{ } else {
return view('../../base/view/common/errortemplate',['file' =>$template]); return view('../../base/view/common/errortemplate', ['file' => $template]);
} }
} }
} }

View File

@ -12,129 +12,127 @@ namespace app\home\controller;
use app\base\BaseController; use app\base\BaseController;
use backup\Backup; use backup\Backup;
use think\facade\Session; use think\facade\Session;
use think\facade\Db;
use think\facade\View; use think\facade\View;
class Database extends BaseController class Database extends BaseController
{ {
//数据表列表 //数据表列表
public function database() public function database()
{ {
if (request()->isAjax()) { if (request()->isAjax()) {
// 数据信息 // 数据信息
$db = new Backup(); $db = new Backup();
$list = $db->dataList(); $list = $db->dataList();
// 计算总大小 // 计算总大小
$total = 0; $total = 0;
foreach ($list as $k => $v) { foreach ($list as $k => $v) {
$total += $v['data_length']; $total += $v['data_length'];
$list[$k]['data_size'] = $v['data_length']; $list[$k]['data_size'] = $v['data_length'];
$list[$k]['data_length'] = format_bytes($v['data_length']); $list[$k]['data_length'] = format_bytes($v['data_length']);
} }
// 提示信息 // 提示信息
$dataTips = '数据库中共有<strong> ' . count($list) . '</strong> 张表,共计 <strong>' . format_bytes($total) . '</strong>大小。'; $dataTips = '数据库中共有<strong> ' . count($list) . '</strong> 张表,共计 <strong>' . format_bytes($total) . '</strong>大小。';
$data['data'] = $list; $data['data'] = $list;
return table_assign(0, $dataTips, $data); return table_assign(0, $dataTips, $data);
} }
return view(); return view();
} }
//备份数据 //备份数据
public function backup() public function backup()
{ {
$db= new Backup(); $db = new Backup();
if(request()->isPost()){ if (request()->isPost()) {
$tables=get_params('tables'); $tables = get_params('tables');
$fileinfo =$db->getFile(); $fileinfo = $db->getFile();
//检查是否有正在执行的任务 //检查是否有正在执行的任务
$lock = "{$fileinfo['filepath']}backup.lock"; $lock = "{$fileinfo['filepath']}backup.lock";
if(is_file($lock)){ if (is_file($lock)) {
return to_assign(2, '检测到有一个备份任务未完成'); return to_assign(2, '检测到有一个备份任务未完成');
} else { } else {
//创建锁文件 //创建锁文件
file_put_contents($lock,time()); file_put_contents($lock, time());
} }
// 检查备份目录是否可写 // 检查备份目录是否可写
if(!is_writeable($fileinfo['filepath'])){ if (!is_writeable($fileinfo['filepath'])) {
return to_assign(1, '备份目录不存在或不可写,请检查后重试'); return to_assign(1, '备份目录不存在或不可写,请检查后重试');
} }
//缓存锁文件 //缓存锁文件
Session::set('lock', $lock); Session::set('lock', $lock);
//缓存备份文件信息 //缓存备份文件信息
Session::set('backup_file', $fileinfo['file']); Session::set('backup_file', $fileinfo['file']);
//缓存要备份的表 //缓存要备份的表
Session::set('backup_tables', $tables); Session::set('backup_tables', $tables);
//创建备份文件 //创建备份文件
if(false !== $db->Backup_Init()){ if (false !== $db->Backup_Init()) {
return to_assign(0, '初始化成功,开始备份...',['tab'=>['id' => 0, 'start' => 0,'table'=>$tables[0]]]); return to_assign(0, '初始化成功,开始备份...', ['tab' => ['id' => 0, 'start' => 0, 'table' => $tables[0]]]);
}else{ } else {
return to_assign(1, '初始化失败,备份文件创建失败'); return to_assign(1, '初始化失败,备份文件创建失败');
} }
}else if(request()->isGet()){ } else if (request()->isGet()) {
$tables = Session::get('backup_tables'); $tables = Session::get('backup_tables');
$file=Session::get('backup_file'); $file = Session::get('backup_file');
$id=get_params('id'); $id = get_params('id');
$start=get_params('start'); $start = get_params('start');
$start= $db->setFile($file)->backup($tables[$id], $start); $start = $db->setFile($file)->backup($tables[$id], $start);
if(false === $start){ if (false === $start) {
return to_assign(1, '备份出错'); return to_assign(1, '备份出错');
}else if(0 === $start){ } else if (0 === $start) {
if(isset($tables[++$id])){ if (isset($tables[++$id])) {
return to_assign(0, '备份完成',['tab'=>['id' => $id, 'start' => 0,'table'=>$tables[$id-1]]]); return to_assign(0, '备份完成', ['tab' => ['id' => $id, 'start' => 0, 'table' => $tables[$id - 1]]]);
} else { //备份完成,清空缓存 } else { //备份完成,清空缓存
unlink(Session::get('lock')); unlink(Session::get('lock'));
Session::delete('backup_tables'); Session::delete('backup_tables');
Session::delete('backup_file'); Session::delete('backup_file');
add_log('bak'); add_log('bak');
return to_assign(0, '备份完成',['tab'=>['start' => 'ok','table'=>$tables[$id-1]]]); return to_assign(0, '备份完成', ['tab' => ['start' => 'ok', 'table' => $tables[$id - 1]]]);
} }
} }
}else{ } else {
return to_assign(1, '参数错误!'); return to_assign(1, '参数错误!');
}
}
//优化表
public function optimize($tables= null)
{
$db= new Backup();
//return to_assign(0, $db->optimize($tables));
if($db->optimize($tables)){
add_log('optimize');
return to_assign(0, '数据表优化完成');
}else{
return to_assign(1, '数据表优化出错请重试');
} }
} }
//修复 //优化表
public function repair($tables= null) public function optimize($tables = null)
{ {
$db= new Backup(); $db = new Backup();
//return to_assign(0, $db->repair($tables)); //return to_assign(0, $db->optimize($tables));
if($db->repair($tables)){ if ($db->optimize($tables)) {
add_log('repair'); add_log('optimize');
return to_assign(0, '数据表修复完成'); return to_assign(0, '数据表优化完成');
}else{ } else {
return to_assign(1, '数据表修复出错请重试'); return to_assign(1, '数据表优化出错请重试');
} }
} }
//修复表
public function repair($tables = null)
{
$db = new Backup();
//return to_assign(0, $db->repair($tables));
if ($db->repair($tables)) {
add_log('repair');
return to_assign(0, '数据表修复完成');
} else {
return to_assign(1, '数据表修复出错请重试');
}
}
//备份文件列表 //备份文件列表
public function backuplist() public function backuplist()
{ {
$db= new Backup(); $db = new Backup();
$list = $db->fileList(); $list = $db->fileList();
$fileinfo =$db->getFile(); $fileinfo = $db->getFile();
$lock = "{$fileinfo['filepath']}backup.lock"; $lock = "{$fileinfo['filepath']}backup.lock";
$lock_time = 0; $lock_time = 0;
if(is_file($lock)){ if (is_file($lock)) {
$lock_time = file_get_contents($lock); $lock_time = file_get_contents($lock);
} }
$listNew = []; $listNew = [];
$indx = 0; $indx = 0;
foreach ($list as $k => $v) { foreach ($list as $k => $v) {
$listNew[$indx]['time'] = $k; $listNew[$indx]['time'] = $k;
$listNew[$indx]['timespan'] = $v['time']; $listNew[$indx]['timespan'] = $v['time'];
@ -143,79 +141,81 @@ class Database extends BaseController
} }
$list = $listNew; $list = $listNew;
array_multisort(array_column($list, 'time'), SORT_DESC, $list); array_multisort(array_column($list, 'time'), SORT_DESC, $list);
return view('',['list'=>$list,'lock_time' => $lock_time]); return view('', ['list' => $list, 'lock_time' => $lock_time]);
} }
//数据还原 //数据还原
public function import($time = 0, $part = null, $start = null) public function import($time = 0, $part = null, $start = null)
{ {
$db= new Backup(); $db = new Backup();
$time =(int)$time; $time = (int) $time;
if(is_numeric($time) && is_null($part) && is_null($start)){ if (is_numeric($time) && is_null($part) && is_null($start)) {
$list = $db->getFile('timeverif',$time); $list = $db->getFile('timeverif', $time);
if(is_array($list)){ if (is_array($list)) {
Session::set('backup_list', $list); Session::set('backup_list', $list);
return to_assign(0, '初始化完成,开始还原...',array('part' => 1, 'start' => 0,'time' => $time)); return to_assign(0, '初始化完成,开始还原...', array('part' => 1, 'start' => 0, 'time' => $time));
}else{ } else {
return to_assign(1, '备份文件可能已经损坏,请检查'); return to_assign(1, '备份文件可能已经损坏,请检查');
} }
}else if(is_numeric($part) && is_numeric($start)){ } else if (is_numeric($part) && is_numeric($start)) {
$list=Session::get('backup_list'); $list = Session::get('backup_list');
$part =(int)$part; $part = (int) $part;
$start =(int)$start; $start = (int) $start;
$start= $db->setFile($list)->import($start,$time,$part); $start = $db->setFile($list)->import($start, $time, $part);
if(false===$start){ if (false === $start) {
return to_assign(1, '还原数据出错,请重试'); return to_assign(1, '还原数据出错,请重试');
}elseif(0 === $start){ } elseif (0 === $start) {
if(isset($list[++$part])){ if (isset($list[++$part])) {
$data = array('part' => $part, 'start' => 0,'time' => $time); $data = array('part' => $part, 'start' => 0, 'time' => $time);
return to_assign(0, "正在还原...卷{$part},请勿关闭当前页面",$data); return to_assign(0, "正在还原...卷{$part},请勿关闭当前页面", $data);
} else { } else {
Session::delete('backup_list'); Session::delete('backup_list');
return to_assign(0, '还原数据成功'); return to_assign(0, '还原数据成功');
} }
}else{ } else {
$data = array('part' => $part, 'start' => $start[0],'time' => $time); $data = array('part' => $part, 'start' => $start[0], 'time' => $time);
if($start[1]){ if ($start[1]) {
$rate = floor(100 * ($start[0] / $start[1])); $rate = floor(100 * ($start[0] / $start[1]));
return to_assign(0, "正在还原...卷{$part} ({$rate}%),请勿关闭当前页面",$data); return to_assign(0, "正在还原...卷{$part} ({$rate}%),请勿关闭当前页面", $data);
} else { } else {
$data['gz'] = 1; $data['gz'] = 1;
return to_assign(0, "正在还原...卷{$part},请勿关闭当前页面",$data); return to_assign(0, "正在还原...卷{$part},请勿关闭当前页面", $data);
} }
return to_assign(0, "正在还原...卷{$part},请勿关闭当前页面"); return to_assign(0, "正在还原...卷{$part},请勿关闭当前页面");
} }
}else{ } else {
return to_assign(1, "参数错误"); return to_assign(1, "参数错误");
} }
} }
/**
* 删除备份文件
*/
public function del($time = 0,$lock=0){
$db= new Backup();
if($lock==1){
$fileinfo =$db->getFile();
$lock = "{$fileinfo['filepath']}backup.lock";
if(is_file($lock)){
$time = file_get_contents($lock);
unlink($lock);
}
}
if($db->delFile((int)$time)){
add_log('delete');
return to_assign(0, '删除成功');
}else{
return to_assign(0, '删除失败,请检查权限');
}
}
/** /**
* 下载备份文件 * 删除备份文件
*/ */
public function downfile($time = 0,$part=0){ public function del($time = 0, $lock = 0)
$db= new Backup(); {
add_log('down'); $db = new Backup();
$db->downloadFile((int)$time,$part-1); if ($lock == 1) {
} $fileinfo = $db->getFile();
$lock = "{$fileinfo['filepath']}backup.lock";
if (is_file($lock)) {
$time = file_get_contents($lock);
unlink($lock);
}
}
if ($db->delFile((int) $time)) {
add_log('delete');
return to_assign(0, '删除成功');
} else {
return to_assign(0, '删除失败,请检查权限');
}
}
/**
* 下载备份文件
*/
public function downfile($time = 0, $part = 0)
{
$db = new Backup();
add_log('down');
$db->downloadFile((int) $time, $part - 1);
}
} }

View File

@ -22,7 +22,7 @@ class Log extends BaseController
$param = get_params(); $param = get_params();
$where = array(); $where = array();
if (!empty($param['keywords'])) { if (!empty($param['keywords'])) {
$where[] = ['name|content|param_id', 'like', '%' . $param['keywords'] . '%']; $where[] = ['name|content|param_id|uid', 'like', '%' . $param['keywords'] . '%'];
} }
if (!empty($param['action'])) { if (!empty($param['action'])) {
$where[] = ['action','=',$param['action']]; $where[] = ['action','=',$param['action']];

View File

@ -89,15 +89,23 @@ class Role extends BaseController
//删除 //删除
public function delete() public function delete()
{ {
$id = get_params("id"); if (request()->isDelete()) {
if ($id == 1) { $id = get_params("id");
return to_assign(1, "该组是系统所有者,无法删除"); if ($id == 1) {
} return to_assign(1, "该组是系统所有者,无法删除");
if (Db::name('AdminGroup')->delete($id) !== false) { }
add_log('delete', $id, []); $count = Db::name('PositionGroup')->where(["group_id" => $id])->count();
return to_assign(0, "删除角色成功"); if ($count > 0) {
return to_assign(1, "该权限组还在使用,请去除使用者关联再删除");
}
if (Db::name('AdminGroup')->delete($id) !== false) {
add_log('delete', $id, []);
return to_assign(0, "删除权限组成功");
} else {
return to_assign(1, "删除失败");
}
} else { } else {
return to_assign(1, "删除失败"); return to_assign(1, "错误的请求");
} }
} }
} }

View File

@ -21,11 +21,11 @@ class Rule extends BaseController
{ {
if (request()->isAjax()) { if (request()->isAjax()) {
$rule = Db::name('adminRule') $rule = Db::name('adminRule')
->field('a.*,m.title as module_title') ->field('a.*,m.title as module_title')
->alias('a') ->alias('a')
->leftJoin('adminModule m','a.module = m.name') ->leftJoin('adminModule m', 'a.module = m.name')
->order('a.sort asc,a.id asc') ->order('a.sort asc,a.id asc')
->select(); ->select();
return to_assign(0, '', $rule); return to_assign(0, '', $rule);
} else { } else {
return view(); return view();
@ -37,7 +37,7 @@ class Rule extends BaseController
{ {
$param = get_params(); $param = get_params();
if (request()->isAjax()) { if (request()->isAjax()) {
$param['src'] = preg_replace('# #','',$param['src']); $param['src'] = preg_replace('# #', '', $param['src']);
if ($param['id'] > 0) { if ($param['id'] > 0) {
try { try {
validate(RuleCheck::class)->scene('edit')->check($param); validate(RuleCheck::class)->scene('edit')->check($param);
@ -71,8 +71,8 @@ class Rule extends BaseController
} else { } else {
$id = isset($param['id']) ? $param['id'] : 0; $id = isset($param['id']) ? $param['id'] : 0;
$pid = isset($param['pid']) ? $param['pid'] : 0; $pid = isset($param['pid']) ? $param['pid'] : 0;
if($id>0){ if ($id > 0) {
$detail = Db::name('AdminRule')->where('id',$id)->find(); $detail = Db::name('AdminRule')->where('id', $id)->find();
View::assign('detail', $detail); View::assign('detail', $detail);
} }
View::assign('id', $id); View::assign('id', $id);
@ -83,17 +83,21 @@ class Rule extends BaseController
//删除 //删除
public function delete() public function delete()
{ {
$id = get_params("id"); if (request()->isDelete()) {
$count = Db::name('AdminRule')->where(["pid" => $id])->count(); $id = get_params("id");
if ($count > 0) { $count = Db::name('AdminRule')->where(["pid" => $id])->count();
return to_assign(1, "该节点下还有子节点,无法删除"); if ($count > 0) {
} return to_assign(1, "该节点下还有子节点,无法删除");
if (Db::name('AdminRule')->delete($id) !== false) { }
clear_cache('adminRules'); if (Db::name('AdminRule')->delete($id) !== false) {
add_log('delete', $id, []); clear_cache('adminRules');
return to_assign(0, "删除节点成功"); add_log('delete', $id, []);
return to_assign(0, "删除节点成功");
} else {
return to_assign(1, "删除失败");
}
} else { } else {
return to_assign(1, "删除失败"); return to_assign(1, "错误的请求");
} }
} }
} }

View File

@ -33,7 +33,7 @@
<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="reset">清除不完整的备份</a> <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="reset">清除不完整的备份</a>
{else/} {else/}
<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="import">数据还原</a> <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="import">数据还原</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">备份删除</a> <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除备份</a>
{/if} {/if}
</div> </div>
</td> </td>

View File

@ -29,7 +29,6 @@
var tableIns = table.render({ var tableIns = table.render({
elem: '#log', elem: '#log',
title: '操作日志列表', title: '操作日志列表',
toolbar: '#toolbarDemo',
url: "/home/log/index", //数据接口 url: "/home/log/index", //数据接口
page: true, //开启分页 page: true, //开启分页
limit: 20, limit: 20,

View File

@ -1,23 +1,28 @@
{extend name="../../base/view/common/base" /} {extend name="../../base/view/common/base" /}
{block name="style"} {block name="style"}
<style> <style>
.checkbox16 .layui-form-checkbox span{font-size:15px;font-weight:800;} .left-note{font-weight:800; vertical-align:top; padding-top:28px!important; text-align:center}
#rule .layui-checkbox-disabled span {color: #666666!important;} .left-note .layui-form-checkbox span{background-color: #969696;}
.left-note .layui-form-checkbox:hover span{background-color: #808080;}
.left-note .layui-form-checked span, .left-note .layui-form-checked:hover span { background-color: #5fb878;}
.checkbox14 .layui-form-checkbox span{font-size:15px;font-weight:800;}
.right-note .layui-checkbox-disabled span {color: #666666!important;}
</style> </style>
{/block} {/block}
<!-- 主体 --> <!-- 主体 -->
{block name="body"} {block name="body"}
<form class="layui-form p-4"> <form class="layui-form p-4">
<h3 class="pb-3">权限角色</h3> <h3 class="pb-3">权限</h3>
<table class="layui-table layui-table-form"> <table class="layui-table layui-table-form">
<tr> <tr>
<td class="layui-td-gray">角色名称<font>*</font> <td class="layui-td-gray-2">权限组名称<font>*</font>
</td> </td>
<td> <td>
<input type="hidden" name="id" value="{$id}" /> <input type="hidden" name="id" value="{$id}" />
<input class="layui-input" type="text" name="title" lay-verify="required" lay-reqText="请输入角色名称" {notempty name="$role.title" <input class="layui-input" type="text" name="title" lay-verify="required" lay-reqText="请输入权限组名称" {notempty name="$role.title"
}value="{$role.title}" {/notempty} placeholder="请输入角色名称" autocomplete="off" /> }value="{$role.title}" {/notempty} placeholder="请输入权限组名称" autocomplete="off" />
</td> </td>
<td class="layui-td-gray">状态<font>*</font> <td class="layui-td-gray">状态<font>*</font>
</td> </td>
@ -32,23 +37,26 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="layui-td-gray" style="vertical-align:top">权限配置<font>*</font></td> <td class="layui-td-gray">权限配置说明<font>*</font></td>
<td colspan="3"> <td colspan="3"><strong class="red">注意:如果右侧子级权限有节点被勾选了,左侧的顶级权限就必须勾选,否则无法查看右侧的子级菜单。</strong></td>
</tr>
<tr>
<td colspan="4">
<table style="width:100%" id="rule"> <table style="width:100%" id="rule">
<tr> <tr>
<td style="text-align:left; background-color:#f8f8f8; width:160px;">选择可操作的顶级权限 <font style="color:red"></font></td> <td style="text-align:center; background-color:#f8f8f8; width:160px;">选择可操作的顶级权限 <font style="color:red"></font></td>
<td style="text-align:left; background-color:#f8f8f8;">选择可操作的子级权限 <font style="color:red"></font></td> <td style="text-align:left; background-color:#f8f8f8;">选择可操作的子级权限 <font style="color:red"></font></td>
</tr> </tr>
{volist name="role_rule" id="vo"} {volist name="role_rule" id="vo"}
<tr> <tr>
<td style="font-weight:800;"> <td class="left-note">
<input type="checkbox" name="rule[]" value="{$vo.id}" title="{$vo.title}" {eq name="$vo.checked" value="true" }checked{/eq}> <input type="checkbox" name="rule[]" value="{$vo.id}" title="{$vo.title}" class="aaa" {eq name="$vo.checked" value="true" }checked{/eq}>
</td> </td>
{notempty name="vo.children"} {notempty name="vo.children"}
<td> <td class="right-note">
<div style="padding:0 0 0 10px;"> <div style="padding:0 0 0 10px;">
{volist name="vo.children" key="k" id="voo"} {volist name="vo.children" key="k" id="voo"}
<div class="checkbox16" style="padding:10px 0;"> <div class="checkbox15" style="padding:10px 0;">
<input type="checkbox" lay-filter="rule" name="rule[]" value="{$voo.id}" lay-skin="primary" title="{$voo.title}" {eq name="$voo.checked" value="true" }checked{/eq}> <input type="checkbox" lay-filter="rule" name="rule[]" value="{$voo.id}" lay-skin="primary" title="{$voo.title}" {eq name="$voo.checked" value="true" }checked{/eq}>
</div> </div>
{notempty name="voo.children"} {notempty name="voo.children"}

View File

@ -16,7 +16,7 @@
</script> </script>
<script type="text/html" id="toolbarDemo"> <script type="text/html" id="toolbarDemo">
<div class="layui-btn-container"> <div class="layui-btn-container">
<button class="layui-btn layui-btn-normal layui-btn-sm" lay-event="add">+ 添加权限组</button> <button class="layui-btn layui-btn-sm" lay-event="add">+ 添加权限组</button>
</div> </div>
</script> </script>
{/block} {/block}
@ -40,7 +40,7 @@
, { field: 'desc', title: '备注' } , { field: 'desc', title: '备注' }
, { field: 'status', title: '状态', toolbar: '#status', align: 'center', width: 80 } , { field: 'status', title: '状态', toolbar: '#status', align: 'center', width: 80 }
, { width: 100,title: '操作',align: 'center',templet: function (d) { , { width: 100,title: '操作',align: 'center',templet: function (d) {
var html = '<div class="layui-btn-group"><button class="layui-btn layui-btn-xs" lay-event="edit">编辑</button><button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</button></div>'; var html = '<div class="layui-btn-group"><button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit">编辑</button><button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</button></div>';
return html; return html;
} }
} }
@ -62,15 +62,12 @@
return; return;
} }
if (obj.event === 'del') { if (obj.event === 'del') {
layer.confirm('确定要删除该权限角色吗?', { icon: 3, title: '提示' }, function (index) { layer.confirm('确定要删除该权限吗?', { icon: 3, title: '提示' }, function (index) {
let callback = function (e) { let callback = function (e) {
layer.msg(e.msg); layer.msg(e.msg);
if (e.code == 0) { if (e.code == 0) {
layer.msg(res.msg); layer.msg(res.msg);
if (res.code == 0) { obj.del();
obj.del();
layer.close(index);
}
} }
} }
tool.delete("/home/role/delete", { id: obj.data.id }, callback); tool.delete("/home/role/delete", { id: obj.data.id }, callback);

View File

@ -3,7 +3,7 @@
{block name="body"} {block name="body"}
<div class="p-3"> <div class="p-3">
<div class="gg-form-bar border-t border-x"> <div class="gg-form-bar border-t border-x">
<button class="layui-btn layui-btn-normal layui-btn-sm add-menu">+ 添加菜单/节点</button> <button class="layui-btn layui-btn-sm add-menu">+ 添加菜单/节点</button>
</div> </div>
<div> <div>
<table class="layui-hide" id="treeTable" lay-filter="treeTable"></table> <table class="layui-hide" id="treeTable" lay-filter="treeTable"></table>
@ -23,7 +23,7 @@
, elem: '#treeTable' , elem: '#treeTable'
, idField: 'id' , idField: 'id'
, url: "/home/rule/index" , url: "/home/rule/index"
, cellMinWidth: 80 , cellMinWidth: 150
, treeId: 'id'//树形id字段名称 , treeId: 'id'//树形id字段名称
, treeUpId: 'pid'//树形父id字段名称 , treeUpId: 'pid'//树形父id字段名称
, treeShowName: 'title'//以树形式显示的字段 , treeShowName: 'title'//以树形式显示的字段
@ -46,7 +46,7 @@
, { , {
width: 188, title: '操作', align: 'center' width: 188, title: '操作', align: 'center'
, templet: function (d) { , templet: function (d) {
var html = '<span class="layui-btn-group"><button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="add">添加子菜单/节点</button><button class="layui-btn layui-btn-xs" lay-event="edit">编辑</button><button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</button>'; var html = '<span class="layui-btn-group"><button class="layui-btn layui-btn-xs" lay-event="add">添加子菜单/节点</button><button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit">编辑</button><button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</button>';
return html; return html;
} }
} }