index.vue 5.64 KB
<!-- 车辆管理 -->
<template>
  <d2-container class="reportingLogs">
    <el-form
      :inline="true"
      :model="searchForm"
      label-width="85px"
      slot="header"
    >
      <el-form-item label="上报时间">
        <el-date-picker
          v-model="searchForm.reportTime"
          type="daterange"
          value-format="yyyy-MM-dd"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="车辆编号">
          <el-input v-model="searchForm.trafficCode" placeholder="请输入车辆编号" clearable @clear="loadingGetList"></el-input>
      </el-form-item>
      <el-form-item label="归属车辆段">
          <el-select v-model="searchForm.stationCode" placeholder="请选择" clearable filterable @clear="loadingGetList">
            <el-option v-for="(item, index) in baseData.station"
              :key="index"
              :value="item.confCode"
              :label="item.confValue"
            ></el-option>
          </el-select>
      </el-form-item>
      <el-form-item label="子系统编号">
          <el-input v-model="searchForm.subSystemCode" placeholder="请输入子系统编号" clearable @clear="loadingGetList"></el-input>
      </el-form-item>
      <el-form-item>
          <el-button type="primary"  icon="el-icon-search" @click="handleSearch">查询</el-button>
      </el-form-item>
    </el-form>
    <el-row style="height: 40px; line-height: 40px">
        <el-col :span="12">上报日志列表</el-col>
        <!-- <el-col :span="12" style="text-align: right">
          <auth-button category="Button"></auth-button>
        </el-col> -->
    </el-row>
    <el-table
      :data="tableData"
      v-loading="tableLoading"
      border
      style="margin: 20px 0;"
    >
      <el-table-column
        align="center"
        width="60px"
        label="序号"
        type='index'
      ></el-table-column>
      <el-table-column
        v-for="(item, index) in tableColumns"
        :key="index"
        :label="item.label"
        :prop="item.prop"
        :width="item.width"
        align="center"
      >
      </el-table-column>
    </el-table>
    <el-pagination
      background
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[10,20,30,40]"
      :page-size="pageSize"
      :total="total"
      layout="sizes,total,->,prev,pager,next,jumper"
    >
    </el-pagination>
  </d2-container>
</template>

<script>
import { getLogsApi, exportApi } from '@api/reportingLogs'
import { BaseData } from '@/common/constants'
import notice from '@/common/notice'
export default {
  name: 'FimsReportingLogs',
  data () {
    return {
      tableLoading: false,
      searchForm: {
        // beginTime: '',
        // endTime: '',
        reportTime: '',
        trafficCode: '',
        stationCode: '',
        subSystemCode: ''
      },
      tableData: [],
      tableColumns: [{
        label: '上报时间',
        prop: 'reportTime'
      }, {
        label: '车辆编号',
        prop: 'trafficCode'
      }, {
        label: '归属车辆段',
        prop: 'stationName'
      }, {
        label: '子系统编号',
        prop: 'subSystemCode'
      }, {
        label: '子系统类型',
        prop: 'subSystemType'
      }, {
        label: '子系统厂家',
        prop: 'merchantName'
      }, {
        label: '上报内容',
        prop: 'reportValue'
      }],
      // 页码
      currentPage: 1,
      pageSize: 10,
      total: 30,
      baseData: {
        station: []
      }
    }
  },

  watch: {
    'searchForm.reportTime' (value) {
      !value && this.loadingGetList()
    }
  },

  mounted () {
    this.loadingGetList()
    this.loadBaseData()
  },

  methods: {
    async loadBaseData () {
      const data = await this.$store.dispatch('d2admin/base/get', BaseData.STATION.KEY)
      this.baseData.station = data
    },

    loadingGetList () {
      this.tableLoading = true
      this.getList()
    },
    getParams () {
      return Object.assign(
        {
          pageCount: this.pageSize,
          pageSize: this.currentPage
        },
        this.searchForm
      )
    },
    getList () {
      const params = this.getParams()
      params.startTime = params.reportTime ? params.reportTime[0] + ' ' + '00:00:00 ' : ''
      params.endTime = params.reportTime ? params.reportTime[1] + ' ' + '23:59:59' : ''
      delete params.reportTime
      getLogsApi(params).then(res => {
        // res.pagination && (this.total = res.pagination.totalCount)
        this.tableData = res.loges
        this.total = res.pagination.totalCount
        this.tableLoading = false
      })
        .catch(() => {
          this.tableLoading = false
          notice.errorTips()
        })
    },

    handleExport () {
      const params = this.getParams()
      params.startTime = params.reportTime ? params.reportTime[0] + ' ' + '00:00:00 ' : ''
      params.endTime = params.reportTime ? params.reportTime[1] + ' ' + '23:59:59' : ''
      delete params.reportTime
      exportApi(params).then(res => {
        // console.log(res)
        // window.location.href = res.url
        this.$open(res.url)
        notice.okTips()
      }).catch(() => {
        notice.errorTips()
      })
    },

    // 搜索
    handleSearch () {
      this.loadingGetList()
    },

    // 页码
    handleSizeChange (value) {
      this.pageSize = value
      // 调接口
      this.loadingGetList()
    },

    handleCurrentChange (value) {
      this.currentPage = value
      // 调接口
      this.loadingGetList()
    }
  }
}

</script>
<style scoped>
</style>