| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379 |
- <template>
- <div class="company-home">
- <customHeader>{{ mainTitle }}</customHeader>
- <div class="company-content">
- <div class="content-item item-1">
- <infoBox class="infoBox1">
- <template #title> 设备数据量 </template>
- <template #container>
- <div class="content-wrapper wrapper-1 grid">
- <div class="data-item">
- <div class="item-icon icon1"></div>
- <div>
- <div class="label">接入设备数量</div>
- <div class="value">{{ deviceData.deviceCount }} </div>
- </div>
- </div>
- <div class="data-item">
- <div class="item-icon icon2"></div>
- <div>
- <div class="label">接入点位数量</div>
- <div class="value status-normal">{{ deviceData.monitorParamsCount }}</div>
- </div>
- </div>
- <div class="data-item">
- <div class="item-icon icon3"></div>
- <div>
- <div class="label">数据存储量(GB)</div>
- <div class="value status-normal">{{ deviceData.databaseDiskUsage.total_size_gb }}</div>
- </div>
- </div>
- <div class="data-item">
- <div class="item-icon icon4"></div>
- <div>
- <div class="label">消息总数量(条)</div>
- <div class="value status-normal">{{ formatNumber(deviceData.collectTotalNum) }}</div>
- </div>
- </div>
- <div class="data-item">
- <div class="item-icon icon5"></div>
- <div>
- <div class="label">共享接口数量</div>
- <div class="value status-normal">{{ deviceData.summaryShareAPINum }}</div>
- </div>
- </div>
- </div>
- </template>
- </infoBox>
- </div>
- <div class="content-item item-2 grid">
- <infoBox class="infoBox2">
- <template #title> 每日采集数据量 </template>
- <template #container>
- <div class="content-wrapper">
- <CustomChart :chart-config="dailyNumOption" :chart-data="deviceData" height="260px" width="100%" />
- </div>
- </template>
- </infoBox>
- <infoBox class="infoBox3">
- <template #title> 系统数据量排名 </template>
- <template #container>
- <div class="content-wrapper">
- <a-table size="small" :dataSource="deviceData.collectGroupByDevKindList" :columns="sysDataColumn" :pagination="false" />
- </div>
- </template>
- </infoBox>
- </div>
- <div class="content-item item-3">
- <infoBox class="infoBox4">
- <template #title> 设备接入情况 </template>
- <template #container>
- <div class="content-wrapper">
- <a-table size="small" :dataSource="accessStatusData" :columns="accessStatusColumn" :pagination="pagination" @change="pageChange">
- <template #action="{ record }">
- <div class="option-cont">
- <div class="view-icon"></div>
- <a class="table-action-link" @click="viewData(record)">查看数据</a>
- </div>
- </template>
- </a-table>
- </div>
- </template>
- </infoBox>
- </div>
- </div>
- </div>
- </template>
- <script lang="ts" setup>
- import { ref, onMounted, reactive } from 'vue';
- import customHeader from '/@/components/vent/customHeader.vue';
- import infoBox from './components/infoBox.vue';
- import { sysDataColumn, accessStatusColumn, dailyNumOption } from './infoCenter.data';
- import CustomChart from '@/views/vent/home/configurable/components/detail/CustomChart.vue';
- import { getDeviceAll, getHomepageSummaryIndexes } from './infoCenter.api';
- import { useRouter } from 'vue-router';
- let mainTitle = ref('智能通风数据中心');
- let router = useRouter();
- //分页参数配置
- const pagination = reactive({
- current: 1, // 当前页码
- pageSize: 5, // 每页显示条数
- total: 0, // 总条目数,后端返回
- // showTotal: (total, range) => `${range[0]}-${range[1]} 条,总共 ${total} 条`, // 分页右下角显示信息
- });
- // 设备接入情况数据
- const accessStatusData = ref([]);
- // 数据中心首页设备数据
- const deviceData = ref({
- monitorParamsCount: 0,
- deviceCount: 0,
- databaseDiskUsage: {
- total_size_bytes: 0,
- total_size_mb: 0,
- total_size_gb: 0,
- },
- collectTotalNum: 0,
- summaryShareAPINum: 0,
- collectDataByStationList: [
- {
- sub_id: '1',
- strName: '测试分站',
- total_num: 0,
- },
- ],
- collectDataByDayList: [
- {
- day: '2025-10-29',
- total_count: 0,
- },
- ],
- collectGroupByDevKindList: [
- {
- devKind: 'bundletube',
- devNum: 0,
- dataCount: 0,
- },
- ],
- });
- // 查看数据
- function viewData(record) {
- console.log(record.devicekind, '设备类型');
- router.push(`/sjzx/deviceCenter/home?deviceType=${record.devicekind}`);
- }
- //分页切换
- const pageChange = async (val) => {
- pagination.current = val.current;
- pagination.pageSize = val.pageSize;
- const res = await getDeviceAll({
- pageNo: pagination.current,
- pageSize: pagination.pageSize,
- });
- accessStatusData.value = res.records; // 赋值给响应式变量
- pagination.total = res.total; // 更新总条数
- };
- // 获取设备数据接口
- const fetchDeviceData = async () => {
- try {
- const summaryRes = await getHomepageSummaryIndexes();
- deviceData.value = summaryRes;
- } catch (error) {
- console.error('获取首页汇总指标数据失败:', error);
- }
- try {
- const deviceRes = await getDeviceAll({
- pageNo: pagination.current,
- pageSize: pagination.pageSize,
- });
- accessStatusData.value = deviceRes.records;
- pagination.total = deviceRes.total;
- } catch (error) {
- console.error('获取设备接入情况数据失败:', error);
- }
- };
- // 数字千位分隔格式化函数
- const formatNumber = (num: number | string): string => {
- // 处理非数字或空值的情况
- if (!num && num !== 0) return '0';
- // 转换为数字后再处理,避免字符串类型的数字出现问题
- const number = typeof num === 'number' ? num : parseFloat(num);
- // 利用正则表达式实现千位分隔
- return number.toLocaleString('zh-CN');
- };
- // 页面挂载时调用接口获取数据
- onMounted(async () => {
- await fetchDeviceData();
- });
- </script>
- <style lang="less" scoped>
- @font-face {
- font-family: 'douyuFont';
- src: url('@/assets/font/douyuFont.otf');
- }
- .company-home {
- width: 100%;
- height: 100%;
- position: relative;
- :deep(.vent-home-header) {
- height: 50px;
- background: url('@/assets/images/vent/home/modal-top.png') no-repeat center;
- background-size: 100% 100%;
- }
- .company-content {
- position: absolute;
- left: 0;
- width: 100%;
- height: calc(100% - 50px);
- padding: 20px 20px 10px 20px;
- --image-border1: url('/@/assets/images/dataCenter/infoCenter/info-border1.png');
- --image-border2: url('/@/assets/images/dataCenter/infoCenter/info-border2.png');
- --image-border3: url('/@/assets/images/dataCenter/infoCenter/info-border3.png');
- --image-border4: url('/@/assets/images/dataCenter/infoCenter/info-border4.png');
- --image-split-line: url('/@/assets/images/dataCenter/infoCenter/split-line.png');
- --image-rank: url('/@/assets/images/dataCenter/infoCenter/rank-bg.png');
- .content-item {
- width: 100%;
- overflow: hidden;
- padding-bottom: 20px;
- .content-wrapper {
- width: 100% !important; // 强制撑满父容器
- height: 100% !important;
- padding: 0 !important; // 抵消默认内边距(如果 infoBox 有内边距,这里需对应调整)
- box-sizing: border-box; // 避免 padding 挤压宽度
- }
- }
- .item-1 {
- height: 20%;
- }
- .item-2 {
- height: 40%;
- grid-template-columns: 6fr 4fr;
- gap: 20px;
- :deep(table) {
- border-collapse: separate !important;
- border-spacing: 0 10px !important;
- .zxm-table-thead {
- height: 35px;
- background-color: unset !important;
- .zxm-table-cell {
- color: #66ffff !important;
- }
- }
- .zxm-table-tbody {
- background-color: unset !important;
- }
- .zxm-table-cell {
- border: none !important;
- background: none !important;
- padding: 0px;
- }
- tr {
- background: var(--image-rank) no-repeat !important;
- background-size: 100% 100% !important;
- }
- }
- .infoBox2 {
- :deep(.box-container) {
- padding: 5px 0px 5px 5px !important;
- }
- }
- }
- .item-3 {
- height: 40%;
- padding-bottom: 0;
- :deep(table) {
- border-collapse: collapse !important;
- // border-spacing: 0 10px !important;
- .zxm-table-thead {
- height: 35px;
- background-color: #0b2542 !important;
- border: 1px solid #1f7eb5;
- .zxm-table-cell {
- border: none !important;
- color: #37e0eb !important;
- }
- }
- .zxm-table-tbody {
- .zxm-table-row:nth-child(odd) {
- background-color: #0e3455;
- }
- /* 偶数行背景色 */
- .zxm-table-row:nth-child(even) {
- background-color: #114268 !important;
- }
- .zxm-table-cell {
- border: none !important;
- background: none !important;
- }
- }
- }
- .box-container {
- overflow: hidden;
- }
- }
- .infoBox1 {
- background-color: var(--image-border1) no-repeat;
- }
- .infoBox2 {
- background-color: var(--image-border2) no-repeat;
- }
- .infoBox3 {
- background-color: var(--image-border3) no-repeat;
- }
- .infoBox4 {
- background-color: var(--image-border4) no-repeat;
- }
- }
- .wrapper-1 {
- grid-template-columns: repeat(5, 1fr);
- .data-item {
- display: flex;
- align-items: center;
- justify-content: center;
- position: relative;
- &::after {
- position: absolute;
- right: 1px;
- top: 5px;
- display: block;
- width: 2px;
- height: 100%;
- background: var(--image-split-line);
- content: '';
- }
- &:last-child::after {
- display: none;
- }
- .value {
- font-family: 'douyuFont';
- color: #66ffff;
- margin-top: 20px;
- max-width: 200px; // 限制最大宽度
- white-space: normal;
- word-break: break-all; // 强制长内容换行(包括数字/字母)
- text-align: center; // 保持文字居中对齐
- }
- .item-icon {
- width: 80px;
- height: 80px;
- background-size: 100% 100%;
- margin-right: 15px;
- }
- .icon1 {
- background-image: url('/@/assets/images/dataCenter/infoCenter/icon1.png');
- }
- .icon2 {
- background-image: url('/@/assets/images/dataCenter/infoCenter/icon2.png');
- }
- .icon3 {
- background-image: url('/@/assets/images/dataCenter/infoCenter/icon3.png');
- }
- .icon4 {
- background-image: url('/@/assets/images/dataCenter/infoCenter/icon4.png');
- }
- .icon5 {
- background-image: url('/@/assets/images/dataCenter/infoCenter/icon5.png');
- }
- }
- }
- .option-cont {
- display: flex;
- justify-content: center;
- align-items: center;
- .view-icon {
- width: 20px;
- height: 20px;
- background-image: url('/@/assets/images/dataCenter/infoCenter/view-icon.png');
- background-repeat: no-repeat;
- background-size: contain;
- background-position: center;
- }
- }
- }
- </style>
|