<template>
  <new-bg>
    <flex-col>
      <system-title show-back/>
      <ModuleContent padding="0px 20px 20px">
        <web2-title>清洁运输+趋势</web2-title>
        <Split height="16"/>
        <a-row :gutter="16">
          <a-col :span="6">
            <ModuleContent2 :border="false" padding="0">
              <web3-title>运输车辆占比</web3-title>
              <web3-title>运输量占比</web3-title>
            </ModuleContent2>
          </a-col>
          <a-col :span="18">
            <CustomTable
              hide-action
              hide-search
              hide-button
              :columns="columns"
              :api-conf="apiConf"
              :form-items="formItems"
            >
              <template slot="search-button" slot-scope="{ search }">
                <a-button type="primary" @click="exportList(search)">查询</a-button>
                <a-button type="primary" @click="exportList(search)" style="margin-left: 10px;">导出</a-button>
                <Split height="10"></Split>
              </template>
            </CustomTable>
          </a-col>
        </a-row>

      </ModuleContent>
    </flex-col>
  </new-bg>

</template>
<script>
import Curd from "../../components/smallCommon/Curd.vue";
import moment from 'moment'
import SystemTitle from "../../components/smallCommon/SystemTitle.vue";
import NewBg from "../../components/NewBg.vue";
import FlexCol from "../../components/FlexCol.vue";
import ModuleContent from "../../components/ModuleContent.vue";
import CustomTable from "../../components/smallCommon/CustomTable.vue";
import Split from "../../components/smallCommon/Split.vue";
import Web2Title from "../../components/smallCommon/Web2Title.vue";
import ModuleContent2 from "../../components/smallCommon/ModuleContent2.vue";
import CustomDesc2 from "../../components/smallCommon/CusDesc2.vue";
import Web3Title from "../../components/smallCommon/Web3Title.vue";

export default {
  name: "user",
  components: {
    Web3Title,
    CustomDesc2, ModuleContent2,
    Web2Title,
    Split,
    CustomTable,
    ModuleContent, FlexCol, NewBg, SystemTitle,
    Curd
  },
  data() {
    return {
      yunshuzongliang: 0,
      isEdit: false,
      roles: [],
      columns: [
        {
          dataIndex: 'outTime',
          key: 'outTime',
          title: '日期'
        },
        {
          dataIndex: 'carNum',
          key: 'carNum',
          title: '车牌号'
        },
        {
          dataIndex: 'carModel',
          key: 'carModel',
          title: '车型'
        },
        {
          dataIndex: 'newCar',
          key: 'newCar',
          title: '新能源',
          customRender(text) {
            if (text) return '是'
            return '否'
          }
        },
        {
          dataIndex: 'emissions',
          key: 'emissions',
          title: '燃油车'
        },
        {
          dataIndex: 'createDateTime',
          key: 'createDateTime',
          title: '出厂日期'
        }
      ],
      apiConf: {
        listApi: {api: '/api/Transport/list', method: 'get'},
      }
    }
  },

  computed: {
    formItems() {
      return [
        {
          type: 'dateRange',
          key: 'time',
          label: '日期',
          isSearch: true,
          hide: true,
          placeholder: ['请选择开始日期', '请选择结束日期'],
          rules: [
            {required: true, message: '请选择时间范围'}
          ],
          fields: ['startTime', 'endTime']
        },
      ]
    }
  },
  created() {
    this.getyunshuzongliang()
  },

  methods: {
    getyunshuzongliang() {
      /*this.$get('/api/Transport/count').then(({ data }) => {
        this.yunshuzongliang = data
      })*/
    },
    editHandler(isEdit) {
      this.isEdit = isEdit
    },
    exportList({time}) {
      const [start, end] = time
      const fmt = 'YYYY-MM-DD'
      window.open(`http://101.43.201.20:5000/api/Ledger/export?start=${moment(start).format(fmt)}&end=${moment(end).format(fmt)}`, '_blank')
    }

  }
}
</script>
<style scoped lang="less">

</style>
