85 lines
2.6 KiB
HTML
85 lines
2.6 KiB
HTML
{extend name="../../base/view/common/base" /}
|
|
<!-- 主体 -->
|
|
{block name="body"}
|
|
<div class="p-3">
|
|
<div class="gg-form-bar border-t border-x" style="padding-bottom:12px;">
|
|
<button class="layui-btn layui-btn-sm add-menu">+ 添加部门</button>
|
|
</div>
|
|
<div>
|
|
<table class="layui-hide" id="treeTable" lay-filter="treeTable"></table>
|
|
</div>
|
|
</div>
|
|
{/block}
|
|
<!-- /主体 -->
|
|
|
|
<!-- 脚本 -->
|
|
{block name="script"}
|
|
<script>
|
|
const moduleInit = ['tool'];
|
|
function gouguInit() {
|
|
var treeTable = layui.treeTable, tool = layui.tool;
|
|
|
|
layui.pageTable = treeTable.render({
|
|
elem: '#treeTable'
|
|
,id: 'treeTable'
|
|
,url: "/user/department/index"
|
|
,tree: { // treeTable 特定属性集
|
|
customName: {name:'title'},
|
|
data: {},
|
|
view: {showIcon:false},
|
|
async: {},
|
|
callback: {}
|
|
}
|
|
,done:function(){
|
|
treeTable.expandAll('treeTable', true); // 关闭全部节点
|
|
}
|
|
, cols: [[
|
|
{ field: 'id', width: 100, title: 'ID号', align: 'center' }
|
|
, { field: 'pid', title: '上级部门ID',width: 120, align: 'center'}
|
|
, { field: 'title', title: '部门名称'}
|
|
, { field: 'sort', title: '排序',width: 80, align: 'center'}
|
|
, { field: 'leader', title: '分管领导',width: 120, align: 'center'}
|
|
, { field: 'manager', title: '部门负责人',width: 120, align: 'center'}
|
|
, { field: 'phone', title: '部门电话',width: 160,}
|
|
, { width:180, title: '操作', align: 'center', templet: function (d) {
|
|
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></span>';
|
|
return html;
|
|
}
|
|
}
|
|
]]
|
|
, page: false
|
|
});
|
|
|
|
//表头工具栏事件
|
|
$('body').on('click','.add-menu', function(){
|
|
tool.side("/user/department/add");
|
|
return;
|
|
});
|
|
|
|
//操作按钮
|
|
treeTable.on('tool(treeTable)', function (obj) {
|
|
if (obj.event === 'add') {
|
|
tool.side("/user/department/add?pid="+obj.data.id);
|
|
return;
|
|
}
|
|
if (obj.event === 'edit') {
|
|
tool.side("/user/department/add?id="+obj.data.id);
|
|
return;
|
|
}
|
|
if (obj.event === 'del') {
|
|
layer.confirm('确定要删除吗?', {icon: 3, title:'提示'}, function(index){
|
|
let callback = function (e) {
|
|
layer.msg(e.msg);
|
|
if (e.code == 0) {
|
|
obj.del();
|
|
}
|
|
}
|
|
tool.delete("/user/department/delete", { id: obj.data.id }, callback);
|
|
layer.close(index);
|
|
});
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
{/block}
|
|
<!-- /脚本 --> |