lastLocation.vue 11 KB
<template>
  <div class="">

    <div class="page_title">
      <h2 class="h2">最后定位报表</h2>
      <h3 class="h3">用于统计和展示设备的最后定位情况</h3>
    </div>

    <!-- 搜索区域 开始 -->
    <div class="search_box">
      <el-form :inline="true" size="small">
        <el-form-item>
          <div class="pre_select_box">
            <el-select v-model="searchForm.queryTimeType" class="small_select mr5" placeholder="请选择">
              <el-option label="最后GPS定位时间" value="1"></el-option>
              <el-option label="最后基站时间" value="2"></el-option>
              <el-option label="激活时间" value="3"></el-option>
            </el-select>
            <el-date-picker v-model="searchForm.timeDate" class="data_picker" value-format="yyyy-MM-dd" type="daterange" range-separator="~" start-placeholder="开始日期" end-placeholder="结束日期">
            </el-date-picker>
          </div>
        </el-form-item>
        <el-form-item label="车辆归属:">
          <el-popover v-model="filterVisible" placement="bottom-start" width="400" trigger="click">
            <div>
              <glsx-organization @change="onChange"></glsx-organization>
            </div>
            <el-input v-model="searchForm.orgName" :placeholder="searchForm.specialShopName || '所属组织'" slot="reference" readonly clearable>
            </el-input>
          </el-popover>
        </el-form-item>
        <el-form-item label="设备类型:">
          <el-select v-model="searchForm.deviceTypeAndSource" class="small_select">
            <el-option label="全部" value=""></el-option>
            <el-option label="GPS/有线" value="8-1"></el-option>
            <el-option label="GPS/无线" value="8-0"></el-option>
            <el-option label="OBD/OBD" value="1-1"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="关键字">
          <el-input v-model="searchForm.keywords" class="long_input" placeholder="工单号|设备号|车架号|姓名"></el-input>
        </el-form-item>
        <el-form-item>
          <template slot="label">
            <el-tooltip class="item" effect="dark" placement="top">
              <div slot="content">
                <p>最后定位数据过滤:</p>
                <p>仅统计该账号权限下,对应车辆“最后定位时间”并且配合展示定位类型,方便平台使用者进行区分</p>
              </div>
              <i class="el-icon-question"></i>
            </el-tooltip>
            <span>最后定位数据过滤:</span>
          </template>
          <el-switch v-model="showColumn">
          </el-switch>
        </el-form-item>
        <el-form-item>
          <el-button icon="el-icon-search" type="primary" @click="getList()">搜索</el-button>
        </el-form-item>
        <el-form-item>
          <el-button icon="el-icon-refresh" type="default" @click="rest()">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <!-- 搜索区域 end -->

    <!-- 操作区域 开始 -->
    <div class="links_group">
      <span class="name">最后定位信息</span>
      <el-button type="primary" size="small" icon="el-icon-download" :loading="dloading" @click="downloadExcel()">导出excel</el-button>
    </div>
    <!-- 操作区域 end -->

    <!-- 表格区域 开始 -->
    <div class="table_box">
      <el-table class="el_table" :data="tableData" border size="small" v-loading="tloading">
        <el-table-column label="工单号" prop="workOrderNo"></el-table-column>
        <el-table-column label="店面名称" prop="shopName"></el-table-column>
        <el-table-column label="姓名" prop="ownerName"></el-table-column>
        <el-table-column label="车架号" prop="vin"></el-table-column>
        <el-table-column label="设备号" prop="sn"></el-table-column>
        <el-table-column label="设备类型" prop="modelName">
          <template slot-scope="{row}">{{(row.deviceTypeStr||'') + (row.sourceStr && row.deviceTypeStr?'/':'') + row.sourceStr}}</template>
        </el-table-column>
        <el-table-column label="激活时间" prop="activeDate"></el-table-column>
        <template v-if="!showColumn">
          <el-table-column label="最后GPS定位时间" prop="finalGpsTime"></el-table-column>
          <el-table-column label="最后基站定位时间" prop="finalBsTime"></el-table-column>
        </template>
        <template v-if="showColumn">
          <el-table-column label="最后定位时间" prop="lastPoiTime"></el-table-column>
          <el-table-column label="最后定位类型" prop="poiType"></el-table-column>
          <el-table-column label="最后定位地址" prop="lastPoiAddress"></el-table-column>
        </template>
        <el-table-column label="操作" fixed="right" align="center" width="180px">
          <template slot-scope="{row}">
            <el-link class="el_link" type="primary" @click="lookLocation(row)" v-if="row.gpsLng || row.bsLng">查看定位位置</el-link>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination_list">
        <el-pagination background layout="sizes, total,prev, pager, next, jumper" :total="pageTotal" :page-size="pageSize" :page-sizes="pageSizes" @current-change="getList" @size-change="changePageSize" />
      </div>
    </div>
    <!-- 表格区域 end -->

  </div>
</template>
<script>
import moment from "moment";
import GlsxOrganization from "@/components/glsx-organization";
import {
  GET_FINALPOSITIONING_SEARCH,
  GET_FINALPOSITIONING_EXPORT,
} from "@/services/report";
import { deepClone, showToast } from "@/utils/util";
import store from "@/store";
import qs from "qs";
export default {
  components: {
    GlsxOrganization,
  },
  data() {
    return {
      showColumn: false,
      searchForm: { queryTimeType: "1" },
      currentPage: 1,
      pageSizes: [10, 20, 30, 40],
      pageSize: 10,
      pageTotal: 0,
      tableData: [],
      showDialog: false,
      uploadFile: {},
      showResult: false,
      loading: false,
      pickerOptions: {
        shortcuts: [
          {
            text: "全部",
            onClick(picker) {
              const end = "";
              const start = "";
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "昨日",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 1);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "本周",
            onClick(picker) {
              const end = moment().format("YYYY-MM-DD");
              const start = moment().weekday(1).format("YYYY-MM-DD");
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "上周",
            onClick(picker) {
              let weekOfDay = parseInt(moment().format("E"));
              const end = moment()
                .subtract(weekOfDay, "days")
                .format("YYYY-MM-DD");
              const start = moment()
                .subtract(weekOfDay + 7 - 1, "days")
                .format("YYYY-MM-DD");
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "本月",
            onClick(picker) {
              const start = moment().add("month", 0).format("YYYY-MM") + "-01";
              const end = moment().format("YYYY-MM-DD");
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "上月",
            onClick(picker) {
              const end = moment()
                .month(moment().month() - 1)
                .endOf("month")
                .format("YYYY-MM-DD");
              const start = moment()
                .month(moment().month() - 1)
                .startOf("month")
                .format("YYYY-MM-DD");
              picker.$emit("pick", [start, end]);
            },
          },
        ],
      },
      filterVisible: false,
      orgInfo: {},
      dloading: false,
      tloading: false,
    };
  },
  created() {
    let o = history.state;
    if (o.alarmStatus) {
      let n = moment().format("YYYY-MM-DD");
      this.$set(this.searchForm, "timeDate", [n, n]);
      this.$set(this.searchForm, "alarmStatus", o.alarmStatus);
    }
  },
  mounted() {
    this.getList();
  },
  methods: {
    // 重置
    rest() {
      this.searchForm = {};
      this.getList();
    },

    // 获取查询参数
    getParams() {
      let oParams = deepClone(this.searchForm);
      let m = oParams.timeDate;
      let i = oParams.queryTimeType;
      let timeStartList = {
        1: "finalGpsTimeStart",
        2: "finalBsTimeStart",
        3: "activeDateStart",
      };
      let timeEndList = {
        1: "finalGpsTimeEnd",
        2: "finalBsTimeEnd",
        3: "activeDateEnd",
      };
      if (m && m.length > 0) {
        oParams[timeStartList[i]] = m[0];
        oParams[timeEndList[i]] = m[1];
      }

      delete oParams.timeDate;
      delete oParams.queryTimeType;

      delete oParams.orgName;
      delete oParams.timeDate;
      return oParams;
    },

    // 获取数据列表
    getList(current) {
      let oParams = this.getParams();
      oParams.pageSize = this.pageSize;
      oParams.pageNumber = current || this.currentPage;
      this.tloading = true;
      GET_FINALPOSITIONING_SEARCH(oParams).then((res) => {
        this.tloading = false;
        let obj = res.data || {};
        this.tableData = obj.list;
        this.pageTotal = obj.totalElements;
      });
    },

    //每页展示
    changePageSize(e) {
      this.pageSize = e;
      this.getList();
    },

    // 监听树
    onChange(e) {
      this.filterVisible = false;
      console.log(e);
      if (e) {
        this.orgInfo = e.origin;
        this.searchForm.orgId = e.origin.orgId;
        this.searchForm.orgType = e.origin.type;
        this.searchForm.orgName = e.origin.orgName;
      }
    },

    // 导出excel
    downloadExcel() {
      let _this = this;
      let oParams = this.getParams();
      _this.dloading = true;
      GET_FINALPOSITIONING_EXPORT(oParams).then((res) => {
        _this.dloading = false;
        if (res.code != 200) {
          return false;
        }
        window.open(res.data);
      });
    },

    // 查看定位位置点
    lookLocation(row) {
      let oParams = { ...row };
      oParams.lng = row.gpsLng;
      oParams.lat = row.gpsLat;
      oParams.address = row.lastGpsAddress;
      oParams.name = row.ownerName;
      oParams.standNo = row.vin;
      oParams.time = row.finalGpsTime;
      oParams.bsLng = row.bsLng;
      oParams.bsLat = row.bsLat;
      oParams.bsAddress = row.lastBsAddress;
      oParams.bsTime = row.finalBsTime;
      oParams.type = 2;
      let path = `/oEshield#/monitor/activeLocation?${qs.stringify(oParams)}`;
      // history.pushState(oParams, "定位位置点", path);
      window.open(path)
    },
  },
};
</script>
<style lang="scss" scoped>
@import "@/styles/hadoop.scss";
</style>