let vue_sjcx = new Vue({
    el: '#sjcx',
    data: {
        searchText: '',
        show: true,
        data_sjlxs: [],
        data_table_wfpz: [],
        num: 0,
        num1: 1000,
        sjlx: '',
        data_sjlxs1: [],
        count: '',
        deptId: getCookie("bjpt_deptId"),
        fy_select: 20,
        gd_span: '',
        show_nums: false,
        state_arr: [],
        cllx_select: [],
        clzt_select: [],
        arr_cllx: [],
        jk_s:[],
        check_s:false,
        cllx: [],
        jk_arr:[]
    },
    methods: {
        fastSearch: function () {
            this.xzml();
        },
        xzml: function () {
            $.ajax({
                url: "/dept/getDeptParent/" + getCookie("bjpt_deptId"),
                dataType: "json",
                type: "GET",
                data: {},
                success: function (result) {
                    if (result.code == 0) {
                        let parIds = result.data[0].parentId;
                        $.ajax({
                            url: "/dept/listvideo",
                            dataType: "json",
                            type: "GET",
                            data: {
                                deptId: getCookie("bjpt_deptId"),
                                username: getCookie("bjpt_realName"),
                                tdmc: vue_sjcx.searchText,
                            },
                            success: function (result) {
                                let defaultData = [];
                                vue_sjcx.jk_arr = [];
                                if (result.code == 0) {
                                    vue_sjcx.jk_arr=result.data;
                                    defaultData = toTree(result.data, parIds + '');
                                    $('#tree-xzxq').treeview({
                                        expandIcon: 'glyphicon glyphicon-triangle-right selected-span',
                                        collapseIcon: 'glyphicon glyphicon-triangle-bottom selected-span',
                                        nodeIcon: 'glyphicon glyphicon-folder-open selected-span',
                                        selectedBackColor: '#ff000000',
                                        selectedColor: '#368ff3',
                                        onhoverColor: '#73a5ff26',
                                        showBorder: false,
                                        data: defaultData,
                                        multiSelect: false,
                                        level: 2,
                                        showCheckbox: 1,//复选框设置，也可以是true
                                        onNodeChecked: function (event, node) { //选中节点
                                            let selectNodes = getChildNodeIdArr(node); //获取所有子节点
                                            if (selectNodes) { //子节点不为空，则选中所有子节点
                                                $(this).treeview('checkNode', [selectNodes, {silent: true}]);
                                            }
                                            //如果当前节点的子节点都被选中了。则父节点也应该要选中
                                            setParentNodeCheck(node);
                                        }, onNodeUnchecked: function (event, node) { //取消选中节点
                                            let selectNodes = getChildNodeIdArr(node); //获取所有子节点
                                            if (selectNodes) { //子节点不为空，则取消选中所有子节点
                                                $(this).treeview('uncheckNode', [selectNodes, {silent: true}]);
                                            }
                                        }, onNodeExpanded: function (event, data) {

                                        }, onNodeSelected: function (event, node) {

                                        }

                                    });
                                    vue_sjcx.query(1, true);
                                }
                            }
                        });
                    }
                }
            });
        },
        qh_tab: function (el) {
            if (el == 1) {
                this.show = false;
            } else {
                this.show = true;
            }
        },
        //事件类型切换
        change: function (item, index) {
            this.num = index;
            this.num1 = 1000;
            this.sjlx = item.id;
            this.gd_span = '';
            vue_sjcx.query(1, true);
        },
        //事件类型切换
        change_gd: function (item, index) {
            this.num = 5;
            this.sjlx = item.id;
            this.num1 = index;
            this.gd_span = item.name;
            vue_sjcx.query(1, true);
        },
        //详情
        xq: function (item) {
            vue_sjsstx.video_src = '';
            vue_sjsstx.data_sj = item;
            vue_sjsstx.class_s = 'class_1';
            vue_sjsstx.class_s1 = 'class_2';
            vue_sjsstx.show_s = false;
            vue_sjsstx.img_src_s = '';
            vue_sjsstx.data_wfsp = [];
            if (item.img1path != null) {
                vue_sjsstx.img_src_s = '/TrafficStatistics/fielagent?ftpPath=' + item.img1path;
                vue_sjsstx.data_wfsp.push({src: '/TrafficStatistics/fielagent?ftpPath=' + item.img1path});
            }
            if (item.img2path != null) {
                vue_sjsstx.data_wfsp.push({src: '/TrafficStatistics/fielagent?ftpPath=' + item.img2path});
            }
            if (item.img3path != null) {
                vue_sjsstx.data_wfsp.push({src: '/TrafficStatistics/fielagent?ftpPath=' + item.img3path});
            }
            if (item.img4path != null) {
                vue_sjsstx.data_wfsp.push({src: '/TrafficStatistics/fielagent?ftpPath=' + item.img4path});
            }
            if (item.img5path != null) {
                vue_sjsstx.data_wfsp.push({src: '/TrafficStatistics/fielagent?ftpPath=' + item.img5path});
            }
            $("#myModal").modal("show");
        },
        query: function (pages, items) {
            let nodes = $('#tree-xzxq').treeview('getChecked').filter(n=>n.level == null).map(n=> {
                return n.href
            });
            let arr_nodes = "";
            if (nodes.length == 0) {
                nodes = "";
            } else {
                nodes.forEach((item, index)=> {
                    arr_nodes = arr_nodes + item + ',';
                });
            }
            if ($('#tree-xzxq').treeview('getChecked').length > 0 && nodes.length == 0) {
                arr_nodes = "null";
            };
            $(".div-ul").find('input').each(function () {
                $(this).removeAttr("checked", false);
                $(this).prop("checked", false);
            });
            this.show_nums = false;
            // arr_nodes = arr_nodes.substring(0,arr_nodes.length -1);
            let starttime = $("#kssj").val().substr(0, 19);
            let endtime = $("#kssj").val().substr(22, 19);
            let li = this.fy_select;
            let type = this.sjlx.toLowerCase();

            let objlabels = "";
            if (this.cllx_select.length == 0) {
                objlabels = "";
            } else {
                this.cllx_select.forEach((item, index)=> {
                    objlabels = objlabels + item + ',';
                });
            }
            ;
            let processstatus = "";
            if (this.clzt_select.length == 0) {
                processstatus = "";
            } else {
                this.clzt_select.forEach((item, index)=> {
                    processstatus = processstatus + item + ',';
                });
            }
            ;
            let json_s = {
                videoids: arr_nodes,
                page: pages,
                limit: li,
                recordtype: type,
                checkstatus: "",
                starttime: starttime,
                endtime: endtime,
                deptid: getCookie("bjpt_deptId"),
                construction: '2',
                objlabel: objlabels,
                processstatus: processstatus,
                rectificationtype:'',
            };
            $.ajax({
                url: "/TrafficStatistics/queryTraffalarmrecordByPage/1",
                dateType: 'json',
                type: "POST",
                contentType: 'application/json',
                data: JSON.stringify(json_s),
                success: function (result) {
                    vue_sjcx.data_table_wfpz = [];
                    if (result.code == 0) {
                        let a_sum = result.count;
                        vue_sjcx.count = result.count;
                        vue_sjcx.data_table_wfpz = result.data;
                        if (items) {
                            $("#fy4").bootstrapPaginator({
                                bootstrapMajorVersion: 3, //版本，这里设置为3，大于2即可
                                currentPage: 1,//当前页
                                totalPages: Math.ceil(((a_sum > 0) ? a_sum : 1) / vue_sjcx.fy_select),//总页数
                                // numberofPages: 10,//显示的页数
                                itemTexts: function (type, page, current) { //修改显示文字
                                    switch (type) {
                                        case "first":
                                            return "首页";
                                        case "prev":
                                            return "上一页";
                                        case "next":
                                            return "下一页";
                                        case "last":
                                            return "末页";
                                        case "page":
                                            return page;
                                    }
                                }, onPageClicked: function (event, originalEvent, type, page) { //异步换页
                                    //请求加载数据
                                    vue_sjcx.query(page, false);
                                }
                            });
                        }
                    }
                }
            });
        },
        getChange: function () {
            setTimeout(function () {
                vue_sjcx.query(1, true);
            }, 200);
        },
        cli_input: function () {
            vue_sjcx.state_arr = [];
            $(".div-ul").find('input:checked').each(function () {
                let arr = $(this).val().split("|");
                vue_sjcx.state_arr.push({recordid:arr[0],channelid:arr[1],fdid:arr[2],recordtime:arr[3],recordtype:arr[4]});
            });
            if (vue_sjcx.state_arr.length > 0) {
                vue_sjcx.show_nums = true;
            } else {
                vue_sjcx.show_nums = false;
            }
        },
        state_cli: function (e) {
            let json_s = [];
            vue_sjcx.state_arr.forEach((item, index)=> {
                json_s.push({recordid: item.recordid,channelid:item.channelid,fdid:item.fdid,recordtime:item.recordtime,recordtype:item.recordtype, processstatus: e});
            });
            $.ajax({
                url: "/TrafficStatistics/updateTraffalarmrecordById",
                dateType: 'json',
                type: "POST",
                contentType: 'application/json',
                data: JSON.stringify(json_s),
                success: function (result) {
                    if (result.code == 0) {
                        vue_sjcx.query(1, true);
                        info_new("状态修改成功");
                        window.setTimeout("$('#info-warning-new').modal('hide')", 2000);
                    }
                }
            });
        },
        zdsx:function () {
            vue_sjcx.check_s=document.getElementById('push').checked;
        }
    },
    mounted(){
        $("#kssj").val(getTime_extent(6).pre_rq_start + ' - ' + getTime().jssj);
        $.ajax({
            url: "/dept/listAllvideoIdsByDeptid",
            dataType: "json",
            type: "GET",
            data: {
                deptid: getCookie("bjpt_deptId"),
            },
            success: function (result) {
                vue_sjcx.jk_s = [];
                if (result.code == 0) {
                    if (result.data.length > 0) {
                        vue_sjcx.jk_s = result.data;
                    }
                }
            }
        });
        $.ajax({
            url: "/TrafficStatistics/listcode",
            dataType: "json",
            type: "GET",
            data: {
                codeid: 3,
                alarmlevel: '',
            },
            success: function (result) {
                vue_sjcx.arr_cllx = [];
                if (result.code == 0) {
                    if (result.data.length > 0) {
                        result.data.forEach((item, index)=> {
                            if (item.id != 'TRICYCLE' && item.id != 'CART')
                                vue_sjcx.arr_cllx.push({id: item.id, value: item.name});
                        });
                        setTimeout(function () {
                            $("#cllxs").selectpicker('refresh');
                            $("#cllxs").selectpicker('render');
                        }, 200);
                    }
                }
            }
        });
        $.ajax({
            url: "/TrafficStatistics/listcode",
            dataType: "json",
            type: "GET",
            data: {
                codeid: 1,
                alarmlevel: '',
            },
            success: function (result) {
                vue_sjcx.data_sjlxs = [];
                if (result.code == 0) {
                    if (result.data.length > 0) {
                        vue_sjcx.data_sjlxs.push({name: '全部', id: "", type: "",});
                        let arrs = [];
                        result.data.forEach((item, index)=> {
                            if (item.id != 'ROADWORKS' && item.id != 'ROADWORKS_OUT_OF_LINE') {
                                arrs.push(item);
                            }
                        });
                        arrs.forEach((item, index)=> {
                            if (index < 4) {
                                vue_sjcx.data_sjlxs.push(item);
                            } else {
                                vue_sjcx.data_sjlxs1.push(item);
                            }
                        });
                    }
                }
            }
        });
        this.xzml();
    },

});
let vue_sjsstx = new Vue({
    el: '#myModal',
    data: {
        sp_src: '',
        data_wfsp: [],
        data_sj: {},
        class_s: 'class_1',
        class_s1: 'class_2',
        show_s: false,
        img_src_s: '',
        video_src: ''
    },
    methods: {
        sp_qh: function (e) {
            if (e == 1) {
                this.class_s = 'class_1';
                this.class_s1 = 'class_2';
                this.show_s = false;
            } else {
                this.class_s = 'class_2';
                this.class_s1 = 'class_1';
                this.show_s = true;
                this.video_src = '/TrafficStatistics/fielagent?ftpPath=' + this.data_sj.videopath;
            }
        },
        click_img_bf: function (src) {
            this.img_src_s = src;
        }
    },
    mounted(){
        if (this.data_wfsp.length > 0) {
            this.data_wfsp[0].kg = true;
            this.sp_src = this.data_wfsp[0].src;
//                document.getElementById("my_video_1").play();
        }
    }
});
//新的模态框,三等级模态框
let vue_sjsstxnow = new Vue({
    el: '#myModal_sj',
    data: {
        yjsj_data: [],
        ejsj_data: [],
        sjsj_data: [],
        index: 0,
    },
    methods: {
        djxx_modal: function (item) {
            vue_sjsstx_li.data_wfsp = [];
            vue_sjsstx_li.data_wfsp = item.src;
            vue_sjsstx_li.data_sj = {
                lx: item.sjlx,
                bjsj: item.bjsj,
                dwmc: item.dwmc,
            };
            vue_sjsstx_li.arrs = {
                timeSpeed: 0,
                timeIntervalSign: null,
                timeIndex: 0,
                videoMessage: '',
            };
            monitor_sx(item.videoid, 'my_video_1', vue_sjsstx_li.arrs, 2);
            $("#myModal_li").modal('show');
        },
        cli_input: function (item, e, indexs, a) {
            this.index++;
            vue_jkgl.is_bd = true;
            let iscz = false;
            vue_jkgl.data_sd.forEach((items, index)=> {
                if (items.video_id == item.videoid) {
                    iscz = true;
                }
            });
            if (e.currentTarget.checked) {
                if (iscz) {
                    e.currentTarget.checked = false;
                    info_new("此监控已在右侧展现，同一监控不可再次添加");
                    window.setTimeout("$('#info-warning-new').modal('hide')", 2000);
                } else {
                    if (a == 1) {
                        vue_sjsstxnow.yjsj_data[indexs].checked = true;
                    } else if (a == 2) {
                        vue_sjsstxnow.ejsj_data[indexs].checked = true;
                    } else {
                        vue_sjsstxnow.sjsj_data[indexs].checked = true;
                    }
                    let ids = 'bd_' + (this.index);
                    vue_jkgl.data_sd.push({
                        name: item.dwmc,
                        id: ids,
                        video_id: item.videoid,
                        timeSpeed: 0,
                        timeIntervalSign: null,
                        timeIndex: 0,
                        videoMessage: '',
                    });
                    monitor_sx(item.videoid, ids, vue_jkgl.data_sd[vue_jkgl.data_sd.length-1], 3);
                }
            } else {
                if (a == 1) {
                    vue_sjsstxnow.yjsj_data[indexs].checked = false;
                } else if (a == 2) {
                    vue_sjsstxnow.ejsj_data[indexs].checked = false;
                } else {
                    vue_sjsstxnow.sjsj_data[indexs].checked = false;
                }
                document.getElementById(vue_jkgl.data_sd[indexs].id).parentNode.parentNode.remove();
                vue_jkgl.data_sd.forEach((items, index)=> {
                    if (items.video_id == item.videoid) {
                        vue_jkgl.data_sd.splice(index, 1);
                    }
                });
                if (vue_jkgl.data_sd.length == 0) {
                    vue_jkgl.is_bd = false;
                }
            }

        },
        state_cli: function (item, e, index, type) {
            let json_s = [];
            json_s.push({
                recordid: item.recordid + '',
                channelid: item.channelid,
                fdid: item.fdid,
                recordtime: item.recordtime,
                recordtype: item.recordtype.toLowerCase(),
                processstatus: e
            });
            $.ajax({
                url: "/TrafficStatistics/updateTraffalarmrecordById",
                dateType: 'json',
                type: "POST",
                contentType: 'application/json',
                data: JSON.stringify(json_s),
                success: function (result) {
                    if (result.code == 0) {
                        info_new("处理成功");
                        window.setTimeout("$('#info-warning-new').modal('hide')", 2000);
                        if (type == 1) {
                            vue_sjsstxnow.yjsj_data[index].ss_type = e;
                        } else if (type == 2) {
                            vue_sjsstxnow.ejsj_data[index].ss_type = e;
                        } else {
                            vue_sjsstxnow.sjsj_data[index].ss_type = e;
                        }
                    }
                }
            });
        }
    },
    mounted(){

    }
});
function toTree(list, parId) {
    let len = list.length;

    function loop(parId) {
        let res = [];
        for (let i = 0; i < len; i++) {
            let item = list[i];
            if (item.parentId === parId) {
                item.nodes = loop(item.href);
                let arr = {
                    href: item.href,
                    text: item.text,
                    level: item.level,
                    parentId: item.parentId,
                }
                if (item.level == 0 || item.level == 1 || item.level == 2) {
                    arr.selectable = false;
                    arr.state = {expanded: true, checked: true};
                } else {
                    arr.icon = 'glyphicon glyphicon-facetime-video zx',
                        arr.state = {expanded: false, checked: true};
                    arr.selectable = true;
                }
                if (item.nodes.length > 0) {
                    arr.nodes = item.nodes;
                }
                res.push(arr);
            }
        }
        return res
    }

    return loop(parId)
}
function checkNode(parentNode, i) {
    if (parentNode.nodes[i].nodes != undefined && parentNode.nodes[i].nodes.length !== 0 && parentNode.nodes[i].nodes.filter(n => n.level === null).length > 0) {
        for (let j = 0; j < parentNode.nodes[i].nodes.length; j++) {
            let d = checkNode(parentNode.nodes[i], j);
            d && j--;
        }
    } else {
        parentNode.nodes.splice(i, 1);
        return true
    }
}
//获取选中的id
function getChildNodeIdArr(node) {
    let ts = [];
    if (node.nodes) {
        for (let x in node.nodes) {
            ts.push(node.nodes[x].nodeId);
            if (node.nodes[x].nodes) {
                let getNodeDieDai = getChildNodeIdArr(node.nodes[x]);
                for (let j in getNodeDieDai) {
                    ts.push(getNodeDieDai[j]);
                }
            }
        }
    } else {
        ts.push(node.nodeId);
    }
    return ts;
};

//设置父节点
function setParentNodeCheck(node) {
    let parentNode = $("#tree-xzxq").treeview("getNode", node.parentId);
    if (parentNode.nodes) {
        let checkedCount = 0;
        for (let x in parentNode.nodes) {
            if (parentNode.nodes[x].state.checked) {
                checkedCount++;
            } else {
                break;
            }
        }
        if (checkedCount === parentNode.nodes.length) {
            $("#tree-xzxq").treeview("checkNode", parentNode.nodeId);
            setParentNodeCheck(parentNode);
        }
    }
};

laydate.render({
    elem: '#kssj'
    , type: 'datetime'
    , theme: '#368ff3'
    , range: true
});
// 全选/取消
$("#all").click(function () {
    $(".div-ul").find('input').each(function () {
        $(this).prop("checked", true);
    });
    vue_sjcx.state_arr = [];
    $(".div-ul").find('input:checked').each(function () {
        // vue_sjcx.state_arr.push($(this).val());
        let arr = $(this).val().split("|");
        vue_sjcx.state_arr.push({recordid:arr[0],channelid:arr[1],fdid:arr[2],recordtime:arr[3],recordtype:arr[4]});
    });
    vue_sjcx.show_nums = true;
});
$("#unall").click(function () {
    $(".div-ul").find('input').each(function () {
        $(this).removeAttr("checked", false);
        $(this).prop("checked", false);
        vue_sjcx.state_arr = [];
    });
    vue_sjcx.show_nums = false;
});
//放大缩小图片
$('[data-gallery=manual]').click(function (e) {

    e.preventDefault();

    var items = [],
        options = {
            index: $(this).index()
        };

    $('[data-gallery=manual]').each(function () {
        items.push({
            src: $(this).attr('src'),
            title: '图片查看'
        });
    });
    new PhotoViewer(items, options);
});
let d = new Date().getTime();
let web_ip = "ws:/localhost:8089/websocket/" + d;
let wss = new WebSocket(web_ip);
wss.onopen = function () {
    console.log("连接成功");
    // var from = {"serialNo": "xxx", "idNo": "xxx"};
    // wss[i].send(JSON.stringify(from));//发送参数
};
wss.onmessage = function (evt) {
    var data = JSON.parse(event.data);
    // console.log(data);
    if (data.type == "alarm") {
            if (data.data.recordtype == 'ROADWORKS' || data.data.recordtype == 'ROADWORKS_OUT_OF_LINE') {
                //排除工程检测
                return;
            }
            //if_cz 判断前来的事件是不是本部门下的
            let if_cz = false;
            //jk_video_id为监控id
            // let a_id = data.data.video_id.slice(0, data.data.video_id.length - 1) + (parseInt(data.data.video_id.slice(data.data.video_id.length - 1, data.data.video_id.length)) + 1) + '';
            
            // let jk_video_id = data.data.fdid+"_"+data.data.channelid;
            let jk_video_id = data.data.video_id;
            vue_sjcx.jk_s.forEach((item, index)=> {
                if(item.VIDOID == jk_video_id )
                {
                    if_cz = true;
                }
            });
        if (if_cz) {
            //事件id
            let sjid = data.recordid;
            //报警时间
            let sj = (new Date(parseInt(data.data.ts))).Format("yyyy-MM-dd hh:mm:ss");
            //事件类型
            let bjlx = '';
            //事件等级
            let sjdj = '';
            vue_sjcx.arr_cllx.forEach((item, index)=> {
                if (item.id == data.data.incident_type) {
                bjlx = item.name;
                sjdj = item.alarmlevel;
            }
        });

            //监控名称
            let jkmc = '';
            vue_sjcx.jk_arr.forEach((item, index)=> {
                if (item.href == jk_video_id) {
                jkmc = item.text;
            }
        });
            //违法图片
            let wfsp = [];
            data.data.img_base64.forEach((item, index)=> {
                let src = 'data:image/jpg;base64,' + item;
            wfsp.push({img_src: src});
        });
            //右边消息弹出框的id
            let tss = 'a' + data.data.ts;
            //判断三级弹出框是否已经弹出，没有弹出，则清空，若是弹出，则继续push
            if ($("#myModal_sj")[0].style.display != 'block') {
                $(".carousel").collapse();
                vue_sjsstx.yjsj_data = [];
                vue_sjsstx.ejsj_data = [];
                vue_sjsstx.sjsj_data = [];
                $("#myModal_sj").modal("show");

                $("#myModal_sj").find('input').each(function () {
                    $(this).removeAttr("checked", false);
                    $(this).prop("checked", false);
                });
            }
            if (sjdj == '1') {
                $("#a1s").collapse();
                vue_sjsstx.yjsj_data.unshift({
                    src: wfsp,
                    videoid: jk_video_id,
                    dwmc: jkmc,
                    sjlx: bjlx,
                    bjsj: sj,
                    checked: false,
                    recordid: sjid,
                    channelid: jk_video_id.slice(jk_video_id.length - 1),
                    fdid: jk_video_id.slice(0, jk_video_id.length - 2),
                    recordtime: sj,
                    recordtype: data.data.incident_type,
                    ss_type: '',
                });
                setTimeout(function () {
                    $("#a1s .carousel-indicators li").removeClass("active");
                    $("#a1s .carousel-inner > div").removeClass("active");
                    $("#a1s .carousel-indicators li:first-child").addClass("active");
                    $("#a1s .carousel-inner > div:first-child").addClass("active");

                    // #点击轮播图下方小圆点可以改变轮播图片
                    $("#a1s li").click(function () {
                        var index = $(this).attr("data-slide-to");
                        $('#a1s').carousel(parseInt(index))
                    });
                    $('#a1s').carousel({
                        interval: 3000,
                    });
                }, 500);
            } else if (sjdj == '2') {
                $("#a2s").collapse();
                vue_sjsstx.ejsj_data.unshift({
                    src: wfsp,
                    videoid: jk_video_id,
                    dwmc: jkmc,
                    sjlx: bjlx,
                    bjsj: sj,
                    checked: false,
                    recordid: sjid,
                    channelid: jk_video_id.slice(jk_video_id.length - 1),
                    fdid: jk_video_id.slice(0, jk_video_id.length - 2),
                    recordtime: sj,
                    recordtype: data.data.incident_type,
                    ss_type: '',
                });
                setTimeout(function () {
                    $("#a2s .carousel-indicators li").removeClass("active");
                    $("#a2s .carousel-inner > div").removeClass("active");
                    $("#a2s .carousel-indicators li:first-child").addClass("active");
                    $("#a2s .carousel-inner > div:first-child").addClass("active");

                    // #点击轮播图下方小圆点可以改变轮播图片
                    $("#a2s li").click(function () {
                        var index = $(this).attr("data-slide-to");
                        $('#a2s').carousel(parseInt(index))
                    });
                    $('#a2s').carousel({
                        interval: 3000,
                    });
                }, 500);

            } else if (sjdj == '3') {
                $("#a3s").collapse();
                vue_sjsstx.sjsj_data.unshift({
                    src: wfsp,
                    videoid: jk_video_id,
                    dwmc: jkmc,
                    sjlx: bjlx,
                    bjsj: sj,
                    checked: false,
                    recordid: sjid,
                    channelid: jk_video_id.slice(jk_video_id.length - 1),
                    fdid: jk_video_id.slice(0, jk_video_id.length - 2),
                    recordtime: sj,
                    recordtype: data.data.incident_type,
                    ss_type: '',
                });
                setTimeout(function () {
                    $("#a3s .carousel-indicators li").removeClass("active");
                    $("#a3s .carousel-inner > div").removeClass("active");
                    $("#a3s .carousel-indicators li:first-child").addClass("active");
                    $("#a3s .carousel-inner > div:first-child").addClass("active");
                    // #点击轮播图下方小圆点可以改变轮播图片
                    $("#a3s li").click(function () {
                        var index = $(this).attr("data-slide-to");
                        $('#a3s').carousel(parseInt(index))
                    });
                    $('#a3s').carousel({
                        interval: 3000,
                    });
                }, 500);
            }
            new NoticeJs({
                text: 'Notification message',
                position: 'bottomRight',
                // id: tss,
                id: 11,
                sjlx: bjlx,
                dwmc: jkmc,
                animation: {
                    open: 'animated bounceIn',
                    close: 'animated bounceOut'
                }
            }).show();
            //播放声音
            let myMp3 = document.getElementById("audio");
            audio.play();
        }
        }

};

$('[name="status"]').bootstrapSwitch({
    onText: "打开",
    offText: "关闭",
    onColor: "success",
    offColor: "warning",
    onSwitchChange: function (event, state) {
        if (state == true) {
            state_sj = true;
            console.log('已打开');
        } else {
            state_sj = false;
            console.log('已关闭');
        }
    }
});
