闫增涛
2025-04-08 b41630280b49408824feb333849d51d83fa06fca
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}
<div class="p-page">
    <table class="layui-hide" id="test" lay-filter="test"></table>
</div>
<script type="text/html" id="toolbarDemo">
  <div class="layui-btn-container">
      <button class="layui-btn layui-btn-sm addNew" type="button">+ 添加审批类型</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'
            ,toolbar: '#toolbarDemo'
            ,defaultToolbar: false
            ,title:'审批模块列表'
            ,url: "/home/cate/flow_type"
            ,page: false
            ,cellMinWidth: 80
            ,cols: [[
                {field:'id',width:80, title: 'ID号', align:'center'}
                ,{field:'title',title: '名称',width:120}
                ,{field:'department',title: '应用部门'}
                ,{field:'name',title: '标识',width:150}
                ,{field:'icon',title: '图标',width:220,templet: function(d){
                    var html='<strong class="iconfont '+d.icon+'"></strong> '+d.icon;
                    return html;
                }}
                ,{field:'type_name', title: '所属分类',width:90,align:'center'}
                ,{field:'status', title: '状态',width:80,align:'center',templet: function(d){
                    var html1='<span class="green">正常</span>';
                    var html2='<span class="yellow">禁用</span>';
                    if(d.status==1){
                        return html1;
                    }
                    else{
                        return html2;
                    }
                }}
                ,{width:100,title: '操作', align:'center',templet: function(d){
                    var html='';
                    var btn='<a class="layui-btn layui-btn-normal  layui-btn-xs" lay-event="edit">编辑</a>';
                    var btn1='<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="disable">禁用</a>';
                    var btn2='<a class="layui-btn layui-btn-xs" lay-event="open">启用</a>';
                    if(d.status==1){
                        html = '<div class="layui-btn-group">'+btn+btn1+'</div>';
                    }
                    else{
                        html = '<div class="layui-btn-group">'+btn+btn2+'</div>';
                    }
                    return html;
                }}
            ]]
        });
            
        table.on('tool(test)',function (obj) {
            if(obj.event === 'edit'){
                tool.side("/home/cate/flow_type_add?id="+obj.data.id);
            }
            if(obj.event === 'disable'){
                layer.confirm('确定要禁用该模块吗?', {icon: 3, title:'提示'}, function(index){
                    let callback = function (e) {
                        layer.msg(e.msg);
                        if (e.code == 0) {
                            layui.pageTable.reload();
                        }
                    }
                    tool.post("/home/cate/flow_type_check", { id: obj.data.id,status: 0}, callback);
                    layer.close(index);
                });
            }
            if(obj.event === 'open'){
                layer.confirm('确定要启用该模块吗?', {icon: 3, title:'提示'}, function(index){
                    let callback = function (e) {
                        layer.msg(e.msg);
                        if (e.code == 0) {
                            layui.pageTable.reload();
                        }
                    }
                    tool.post("/home/cate/flow_type_check", { id: obj.data.id,status: 1}, callback);
                    layer.close(index);
                });
            }
        });
        
        $('body').on('click','.addNew',function(){
            tool.side("/home/cate/flow_type_add");
            return false;
        });        
    }
</script>
{/block}
<!-- /脚本 -->