alarmCore.vue 7.61 KB
<template>
	<v-layout>
		<template slot="tab">
			<el-tabs class="tab_wrap" v-model="tabActiveName" type="card" @tab-click="handleClick" >
				<el-tab-pane label="常规警情" name="default" style="background:#fff"></el-tab-pane>
				<el-tab-pane label="复合警情" name="mix" style="background:#fff"></el-tab-pane>
			</el-tabs>
		</template>
		<template slot="breadcrumb">
			<div v-show="tabActiveName==='default'">
				<el-breadcrumb-item>统计报表</el-breadcrumb-item>
				<el-breadcrumb-item>警情中心(广汽)</el-breadcrumb-item>
			</div>
			<div v-show="tabActiveName==='default'">
				<p style="font-weight:bold; padding-top: 10px;font-size:20px;">警情中心(广汽)-常规警情</p>
				<p>以单一条件为判断依据,统计和导出车辆的风险综合预警情况,包含:电量报警、超时报警、超时离线报警、设备报警、设备分离报警、区域报警(个人)</p>
			</div>
			<div v-show="tabActiveName==='mix'">
				<el-breadcrumb-item>统计报表</el-breadcrumb-item>
				<el-breadcrumb-item>警情中心(广汽)</el-breadcrumb-item>
			</div>
			<div v-show="tabActiveName==='mix'">
				<p style="font-weight:bold; padding-top: 10px;font-size:20px;">警情中心(广汽)-复合警情</p>
				<p>以两个或者两个以上的复合条件为判断依据,统计和导出车辆的风险综合预警汇总情况,包含:出省报警(经销商)</p>
			</div>
		</template>
		<template slot="main">
			<alarm-Core-Default v-show="tabActiveName==='default'"></alarm-Core-Default>
			<alarm-Core-Mix v-show="tabActiveName==='mix'"></alarm-Core-Mix>
		</template>
		
	</v-layout>
</template>
<script>
import vDateRange from 'components/DateRange.vue'
const vVechicleSelect = () => import(/* webpackChunkName: "vVechicleSelect" */ 'components/VechicleSelect.vue');
import alareCoreModule from './alareCoreModule'
import alarmCoreDefault from './alarmCoreDefault'
import alarmCoreMix from './alarmCoreMix'
import {exportExcel} from 'utils'
import {services} from '../../api'

const REPORT_SERVICE =  services.report;
export default{
	data(){
		return {
			form: {
		        agentCity: '',
		        agentProv: '',
		        alarmType: '',
				businessType: '',
				homeProv:'',
				name:'',
				projectType:'',
				standNo:''
			},
			addressOptions:[],
			optionsCity:[],
			optionsProvince:[],
			optionsProject:[],
			addresslabel:'',
			provincelabel:'',
			citylabel:'',
			projectlabel:'',
			detailForm:{},
			loading: true,
			detailFormVisible: false,
			currentPage: 1,
			pageSize: 10,
			total: 0,
			tableData: [],
			itemTableDate:{},
			expandKeys:[],/** 新增 **/
			getRowKeys(row) {
        		return row.index;
			},
			selectedIds: [],
			tabActiveName: 'default'
		}
	},
	created(){
		this.getData();
		this.getList();
	},
	computed: {
		
	},
	methods: {
		selectChange(selection){
			this.selectedIds = [];
			selection.map((obj)=>{
				this.selectedIds.push(obj.id)
			});
			
		},
		getIndex(index){
			return (this.currentPage-1)*this.pageSize+index+1;
		},
		getList(curr=this.currentPage, size=this.pageSize){
			this.loading = true;
			let params = this.getParams();
			params.currentPage = curr;
			params.pageSize = size;

			REPORT_SERVICE.listGqBusissDataPage(params).then((response)=>{
				if(Array.isArray(response.data)){
					response.data.map((item, index)=>{
						item.index = this.getIndex(index)
					});
					this.tableData = response.data;
					this.total = response.recordsTotal;
				}else{
					this.tableData = [];
					this.total = 0;
				}
				this.loading = false;
			});
			
		},
		resetForm(formName) {
			this.projectlabel = '';
			this.addresslabel = '';
			this.provincelabel = '';
			this.citylabel= '';	
			this.$refs[formName].resetFields();
			this.getList()
		},
		getData(){
			REPORT_SERVICE.gqQueryTerm({queryId:0}).then((response)=>{
				this.addressOptions = response.data
			});
			REPORT_SERVICE.gqQueryTerm({queryId:1}).then((response)=>{
				this.optionsProvince = response.data
			});
			REPORT_SERVICE.gqQueryTerm({queryId:2}).then((response)=>{
				this.optionsCity = response.data
			});
			REPORT_SERVICE.gqQueryTerm({queryId:3}).then((response)=>{
				this.optionsProject = response.data
			});
			if(typeof this.$route.params.alarmType !== 'undefined'){
				this.form.alarmType = this.$route.params.alarmType;
			}
		},
		getParams(){
			const form = this.form;
			const params = {};
			if(this.citylabel){
				params.agentCity = this.citylabel;
			}
			if(this.provincelabel){
				params.agentProv = this.provincelabel;
			}
			if(form.alarmType){
				params.alarmType = form.alarmType;
			}
			if(form.businessType){
				params.businessType = form.businessType;
			}
			if(this.addresslabel){
				params.homeProv = this.addresslabel;
			}
			if(form.name){
				params.name = form.name;
			}
			if(this.projectlabel){
				params.projectType = this.projectlabel;
			}
			if(form.standNo){
				params.standNo = form.standNo;
			}

			return params;
		},
	
		expandChange(row, expandedRows) {console.log(row)
			if(this.expandKeys.indexOf(row.index)>=0){
				//收起当前行
				this.expandKeys.shift()
				return;
			}
			let _this = this
			//恢复默认值
			// _this.loading = true
			_this.itemTableDate = []
			//加载数据
			// axios.get('/subtable/data')
			// 	.then(function (res) {
			REPORT_SERVICE.getAlarmDataById({vehicleId:row.vehicleId, alarmNumType: row.alarmNumType}).then((response)=>{
				this.itemTableDate = response.data
			});					
			_this.expandKeys.shift()            /** 新增 **/
			_this.expandKeys.push(row.index)       /** 新增 **/
			
			if (expandedRows.length > 1) {
				//只展开当前选项
				expandedRows.shift()
			}
		},
		getAddressLabel(val){
			let obj = {};
			  obj = this.addressOptions.find((item)=>{
			     return item.value === val;
			  });
			  this.addresslabel = obj.lable;
			  console.log(this.addresslabel)
		},
		getProvinceLabel(val){
			let obj = {};
			  obj = this.optionsProvince.find((item)=>{
			     return item.value === val;
			  });
			  this.provincelabel = obj.lable;
			  console.log(this.provincelabel)
		},
		getCityLabel(val){
			let obj = {};
			  obj = this.optionsCity.find((item)=>{
			     return item.value === val;
			  });
			  this.citylabel = obj.lable;
			  console.log(this.citylabel)
		},
		getProjectLabel(val){
			let obj = {};
			  obj = this.optionsProject.find((item)=>{
			     return item.value === val;
			  });
			  this.projectlabel = obj.lable;
			  console.log(this.projectlabel)
		},
      	exportExcel(){
      		const url = 'gqAlarmCenter/exportGqAlarmCenter';				
			
      		if(this.selectedIds.length){
      			exportExcel(url, JSON.stringify({idList: this.selectedIds}), 'post')
      		}else{
      			exportExcel(url, this.getParams())
      		}
      	},
		seach(){
			this.getList()
		},
		alarmModule(isOpen){
	    	this.detailFormVisible = isOpen
	    },
		alarmHandle(snStr,vehicleId, alarmNumType){
			REPORT_SERVICE.queryAlarmBySn({snStr:snStr, alarmNumType}).then((response)=>{
				if(response.returnCode==0){
					this.detailForm = response.data
					this.vehileId = vehicleId;
					this.snList = snStr;
					this.alarmNumType = alarmNumType;
					this.detailFormVisible = true;
				}
			});
			
		},
		handleSizeChange(val) {
	      	this.pageSize = val;
	        this.getList(this.currentPage,this.pageSize)
	    },
      	handleCurrentChange(val) {
      		this.currentPage = val;
        	this.getList(val)
      	},

    },
   
	components:{
		vDateRange,
		vVechicleSelect,
		alareCoreModule,
		alarmCoreDefault,
		alarmCoreMix
	}
}
</script>
<style lang="scss" >
	.tab_wrap{
		padding-left: 20px;
	}
	.tab_wrap>.el-tabs__header{
		margin: 0;
	}
	.tab_wrap .el-tabs__item.is-active{
		background: #fff;
	}
</style>