driverDetail.vue 8.13 KB
<template>
  <div class="system-container">
    <div class="container">
      <h1>试驶详情汇总</h1>

      <!-- 搜索区域 开始 -->
      <div class="search_box">
        <el-form :model="searchForm" :inline="true" size="small">
          <el-form-item label="关键字:">
            <el-input v-model="searchForm.keywords" class="a_input" placeholder="特约店编码|店名称|车牌号|设备号"></el-input>
          </el-form-item>
          <el-form-item label="试驾是/否有效:">
            <el-select v-model="searchForm.validDriveType" placeholder="请选择">
              <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 label="日期:">
            <el-date-picker v-model="timeDate" type="daterange" unlink-panels range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd" :picker-options="pickerOptions">
            </el-date-picker>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="getList()">搜索</el-button>
            <el-button type="primary" icon="el-icon-refresh" size="mini" @click="rest()">重置</el-button>
          </el-form-item>
          <!-- <el-form-item>
            
          </el-form-item> -->
        </el-form>
      </div>
      <!-- 搜索区域 end -->

      <!-- 按钮区域 开始 -->
      <div class="links_group">
        <span>试驾详情</span>
        <el-button class="pull-right" type="primary" icon="el-icon-download" size="mini" :loading="dloading" @click="downloadExcel()">导出Excel</el-button>
      </div>
      <!-- 按钮区域 end -->

      <!-- 列表 开始 -->
      <glsx-table ref="glsxTable" v-loading="loading" :list="tableData" :column="columnList" :pageTotal="pageTotal" @change="getList">
        <div slot="operate" slot-scope="{scope}">
          <!-- <el-button size="mini" :id="scope.id">试驾轨迹</el-button> -->
          <el-link type="primary" :unline="false" :id="scope.id" @click="lookTrack(scope)">试驾轨迹</el-link>
        </div>
      </glsx-table>
      <!-- 列表 end -->
    </div>
  </div>
</template>

<script>
import GlsxTable from "@/components/glsx-table";
import { DRIVE_DETAIL_SEARCH, DRIVE_STATISTICS_EXPORT } from "services/report";
import moment from "moment";
import { deepClone } from "@/utils/util";
export default {
  data() {
    return {
      searchForm: {keywords:this.$route.query.vin},
      loading: false,
      tableData: [],
      columnList: [
        { label: "特约店编码", prop: "account", align: "center" },
        { label: "特约店名称", prop: "username" },
        { label: "车牌号", prop: "licensePlate" },
        { label: "车架号", prop: "vin" },
        { label: "设备号", prop: "sn" },
        { label: "车型", prop: "typeName" },
        { label: "开始时间", prop: "journeyBeginTime" },
        { label: "结束时间", prop: "journeyEndTime" },
        { label: "是否有效", prop: "valid",formatter:row => {return row.valid?'是':'否'} },
        { label: "无效原因", prop: "reason",formatter:row => {return row.reason?row.reason:'--'} },
      ],
      pageTotal: 0,
      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]);
            },
          },
        ],
      },
      dloading: false,
      timeDate: [],
    };
  },
  components: {
    GlsxTable,
  },
  watch:{
    '$route.query':{
      handler:function(n,o){
        console.log(n)
        this.searchForm.keywords = n.vin;
        this.timeDate = n.day?[n.day,n.day]:[]
        this.getList()
      },
      immediate: true,
    }
  },
  created(){
    let o = this.$route.query;
    this.timeDate = o.day?[moment(o.day).format('yyyy-MM-DD'),moment(o.day).format('yyyy-MM-DD')]:[]
  },
  mounted() {
    this.getList();
  },
  methods: {
    // 获取查询参数
    getParams() {
      let oParams = deepClone(this.searchForm);
      let o = this.timeDate || [];

      if (o && o.length > 0) {
        oParams.sDate = o[0];
        oParams.eDate = o[1];
      }

      oParams.vin = this.$route.query.vin

      return oParams;
    },

    // 获取列表
    getList(options) {
      let oParams = this.getParams();
      console.log(this.$refs.glsxTable.pageSize)
      oParams.pageSize = this.$refs.glsxTable.pageSize;
      oParams.pageNumber = options ? options.pageNumber || 1 : 1;
      this.loading = true
      DRIVE_DETAIL_SEARCH(oParams).then((res) => {
        this.loading = false
        let { data } = res;
        let { list, totalElements } = data;
        this.pageTotal = totalElements;
        this.tableData = list;
      }).catch(error => {
        this.loading = false
      });
    },

    // 查看详情
    lookDetail(row) {
      console.log(row);
      this.$router.push({ name: "mileageDetail" });
    },

    // 导出excel
    downloadExcel() {
      let _this = this;
      let oParams = this.getParams();
      _this.dloading = true;
      _this.$Common.exportExcel({
        url: `${_this.$store.state.baseURL}${DRIVE_STATISTICS_EXPORT}`,
        method: "GET",
        data: oParams,
        fileName: "试驾详情报表",
        success: () => {
          _this.dloading = false;
        },
        fail: () => {
          _this.dloading = false;
        },
      });
    },

    // 重置
    rest(){
      this.timeDate = []
      this.searchForm = {};
      this.getList();
      this.$refs.glsxTable.rest();
    },

    // 查看轨迹
    lookTrack(row) {
      let path = `/oEshield#/monitor/replay?sn=${row.sn}&isInitFence=1&name=${row.ownerName}&standno=${row.vin}&startTime=${row.journeyBeginTime||''}&endTime=${row.journeyEndTime||''}&fenceId=${row.fenceId}`;
      //let query = {sn:row.sn,isInitFence:1,name:row.name,standno:row.vin};
      let query = {}
      //this.$router.push({path:path})
      // history.pushState(query, path, path);
      window.open(path)
    }

  },
};
</script>

<style lang="scss" scoped>
.pre_select {
  width: 100px;
}
.title_tips {
  font-size: 14px;
}
.links_group {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.search_box{
  .a_input{
    width:260px;
  }
}
</style>>