**combotree**
<div class="layui-col-md3">
<label class="layui-form-label">树形结构:</label>
<div class="layui-input-block">
<input id="treedata" type="text" name="title" required lay-verify="required"
autocomplete="off" class="layui-input">
</div>
</div>
<div data-options="region:'center',fit:true,border:false">
<table id="pagegrid" data-options="region:'center',fit:true,border:false">
</table>
</div>
$(’#treedata’).combotree()使用
//get请求 //请求路径 //{参数}
$.get('/api/···', {
userId: id,
roleLevel:roleLevel,
},
function (data) {
//data就是所在板块的所有数据
let list = [];
list.push({
id: "",
isLeaf: false,
name: "全部",
parentId: "0",
text: "全部",
children: data.list
});
//异步请求
$('#treedata').combotree({
data: list,
required: false,
width: '100%',
panelWidth: 300,
onLoadSuccess: function () {
let tree = $('#treedata').combotree('tree');
tree.tree('collapseAll');
},
onClick: function (node) {
}
});
});
$(’#pagegrid’).datagrid()使用 ,datagrid是个建表插件~用法
//查询参数 根据这些参数的选择对 $('#pagegrid').datagrid()表中的数据进行筛选显示
function getParams() {
let params = {
'roleLevel': roleLevel,
'userId': userId,
'manage': 2,
'type': $.trim($("#type").val()),
'title': $.trim($("#title").val()),
'parentId': $.trim($("#treedata").val()),
'create_time': $.trim($("#create_time").val()),
'create_time_gt': $.trim($("#create_time_gt").val()),
'create_time_lt': $.trim($("#create_time_lt").val()),
'is_disabled': $.trim($("#is_disabled").val()),
'status': $.trim($("#status").val()),
'token': getToken(),
};
return params;
}
$('#pagegrid').datagrid({
url: '/public/···',//请求路径
striped: true,
pagination: true,//分页控件
nowrap: false,
pageSize: 10,
pageList: [10, 20, 100],
loader: trueLoader,
queryParams: getParams(),//查询参数
//固定属性列
/*frozenColumns: [[
]],*/
columns: [[
{title: 'checkbox', field: 'checkbox', checkbox: true, halign: 'center', align: 'center', width: 120},
{
title: '内容', field: 'title', halign: 'center', sortable: true, align: 'left', width: 300,
formatter: function (value, row, index) {
let e = "";
if (row.type == "content" && row.status == "1") {
e = "<div style='text-align: center'><b>" + '<a target="_blank" href="${request.contextPath}/' + row.id + '" style="color:blue;text-decoration:underline" >' + row.title + '</a> '
+ "</b></div>";
} else if (!!row.title) {
e = "<div style='text-align: center'><b>" + row.title + "</b></div>";
} else {
e = "";
}
return e + row.content;
}
},
{
title: '类型',//表头
field: 'type',//需要的变量值
halign: 'center',
align: 'center',
width: 60,
formatter: function (value, row, index) {
if (row.type == "content") {
return "帖子";
} else if (row.type == "replay") {
return "回复";
} else if (row.type == "tip-off") {
return "举报";
}
}
},
{title: '创建时间', field: 'createDate', sortable: true, halign: 'center', align: 'center', width: 150},
{
title: '操作',
field: '操作',
halign: 'center',
width: 100,
align: 'left',
formatter: function (value, row, index) {
let e = "";
if (row.type == "content") {
if (row.contenttype != 'txt_content') {
if (!!!row.topTime) {
e = e + '<a href="#" style="color:red;text-decoration:underline" οnclick="zd(' + JSON.stringify(row).replace(/"/g, '\'') + ')">置顶</a> ';
} else {
e = e + '<a href="#" style="color:red;text-decoration:underline" οnclick="unzd(' + JSON.stringify(row).replace(/"/g, '\'') + ')">取消</a> ';
}
}
}
if (row.isDisabled == "0") {
e = e + '<a href="#" style="color:red;text-decoration:underline" οnclick="jy(' + row.id + ')">禁用</a> ';
} else if (row.isDisabled == "1") {
e = e + '<a href="#" style="color:red;text-decoration:underline" οnclick="qy(' + row.id + ')">启用</a> ';
}
//e += '<a href="#" style="color:red;text-decoration:underline" οnclick="op(' + JSON.stringify(row).replace(/"/g, '\'') + ')">修改</a> ';
e += '<a href="#" style="color:red;text-decoration:underline" οnclick="op1(' + JSON.stringify(row).replace(/"/g, '\'') + ')">删除</a> ';
return e;
}
},
]],
toolbar: '#toolbar',
onLoadSuccess: onLoadSuccess,
onLoadError: onLoadError,
loadFilter: loadFilter
});
});