<template>
  <div class="app-container home">
    <el-row :gutter="20">
      <el-col :xs="24" :sm="12" :lg="6">
        <Panel title="网关">
          <template #icon>
            <Connection/>
          </template>
          <div>在线 {{ 0 }} 个</div>
          <div>离线 {{ 0 }} 个</div>
        </Panel>
      </el-col>
      <el-col :xs="24" :sm="12" :lg="6">
        <Panel title="标签">
          <template #icon>
            <Cellphone/>
          </template>
          <div>在线 {{ 0 }} 个</div>
          <div>离线 {{ 0 }} 个</div>
        </Panel>
      </el-col>
      <el-col :xs="24" :sm="12" :lg="6">
        <Panel title="更新">
          <template #icon>
            <Refresh/>
          </template>
          <div>成功 {{ 0 }} 个</div>
          <div>失败 {{ 0 }} 个</div>
        </Panel>
      </el-col>
      <el-col :xs="24" :sm="12" :lg="6">
        <Panel title="电量">
          <template #icon>
            <WindPower/>
          </template>
          <div>正常 {{ 0 }} 个</div>
          <div>低电量 {{ 0 }} 个</div>
        </Panel>
      </el-col>
    </el-row>

    <el-divider></el-divider>

    <el-row :gutter="20">
      <el-col :xs="24" :sm="12">
        <el-card>
          <template #header>
            <h3>最近一周标签更新情况</h3>
          </template>
          <template #default>
<!--            <div style="min-height: 400px;">-->
<!--              <el-skeleton :rows="5"/>-->
<!--            </div>-->
            <div>
              <h2>图表1</h2>
              <div id="chartDom" class="chart">
              </div>
            </div>
          </template>
        </el-card>
      </el-col>
      <el-col :xs="24" :sm="12">
        <el-card>
          <template #header>
            <h3>更新成功率</h3>
          </template>
          <template #default>
<!--            <div style="min-height: 400px;">-->
<!--              <el-skeleton :rows="5"/>-->
<!--            </div>-->
            <div>
              <h2>图表2</h2>
              <div id="chartBin" class="chart">
                容纳后期的图表
              </div>
            </div>
          </template>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script setup>
import Panel from "@/components/Panel";
import {Cellphone, Refresh, WindPower} from "@element-plus/icons-vue";
//echarts图标组件
import {inject,onMounted} from "vue"

onMounted(() => {
  let $echarts = inject("echarts")
  let myChart1 = $echarts.init(document.getElementById("chartDom"));
  let myChart2 = $echarts.init(document.getElementById("chartBin"));
  console.log(myChart1)
  console.log(myChart2)
  myChart1.setOption({
    title: {
      text: '更新情况'
    },
    tooltip: {},
    legend: {
      data: ["更新次数","更新成功"]
    },
    xAxis: {
      data: ['9.16', '9.17', '9.18', '9.19', '9.20', '9.21']
    },
    yAxis: {},
    series: [
      {
        name: '更新次数',
        type: 'bar',
        data: [30, 20, 36, 55, 27, 20]
      },
      {
        name: '更新成功',
        type: 'bar',
        data: [27, 18, 33, 54, 22, 19]
      }
    ]
  })
  myChart2.setOption({
    title: {
      // 饼图的标题
      text: '价签更新成功率',
      //饼图的二级标题
      subtext: 'Fake Data',
      left: 'center'
    },
    tooltip: {
      trigger: 'item'
    },
    legend: {
      orient: 'vertical',
      left: 'left'
    },
    series: [
      {
        name: '价签',
        type: 'pie',
        radius: '50%',
        data: [
          { value: 3.123, name: '成功率' },
          { value: 96.867, name: '失败率' }
        ],
        emphasis: {
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: 'rgba(0, 0, 0, 0.5)'
          }
        }
      }
    ]
  })
})

const version = ref('3.8.3')

function goTarget(url) {
  window.open(url, '__blank')
}


</script>

<style scoped lang="scss">
h2{
  /* 48像素 */
  height: 0.6rem;
  color: #fff;
  line-height: 0.6rem;
  text-align: center;
  font-size: 0.25rem;

}
.chart{
  /* 高度360 */
  //height: 7.5rem;
  height: 25rem;
  background-color: #f1f1f1;
}
.home {
  .panel {
    margin-bottom: 12px;
  }

  blockquote {
    padding: 10px 20px;
    margin: 0 0 20px;
    font-size: 17.5px;
    border-left: 5px solid #eee;
  }

  hr {
    margin-top: 20px;
    margin-bottom: 20px;
    border: 0;
    border-top: 1px solid #eee;
  }

  .col-item {
    margin-bottom: 20px;
  }

  ul {
    padding: 0;
    margin: 0;
  }

  font-family: "open sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #676a6c;
  overflow-x: hidden;

  ul {
    list-style-type: none;
  }

  h4 {
    margin-top: 0px;
  }

  h2 {
    margin-top: 10px;
    font-size: 26px;
    font-weight: 100;
  }

  p {
    margin-top: 10px;

    b {
      font-weight: 700;
    }
  }

  .update-log {
    ol {
      display: block;
      list-style-type: decimal;
      margin-block-start: 1em;
      margin-block-end: 1em;
      margin-inline-start: 0;
      margin-inline-end: 0;
      padding-inline-start: 40px;
    }
  }
}
</style>

