zhitong.yu
2024-03-15 ebd89b9ffa8980ac944a7e79ecc64c01637d4f17
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
 
layui.use('table', function(){
    var table = layui.table;
    var layer = layui.layer;
    //告警汇总
    table.render({
        elem: '#shipin'
        ,url: '/hxzkuwb/findhk'
        ,page: true //开启分页
        ,size:'sm'
        ,height:702
        ,toolbar:'#toolbarDemo' //开启工具栏,此处显示默认图标,可以自定义模板,详见文档
        ,cols: [[ //表头
            {type:'checkbox',sort: true,fixed: "left"}
            ,{field: 'id', title: '序号', sort: true}
            ,{ field: 'ip', title: 'Ip地址'}
            ,{field: 'port', title: '端口' }
            ,{field: 'username', title: '用户名'}
            ,{field: 'password',title: "密码"}
            ,{field: 'shebeiport',title: "设备端口"}
        ]]
        ,limits: [10, 20, 30, 40, 50,60,70,80,90,100]
        ,limit: 20,
    });
    table.on('tool(shipin)', function(obj){
        var data = obj.data;
        console.log(data.id)
    })
    table.on('toolbar(shipin)', function(obj) {
        var checkStatus = table.checkStatus(obj.config.id);
        switch(obj.event) {
            case 'getadd' :
                $(".add").show();
                $(".heimu").show();
                break;
            case 'getUpdate':
                var data = checkStatus.data;
                if(data.length>1){
                    layer.alert("一次只能选中一个进行修改")
                }else if(data.length == 0){
                    layer.alert("请选中一条数据")
                }else{
                    $("#up1").val(data[0].ptagid)
                    $(".update").show();
                    $(".heimu").show();
                }
 
                break;
            case 'getdelete':
                var data = checkStatus.data;
                if(data<1){
                    layer.alert("请选中一条数据")
                }else{
                    for (var i = 0; i<data.length;i++){
                        var ds = "id="+data[i].username
                        $.get("/hxzkuwb/deleteHk",ds,function (data){
 
                        })
                    }
                    layer.msg('操作成功')
                }
                break;
        }
    })
});
function quxiao(){
    layer.msg('操作成功')
    setTimeout(function() {
        $(".add").hide();
        $(".update").hide();
        $(".heimu").hide();
    }, 500);
 
}