
var vm = new Vue({
	el: '#app',

	data:{
		varList: [],	//list
		SUBJECT: '',	//科目
		CLASSHOUR: '',	//课时
		page: [],		//分页类
		KEYWORDS:'',	//检索条件,关键词
		showCount: -1,	//每页显示条数(这个是系统设置里面配置的，初始为-1即可，固定此写法)
		currentPage: 1,	//当前页码
		loading:false	//加载状态
    },

	methods: {

        //初始执行
        init() {
        	this.getDic();
    		this.getList();
        },

        //获取列表
        getList: function(){
        	this.loading = true;
        	$.ajax({
        		xhrFields: {
                    withCredentials: true
                },
        		type: "POST",
        		url: httpurl+'video/list?showCount='+this.showCount+'&currentPage='+this.currentPage,
        		data: {KEYWORDS:this.KEYWORDS,SUBJECT:this.SUBJECT,CLASSHOUR:this.CLASSHOUR,tm:new Date().getTime()},
        		dataType:"json",
        		success: function(data){
        		 if("success" == data.result){
        			 vm.varList = data.varList;
        			 vm.page = data.page;
        			 vm.loading = false;
        			 $("input[name='ids']").attr("checked", false);
        		 }else if ("exception" == data.result){
                 	showException("视频课程",data.exception);//显示异常
                 }
        		}
        	}).done().fail(function(){
                swal("登录失效!", "请求服务器无响应，稍后再试", "warning");
                setTimeout(function () {
                	window.location.href = "../../login.html";
                }, 2000);
            });
        },

      	//观看视频
    	goView: function(id){
    		 var diag = new Dialog();
    		 diag.Drag=true;
    		 diag.Title ="播放视频";
    		 diag.URL = '../../course/video/video_view.html?FID='+id;
    		 diag.Width = 1000;
    		 diag.Height = 696;
    		 diag.Modal = true;				//有无遮罩窗口
    		 diag.CancelEvent = function(){ //关闭事件
    			diag.close();
    		 };
    		 diag.show();
    	},

    	//调用数据字典(科目和课时)
    	getDic: function(){
    		$.ajax({
    			xhrFields: {
                    withCredentials: true
                },
    			type: "POST",
    			url: httpurl+'dictionaries/getLevels',
    	    	data: {DICTIONARIES_ID:'19cdec7037094b3c8cfa1bd85b7bcece',tm:new Date().getTime()},//科目
    			dataType:'json',
    			success: function(data){
    				$("#SUBJECT").html('<option value="" >选择科目</option>');
    				 $.each(data.list, function(i, dvar){
    					 $("#SUBJECT").append("<option value="+dvar.BIANMA+">"+dvar.NAME+"</option>");
    				 });
    			}
    		});
    		$.ajax({
    			xhrFields: {
                    withCredentials: true
                },
    			type: "POST",
    			url: httpurl+'dictionaries/getLevels',
    	    	data: {DICTIONARIES_ID:'8a4cd096d20b47bfa8da3e54f4a0a8d0',tm:new Date().getTime()},//课时
    			dataType:'json',
    			success: function(data){
    				$("#CLASSHOUR").html('<option value="" >选择课时</option>');
    				 $.each(data.list, function(i, dvar){
    					 $("#CLASSHOUR").append("<option value="+dvar.BIANMA+">"+dvar.NAME+"</option>");
    				 });
    			}
    		});
    	},

        //-----分页必用----start
        nextPage: function (page){
        	this.currentPage = page;
        	this.getList();
        },
        changeCount: function (value){
        	this.showCount = value;
        	this.getList();
        },
        toTZ: function (){
        	var toPaggeVlue = document.getElementById("toGoPage").value;
        	if(toPaggeVlue == ''){document.getElementById("toGoPage").value=1;return;}
        	if(isNaN(Number(toPaggeVlue))){document.getElementById("toGoPage").value=1;return;}
        	this.nextPage(toPaggeVlue);
        }
       //-----分页必用----end

	},

	mounted(){
        this.init();
    }
})
