<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="8" :lg="7" :md="8" :sm="24">
            <a-form-item label="海事机构">
              <j-dict-select-tag
                v-model="queryParam.departId"
                placeholder="请选择机构"
                dictCode="view_depart,depart_nam,depart_no,updepart_no=384"
              />
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="设备类型">
              <j-dict-select-tag allowClear v-model="queryParam.type" placeholder="请选择设备类型" dictCode="ad_device_type"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
<!--              <a-button type="primary" icon="download" @click="handleExportXls('企业月供电')" style="margin-left: 8px">导出</a-button>-->
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i>总设备数&nbsp;<a style="font-weight: 600">{{ statistics['totalDeviceNum'] }}</a>台&nbsp;&nbsp;
        <i class="anticon anticon-info-circle ant-alert-icon"></i>总企业数 <a style="font-weight: 600">{{ statistics['totalEntNum'] }}</a>个&nbsp;&nbsp;
        <i class="anticon anticon-info-circle ant-alert-icon"></i>总供电艘次&nbsp;<a style="font-weight: 600">{{ statistics['totalShipNum'] }}</a>次&nbsp;&nbsp;
        <i class="anticon anticon-info-circle ant-alert-icon"></i>总供电量&nbsp;<a style="font-weight: 600">{{ statistics['totalConsumption'] }}</a>kW-h&nbsp;&nbsp;
        <i class="anticon anticon-info-circle ant-alert-icon"></i>总供电时长&nbsp;<a style="font-weight: 600">{{ statistics['totalChargeLength'] }}</a>小时&nbsp;&nbsp;
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="false"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange">

      </a-table>
    </div>

  </a-card>
</template>

<script>
  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import JTreeSelect from '@/components/jeecg/JTreeSelect'
  import { getAction } from '@/api/manage'
  import JDictSelectTag from '@/components/dict/JDictSelectTag.vue'

  export default {
    name: "AdChargingStatistics",
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      JDictSelectTag,
      JTreeSelect,
    },
    data () {
      return {
        description: '供电统计',
        // 表头
        columns: [
          {
            title:'机构名称',
            align:"center",
            dataIndex: 'departNam'
          },
          {
            title:'岸电设备数',
            align:"center",
            dataIndex: 'deviceNum'
          },
          {
            title:'岸电企业数',
            align:"center",
            dataIndex: 'entNum'
          },
          {
            title:'供电艘次',
            align:"center",
            dataIndex: 'shipNum'
          },
          {
            title:'供电量(kW-h)',
            align:"center",
            dataIndex: 'consumption'
          },
          {
            title:'供电时长(时)',
            align:"center",
            dataIndex: 'chargeLength'
          }
        ],
        url: {
          listStatis: "/ad/adChargingRecord/listCharging",
          exportXlsUrl: "/ad/adChargingRecord/exportChargingXls",
        },
        dictOptions:{},
        queryParam: {
          departId: null,
          status: null,
          type: null
        },
        statistics: {}
      }
    },
    computed: {

    },
    created() {
      this.initTableData()
    },
    methods: {
      initDictConfig(){
      },
      initTableData () {
        getAction(this.url.listStatis, this.queryParam).then(res => {
          if (res.code === 200) {
            this.dataSource = []
            this.dataSource = res.result.list
            this.statistics = res.result
            console.log(res.result,this.dataSource)
          }
        })
      },
      handleTableChange() {

      },
      searchQuery() {
        this.initTableData()
      },
      searchReset() {
        this.queryParam = {
          departId: null,
          status: null,
          type: null
        }
      }
    }
  }
</script>
<style scoped>
  /*@import '~@assets/less/common.less';*/
</style>