lyg
2025-03-04 72bbec1590f85974d369ce7aeaa05be8905672a0
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
{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}
<div class="p-page">
    <form class="layui-form gg-form-bar border-t border-x">
        <div class="layui-input-inline">
            <input type="text" name="keywords" placeholder="关键字" class="layui-input" autocomplete="off"/>
        </div>
        <div class="layui-input-inline" style="width:150px;">
            <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="table-search"><i class="layui-icon layui-icon-search mr-1"></i>搜索</button>
            <button type="reset" class="layui-btn layui-btn-reset" lay-filter="table-reset">清空</button>
        </div>
    </form>
    <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" lay-event="add">+ 添加人事调动记录</button>
  </div>
</script>
{/block}
<!-- /主体 -->
 
<!-- 脚本 -->
{block name="script"}
<script>
    const moduleInit = ['tool','tablePlus'];
    function gouguInit() {
        var table = layui.tablePlus, tool = layui.tool ,form = layui.form;
        layui.pageTable = table.render({
            elem: '#test'
            , toolbar: '#toolbarDemo'
            ,defaultToolbar: false
            , url: "/user/personal/change"
            , page: true //开启分页
            , limit: 20
            , cols: [[
                { field: 'id', width: 80, title: '序号', align: 'center' }
                , { field: 'name', width: 100, title: '员工姓名', align: 'center'}
                , { field: 'adepartment', width: 160, title: '调出部门'}
                , { field: 'bdepartment', width: 160, title: '调入部门'}
                , { field: 'remark', title: '调动原因'}
                , { field: 'move_time', title: '调动日期',width: 100, align: 'center'}
                , { field: 'admin', title: '调动操作人',width: 100, align: 'center'}
                , {
                    width: 80, title: '操作', align: 'center'
                    , templet: function (d) {
                        var html = '';
                        var delBtn = '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit">编辑</button>';
                        return delBtn;
                    }
                }
            ]]
        });
        
        //监听行工具事件
        table.on('tool(test)', function(obj){
            var data = obj.data;
            if(obj.event === 'edit'){
                tool.side('/user/personal/change_add?id='+data.id);
                return;
            }
        });
        
        //表头工具栏事件
        table.on('toolbar(test)', function(obj){
            if (obj.event === 'add') {
                tool.side("/user/personal/change_add");
                return;
            }
        });
 
        //监听搜索提交
        form.on('submit(webform)', function(data){
            if(data.field.keywords) {
                layui.pageTable.reload({where:{keywords:data.field.keywords},page:{curr:1}});              
            }
            else{
                location.reload();
            }
            return false;
        });
    }
</script>
{/block}
<!-- /脚本 -->