【优化】优化新版treeTable下【菜单管理】使用简单数据模式可能导致数据混乱的问题,改为后台进行递归后返回数据到前端展示树。

This commit is contained in:
jianweie
2023-05-09 11:25:35 +08:00
parent b3125c17f0
commit c4670f2577
5 changed files with 95 additions and 48 deletions

View File

@@ -67,35 +67,11 @@ namespace CoreCms.Net.Web.Admin.Controllers
public async Task<AdminUiCallBack> GetPageList()
{
var jm = new AdminUiCallBack();
var where = PredicateBuilder.True<SysMenu>();
where = where.And(p => p.deleted == false);
//查询筛选
////菜单名称 nvarchar
//var menuName = Request.Form["menuName"].FirstOrDefault();
//if (!string.IsNullOrEmpty(menuName))
//{
// where = where.And(p => p.menuName.Contains(menuName));
//}
////菜单组件地址 nvarchar
//var component = Request.Form["component"].FirstOrDefault();
//if (!string.IsNullOrEmpty(component))
//{
// where = where.And(p => p.component.Contains(component));
//}
////权限标识 nvarchar
//var authority = Request.Form["authority"].FirstOrDefault();
//if (!string.IsNullOrEmpty(authority))
//{
// where = where.And(p => p.authority.Contains(authority));
//}
//获取数据
var list = await _sysMenuServices.QueryListByClauseAsync(where, p => p.sortNumber, OrderByType.Asc);
var list = await _sysMenuServices.QueryListByClauseAsync(p => p.deleted == false, p => p.sortNumber, OrderByType.Asc);
//返回数据
jm.data = list;
jm.data = SysMenuHelper.GetTree(list, false).data;
jm.code = 0;
jm.count = list.Count;
jm.msg = "数据调用成功!";
@@ -260,7 +236,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
var bl = await _sysMenuServices.InsertAsync(list, true) > 0;
jm.code = bl ? 0 : 1;
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
jm.msg = bl ? "数据导入成功" : "数据导入失败";
return jm;

View File

@@ -132,7 +132,7 @@
var list = [];
let item = {
menuName: "无上级",
title: "无上级",
id: 0
}
list.push(item);
@@ -153,7 +153,7 @@
model: { label: { type: 'text' } },
name: 'parentId',
prop: {
name: 'menuName',
name: 'title',
value: 'id'
},
radio: true,

View File

@@ -134,7 +134,7 @@
var list = [];
let item = {
menuName: "无上级",
title: "无上级",
id: 0
}
list.push(item);
@@ -154,7 +154,7 @@
model: { label: { type: 'text' } },
name: 'parentId',
prop: {
name: 'menuName',
name: 'title',
value: 'id'
},
radio: true,

View File

@@ -30,7 +30,7 @@
<script type="text/html" id="LAY-app-SysMenu-tableBox-bar">
{{# if(d.path != '' && d.path != null && d.menuType===0){ }}
{{# if(d.otherData.path != '' && d.otherData.path != null && d.otherData.menuType===0){ }}
<a class="layui-btn layui-btn-xs" lay-event="importButton">导入按钮</a>
{{# } }}
@@ -41,7 +41,7 @@
<div class="dropdown-anchor"></div>
<div class="dropdown-popconfirm-title">
<i class="layui-icon layui-icon-help"></i>
确定要删除{{d.menuName}}
确定要删除{{d.otherData.menuName}}
</div>
<div class="dropdown-popconfirm-btn">
<a class="layui-btn layui-btn-primary cursor" btn-cancel>取消</a>
@@ -90,44 +90,40 @@
indent:25
},
data: {
isSimpleData: true,
isSimpleData: false,
}
},
height: 'full-127',//无面包屑127,搜索框189,1行62
toolbar: '#LAY-app-SysMenu-tableBox-toolbar',
cols: [[
{field: 'id', title: '序列', width: 60},
{field: 'menuName', title: '菜单名称', minWidth: 110},
{ field: 'menuName', title: '菜单名称', minWidth: 110, templet: function (d) { return d.otherData.menuName } },
{
title: '图标', templet: '<p><i class="layui-icon {{d.menuIcon}}"></i></p>',
title: '图标', templet: '<p><i class="layui-icon {{d.otherData.menuIcon}}"></i></p>',
align: 'center', width: 60, minWidth: 60
},
{field: 'path', title: '菜单Url'},
{field: 'identificationCode', title: '文件夹标识'},
{field: 'component', title: 'API请求地址'},
{field: 'authority', title: '权限标识'},
{ field: 'path', title: '菜单Url', templet: function (d) { return d.otherData.path == null || d.otherData.path == '' ? '' : d.otherData.path } },
{ field: 'identificationCode', title: '文件夹标识', templet: function (d) { return d.otherData.identificationCode } },
{ field: 'component', title: 'API请求地址', templet: function (d) { return d.otherData.component } },
{ field: 'authority', title: '权限标识', templet: function (d) { return d.otherData.authority } },
{
field: 'sortNumber', title: '排序', align: 'center',
width: 60, minWidth: 60
field: 'sortNumber', title: '排序', align: 'center', width: 60, minWidth: 60, templet: function (d) { return d.otherData.sortNumber }
},
{
title: '隐藏', templet: function (d) {
return d.hide ? '<span class="text-danger">隐藏</span>' : '显示';
return d.otherData.hide ? '<span class="text-danger">隐藏</span>' : '显示';
}, align: 'center', width: 60, minWidth: 60
},
{
title: '类型', templet: function (d) {
var strs = ['<span class="layui-badge layui-badge-green">菜单</span>', '<span class="layui-badge layui-badge-gray">按钮</span>'];
return strs[d.menuType];
return strs[d.otherData.menuType];
}, align: 'center', width: 70, minWidth: 70
},
//{field: 'createTime', title: '创建时间'},
{title: '操作', toolbar: '#LAY-app-SysMenu-tableBox-bar', align: 'center', width: 180}
]],
initSort: {
field: 'sortNumber',
type: 'asc'
},
//autoSort: false,
page: false
});