event.vue 12.2 KB
<template>
  <div class="innnerBox">
		   <el-col :span="22">
			  <el-form ref="form" label-width="80px" inline>
					  <el-form-item label="资源类型" >
						   <span class="inputBox">
							   <el-select placeholder="请选择" :popper-append-to-body=false v-model="conditions.source_type">
									<el-option value="pull_video_stream" label='拉取视频'></el-option>
									<el-option value="pull_pic_files" label='拉取图片'></el-option>
								</el-select>
						   </span>
					  </el-form-item>
					 <el-form-item label="事件类型">
					 	<span class="selectBox">
					 	   <el-select placeholder="请选择" :popper-append-to-body=false v-model="conditions.type">
							   <el-option value="" label="全部"></el-option>
								<el-option v-for='item in eventList' :value="item.code" :key="item.code" :label='item.name'></el-option>
					 		</el-select>
					 	</span>
					 </el-form-item>
					 <el-form-item label="任务名称">
					   <span class="inputBox">
						 <el-input placeholder="请输入任务名称"  v-model="conditions.task_name"></el-input>
					   </span>
					 </el-form-item>
					<el-form-item label="起始时间">
						  <span class="dateBox">
							  <el-date-picker
							   v-model="dates"
							   value-format="yyyy-MM-dd HH:mm:ss"
								:default-time="['00:00:00', '23:59:59']"
							   type="datetimerange"
							   range-separator="至"
							   start-placeholder="开始日期"
							   end-placeholder="结束日期">
							 </el-date-picker>
						  </span>
					  </el-form-item>
			  </el-form>
		  </el-col>
		   <el-col :span="2">
			   <div style="margin-bottom: 6px;padding-top: 3px;">
					<el-button type="primary" style="" @click="query" class="block">查询</el-button>
					<el-button type="success" class="block" @click="exportFun">导出</el-button>
				</div>
		   </el-col>
		  <div  style="">
			  <el-table
			       :data="formattterData"
			       height="574"
				   stripe
				   border
			      @selection-change="handleSelectionChange">
			       <el-table-column
			         prop="event_type"
			          align="center"
			         label="事件类型">
			       </el-table-column>
			         <el-table-column
			         prop="task_name"
			          align="center"
			         label="任务名称">
			       </el-table-column>
				   <el-table-column
				      align="center"
				     label="地点">
					 <template slot-scope="scope" >
					   <div>
					     <span v-if="scope.row.event_cate == 'behavior'&&scope.row.event_data&&scope.row.event_data">{{scope.row.event_data.locate_name}}</span>
					   </div>
					 </template>
				   </el-table-column>
				   <el-table-column
				      align="center"
				     label="面积(㎡)">
					 <template slot-scope="scope" >
					   <div>
					     <span v-if="scope.row.event_cate == 'behavior'&&scope.row.event_data&&scope.row.event_data.area_list">{{scope.row.area_list[0].area}}</span>
					   </div>
					 </template>
				   </el-table-column>
				   <el-table-column
				      align="center"
				     label="人数(个)">
					 <template slot-scope="scope" >
					   <div>
					      <span v-if="scope.row.event_cate == 'behavior'&&scope.row.event_data&&scope.row.event_data.area_list">{{scope.row.area_list[0].count}}</span>
					   </div>
					 </template>
				   </el-table-column>
				   <el-table-column
				      align="center"
				     label="进入阈值">
					 <template slot-scope="scope" >
					   <div>
					     <span v-if="scope.row.event_cate == 'behavior'&&scope.row.event_data&&scope.row.event_data.area_list">{{scope.row.area_list[0].max_len}}</span>
					   </div>
					 </template>
				   </el-table-column>
				   <el-table-column
				      align="center"
				     label="离开阈值">
					 <template slot-scope="scope" >
					   <div>
					      <span v-if="scope.row.event_cate == 'behavior'&&scope.row.event_data&&scope.row.event_data.area_list">{{scope.row.area_list[0].normal_len}}</span>
					   </div>
					 </template>
				   </el-table-column>
			        <el-table-column
			         prop="shoot_date"
			          align="center"
			         label="抓拍时间">
					 <template slot-scope="scope">
						 <span v-if="scope.row.event_cate == 'behavior'&&scope.row.event_data">{{scope.row.shoot_date}} {{scope.row.shoot_time}}</span>
					 </template>
			       </el-table-column>
				   <el-table-column
				      align="center"
				     label="车道号">
					 <template slot-scope="scope">
					   <div>
					     <span v-if="scope.row.event_cate == 'behavior'&&scope.row.event_data">{{scope.row.event_data.lane.number}}</span>
					   </div>
					 </template>
				   </el-table-column>
				   <el-table-column
				      align="center"
				     label="方向类型">
					 <template slot-scope="scope">
					   <div>
					     <span v-if="scope.row.event_cate == 'behavior'&&scope.row.event_data &&scope.row.event_type !=='jinggaidiushi'&&scope.row.event_type !=='daobantingche'">{{scope.row.direction_text}}</span>
					   </div>
					 </template>
				   </el-table-column>
				   <el-table-column
				      align="center"
				     label="车道类型">
					 <template slot-scope="scope">
					   <div>
					     <span v-if="scope.row.event_cate == 'behavior'&&scope.row.event_data">{{scope.row.lane_text}}</span>
					   </div>
					 </template>
				   </el-table-column>
				   <el-table-column
				      align="center"
				     label="事件发生时间">
					 <template  slot-scope="scope">
					   <div>
					     <span v-if="scope.row.event_cate == 'behavior'&&scope.row.event_data">{{$moment($moment.utc(scope.row.event_data.start_dt).format()).local().format('YYYY-MM-DD HH:mm:ss')}}</span>
					   </div>
					 </template>
				   </el-table-column>
				   <el-table-column
				      align="center"
				     label="事件结束时间">
					 <template  slot-scope="scope">
					   <div>
					      <span v-if="scope.row.event_cate == 'behavior'&&scope.row.event_data">{{$moment($moment.utc(scope.row.event_data.end_dt).format()).local().format('YYYY-MM-DD HH:mm:ss')}}</span>
					   </div>
					 </template>
				   </el-table-column>
			       <el-table-column
			        align="center"
			         label="操作">
			         <template slot-scope="scope">
						 <el-tooltip content="播放" placement="bottom" effect="light" :visible-arrow=false>
						 	<span :class="{'iconfont icon-bofang playIcon':true,'no-btn':scope.row.video&&scope.row.video[0].src_url!=''?false:true}"  @click="playFun(scope.$index, scope.row)"></span>
						 </el-tooltip>
						 <span class="tableSpanBorder"></span>
			         	<el-tooltip content="详情" placement="bottom" effect="light" :visible-arrow=false>
			         		<span class="iconfont icon-xiugai editIcon"   @click="detailFun(scope.$index, scope.row)"></span>
			         	</el-tooltip>
			         </template>
			       </el-table-column>
			  </el-table>
				<div style="margin-top: 28px;">
					<el-pagination
					style="float: right;"
					  background
					  prev-text="上一页"
					  next-text="下一页"
					   :page-sizes="[30, 50, 100, 200]"
					  layout="prev, pager, next,sizes"
					  :current-page="page"
					  @size-change="handleSizeChange"
					  @current-change="handleCurrentChange"
					  :total="total">
					</el-pagination>
					<div style="clear: both;"></div>
				</div>
		  </div>
		  <el-dialog
		    title="详情"
		    top="12vh"
		    :visible.sync="detailVisible"
		    width="700px">
			<div style="position: relative;padding: 10px 20px;">
				<div class="leftArrow" @click="leftFun"><i class="el-icon-d-arrow-left"></i></div>
				<div class="detaiCon">
					<el-image style="width: 100%;" :src="this.detailImg">
					  <div slot="error" class="image-slot">
						<img :src="carImg" alt="" style="width: 40%;display: block;margin: 0 auto;">
					  </div>
					</el-image>
					<el-form  label-width="120px" inline>
						<div>
							<el-form-item label="经过日期:">
								<span>{{ detailObj.shoot_date ? detailObj.shoot_date : '' }}</span>
							</el-form-item>
							<el-form-item label="经过时间:">
								<span>{{ detailObj.shoot_time ? detailObj.shoot_time : '' }}</span>
							</el-form-item>
						</div>
						<div>
							<el-form-item label="事件类型:">
								<span>{{ detailObj.event_type }}</span>
							</el-form-item>
						</div>
					</el-form>
				</div>
				<div class="rightArrow"  @click="rightFun"><i class="el-icon-d-arrow-right"></i></div>
			</div>
		    <span slot="footer" class="dialog-footer">
		      <el-button type="primary" @click="detailVisible = false">关 闭</el-button>
		    </span>
		  </el-dialog>
		  <curVideo ref="visableDialog" :playersrc="playurl"></curVideo>
  </div>
</template>
<script>
	import videoDialog from '@/components/video'
	export default {
		data(){
			let start_dt = this.$moment('2019-12-20').format('YYYY-MM-DD')+' 00:00:00';
			let end_dt = this.$moment().format('YYYY-MM-DD')+' 23:59:59';
			return{
				detailObj:{},
				carImg:require("@/assets/img/home/defaultImg.png"),
				detailImg:'',
				detailVisible:false,
				dates:[ start_dt,end_dt ],
				conditions: {
					start_dt:start_dt,
					end_dt:end_dt,
					type: '',
					source_type:'',
					task_name:''
				},
				tableData:[],
				formattterData:[],
				total:0,
				page:1,
				pageSize:30,
				selectcheck:[],
				currentIndex:0,
				eventList:JSON.parse(window.localStorage.getItem('安防事件')),
				playurl:''
			}
		},
		watch:{
			dates(val){
				this.conditions.start_dt=val[0];
				this.conditions.end_dt=val[1];
			}
		},
		components:{
			videoDialog
		},
		mounted(){
			this.getData()
		},
		methods:{
			exportFun(){
				  window.open(
				    encodeURI(
					process.env.VUE_APP_URL+
					  "/api/v1/behavior/events/export?s=" + Math.random()+
					 '&event_dt__gte='+ this.$moment(this.conditions.start_dt).utc().format('YYYY-MM-DD HH:mm:ss') +
					 '&event_dt__lt='+this.$moment(this.conditions.end_dt).utc().format('YYYY-MM-DD HH:mm:ss') +
					 '&task_name='+this.conditions.task_name+
					 '&event_type='+this.conditions.type
				    )
				  );
			},
			leftFun(){
				if(this.currentIndex-1<0){
					  this.$message({
						  message: '目前为第一条',
						  type: 'warning'
						});
						return false;
				}
				this.detailObj=this.formattterData[this.currentIndex-1];
				this.currentIndex-=1;
				this.getImg(this.detailObj.pics[0].pic_unid);
			},
			rightFun(){
				if(this.currentIndex==this.formattterData.length-1){
					  this.$message({
						  message: '目前为最后一条',
						  type: 'warning'
						});
						return false;
				}
				this.detailObj=this.formattterData[this.currentIndex+1];
				this.currentIndex+=1;
				this.getImg(this.detailObj.pics[0].pic_unid);
			},
			handleSelectionChange(obj){
			   this.selectcheck = [];
				 obj.forEach(item => {
				   this.selectcheck.push(item.id)
				 });
			},
			handleSizeChange(val) {
				this.pageSize=val;
				this.getData();
			},
			handleCurrentChange(val) {
				this.page=val;
				this.getData();
			  },
			query(){
				this.getData();
			},
			getData(){
				this.formattterData=[];
				let offset = (this.page - 1) * this.pageSize;
				let search_params = {
					limit: this.pageSize,
					offset: offset,
					task_name: this.conditions.task_name ? this.conditions.task_name.replace(/\s\s*/g, '') : this.conditions.task_name,
					event_type: this.conditions.type,
					event_dt__gte: this.$moment(this.conditions.start_dt).utc().format('YYYY-MM-DD HH:mm:ss'),
					event_dt__lt:this.$moment(this.conditions.end_dt).utc().format('YYYY-MM-DD HH:mm:ss')
				}
				this.$api.search.eventTableList(search_params
				).then((res)=>{
					this.total=res.total_num;
					res.list_data.forEach((item,index)=>{
						this.formattterData.push(this.$buildCode.init(item));
					})
					
				}).catch((err)=>{
					
				})
			},
			getImg(unid){
				this.$api.search.detailImg({
				},unid).then(res=>{
					this.detailImg=res.pic_url ? res.pic_url : carImg;
				}).catch(e=>{
					
				})
			},
			playFun(index,row){
					if(!row.video) {
						return
				  }
					var play_url = '';
					if(row.video) {
						play_url = row.video[0].src_url
				  }
				  this.$refs.visableDialog.playvideos(play_url);
			},
			detailFun(index,row){
				this.currentIndex=index;
				if(row.pics.length>0){
					this.detailObj = Object.assign({},row);
					this.getImg(row.pics[0].pic_unid);
				}
				this.detailVisible=true;
			}
		},
	}
</script>
<style lang="scss" scoped>
</style>