alarmLog.vue 8.41 KB
<template>
	<v-layout>
		<template slot="breadcrumb" style="position: relative">
			<el-breadcrumb-item>统计报表</el-breadcrumb-item>
			<el-breadcrumb-item>警情中心</el-breadcrumb-item>
			<el-breadcrumb-item class="last">处理日志</el-breadcrumb-item>
			<p style="font-weight:bold; padding-top: 10px;font-size:20px;">处理日志</p>
			<p>用于统计和展示跟踪车辆警情的日志</p>
		</template>
		<template slot="main">
			<div class="ibox ibox-search">
				<!-- 表单查询 -->
				<el-form :inline="true" :rules="rules" ref="form" :model="form">
					<el-form-item prop="queryTerm">
						<el-input placeholder="请输入对应条件值" v-model="form.queryTerm" size="small" class="input-with-select" clearable>
						    <el-select v-model="form.queryType" slot="prepend" style="width:100px;" placeholder="请选择" size="small">
						      <el-option label="工单号" value="sqbh"></el-option>
						      <el-option label="车架号" value="standno"></el-option>
						      <el-option label="姓名" value="name"></el-option>
						      <el-option label="设备号" value="sn"></el-option>
						    </el-select>
						</el-input>
					</el-form-item>	
					<!-- 车辆分组分类组件 -->
					<v-vechicle-select ref="vechicle" label="车辆归属:" @onVechicleChange="vechicleChange"></v-vechicle-select>
					<!-- 车辆分组分类组件 /-->
					<br/>
					<el-form-item>
						<!-- 时间范围选择组件 -->
	                	<v-date-range 
	                		:date="form.dateRange" 
	                		activeType="yesterday"
	                		:options="['yesterday', 'last3', 'last7', 'last15']"  
	                		@onDateRangeChange="dateRangeChange">
	                	</v-date-range>
	                	<!-- 时间范围选择组件 -->
	                </el-form-item>
					<el-form-item>
					    <el-button type="primary" @click="onSubmit('form')" size="small">查询</el-button>
					</el-form-item>
					<el-form-item>
					    <el-button type="primary" @click="resetForm('form')" size="small">重置</el-button>
					</el-form-item>

				</el-form>
				<!-- 表单查询 /-->
            </div>
            <div class="ibox">
            	<div class="ibox-title">
            		<el-button type="primary" plain size="small" class="pull-right ibox-ctrl" @click="exportExcel">导出excel&nbsp;<i class="fa fa-download"></i></el-button>
            	</div>
            	<div class="ibox-content">
            		<el-table
					    :data="tableData"
					    border
					    size="small"
					    v-loading="loading"
					    @selection-change="selectChange"
					    style="width: 100%">

					    <el-table-column type="selection" width="40" align="center"></el-table-column>
						<el-table-column fixed type="index" label="序号" :index="getIndex" align="center" width="70"></el-table-column>
						
						<el-table-column fixed :render-header="renderHeader" width="300" align="center">
							<template slot-scope="scope">
								<div>
									{{scope.row.sqbh}}/{{scope.row.name}}/{{scope.row.sn}}
						        	<br/>{{scope.row.standno}}
								</div>
					      	</template>
						</el-table-column>
						<el-table-column prop="alarmLevel" label="警情等级" min-width="80" align="center"></el-table-column>
						
						<el-table-column prop="sn" label="报警说明&建议" min-width="220" align="left">
							<template slot-scope="scope">
								<div>
									说明:{{scope.row.alarmExplain}}
						        	<br/>建议:{{scope.row.alarmSuggest}}
								</div>
					      	</template>
						</el-table-column>
						<el-table-column prop="sn" label="采取措施&备注" min-width="220" align="left">
							<template slot-scope="scope">
								<div>
									措施:{{scope.row.resolvent}}
						        	<br/>备注:{{scope.row.remark}}
								</div>
					      	</template>
						</el-table-column>
						<el-table-column prop="handleTime" label="处理时间" min-width="180" align="center"></el-table-column>
						<el-table-column fixed="right"  label="操作" width="80" align="center">
							<template slot-scope="scope">
								<el-button @click="openDetail(scope.row)" type="text" size="medium">详情</el-button>
							</template>
						</el-table-column>
						
					</el-table>
					<div class="table-page-wrap">
					    <el-pagination
					      @size-change="handleSizeChange"
					      @current-change="handleCurrentChange"
					      :current-page="currentPage"
					      :page-sizes="[10, 20, 30, 40]"
					      :page-size="pageSize"
					      layout="total, sizes, prev, pager, next, jumper"
					      :total="total">
					    </el-pagination>
					</div>
            	</div>
            </div>
		</template>
	</v-layout>
</template>
<script>
import vDateRange from 'components/DateRange.vue'
const vVechicleSelect = () => import(/* webpackChunkName: "vVechicleSelect" */ 'components/VechicleSelect.vue');
import {exportExcel} from 'utils'
import {services} from '../../api'

const REPORT_SERVICE =  services.report;
export default{
	data(){
		return {
			loading: true,
			currentPage: 1,
			pageSize: 10,
			total: 0,
			tableData: [],
			search: '',
			form: {
				dateRange: [],
		        classIdList: '',
		        groupId: '',
		        queryType: 'sqbh',
		        queryTerm: '',
		        sTime: moment().subtract(1, 'days').startOf('day').format('YYYY-MM-DD HH:mm:ss'),
		        eTime: moment().subtract(1, 'days').endOf('day').format('YYYY-MM-DD HH:mm:ss')
			},
			selectedIds: [],
			label: '工单号/姓名/设备号<br/>车架号'
		}
	},
	created(){
		this.getData();
	},
	computed: {
		
	},
	methods: {
		getIndex(index){
			return (this.currentPage-1)*this.pageSize+index+1;
		},
		getData(curr=this.currentPage, size=this.pageSize){
			this.loading = true;
			let params = this.getParams();
			params.currentPage = curr;
			params.pageSize = size;

			REPORT_SERVICE.getAlarmLogList(params).then((response)=>{
				if(Array.isArray(response.data)){
					this.tableData = response.data;
					this.total = response.recordsTotal;
				}else{
					this.tableData = [];
					this.total = 0;
				}
				this.loading = false;
			});
		},
		resetForm(formName) {
        	this.$refs[formName].resetFields();
        	this.$refs.vechicle.resetSelet();
		},
		getParams(){
			const form = this.form;
			const params = {};
			
			if(form.groupId){
				params.groupId = form.groupId;
			}
			if(form.classIdList){
				params.classId = form.classIdList;
			}
			if(form.sTime && form.eTime){
				params.sTime = form.sTime;
				params.eTime = form.eTime;
			}
			const queryTerm = form.queryTerm.trim();
			if(queryTerm){
				params[form.queryType] = queryTerm;
			}
			
			return params;
		},
		dateRangeChange(dateArr){
			if(dateArr && dateArr.length){
				this.form.sTime = dateArr[0].startOf('day').format('YYYY-MM-DD HH:mm:ss');
				this.form.eTime = dateArr[1].endOf('day').format('YYYY-MM-DD HH:mm:ss');
			}else{
				this.form.sTime = '';
				this.form.eTime = '';
			}
		},
		selectChange(selection){
			this.selectedIds = [];
			selection.map((obj)=>{
				this.selectedIds.push(obj.id)
			});
			
		},
		vechicleChange(groupId, classId){
			this.form.groupId = groupId;
			this.form.classIdList = classId;
		},
		handleSizeChange(val) {
	      	this.pageSize = val;
	        this.getData(this.currentPage,this.pageSize)
	    },
      	handleCurrentChange(val) {
      		this.currentPage = val;
        	this.getData(val)
      	},
      	onSubmit(form){
      		this.$refs[form].validate((valid) => {
	          if (valid) {
	            this.currentPage = 1;
	      		this.pageSize = 10;
	      		this.getData();
	          } else {
	            return false;
	          }
        });
      		
      	},
      	exportExcel(){
      		const url = 'alarmCenterLog/exportLog';
      		
      		if(this.selectedIds.length){
      			exportExcel(url, {idList: this.selectedIds.join(',')})
      		}else{
      			exportExcel(url, this.getParams())
      		}
      	},
      	openDetail(row){
      		let routeData = this.$router.resolve({ 
      			path: '/report/alarmDetail', 
      			query: {
      				vehicleId: row.vehicleId
      			}
      		});

			window.open(routeData.href, '_blank');
      	},
      	renderHeader(h, { column, $index }) { 
			const self = this;
	        return [
	            h('span', '工单号/姓名/设备号'),
	            h('br'),
	            h('span', '车架号'),
	        ];
	    }
    },
	components:{
		vDateRange,
		vVechicleSelect
	}
}
</script>
<style scoped>
	.cmd-gp{
		position: absolute;
		bottom: 20px;
		right: 20px;
	}
</style>