lastLocation.vue 12.8 KB
<template>
	<v-layout>
		<template slot="breadcrumb">
			<el-breadcrumb-item>统计报表</el-breadcrumb-item>
			<el-breadcrumb-item>最后定位列表</el-breadcrumb-item>
		</template>
		<template slot="main">
			<div class="ibox ibox-search">
				<el-form>
					<el-form-item>
						<el-select v-model="query.dateType" class="pull-left" style="width: 160px;margin-right:5px;" placeholder="请选择" size="small">
					      <el-option label="最后GPS定位时间" value="1"></el-option>
					      <el-option label="最后基站定位时间" value="2"></el-option>
					    </el-select>
						<!-- 时间范围选择组件 -->
		            	<v-date-range 
		            		class="pull-left"
		            		:date="query.dateRange" 
		            		activeType="all"
		            		ref="dateRange"
		            		:options="['all','last3', 'last7', 'thisMonth']"  
		            		@onDateRangeChange="(arr)=>query.dateRange=arr">
		            	</v-date-range>
		            	<!-- 时间范围选择组件 -->
					</el-form-item>
					<el-form-item label="激活时间:">
						<!-- 时间范围选择组件 -->
		            	<v-date-range 
		            		:date="query.activeDateRange" 
		            		activeType="all"
		            		ref="activeDateRange"
		            		:options="['all','last3', 'last7', 'thisMonth']"  
		            		@onDateRangeChange="(arr)=>query.activeDateRange=arr">
		            	</v-date-range>
		            	<!-- 时间范围选择组件 -->
					</el-form-item>
				</el-form>
				<el-form :inline="true">
					<!-- 车辆分组分类组件 -->
					<v-vechicle-select ref="vechicle" label="车辆分组/分类:" @onVechicleChange="vechicleChange"></v-vechicle-select>
					<!-- 车辆分组分类组件 /-->
					<el-form-item label="设备类型:">
						<el-select v-model="query.deviceModel" style="width: 80px;" size="small">
					      <el-option label="全部" value=""></el-option>
					      <el-option label="有线" value="1"></el-option>
					      <el-option label="无线" value="2"></el-option>
					    </el-select>
					</el-form-item>
					<el-form-item>
						<el-input placeholder="请输入对应条件值" v-model="query.queryTerm" size="small" class="input-with-select" clearable>
						    <el-select v-model="query.queryType" slot="prepend" style="width:100px;" placeholder="请选择" size="small">
						      <el-option label="申请单号" value="sqbh"></el-option>
						      <el-option label="店面名称" value="shopName"></el-option>
						      <el-option label="姓名" value="name"></el-option>
						      <el-option label="车架号" value="standno"></el-option>
						      <el-option label="设备号" value="sn"></el-option>
						    </el-select>
						</el-input>
					</el-form-item>	
					<el-form-item>
						<el-switch v-model="query.isIntelligence" active-color="#094" inactive-color="#ccc"></el-switch>
						<span style="margin-right: 15px;">
							最后定位数据过滤
							<el-tooltip class="item" effect="dark" placement="top">
								<div slot="content">
									<p>最后定位数据过滤:</p>
									<p>仅统计该账号权限下,对应车辆“最后定</p>
									<p>位时间”并且配合展示定位类型,方便平</p>
									<p>台使用者进行区分</p>
								</div>
								<i class="el-icon-question el-icon--right"></i>
							</el-tooltip>
						</span>
						<el-button type="primary" size="small" @click="onSubmit">搜索</el-button>
            			<el-button type="primary" size="small" @click="tableReset">重置</el-button>
            		</el-form-item>
				</el-form>
			</div>
            <div class="ibox">
            	<div class="ibox-title">
            		<h3 class="pull-left">最后定位列表</h3>
            		<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 prop="sqbh" label="申请单号" min-width="160" align="center"></el-table-column>
						<el-table-column fixed prop="shopName" label="店面名称" min-width="200" align="center"></el-table-column>
						<el-table-column fixed prop="name" label="姓名" min-width="180" align="center"></el-table-column>
						<el-table-column prop="standno" label="车架号" min-width="160" align="center"></el-table-column>
						<el-table-column prop="sn" label="设备号" min-width="120" align="center"></el-table-column>
						<el-table-column prop="deviceModel" label="设备型号" min-width="140" align="center">
					    	<template slot-scope="scope">
					        	<span v-if="scope.row.deviceModel=='1'" class="ing">有线</span>
					        	<span v-if="scope.row.deviceModel=='2'" class="stop">无线</span>
					      	</template>
					    </el-table-column>  
						<el-table-column prop="activeDate" label="激活时间" min-width="240" align="center"></el-table-column>
						<el-table-column v-if="!query.isIntelligence" prop="finalGPSPositioningTime" key="finalGPSPositioningTime"  label="最后GPS定位时间" min-width="240" align="center"></el-table-column>
						<el-table-column v-if="!query.isIntelligence" prop="finalRTPositioningTime" key="finalRTPositioningTime"  label="最后基站定位时间" min-width="240" align="center"></el-table-column>
						<el-table-column v-if="query.isIntelligence" prop="lastPoiTime" key="lastPoiTime" label="最后定位时间" min-width="240" align="center"></el-table-column>
						<el-table-column v-if="query.isIntelligence" prop="poiType" key="poiType" label="最后定位类型" min-width="120" align="center"></el-table-column>
						<el-table-column v-if="query.isIntelligence" prop="lastAddress" key="lastAddress" label="最后定位地址" min-width="240" align="center"></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: [],
			selectedIds: [],
			query: {
				dateType: '1',
				dateRange: [],
				activeDateRange: [],
				deviceModel: '',
				queryTerm: '',
				queryType: 'sqbh',
				groupId: '',
				classId: '',
				isIntelligence: false
			}
		}
	},
	created(){
		this.getData();

	},
	computed: {
		
	},
	watch: {
		'query.isIntelligence'(){
			this.onSubmit()
		}
	},
	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.finalPostioning(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;
			});
			REPORT_SERVICE.finalTotal(param).then((response)=>{
				if(response.data){
					//this.tableData = response.data;
					this.total = response.data;
				}else{
					//this.tableData = [];
					this.total = 0;
				}
				//this.loading = false;
			});
		},
		getParams(){
			const query = this.query;
			const params = {};
			
			if(query.groupId){
				params.groupId = query.groupId
			}
			if(query.classId){
				params.classId = query.classId
			}
			if(query.dateRange&&query.dateRange.length){
				if(query.dateType === '1'){
					params.finalGPSPositioningTimeStart = moment(query.dateRange[0]).format('YYYY-MM-DD HH:mm:ss');
					params.finalGPSPositioningTimeEnd = moment(query.dateRange[1]).endOf('day').format('YYYY-MM-DD HH:mm:ss')
				}else if(query.dateType === '2'){
					params.finalRTPositioningTimeStart = moment(query.dateRange[0]).format('YYYY-MM-DD HH:mm:ss');
					params.finalRTPositioningTimeEnd = moment(query.dateRange[1]).endOf('day').format('YYYY-MM-DD HH:mm:ss')
				}
			}
			if(query.activeDateRange&&query.activeDateRange.length){
				params.activeDateStart = moment(query.activeDateRange[0]).format('YYYY-MM-DD HH:mm:ss');
				params.activeDateEnd = moment(query.activeDateRange[1]).endOf('day').format('YYYY-MM-DD HH:mm:ss')
			}
			if(query.queryTerm){
				params[query.queryType] = query.queryTerm
			}
			params.deviceModel = query.deviceModel;

			params.filterFlag = query.isIntelligence?1:0

			return params;
		},
		tableReset(){
			this.query = {
				dateType: '1',
				dateRange: [],
				activeDateRange: [],
				deviceModel: '',
				queryTerm: '',
				queryType: 'sqbh',
				groupId: '',
				classId: ''
			}
			this.$refs.vechicle.resetSelet();
			this.$refs.dateRange.reset();
			this.$refs.activeDateRange.reset();
		},
		renderHeaderInput: function (h, { column, $index }) { 
			const self = this;
	        return h(
	          'p',{
	          	class: 'table-header-ctrl'
	          },[
	            h('span', [column.label]),
	            h('br'),
	            h('el-input', {
	            	props: {
	            		size: 'mini',
	            		value: self.query[column.property]
	            	},
	            	on: {
                        input(query) {
                           self.query[column.property] = query;
                        }
                    }
	            })
	          ]
	        );
	    },
	    renderDatePicker: function (h, { column, $index }) { 
			const self = this;
			const result = h('el-date-picker', {
            	props: {
            		size: 'mini',
            		type: 'daterange',
            		placeholder: '',
            		value: self.query[column.property]
            	},
            	on: {
                    input(val) {
                       self.query[column.property] = val;
                    }
                }
            })
			return h(
	          'p',{
	          	class: 'table-header-ctrl'
	          },[
	            h('span', [column.label]),
	            result
	          ]
	        );
	    },
	   	renderSelect(h, { column, $index }){
	    	const self = this;
	        return h(
	          'p',{
	          	class: 'table-header-ctrl'
	          },[
	            h('span', [column.label]),
	            h('br'),
	            h('el-select', {
	            	props: {
	            		size: 'mini',
	            		value: self.query.deviceModel
	            	},
	            	on: {
                        change(val) {
                        	self.query.deviceModel = val;

                        }
                    }
	            },[
	            	h('el-option', {
	            		props: {
	            			value: '0',
	            			label: '全部'
	            		}
	            	}),
	            	h('el-option', {
	            		props: {
	            			value: '1',
	            			label: '有线'
	            		}
	            	}),
	            	h('el-option', {
	            		props: {
	            			value: '2',
	            			label: '无线'
	            		}
	            	})
	            ])
	          ]
	        );
	    },
		selectChange(selection){
			this.selectedIds = [];
			selection.map((obj)=>{
				this.selectedIds.push(obj.trackerId)
			});
			
		},
		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 = 'finalPostioning/exportFinalPositingList';
      		
      		if(this.selectedIds.length){
      			exportExcel(url, {idList: this.selectedIds.join(',')})
      		}else{
      			exportExcel(url, this.getParams())
      		}
      	},
      	vechicleChange(groupId, classId){
			this.query.groupId = groupId;
			this.query.classId = classId;
		}
    },
	components:{
		vDateRange,
		vVechicleSelect
	}
}
</script>
<style lang="scss">
	
</style>