history.js 6.5 KB
new Vue({
	el: '#his',
	data() {
		return {
			city: '',
			reservoir: {},
			monitor: {},
			lslist:[],
			xzdsk:'',
			fy:'',
			sbid:'',
			checkindex: 0,
			monitor: 0,
            selectedCityId:"",
            selectedShuikuId:"",
            selectedShebeiId:"",
            curpage:1,
            pages:1,
            selectArr:[],
		}
	},
	methods:{
        selectAll(event){//全选
            var _this = this;
            if(!event.currentTarget.checked) {
                this.selectArr = [];
            }else{
                this.selectArr = [];
                this.lslist.forEach((item,i)=>{
                    this.selectArr.push(item.id)
                })
            }
        },
        deleteSel(){//选择删除
            console.log(this.selectArr);
            if(this.selectArr.length>0){
                var durl = "https://www.ynzhsk.cn/api/video/index/bat_delete_alarm_log";
                axios.post(durl,{"delete_ids":this.selectArr}).then(response => (
                    alert(response.data.msg),
                    this.xkxz(this.selectedShebeiId)
                ));
            }
            // let arr = [];
            // var len = this.lslist.length;
            // for(let i = 0;i<len;i++) {
            //     if (this.selectArr.indexOf(i) >=0 ) {
            //
            //     }else{
            //         arr.push(this.lslist[i]);
            //     }
            // }
            // this.lslist = arr;
            // this.selectArr = [];
        },
		xkxz:function(event){
            this.lslist = [];
            this.selectedShebeiId =event;
			var url = "https://www.ynzhsk.cn/api/video/index/history2?monitor=" + event +"&page=1"
			var urlpage =  "https://www.ynzhsk.cn/api/video/index/page2?monitor=" + event
// 			console.log(urlpage)
			axios.get(url).then(response => (
				this.lslist = response.data.data,
				this.sbid = event
			));
			axios.get(urlpage).then(res => (
				this.fy = res.data.data.list,
                this.pages = res.data.data.pages
			));
		},
		
		// 水库请求
		skn:function(id){
            this.lslist = []
            this.fy = []
            this.pages =1
		  //  this.monitor = id
		  //  alert(this.monitor)
		    // 获取硬件设备
            this.selectedShuikuId =id;
		    this.selectedShebeiId ="";
		    axios.get("https://www.ynzhsk.cn/api/video/index/monitor2/?reservoir="+ id)
			.then(response => (
				this.monitor = response.data.data
			    
			))
			.catch(function(error) { // 请求失败处理
				console.log(error);
			});  
		   console.log(this.monitor.length)
		},
        // 上一页
        deduction(){
            if(this.curpage - 1 >0){
                this.curpage = this.curpage-1;
                this.selectArr=[];
                this.fyclick();
            }else{
                this.curpage  = 1;
            }
        },
        // 下一页
        score(){  //若果是最后一页
            if(this.curpage  >= this.pages ){
                this.curpage = this.pages;
            }else{
                this.curpage= this.curpage+1;
                this.selectArr=[];
                this.fyclick();
            }
        },
		
		fyclick:function(){
			var url = "https://www.ynzhsk.cn/api/video/index/history2?monitor=" + this.sbid + "&page=" + this.curpage
			axios.get(url).then(response => (
				this.lslist = response.data.data
			));
			this.checkindex = index
// 			this.sw = true
// 			console.log(index)
		}
	},
	mounted() {
		var url = "https://www.ynzhsk.cn/api/video/index/history2?monitor=iDS-2DC7423MW-AB20210402AACHF77587632&page=1"
		var pageurl = "https://www.ynzhsk.cn/api/video/index/page2?monitor=iDS-2DC7423MW-AB20210402AACHF77587632"
		axios.get(url).then(response => (
			this.lslist = response.data.data
		));
		
		axios.get(pageurl).then(res => (
			this.fy = res.data.data.list,
            this.pages = res.data.data.pages
		));
		//  获取城市
		axios.get('https://www.ynzhsk.cn/api/video/index/city')
			.then(response => (
				this.city = response.data.data[0].name,
                this.selectedCityId = response.data.data[0].id
			))
			.catch(function(error) { // 请求失败处理
				console.log(error);
			});

		//  获取水库
		axios.get('https://www.ynzhsk.cn/api/video/index/reservoir?city=1')
			.then(response => (
				this.reservoir = response.data.data

			))
			.catch(function(error) { // 请求失败处理
				console.log(error);
			});


			
		// 获取今日统计
		axios.get('https://www.ynzhsk.cn/api/video/index/fyclick?reservoir=4')
			.then(response => (
				this.early = response.data.data,
				this.sum = this.early.sum,
				this.exist = this.early.exist,
				this.line = this.early.line
			))
// 			.catch(function(error) { // 请求失败处理
// 				console.log(error);
// 			});
			
		// 人员入侵预警
		
	},
	filters: {
	  capitalize: function (value) {
	    if (value == 1){
			return "入侵记录"
		}else{
			return "进入记录"
		}
	  },
	  settime:function(value){
		  return new Date(parseInt(value) * 1000).toLocaleString().replace(/:\d{1,2}$/,' '); 
	  }
	}
	
	
	// filters:{
	// 	ivc(val){
	// 		if(){
	// 			return "入侵"
	// 		}else{
	// 			return "进入"
	// 		}
	// 	}
	// }
})

//2
var sbzt = new Vue({
	el: '#right1',
	data:{

			early:{},
			sum:'',
			exist: '',
			line: '',

	},
	methods:{
	    sbzt:function(id){
	        	// 获取今日统计
		axios.get('https://www.ynzhsk.cn/api/video/index/quantity?reservoir=4')
			.then(response => (
				this.early = response.data.data,
				this.sum = this.early.sum,
				this.exist = this.early.exist,
				this.line = this.early.line
			))
			.catch(function(error) { // 请求失败处理
				console.log(error);
			});
	    }
	},

	mounted() {
        this.sbzt()

		//  获取城市
		
			
	
			
		// 人员入侵预警
		
	}

})
//3

var sbyj = new Vue({
	el: '#right2',
	data() {
		return {
			name: '',
			monitoring: '',
			record: '',
			createtime: '',
			address: ''
		}
	},
	mounted() {
// 	console.log("另一个vue",skxz.sbdata)
	axios.get('https://www.ynzhsk.cn/api/video/index/perEarly?monitor=iDS-2DC7423MW-AB20210402AACHF77587632')
		.then(response => (
			this.name = response.data.data.reservoir[0].name,
			this.monitoring = response.data.data.monitoring[0].name,
			this.record = response.data.data.record,
			this.createtime = response.data.data.date.createtime,
			this.address = response.data.data.reservoir[0].address,
// 			console.log(111111111111111111111111111111111111111111111111111111111111111111111),
			console.log(response)
			
			
		))
		.catch(function(error) { // 请求失败处理
			console.log(error);
		});
	}

})

//历史记录