alarmIgnore.vue 7.36 KB
<template>
	<v-layout>
		<template slot="breadcrumb" style="position: relative">
			<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>
					<!-- 车辆分组分类组件 /-->
					<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" min-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="ignoreTime" label="忽略时间" min-width="160" align="center"></el-table-column>
						<el-table-column fixed="right"  label="操作" width="140" align="center">
							<template slot-scope="scope">
								<el-row>
					      			<el-col :span="12">
						        		<el-button @click="openDetail(scope.row)" type="text" size="medium">详情</el-button>
					      			</el-col>
					      			<el-col :span="12">
										<el-button type="text" size="medium" @click="cancelIgnore(scope.row.vehicleId)">取消忽略</el-button>
					      			</el-col>
					      		</el-row>
							</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: {
				date: moment().subtract(1, 'days'),
		        classIdList: '',
		        groupId: '',
		        queryType: 'sqbh',
		        queryTerm: ''
			},
			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.getAlarmIgnoreList(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;
			}
			const queryTerm = form.queryTerm.trim();
			if(queryTerm){
				params[form.queryType] = queryTerm;
			}
			
			return params;
		},
		
		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 = 'attentionCenter/exportIgnore';
      		
      		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');
      	},
      	cancelIgnore(vehicleId){
      		REPORT_SERVICE.toggleAlarmItemStatus({
      			vehicleId,
      			status: 0
      		}).then((result)=>{
	        	if(result.returnCode == 0){
	        		this.$message({
    					type: 'success',
    					message: '取消忽略成功'
    				});
    				this.getData();
	        	}else{
	        		this.$message({
    					type: 'error',
    					message: '取消忽略失败'
    				});
	        	}
	        })
      	},
      	renderHeader(h, { column, $index }) { 
			const self = this;
	        return [
	            h('span', '工单号/姓名/设备号'),
	            h('br'),
	            h('span', '车架号'),
	        ];
	    }
    },
	components:{
		vDateRange,
		vVechicleSelect
	}
}
</script>
<style scoped>
	
</style>