<template>
  <div class="page-header-index-wide">
    <a-row :gutter="24">
      <a-col :sm="24" :md="12" :xl="8" :style="{ marginBottom: '24px' }">
        <chart-card :loading="loading" total="所有任务">
          <div>
            <trend flag style="margin-right: 16px;">
              <div @click="zhengchang(1)">
                <span slot="term">待办</span>
                12
              </div>
            </trend>
            <trend flag style="margin-right: 16px;">
              <div @click="zhengchang(2)">
                <span slot="term">进行中</span>
                13
              </div>
            </trend>
            <trend flag>
              <div @click="zhengchang(3)">
                <span slot="term">完成</span>
                11
              </div>
            </trend>
          </div>
        </chart-card>
        <span class="recent">[近30天]</span>
        <div class="numRecent">
          <div style="font-size:35px; color: #e91111;">123</div>
          <div style="font-size:20px; padding-top:8%; padding-left:5px;">项</div>
        </div>
      </a-col>
      <a-col :sm="24" :md="12" :xl="8" :style="{ marginBottom: '24px' }">
        <chart-card :loading="loading" total="待办任务">

        </chart-card>
        <div class="numRecent">
          <div style="font-size:35px; color: #e91111;">12</div>
          <div style="font-size:20px; padding-top:8%; padding-left:5px;">项</div>
        </div>
      </a-col>
      <a-col :sm="24" :md="12" :xl="8" :style="{ marginBottom: '24px' }">
        <chart-card :loading="loading" total="快捷入口">
          <div>
            <trend flag style="margin-right: 16px;">
              <a slot="term" @click="$router.push({path:'/itdmGongdanMaster/itdmGongdanMasterList'})">拆解工单</a>
            </trend>
            <trend flag style="margin-right: 16px;">
              <a slot="term" @click="$router.push({path:'/gongdandetail/itdmGongdanDetailList'})">工单确认</a>
            </trend>
            <trend flag>
              <a slot="term" @click="$router.push({path:'/gongdanshuju/ItdmGongdanShujuList'})">数据确认</a>
            </trend>
          </div>
        </chart-card>
      </a-col>
    </a-row>

    <a-card :loading="loading" :bordered="false" :body-style="{padding: '0'}">
      <div class="salesCard">
        <a-tabs default-active-key="1" size="large" :tab-bar-style="{marginBottom: '24px', paddingLeft: '16px'}">
          <a-tab-pane loading="true" :tab="tab" key="1">
            <a-row>
              <a-col :xl="16" :lg="12" :md="12" :sm="24" :xs="24">
                <bar title="销售额排行" :dataSource="barData"/>
              </a-col>
              <a-col :xl="8" :lg="12" :md="12" :sm="24" :xs="24">
                <rank-list title="门店销售排行榜" :list="rankList"/>
              </a-col>
            </a-row>
          </a-tab-pane>
        </a-tabs>
      </div>
    </a-card>
  </div>
</template>

<script>
  import ChartCard from '@/components/ChartCard'
  import ACol from "ant-design-vue/es/grid/Col"
  import ATooltip from "ant-design-vue/es/tooltip/Tooltip"
  import MiniArea from '@/components/chart/MiniArea'
  import MiniBar from '@/components/chart/MiniBar'
  import MiniProgress from '@/components/chart/MiniProgress'
  import RankList from '@/components/chart/RankList'
  import Bar from '@/components/chart/Bar'
  import LineChartMultid from '@/components/chart/LineChartMultid'
  import HeadInfo from '@/components/tools/HeadInfo.vue'

  import Trend from '@/components/Trend'
  import { getLoginfo,getVisitInfo } from '@/api/api'

  const rankList = []
  for (let i = 0; i < 7; i++) {
    rankList.push({
      name: '白鹭岛 ' + (i+1) + ' 号店',
      total: 1234.56 - i * 100
    })
  }
  const barData = []
  for (let i = 0; i < 12; i += 1) {
    barData.push({
      x: `${i + 1}月`,
      y: Math.floor(Math.random() * 1000) + 200
    })
  }
  export default {
    name: "IndexChart",
    components: {
      ATooltip,
      ACol,
      ChartCard,
      MiniArea,
      MiniBar,
      MiniProgress,
      RankList,
      Bar,
      Trend,
      LineChartMultid,
      HeadInfo
    },
    data() {
      return {
        loading: true,
        tab: '待办',
        center: null,
        rankList,
        barData,
        loginfo:{},
        visitFields:['ip','visit'],
        visitInfo:[],
        indicator: <a-icon type="loading" style="font-size: 24px" spin />
      }
    },
    created() {
      setTimeout(() => {
        this.loading = !this.loading
      }, 1000)
      this.initLogInfo();
    },
    methods: {
      initLogInfo () {
        getLoginfo(null).then((res)=>{
          if(res.success){
            Object.keys(res.result).forEach(key=>{
              res.result[key] =res.result[key]+""
            })
            this.loginfo = res.result;
          }
        })
        getVisitInfo().then(res=>{
          if(res.success){
             this.visitInfo = res.result;
           }
         })
      },
      zhengchang(num){
        console.log(num)
        if (num == 1) {
          this.tab = '待办'
        }
        if (num == 2) {
          this.tab = '进行中'
        }
        if (num == 3) {
          this.tab = '完成'
        }
        // this.deviceOptions = []
        // console.log(this.deviceOptions)
        // var deOption = this.allDevOptions
        // if( !num && num == undefined ){
        //   this.deviceOptions = this.allDevOptions
        //   return false
        // }
        // for (var i = 0; i < deOption.length; i++) {
        //   console.log(deOption[i].deviceStatus)
        //   if(deOption[i].deviceStatus == num){
        //     this.deviceOptions.push(deOption[i])
        //     console.log(this.deviceOptions)
        //   }
        // }
      },
    }
  }
</script>

<style lang="less" scoped>
  ::v-deep .total{
    width: 50%;
  }
  .recent{
    position: absolute;
    top: 29%;
    left: 32%;
  }
  .numRecent{
    height: 30%;
    width: 40%;
    // background-color: aquamarine;
    position: absolute;
    top: 12%;
    right: 8%;
    display: flex;
    justify-content: flex-end;
  }
  .circle-cust{
    position: relative;
    top: 28px;
    left: -100%;
  }
  .extra-wrapper {
    line-height: 55px;
    padding-right: 24px;

    .extra-item {
      display: inline-block;
      margin-right: 24px;

      a {
        margin-left: 24px;
      }
    }
  }

  /* 首页访问量统计 */
  .head-info {
    position: relative;
    text-align: left;
    padding: 0 32px 0 0;
    min-width: 125px;

    &.center {
      text-align: center;
      padding: 0 32px;
    }

    span {
      color: rgba(0, 0, 0, .45);
      display: inline-block;
      font-size: .95rem;
      line-height: 42px;
      margin-bottom: 4px;
    }
    p {
      line-height: 42px;
      margin: 0;
      a {
        font-weight: 600;
        font-size: 1rem;
      }
    }
  }
</style>