【优化】使用新版treeTable应用于【页面设计】的获取商品分类、获取文章分类。

This commit is contained in:
jianweie
2023-05-09 12:06:37 +08:00
parent c4670f2577
commit 3161855ee2
4 changed files with 76 additions and 55 deletions

View File

@@ -1085,9 +1085,9 @@ namespace CoreCms.Net.Web.Admin.Controllers
var jm = new AdminUiCallBack();
//获取数据
var list = await _goodsCategoryServices.QueryAsync();
var list = await _goodsCategoryServices.QueryListByClauseAsync(p => p.id > 0, p => p.sort, OrderByType.Asc, true, true);
//返回数据
jm.data = list;
jm.data = GoodsHelper.GetTree(list, false).data;
jm.code = 0;
jm.msg = "数据调用成功!";
return jm;

View File

@@ -32,30 +32,31 @@
//数据绑定
var insTb = treeTable.render({
elem: '#LAY-app-CoreCmsArticleType-tableBox',
url: layui.setter.apiUrl + 'Api/Tools/GetArticleTypes',
method: 'POST',
tree: {
iconIndex: 1,
idName: 'id', // id的字段名
pidName: 'parentId', // pid的字段名
openName: 'name',
isPidData: true
customName: {
id: 'id',
pid: 'parentId',
name: 'name',
},
view: {
showIcon: false,
indent: 25
},
data: {
//isSimpleData: true,
},
callback: {}
},
height: 'full-232',//无面包屑127,搜索框189,1行62
cols: [
cols: [[
{ field: 'id', title: '序列', width: 60, sort: false },
{ field: 'name', title: '分类名称', sort: false },
{ field: 'sort', title: '排序 ', sort: false, width: 105 },
{ width: 140, title: '操作', align: 'center', toolbar: '#articleTypeBar' }
],
reqData: function (data, callback) {
coreHelper.Post('Api/Tools/GetArticleTypes', null, function (res) {
if (res.code === 0) {
callback(res.data);
} else {
layer.msg(res.msg, { icon: 5, time: 2000 });
}
})
},
style: 'margin-top:0;'
]],
page: false
});
});
};

View File

@@ -12,7 +12,7 @@
if (debug) { console.log(d); }
indexData = d.data;
layui.use(['index', 'table', 'laydate', 'util', 'coreHelper', 'treeTable'],
layui.use(['index', 'table', 'laydate', 'util', 'coreHelper'],
function () {
var $ = layui.$
, admin = layui.admin
@@ -31,31 +31,50 @@
//数据绑定
var insTb = treeTable.render({
id: 'treeTableBox',
url: layui.setter.apiUrl + 'Api/Tools/GetGoodTypes',
elem: '#LAY-app-CoreCmsArticleType-tableBox',
method: 'POST',
tree: {
iconIndex: 1,
idName: 'id', // id的字段名
pidName: 'parentId', // pid的字段名
openName: 'name',
isPidData: true
customName: {
id: 'id',
pid: 'parentId',
name: 'title',
},
view: {
showIcon: false,
indent: 25
},
data: {
//isSimpleData: true,
},
callback: {}
},
height: 'full-232',//无面包屑127,搜索框189,1行62
cols: [
cols: [[
{ field: 'id', title: '序列', width: 60, sort: false },
{ field: 'name', title: '分类名称', sort: false },
{ field: 'sort', title: '排序 ', sort: false, width: 105 },
{ width: 140, title: '操作', align: 'center', toolbar: '#articleTypeBar' }
],
reqData: function (data, callback) {
coreHelper.Post('Api/Tools/GetGoodTypes', null, function (res) {
if (res.code === 0) {
callback(res.data);
} else {
layer.msg(res.msg, { icon: 5, time: 2000 });
{ field: 'title', title: '名称', sort: false },
{
field: 'sort', title: '排序', sort: false, width: 105, templet: function (d) {
return d.otherData.sort
}
})
},
{
field: 'imageUrl', title: '图片', width: 80, sort: false,
templet: function (d) {
if (d.otherData.imageUrl) {
return '<a href="javascript:void(0);" onclick=layui.coreHelper.viewImage("' + d.otherData.imageUrl + '")><image style="max-width:28px;max-height:28px;" src="' + d.otherData.imageUrl + '" /></a>';
} else {
return '<a href="javascript:void(0);" onclick=layui.coreHelper.viewImage("' + setter.noImagePicUrl + '")><image style="max-width:30px;max-height:30px;" src="' + setter.noImagePicUrl + '" /></a>';
}
}
},
{ width: 140, title: '操作', align: 'center', toolbar: '#articleTypeBar' }
]],
done: function (res, curr, count) {
treeTable.expandAll('treeTableBox', true);
},
style: 'margin-top:0;'
page: false
});
});
};

View File

@@ -36,30 +36,31 @@
//数据绑定
var insTb = treeTable.render({
elem: '#LAY-app-CoreCmsArticleType-tableBox',
url: layui.setter.apiUrl + 'Api/CoreCmsAdvertisement/GetArticleType',
method: 'POST',
tree: {
iconIndex: 1,
idName: 'id', // id的字段名
pidName: 'parentId', // pid的字段名
openName: 'name',
isPidData: true
customName: {
id: 'id',
pid: 'parentId',
name: 'name',
},
view: {
showIcon: false,
indent: 25
},
data: {
//isSimpleData: true,
},
callback: {}
},
height: 'full-262',//无面包屑127,搜索框189,1行62
cols: [
cols: [[
{ field: 'id', title: '序列', width: 60, sort: false },
{ field: 'name', title: '分类名称', sort: false },
{ field: 'sort', title: '排序 ', sort: false, width: 105 },
{ width: 182, align: 'center', title: '操作', fixed: 'right', toolbar: '#LAY-app-CoreCmsArticleType-tableBox-bar' }
],
reqData: function (data, callback) {
coreHelper.Post('Api/CoreCmsAdvertisement/GetArticleType', null, function (res) {
if (res.code === 0) {
callback(res.data);
} else {
layer.msg(res.msg, { icon: 5, time: 2000 });
}
})
},
style: 'margin-top:0;'
]],
page: false
});
});
};