alarmDispose.vue 9.19 KB
<template>
	<v-layout>
		<template slot="breadcrumb">
			<div style="width: 100%;height: 100%;z-index: 1000;"></div>
			<el-breadcrumb-item>统计报表</el-breadcrumb-item>
			<el-breadcrumb-item>警情配置(广汽)</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" style="padding: 0">
				<!-- 表单查询 -->
				<el-form :inline="true" :model="form" ref="form"  >
					<div style="width: 100%; border-bottom: 1px solid #e7eaec;">
						<div class="ibox-title" style="padding-bottom: 0">
	            			<h3 class="pull-left" style="margin-top:5px;margin-left:20px;padding:18px;border-bottom: 2px solid #094;">配置列表</h3>
	            		</div>
            		</div>
					<!-- 项目分组 -->
					<el-form-item class='seachFrist'>
						<el-select v-model='form.groupName' placeholder="项目分组" size="small" @change="getLabel">
						    <el-option
						        v-for="(item,index) in options"
						        :key="index"
						        :label="item.lable"
						        :value="item.value"
							></el-option>
					    </el-select>
						
					</el-form-item>	
					<!-- 报警类型分类 /-->
					<el-form-item  style=
					"margin-top: 20px;">
					    <el-select v-model="form.alarmType" placeholder="报警类型" size="small">
					    	<el-option label="电量报警" value="0"></el-option>
					    	<el-option label="超时报警" value="1"></el-option>
					    	<el-option label="离线超时报警" value="2"></el-option>
					    	<el-option label="设备报警" value="3"></el-option>
							<el-option label="设备分离报警" value="10"></el-option>
							<el-option label="出省报警(经销商)" value="9"></el-option>
							<el-option label="区域报警(个人)" value="12"></el-option>
					    	<!-- <el-option label="二押区域报警" value="4"></el-option>
					    	<el-option label="翻转报警" value="5"></el-option>
					    	<el-option label="高危区域报警" value="6"></el-option>
					    	<el-option label="出国报警" value="7"></el-option>
					    	<el-option label="出入边境省份预警" value="8"></el-option>
					    	   -->
					    </el-select>
					</el-form-item>	
					<el-form-item style=
					"margin-top: 20px;" label="规则名称">
						<el-input placeholder="请输入规则名称" v-model="form.ruleName" size="small" class="input-with-select" clearable>
						</el-input>
					</el-form-item>		
					<el-form-item  class='search'>
					    <el-button type="primary" @click="onSubmit" size="small">查询</el-button>
					</el-form-item>
					<el-form-item  class='search'>
						<el-button type="primary" @click="resetForm('form')" size="small">重置</el-button>
					</el-form-item>
					<el-form-item class='search'>
						<el-button type="primary" @click="newAlarmDispose('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">批量导出&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 prop="ruleName" label="规则名称" min-width="160" align="center"></el-table-column>
						<el-table-column fixed prop="alarmType" label="报警类型" min-width="160" align="center"></el-table-column>
						<el-table-column prop="projectType" label="项目分组" min-width="100" align="center"></el-table-column>
						<el-table-column fixed prop="alarmLevel" label="报警级别" min-width="180" align="center"></el-table-column>
						<el-table-column prop="alarmCondition" label="报警条件" min-width="120" align="center"></el-table-column>
						<el-table-column prop="setTime" label="设置日期" min-width="100" align="center"></el-table-column>
						<el-table-column fixed="right"  label="操作" min-width="160" align="center">
							<template slot-scope="scope">
								<el-button @click='editAlarm(scope.row.id)' type="text" size="medium">修改</el-button>
								<el-button @click='delet(scope.row.id)' 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>
			<alarm-dispose-module @getData = 'getData' :detailFormVisible="detailFormVisible" :detailForm="detailForm" @onAlarmDisposeModuleChange="alarmDisposeModule" :optionsData='optionsData' :dataId='id'></alarm-dispose-module>
		</template>
	</v-layout>
</template>
<script>
const vVechicleSelect = () => import(/* webpackChunkName: "vVechicleSelect" */ 'components/VechicleSelect.vue');
import alarmDisposeModule from './alarmDisposeModule'
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: [],
			options:[],
			optionsData:[],
			form: {
				groupName:'',
		        alarmType: '',
		        ruleName: ''
			},
			labelName:'',
			id:'',
			detailForm:{},
			detailFormVisible: false,
			selectedIds: []
		}
	},
	created(){
		this.getData();
		this.gqQueryTerm();
	},
	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();
			let param=this.getParams();
			params.currentPage = curr;
			params.pageSize = size;
			REPORT_SERVICE.gqAlarmCenterList(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;
			});
		},
		gqQueryTerm(){
			REPORT_SERVICE.gqQueryTerm({queryId:3}).then((response)=>{
				this.options = response.data
				this.optionsData = response.data
			});
		},
		getLabel(val){
		  let obj = {};
		  obj = this.options.find((item)=>{
		     return item.value === val;
		  });
		  this.labelName = obj.lable;
		  console.log(this.labelName)
		},
		resetForm(formName) {
        	this.form.groupName =''
		    this.form.alarmType =''
		    this.form.ruleName =''
		    this.labelName = ''
		},
		newAlarmDispose(){
			this.id= '';
			this.detailFormVisible = true;
		},
		getParams(){
			const form = this.form;
			const params = {};
			if(this.labelName){
				params.groupName = this.labelName;
			}
			if(form.alarmType){
				params.alarmType = form.alarmType;
			}
			if(form.ruleName){
				params.ruleName = form.ruleName;
			}
			return params;
		},
		selectChange(selection){
			this.selectedIds = [];
			selection.map((obj)=>{
				this.selectedIds.push(obj.id)
			});
		},
		alarmDisposeModule(isOpen){
	    	this.detailFormVisible = isOpen
	    },
		delet(id){
			this.$confirm('确定要删除该配置吗?', '提示', {
	          confirmButtonText: '确定',
	          cancelButtonText: '取消',
	          type: 'warning'
	        }).then(() => {
		          REPORT_SERVICE.deleteAlarmRule({id: id}).then((res)=>{
		          	if(res.returnCode == 0){
		          		this.$message({
				          	message: res.message,
				          	type: 'success'
				        });
				        this.getData()
		          	}
		          });
	        });
		},
		editAlarm(id){
			REPORT_SERVICE.getAlarmRuleById({id: id}).then((res)=>{
	          	if(res.returnCode == 0){
	          		this.id = id;
	          		this.detailForm = res.data;
			        this.detailFormVisible = true;
	          	}
		    });
		},
		handleSizeChange(val) {
	      	this.pageSize = val;
	        this.getData(this.currentPage,this.pageSize)
	    },
      	handleCurrentChange(val) {
      		this.currentPage = val;
        	this.getData(val)
      	},
      	onSubmit(){
      		this.currentPage = 1;
      		this.pageSize = 10;
      		this.getData();
      	},
      	exportExcel(){
      		const url = 'gqAlarmCenter/exportGqAlarmRule';
      		if(this.selectedIds.length){
      			exportExcel(url, {idList: this.selectedIds.join(',')})
      		}else{
      			exportExcel(url, this.getParams())
      		}
      	}
    },
	components:{
		alarmDisposeModule,
		vVechicleSelect
	}
}
</script>
<style lang="scss" scoped>
	.seachFrist{
		padding-left:20px;
		margin-top: 20px;
	}
	.search{
		margin-top: 20px;
	}
</style>