outStore.vue 4.49 KB
<template>
  <div class="system-container">
    <div class="container">
      <h1>无在店统计</h1>
      <div class="m-b-md">统计车辆在店情况,以自然日为时间单位判断车辆在店情况,统计报表中有数值代表车辆不在店</div>
      <search-form
        class="searchTop border-shadow"
        :formModel="searchForm"
        :formList="reportFormList"
      >
        <span
          class="inline-b"
          slot="form-slot"
        >
          <el-button
            type="primary"
            :size="btn_size"
            icon="el-icon-search"
            :id="reportTableParams.btnId"
          >搜索</el-button>
          <el-button
            type="primary"
            :size="btn_size"
            icon="el-icon-refresh"
            @click="refresh"
          >重置</el-button>

        </span>
      </search-form>
      <h3>
        无在店信息
        <el-button
          class="pull-right"
          type="primary"
          :size="btn_size"
          @click="btnClick('export')"
        >导出Excel</el-button>
      </h3>
      <basic-table
        ref="reportTable"
        :tableParams="reportTableParams"
        :beforeSearchFn="beforeSearchFn"
        :searchForm="searchDataForm"
        :getListApi="getListApi"
        @dataFinished="tableDataFinished"
        :hasNum="false"
      >
      </basic-table>
    </div>
  </div>
</template>

<script>
import { REPORT_API } from '@/config/config'
import store from '@/store'
import { getOutStoreList, getYears } from 'services/report'
export default {
  data() {
    const _this = this
    return {
      searchDataForm: {},
      searchForm: {},
      reportFormList: [
        {
          type: 'input',
          inputType: 'text',
          prop: 'keywords',
          placeholder: '特约店编码|店名称|车架号|车型',
        },
        {
          type: 'singleDate',
          dateType: 'month',
          prop: 'date',
          placeholder: '请选择年月',
          pickerOptions: {
            disabledDate(time) {
              return time.getTime() < new Date(_this.date).getTime()
            }
          }
        }
      ],
      reportTableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        tableOption: false,
        tableColumns: [
          {
            label: '特约店编码',
            prop: 'shopCode',
            fixed: true
          }, {
            label: '特约店名称',
            prop: 'shopName',
            fixed: true
          }, {
            label: '车型',
            prop: 'modelName',
            fixed: true
          }, {
            label: '设备号',
            prop: 'sn',
            width: 80,
            fixed: true
          }, {
            label: '车架号VIN码',
            prop: 'vin',
            width: 120,
            fixed: true
          },{
            label: '时间',
            prop: 'statDate',
            fixed: true
          }
        ]
      },
      getListApi: getOutStoreList,
      date: '',
      statDate: '',
    }
  },
  mounted() {
    getYears({}).then(res => {
      let m = res.data||[]
      let min = Math.min(...m)
      this.date = `${min}-01-01`
    })
    for (let i = 1; i <= 31; i++) {
      this.reportTableParams.tableColumns.push({
        label: `${i}日`,
        prop: `dayNum${i}`
      })
      if (i == 31) {
        this.reportTableParams.tableColumns.push({
          label: '总计',
          prop: 'summation'
        })
      }
    }

  },
  methods: {
    refresh() {
      this.searchForm = {}
      this.searchDataForm = {}
      this.$refs.reportTable.refreshTable()
    },
    beforeSearchFn() {
      return new Promise((resolve, reject) => {
        console.log(this.searchForm.date)
        if (this.searchForm.date) {
          this.searchDataForm.year = this.searchForm.date.split('-')[0]
          this.searchDataForm.month = this.searchForm.date.split('-')[1]
        } else {
          this.searchDataForm.year = ''
          this.searchDataForm.month = ''
        }
        this.searchDataForm.keywords = this.searchForm.keywords
        resolve()
      })
    },
    btnClick(type, scope) {
      this.$Common.exportExcel({
        url: `${store.state.baseURL}/trialdrive/notinstorereport/export`,
        method: 'GET',
        data: this.searchDataForm,
        fileName: '无在店统计报表'+moment().format('YYYY.MM.DD')+'.xls'
      })
    },
    tableDataFinished(data) {
      this.statDate = data[0].statDate
    },
  },
}
</script>

<style>
</style>