<template>
  <div ref="homePage" class="page">
      
    <el-row :gutter="20" class="mgb20">


 
      <el-col :span="6">
        <div style="width: 100%;border-radius: 12px;box-shadow: 0 0 20px -5px rgba(84, 151, 232, 0.5);">
          <div class="grid-message" style="background: #fff;border-radius:15px">
            <el-icon class="grid-msg-icon" style="border-radius: 12px 0 0 12px;" :style="{background:'#67C23A'}">
              <component is="SuccessFilled" />
            </el-icon>
            <div class="grid-msg-right" @click="toRout('/vehicle/car')">
              <div class="grid-msg-num" :style="{ color: '#67C23A'}">
                {{ cltotal }}
              </div>
              <div style="font-size: 16px;">车辆总数</div>
            </div>

          </div>
        </div>
      </el-col>

      <el-col :span="6">
        <div style="width: 100%;border-radius: 12px;box-shadow: 0 0 20px -5px rgba(84, 151, 232, 0.5);">
          <div class="grid-message" style="background: #fff;border-radius:15px">
            <el-icon class="grid-msg-icon" style="border-radius: 12px 0 0 12px;" :style="{background:'#E6A23C'}">
              <component is="BellFilled" />
            </el-icon>
            <div class="grid-msg-right" @click="toRout('/vehicle/wxuser')">
              <div class="grid-msg-num" :style="{ color: '#E6A23C'}">
                {{ ygtotal }}
              </div>
              <div style="font-size: 16px;">员工总数</div>
            </div>
         
          </div>
        </div>
      </el-col>
      
      <el-col :span="6">
        <div style="width: 100%;border-radius: 12px;box-shadow: 0 0 20px -5px rgba(84, 151, 232, 0.5);">
          <div class="grid-message" style="background: #fff;border-radius:15px">
            <el-icon class="grid-msg-icon" style="border-radius: 12px 0 0 12px;" :style="{background:'#E6A23C'}">
              <component is="BellFilled" />
            </el-icon>
            <div class="grid-msg-right" @click="toRout('/order/replabatt')">
              <div class="grid-msg-num" :style="{ color: '#E6A23C'}">
                {{ djstotal }}
              </div>
              <div style="font-size: 16px;">待支付订单</div>
            </div>
         
          </div>
        </div>
      </el-col>
      <el-col :span="6">
        <div style="width: 100%;border-radius: 12px;box-shadow: 0 0 20px -5px rgba(84, 151, 232, 0.5);">
          <div class="grid-message" style="background: #fff;border-radius:15px">
            <el-icon class="grid-msg-icon" style="border-radius: 12px 0 0 12px;" :style="{background:'#E6A23C'}">
              <component is="BellFilled" />
            </el-icon>
            <div class="grid-msg-right">
              <div class="grid-msg-num" :style="{ color: '#E6A23C'}">
                {{ djsjetotal/100 }}
              </div>
              <div style="font-size: 16px;">待支付金额</div>
            </div>
         
          </div>
        </div>
      </el-col>
    </el-row>


  
    <el-row >
      <el-col :span="24">
        <div style="width: 100%;border-radius: 10px;box-shadow: 0 0 20px -5px rgba(84, 151, 232, 0.5);">
          <el-table 
            :data="list"
            border
            stripe
            height="700px"
          >
              <el-table-column label="换电时间" min-width="200" align="center" prop="swapTime" :show-overflow-tooltip="true" />
              <el-table-column label="换电车辆" min-width="200" align="center" prop="swapCar" :show-overflow-tooltip="true" />
              <el-table-column label="换电人" min-width="200" align="center" prop="swapUserName" :show-overflow-tooltip="true" />
              <el-table-column label="换电金额(元)" min-width="200" align="center" prop="swapAmount" :show-overflow-tooltip="true">
                <template #default="scope">
                    <div>{{scope.row.swapAmount/100}}</div>
                </template>
              </el-table-column>
            </el-table>
        </div>
        
          
      </el-col>
      
    </el-row>
  </div>
</template>
<script lang="ts" setup name="homePage">
import { 
  ref,
} from 'vue'
import { useRouter } from 'vue-router'

import { 

  gongsdata
} from '@/api/home'


let cltotal = ref<any>('')
let ygtotal = ref<any>('')
let djstotal = ref<any>('')
let djsjetotal = ref<any>('')

let list = ref<any>([])

gongsdata().then((rps:any) => {
     cltotal.value = rps.data.carNum	//车辆		
     ygtotal.value = rps.data.userNum	//员工

     djsjetotal.value = rps.data.pendingOrderAmount	  //待支付金额	
     djstotal.value = rps.data.pendingOrderNum    //待支付订单

     if(rps.data.orderList && rps.data.orderList.length > 0){
      list.value = rps.data.orderList
     }
     
})

function glnum(n:any){
  if(n>10000000){
    return Math.round((n/1000000)*100)/100
  }
  return n/100
}


let router = useRouter()
function toRout(path:string,query:Record<string, any> = {}) {
  router.push({
    path,
    query
  })
}



















// defineExpose无需导入，直接使用
// defineExpose({ value });
</script>

<style lang="less" scoped>
@message-width: 80px;

.page {
  padding-bottom: 20px;
}

.grid-message {
  display: flex;
  align-items: center;
  height: @message-width;
  cursor: pointer;
}

.grid-msg-right {
  flex: 1;
  text-align: center;
  font-size: 14px;
  color: #999;
  border-right:1px solid #ccc;
}

.grid-msg-num {
  font-size: 30px;
  font-weight: bold;
}

.grid-msg-icon {
  font-size: 50px;
  width: @message-width;
  height: @message-width;
  text-align: center;
  line-height: @message-width;
  color: #fff;
}

.chart-cont {
  height: 140px;

  > h1 {
    color: #606266;
    font-weight: normal;
    display: flex;
    font-size: 14px;
    justify-content: space-between;
  }

  > p {
    margin: 0;
    padding: 0;
    font-size: 30px;
    line-height: 40px;
  }

  > div {
    height: 60px;
    width: 100%;

    > p {
      margin: 0;
      padding-top: 10px;
      line-height: 20px;
      font-size: 12px;
      color: #909399;
    }
  }
}

.chart-cont2 {
  height: 260px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
</style>
