117 lines
2.8 KiB
HTML
117 lines
2.8 KiB
HTML
{extend name="../../base/view/common/base" /}
|
|
<!-- 主体 -->
|
|
{block name="body"}
|
|
<div class="p-3">
|
|
<table class="layui-hide" id="test" lay-filter="test"></table>
|
|
</div>
|
|
|
|
<script type="text/html" id="status">
|
|
<i class="layui-icon {{# if(d.status == 1){ }}green layui-icon-ok{{# } else { }}yellow layui-icon-close{{# } }}"></i>
|
|
</script>
|
|
<script type="text/html" id="toolbarDemo">
|
|
<div class="layui-btn-container">
|
|
<button class="layui-btn layui-btn-sm" lay-event="add">+ 添加岗位</button>
|
|
</div>
|
|
</script>
|
|
<script type="text/html" id="barDemo">
|
|
<div class="layui-btn-group"><button class="layui-btn layui-btn-xs layui-btn-normal" lay-event="view">详情</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></div>
|
|
</script>
|
|
|
|
{/block}
|
|
<!-- /主体 -->
|
|
|
|
<!-- 脚本 -->
|
|
{block name="script"}
|
|
<script>
|
|
const moduleInit = ['tool'];
|
|
function gouguInit() {
|
|
var table = layui.table, tool = layui.tool;
|
|
layui.pageTable = table.render({
|
|
elem: '#test',
|
|
title: '岗位列表',
|
|
toolbar: '#toolbarDemo',
|
|
defaultToolbar: false,
|
|
url: "/user/position/index", //数据接口
|
|
page: false, //开启分页
|
|
cols: [
|
|
[
|
|
{
|
|
field: 'id',
|
|
title: 'ID号',
|
|
align: 'center',
|
|
width: 80
|
|
}, {
|
|
field: 'title',
|
|
title: '岗位名称',
|
|
align: 'center',
|
|
width: 120
|
|
},{
|
|
field: 'groupName',
|
|
title: '权限角色'
|
|
},{
|
|
field: 'remark',
|
|
title: '备注'
|
|
},{
|
|
field: 'work_price',
|
|
title: '岗位工时单价(元)',
|
|
align: 'center',
|
|
width: 132
|
|
}, {
|
|
field: 'status',
|
|
title: '状态',
|
|
toolbar: '#status',
|
|
align: 'center',
|
|
width: 60
|
|
}, {
|
|
field: 'right',
|
|
title: '操作',
|
|
toolbar: '#barDemo',
|
|
width: 132,
|
|
align: 'center'
|
|
}
|
|
]
|
|
]
|
|
});
|
|
|
|
//表头工具栏事件
|
|
table.on('toolbar(test)', function(obj){
|
|
if (obj.event === 'add') {
|
|
tool.side("/user/position/add");
|
|
return;
|
|
}
|
|
});
|
|
//监听行工具事件
|
|
table.on('tool(test)', function (obj) {
|
|
var data = obj.data;
|
|
if(obj.event === 'view'){
|
|
tool.side('/user/position/view?id='+data.id);
|
|
return;
|
|
}
|
|
if(obj.event === 'edit'){
|
|
tool.side('/user/position/add?id='+data.id);
|
|
return;
|
|
}
|
|
if (obj.event === 'del') {
|
|
if (data.id == 1) {
|
|
layer.msg('超级岗位不能删除');
|
|
return;
|
|
}
|
|
layer.confirm('您确定要删除该岗位', {
|
|
icon: 3,
|
|
title: '提示'
|
|
}, function (index) {
|
|
let callback = function (e) {
|
|
layer.msg(e.msg);
|
|
if (e.code == 0) {
|
|
obj.del();
|
|
}
|
|
}
|
|
tool.delete("/user/position/delete", { id: obj.data.id }, callback);
|
|
layer.close(index);
|
|
});
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
{/block}
|
|
<!-- /脚本 --> |