let vue_sjcx = new Vue({
    el: '#sjcx',
    data: {
        data_sjlxs: [],
        data_table_wfpz: [],
        data_sjlxs1: [],
        count: '',
        deptId: getCookie("bjpt_deptId"),
        fy_select: 20,
        state_arr: [],
        cllx_select: [],
        clzt_select: 9,
        arr_cllx: [],
        sjlx_select: '2',
        tssj_s: true,
    },
    methods: {
        tss: function () {
            vue_sjcx.state_arr = [];
            $(".div-pub-gt").find('input:checked').each(function () {
                vue_sjcx.state_arr.push($(this).val());
            });
            if (vue_sjcx.state_arr.length == 0) {
                info_new("未选择行");
                window.setTimeout("$('#info-warning-new').modal('hide')", 2000);
                return;
            }
            vue_ts.data_table_ts = [];
            vue_sjcx.state_arr.forEach((item, index)=> {
                vue_sjcx.data_table_wfpz.forEach((items, indexs)=> {
                    if (item == items.recordid) {
                        vue_ts.data_table_ts.push(items);
                    }
                });
            });
            $("#myModal_ts").modal("show");
        },
        getChange_tszt: function () {
            setTimeout(function () {
                vue_sjcx.query(1, true);
            }, 200);
            if (this.clzt_select == 0) {
                this.tssj_s = false;
            } else {
                this.tssj_s = true;
            }
        },
        qx_s: function (e) {
            if (e.currentTarget.checked) {
                $(".div-pub-gt").find('input').each(function () {
                    $(this).prop("checked", true);
                });
                vue_sjcx.state_arr = [];
                $(".div-pub-gt").find('input:checked').each(function () {
                    vue_sjcx.state_arr.push($(this).val());
                });
            } else {
                $(".div-pub-gt").find('input').each(function () {
                    $(this).removeAttr("checked", false);
                    $(this).prop("checked", false);
                    vue_sjcx.state_arr = [];
                });
            }
        },
        //详情
        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 starttime = $("#kssj").val().substr(0, 19);
            let endtime = $("#kssj").val().substr(22, 19);
            $.ajax({
                url: "/TrafficStatistics/list/pushrecordsBypage",
                dateType: 'json',
                type: "GET",
                contentType: 'application/json',
                data: {
                    starttime: starttime,
                    endtime: endtime,
                    page: pages,
                    limit: this.fy_select,
                    pushstatus: this.clzt_select,
                    construction: this.sjlx_select,
                    deptid:getCookie("bjpt_deptId"),
                },
                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);
        },
    },
    mounted(){
        $("#kssj").val(getTime_extent(6).pre_rq_start + ' - ' + getTime().jssj);
        this.query(1, true);
    },

});
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_ts = new Vue({
    el: '#myModal_ts',
    data: {
        data_table_ts: [],
    },
    methods: {
        //删除
        deletes: function (item, index) {
            vue_ts.data_table_ts.splice(index, 1);
        },
        //开始推送
        ts_ok: function () {
            if (!confirm("确认推送当前表格中的事件吗")) {
                return;
            }
            ;
            let arrs = '';
            vue_sjcx.state_arr.forEach((item, index)=> {
                arrs = arrs + item + ',';
            });
            $.ajax({
                url: "/traffresult/sendEvents",
                dataType: "json",
                type: "POST",
                data: {
                    recordid: arrs,
                },
                success: function (result) {
                    if (result.length > 0) {
                        result.forEach((item, index)=> {
                            vue_ts.data_table_ts.forEach((items, indexs)=> {
                                if (item.data == parseInt(items.recordid)) {
                                    items.pushdesc = item.msg;
                                    if(item.status==200){
                                        items.pushstatus = 0;
                                    }else{
                                        items.pushstatus = 1;
                                    }
                                }
                            });
                        });

                    }
                }
            });
        },
        //单个推送
        ts_s: function () {

        },
        //详情
        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");
        },
    }
});
laydate.render({
    elem: '#kssj'
    , type: 'datetime'
    , theme: '#368ff3'
    , range: true
});
//放大缩小图片
$('[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);
});
$('#myModal_ts').on('hidden.bs.modal', function () {
    vue_sjcx.query(1,true);
});
