> For the complete documentation index, see [llms.txt](https://close.gitbook.io/yun-wei-bi-ji/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://close.gitbook.io/yun-wei-bi-ji/centos/vue/xiang-mu/2-16.-tong-ji-mian-ban-zu-jian-kai-fa.md).

# 2 16.统计面板组件开发

* #### 统计面板

> src/pages/index.vue

```js
<template>
    <div>
        <el-row :gutter="20">

            <!-- 骨架屏优化体验 -->
            <template v-if="panels.length == 0">
                <el-col :span="6" :offset="0" v-for="i in 4" :key="i">
                <el-skeleton style="width: 100%;" animated loading>
                    <template #template>
                        <el-card shadow="hover" class="border-0">
                            <template #header>
                                <div class="flex justify-between">
                                    <el-skeleton-item variant="text" style="width: 50%" />
                                    <el-skeleton-item variant="text" style="width: 10%" />

                                </div>
                            </template>

                            <el-skeleton-item variant="text" style="width: 80%" />
                            <el-divider></el-divider>
                            <div class="flex justify-between text-sm text-gray-500">
                                <el-skeleton-item variant="text" style="width: 50%" />
                                <el-skeleton-item variant="text" style="width: 10%" />
                            </div>


                        </el-card>

                        <el-skeleton-item variant="text" style="width: 30%" />
                    </template>
                </el-skeleton>
            </el-col>
            </template>

            <!--  -->
            <el-col :span="6" :offset="0" v-for="(item, index) in panels" :key="index">
                <el-card shadow="hover" class="border-0">
                    <template #header>
                        <div class="flex justify-between">
                            <span>{{ item.title }}</span>
                            <el-tag :type="item.unitColor" effect="plain">
                                {{ item.unit }}
                            </el-tag>

                        </div>
                    </template>

                    <span class="text-3xl font-bold text-gray-500">
                        {{ item.value }}
                    </span>
                    <el-divider></el-divider>
                    <div class="flex justify-between text-sm text-gray-500">
                        <span>{{ item.subTitle }}</span>
                        <span>{{ item.subValue }}</span>
                    </div>


                </el-card>

            </el-col>
        </el-row>


</div>
</template>

<script setup>
import { getStatistics1 } from '../api';
import { ref } from 'vue';

const panels = ref([])
getStatistics1().then(res => {
    console.log(res.panels)
    panels.value = res.panels
})

</script>
```

<div><img src="C:%5CUsers%5CAdministrator.DESKTOP-UK43ECI%5CAppData%5CRoaming%5Cmarktext%5Cimages%5C2023-02-22-17-36-32-image.png" alt=""> <figure><img src="https://2134947750-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvILwbD2PrkBCkSitM3m4%2Fuploads%2FN3Z0rkM80uGInjX6T6mT%2F2023-02-22-17-36-32-image.png?alt=media&amp;token=2dde15d5-62ef-45a9-84fc-c81eac0e604c" alt=""><figcaption></figcaption></figure></div>

```json
{
"msg": "ok", 

"data": {
"panels": [
{
"title": "支付订单", 

"value": 49, 

"unit": "年", 

"unitColor": "success", 

"subTitle": "总支付订单", 

"subValue": 49, 

"subUnit": "" 

},
{
"title": "订单量", 

"value": 555, 

"unit": "周", 

"unitColor": "danger", 

"subTitle": "转化率", 

"subValue": "60%", 

"subUnit": "" 

},
{
"title": "销售额", 

"value": "￥3.54", 

"unit": "年", 

"unitColor": "primary", 

"subTitle": "总销售额", 

"subValue": 3.54, 

"subUnit": "" 

},
{
"title": "新增用户", 

"value": 16, 

"unit": "年", 

"unitColor": "warning", 

"subTitle": "总用户", 

"subValue": 16, 

"subUnit": "人" 

}
] 

} 

}
```
