CZT
2023-10-20 3631219246be48aec1e745e94e5b28ff4e8799c8
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
var layer;
 
var windowWidth = 1700;
var windowHeight = 810;
 
$(function () {
    layui.use(['layer'], function () {
        layer = layui.layer;
        addDevice(listCamera);
    });
});
 
window.onload = function () {
    // var imgName = "aerial-" + companyId + ".png";
    // $("#m-container").css("background-image", "url(../../static/img/" + imgName+")");
    $("#m-container").css("background-image", "url(" + backgroundImg +")");
 
    windowWidth = document.body.offsetWidth;
    windowHeight = document.body.offsetHeight;
};
 
function showVideo(id) {
    layer.msg("调用视频查看……");
    //获取视频信息
    var curVideo = null;
    $.each(listCamera, function (index, item) {
        if (item.id == id) {
            curVideo = item;
            return true;
        }
    });
    if (!curVideo) {
        layer.alert("没有获取到当前视频信息……");
        return;
    }
    var url = "../../basic/security/video-play?cameraId=" + curVideo.id + "&playType=" + curVideo.playType;
    if(curVideo.playType == "MEDIA_HIK"){
        //海康插件直接window.open新页面播放
        var iHeight = 550;
        var iWidth = 1100;
        var iTop = (window.screen.height-30-iHeight)/2; //获得窗口的垂直位置;
        var iLeft = (window.screen.width-10-iWidth)/2; //获得窗口的水平位置;
        console.log(iWidth + "-" + iHeight);
        console.log(iTop + "-" + iLeft);
        var name = "视频预览";
        window.open(url,name,'height='+iHeight+',innerHeight='+iHeight+',width='+iWidth+',innerWidth='+iWidth+',top='+iTop+',left='+iLeft+',toolbar=0,menubar=0,scrollbars=auto,resizeable=0,location=0,status=no');
    }else {
        if (windowWidth > 1350) {
            layer.open({
                type: 2,
                title: false,//"当前预览:" + curVideo.name,
                area: ['1315px', '570px'],
                shade: 0,
                content: url,
                btn: 0,
                closeBtn: 2
            });
        } else {
            layer.open({
                type: 2,
                title: false,//"当前预览:" + curVideo.name,
                area: ['1315px', (windowHeight - 30) + 'px'],
                shade: 0,
                content: url,
                btn: 0,
                closeBtn: 2
            });
        }
    }
};
 
function showTips(name) {
    $("#camera_info").text("提示:当前设备名称- " + name);
};
 
// 开始拖拽
function drag() {
    var tips = $(".device");
    if (tips.length == 0) {
        return;
    }
    // var container = $("#m-container");
    // var parentLeft = container.offset().left;
    // var maxX = parentLeft + container.width();
 
    var maxX = windowWidth;
    var maxY = windowHeight;
 
    $.each(tips, function (index, item) {
        var dd = new Dragdrop({
            target: item,
            area: [0, maxX, 0, maxY],
            callback: function (obj) {
                console.log('x:' + (obj.moveX) + ' y:' + (obj.moveY));
            }
        });
        dd.dragAll();
    });
};
 
//添加设备信息
function addDevice(list) {
   //  console.log(list);
 
    if (!list || list.length == 0) return;
    var container = $("#m-container");
    var parentWidth = container.width();
    var parentHeight = container.height();
 
    var temp;
    var left = 50, top = 50;
    $.each(list, function (index, item) {
        left = (parentWidth * item.posX).toFixed(4);
        top = (parentHeight * item.posY).toFixed(4);
        if (left < 1) left = 50;
        if (top < 1) top = 50;
 
        temp = "";
        temp += "<div id='" + item.id + "' class='device' "
            + "' onclick=showTips('" + item.name + "') "
            + "' ondblclick=showVideo('" + item.id + "') style='left:"
            + left + "px;top:" + top + "px;'>";
        temp += "<img src='../../static/images/ca-4.png' /></div>";
        container.append(temp);
    });
};
 
// 保存设备位置信息
function updatePos() {
    var tips = $(".device");
    if (tips.length == 0) {
        return;
    }
    var container = $("#m-container");
    var parentWidth = container.width();
    var parentHeight = container.height();
    var parentTop = container.offset().top;
    var parentLeft = container.offset().left;
 
    // 封装数据进行保存
    var data = new Array();
    var id = null, posX = 0.0, posY = 0.0;
    var offset;
    $.each(tips, function (index, item) {
        id = item.id;
        offset = $('#' + id).offset();
 
        posX = (offset.left - parentLeft) / parentWidth;
        posY = (offset.top - parentTop) / parentHeight;
 
        data[index] = {
            id: id,
            posX: posX.toFixed(4),
            posY: posY.toFixed(4)
        };
    });
    $.ajax({
        type: 'POST',
        url: "../../basic/security/update-pos",
        dataType: 'JSON',
        contentType: "application/json;charset=UTF-8",
        data: JSON.stringify(data),
        success: function (result) {
            layer.msg("信息更新完成!!");
        },
        error: function (result) {
            layer.msg(result.msg);
        }
    });
}