let vue_sjcx1 = new Vue({
    el: '#symrcxjk',
    data: {
        clzt_select: '',
        data_sjdj: [],
    },
    methods: {
        add_sjlx: function () {
            $("#myModal2").modal("show");
            $("#dj").selectpicker('deselectAll');
            $("#cllxs").selectpicker('deselectAll');
            vue_sjcx1.cxsjlx();
        },
        del:function (item) {
            let arr = [];
            arr.push({key: item.id, alarmlevel: ''});
            $.ajax({
                url: "/code/update",
                dateType: 'json',
                type: "POST",
                contentType: 'application/json',
                data: JSON.stringify(arr),
                success: function (result) {
                    if (!confirm("确认删除此事件类型吗？")) {
                        return;
                    }
                    if (result.code == 0) {
                        vue_sjcx1.query();
                        info_new("事件类型删除成功");
                        window.setTimeout("$('#info-warning-new').modal('hide')", 2000);
                    }
                }
            });
        },
        query: function () {
            $.ajax({
                url: "/TrafficStatistics/listcode",
                dataType: "json",
                type: "GET",
                data: {
                    codeid: 1,
                    alarmlevel: this.clzt_select,
                },
                success: function (result) {
                    vue_sjcx1.data_sjdj = [];
                    if (result.code == 0) {
                        if (result.data.length > 0) {
                            result.data.forEach((item, index)=> {
                                vue_sjcx1.data_sjdj.push(item);
                            });
                        }
                    }
                }
            });
        },
        cxsjlx: function () {
            $.ajax({
                url: "/TrafficStatistics/listcode",
                dataType: "json",
                type: "GET",
                data: {
                    codeid: 1,
                    alarmlevel: '',
                },
                success: function (result) {
                    vue_sjdj.arr_cllx = [];
                    if (result.code == 0) {
                        if (result.data.length > 0) {
                            result.data.forEach((item, index)=> {
                                if (item.alarmlevel == null) {
                                    vue_sjdj.arr_cllx.push({id: item.id, value: item.name});
                                }
                            });
                            setTimeout(function () {
                                $("#cllxs").selectpicker('refresh');
                                $("#cllxs").selectpicker('render');
                            }, 200);
                        }
                    }
                }
            });
        }
    },
    mounted(){
        this.query();
    }
});
//endregion
let vue_sjdj = new Vue({
    el: '#myModal2',
    data: {
        arr_cllx: [],
        clzt_select1: '',
        cllx_select: [],
    },
    methods: {
        define: function () {
            if (vue_sjdj.clzt_select1 == '') {
                return;
            }
            if (vue_sjdj.cllx_select.length == 0) {
                return;
            }
            let arr = [];
            vue_sjdj.cllx_select.forEach((item, index)=> {
                arr.push({key: item, alarmlevel: vue_sjdj.clzt_select1});
            });
            $.ajax({
                url: "/code/update",
                dateType: 'json',
                type: "POST",
                contentType: 'application/json',
                data: JSON.stringify(arr),
                success: function (result) {
                    if (result.code == 0) {
                        vue_sjcx1.query();
                        info_new("事件类型添加成功");
                        window.setTimeout("$('#info-warning-new').modal('hide')", 2000);
                        $("#myModal2").modal("hide");
                    }
                }
            });
        }
    },
    mounted(){
    }
});
$("#sjlxsss").change(function () {
    vue_sjcx1.query();
});
