index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. <template>
  2. <div class="company-home">
  3. <customHeader>{{ mainTitle }}</customHeader>
  4. <div class="company-content">
  5. <div class="content-item item-1">
  6. <infoBox class="infoBox1">
  7. <template #title> 设备数据量 </template>
  8. <template #container>
  9. <div class="content-wrapper wrapper-1 grid">
  10. <div class="data-item">
  11. <div class="item-icon icon1"></div>
  12. <div>
  13. <div class="label">接入设备数量</div>
  14. <div class="value">{{ deviceData.deviceCount }} </div>
  15. </div>
  16. </div>
  17. <div class="data-item">
  18. <div class="item-icon icon2"></div>
  19. <div>
  20. <div class="label">接入点位数量</div>
  21. <div class="value status-normal">{{ deviceData.monitorParamsCount }}</div>
  22. </div>
  23. </div>
  24. <div class="data-item">
  25. <div class="item-icon icon3"></div>
  26. <div>
  27. <div class="label">数据存储量(MB)</div>
  28. <div class="value status-normal">{{ deviceData.databaseDiskUsage.total_size_mb }}</div>
  29. </div>
  30. </div>
  31. <div class="data-item">
  32. <div class="item-icon icon4"></div>
  33. <div>
  34. <div class="label">消息总数量(条)</div>
  35. <div class="value status-normal">{{ formatNumber(deviceData.collectTotalNum) }}</div>
  36. </div>
  37. </div>
  38. <div class="data-item">
  39. <div class="item-icon icon5"></div>
  40. <div>
  41. <div class="label">共享接口数量</div>
  42. <div class="value status-normal">{{ deviceData.summaryShareAPINum }}</div>
  43. </div>
  44. </div>
  45. </div>
  46. </template>
  47. </infoBox>
  48. </div>
  49. <div class="content-item item-2 grid">
  50. <infoBox class="infoBox2">
  51. <template #title> 每日采集数据量 </template>
  52. <template #container>
  53. <div class="content-wrapper">
  54. <CustomChart :chart-config="dailyNumOption" :chart-data="deviceData" height="245px" />
  55. </div>
  56. </template>
  57. </infoBox>
  58. <infoBox class="infoBox3">
  59. <template #title> 系统数据量排名 </template>
  60. <template #container>
  61. <div class="content-wrapper">
  62. <a-table size="small" :dataSource="deviceData.collectGroupByDevKindList" :columns="sysDataColumn" :pagination="false" />
  63. </div>
  64. </template>
  65. </infoBox>
  66. </div>
  67. <div class="content-item item-3">
  68. <infoBox class="infoBox4">
  69. <template #title> 设备接入情况 </template>
  70. <template #container>
  71. <div class="content-wrapper">
  72. <a-table size="small" :dataSource="accessStatusData" :columns="accessStatusColumn" :pagination="pagination" @change="pageChange">
  73. <template #action="{ record }">
  74. <div class="option-cont">
  75. <div class="view-icon"></div>
  76. <a class="table-action-link" @click="viewData(record)">查看数据</a>
  77. </div>
  78. </template>
  79. </a-table>
  80. </div>
  81. </template>
  82. </infoBox>
  83. </div>
  84. </div>
  85. </div>
  86. </template>
  87. <script lang="ts" setup>
  88. import { ref, onMounted, reactive } from 'vue';
  89. import customHeader from '/@/components/vent/customHeader.vue';
  90. import infoBox from './components/infoBox.vue';
  91. import { sysDataColumn, accessStatusColumn, dailyNumOption } from './infoCenter.data';
  92. import CustomChart from '@/views/vent/home/configurable/components/detail/CustomChart.vue';
  93. import { getDeviceAll, getHomepageSummaryIndexes } from './infoCenter.api';
  94. let mainTitle = ref('智能通风数据中心');
  95. //分页参数配置
  96. const pagination = reactive({
  97. current: 1, // 当前页码
  98. pageSize: 5, // 每页显示条数
  99. total: 0, // 总条目数,后端返回
  100. // showTotal: (total, range) => `${range[0]}-${range[1]} 条,总共 ${total} 条`, // 分页右下角显示信息
  101. });
  102. // 设备接入情况数据
  103. const accessStatusData = ref([]);
  104. // 数据中心首页设备数据
  105. const deviceData = ref({
  106. monitorParamsCount: 0,
  107. deviceCount: 0,
  108. databaseDiskUsage: {
  109. total_size_bytes: 0,
  110. total_size_mb: 0,
  111. total_size_gb: 0,
  112. },
  113. collectTotalNum: 0,
  114. summaryShareAPINum: 0,
  115. collectDataByStationList: [
  116. {
  117. sub_id: '1',
  118. strName: '测试分站',
  119. total_num: 0,
  120. },
  121. ],
  122. collectDataByDayList: [
  123. {
  124. day: '2025-10-29',
  125. total_count: 0,
  126. },
  127. ],
  128. collectGroupByDevKindList: [
  129. {
  130. devKind: 'bundletube',
  131. devNum: 0,
  132. dataCount: 0,
  133. },
  134. ],
  135. });
  136. // 查看数据
  137. function viewData(record) {
  138. console.log(record);
  139. }
  140. //分页切换
  141. const pageChange = async (val) => {
  142. pagination.current = val.current;
  143. pagination.pageSize = val.pageSize;
  144. const res = await getDeviceAll({
  145. pageNo: pagination.current,
  146. pageSize: pagination.pageSize,
  147. });
  148. accessStatusData.value = res.records; // 赋值给响应式变量
  149. pagination.total = res.total; // 更新总条数
  150. };
  151. // 获取设备数据接口
  152. const fetchDeviceData = async () => {
  153. try {
  154. const summaryRes = await getHomepageSummaryIndexes();
  155. deviceData.value = summaryRes;
  156. } catch (error) {
  157. console.error('获取首页汇总指标数据失败:', error);
  158. }
  159. try {
  160. const deviceRes = await getDeviceAll({
  161. pageNo: pagination.current,
  162. pageSize: pagination.pageSize,
  163. });
  164. accessStatusData.value = deviceRes.records;
  165. pagination.total = deviceRes.total;
  166. } catch (error) {
  167. console.error('获取设备接入情况数据失败:', error);
  168. }
  169. };
  170. // 数字千位分隔格式化函数
  171. const formatNumber = (num: number | string): string => {
  172. // 处理非数字或空值的情况
  173. if (!num && num !== 0) return '0';
  174. // 转换为数字后再处理,避免字符串类型的数字出现问题
  175. const number = typeof num === 'number' ? num : parseFloat(num);
  176. // 利用正则表达式实现千位分隔
  177. return number.toLocaleString('zh-CN');
  178. };
  179. // 页面挂载时调用接口获取数据
  180. onMounted(async () => {
  181. await fetchDeviceData();
  182. });
  183. </script>
  184. <style lang="less" scoped>
  185. @font-face {
  186. font-family: 'douyuFont';
  187. src: url('@/assets/font/douyuFont.otf');
  188. }
  189. .company-home {
  190. width: 100%;
  191. height: 100%;
  192. position: relative;
  193. :deep(.vent-home-header) {
  194. height: 50px;
  195. background: url('@/assets/images/vent/home/modal-top.png') no-repeat center;
  196. background-size: 100% 100%;
  197. }
  198. .company-content {
  199. position: absolute;
  200. left: 0;
  201. width: 100%;
  202. height: calc(100% - 50px);
  203. padding: 20px 20px 10px 20px;
  204. --image-border1: url('/@/assets/images/dataCenter/infoCenter/info-border1.png');
  205. --image-border2: url('/@/assets/images/dataCenter/infoCenter/info-border2.png');
  206. --image-border3: url('/@/assets/images/dataCenter/infoCenter/info-border3.png');
  207. --image-border4: url('/@/assets/images/dataCenter/infoCenter/info-border4.png');
  208. --image-split-line: url('/@/assets/images/dataCenter/infoCenter/split-line.png');
  209. --image-rank: url('/@/assets/images/dataCenter/infoCenter/rank-bg.png');
  210. .content-item {
  211. width: 100%;
  212. overflow: hidden;
  213. padding-bottom: 20px;
  214. }
  215. .item-1 {
  216. height: 20%;
  217. }
  218. .item-2 {
  219. height: 40%;
  220. grid-template-columns: 6fr 4fr;
  221. gap: 20px;
  222. :deep(table) {
  223. border-collapse: separate !important;
  224. border-spacing: 0 10px !important;
  225. .zxm-table-thead {
  226. height: 35px;
  227. background-color: unset !important;
  228. .zxm-table-cell {
  229. color: #66ffff !important;
  230. }
  231. }
  232. .zxm-table-tbody {
  233. background-color: unset !important;
  234. }
  235. .zxm-table-cell {
  236. border: none !important;
  237. background: none !important;
  238. padding: 0px;
  239. }
  240. tr {
  241. background: var(--image-rank) no-repeat !important;
  242. background-size: 100% 100% !important;
  243. }
  244. }
  245. }
  246. .item-3 {
  247. height: 40%;
  248. padding-bottom: 0;
  249. :deep(table) {
  250. border-collapse: collapse !important;
  251. // border-spacing: 0 10px !important;
  252. .zxm-table-thead {
  253. height: 35px;
  254. background-color: #0b2542 !important;
  255. border: 1px solid #1f7eb5;
  256. .zxm-table-cell {
  257. border: none !important;
  258. color: #37e0eb !important;
  259. }
  260. }
  261. .zxm-table-tbody {
  262. .zxm-table-row:nth-child(odd) {
  263. background-color: #0e3455;
  264. }
  265. /* 偶数行背景色 */
  266. .zxm-table-row:nth-child(even) {
  267. background-color: #114268 !important;
  268. }
  269. .zxm-table-cell {
  270. border: none !important;
  271. background: none !important;
  272. }
  273. }
  274. }
  275. .box-container {
  276. overflow: hidden;
  277. }
  278. }
  279. .infoBox1 {
  280. background-color: var(--image-border1) no-repeat;
  281. }
  282. .infoBox2 {
  283. background-color: var(--image-border2) no-repeat;
  284. }
  285. .infoBox3 {
  286. background-color: var(--image-border3) no-repeat;
  287. }
  288. .infoBox4 {
  289. background-color: var(--image-border4) no-repeat;
  290. }
  291. }
  292. .wrapper-1 {
  293. grid-template-columns: repeat(5, 1fr);
  294. .data-item {
  295. display: flex;
  296. align-items: center;
  297. justify-content: center;
  298. position: relative;
  299. &::after {
  300. position: absolute;
  301. right: 1px;
  302. top: 5px;
  303. display: block;
  304. width: 2px;
  305. height: 100%;
  306. background: var(--image-split-line);
  307. content: '';
  308. }
  309. &:last-child::after {
  310. display: none;
  311. }
  312. .value {
  313. font-family: 'douyuFont';
  314. color: #66ffff;
  315. margin-top: 20px;
  316. }
  317. .item-icon {
  318. width: 80px;
  319. height: 80px;
  320. background-size: 100% 100%;
  321. margin-right: 15px;
  322. }
  323. .icon1 {
  324. background-image: url('/@/assets/images/dataCenter/infoCenter/icon1.png');
  325. }
  326. .icon2 {
  327. background-image: url('/@/assets/images/dataCenter/infoCenter/icon2.png');
  328. }
  329. .icon3 {
  330. background-image: url('/@/assets/images/dataCenter/infoCenter/icon3.png');
  331. }
  332. .icon4 {
  333. background-image: url('/@/assets/images/dataCenter/infoCenter/icon4.png');
  334. }
  335. .icon5 {
  336. background-image: url('/@/assets/images/dataCenter/infoCenter/icon5.png');
  337. }
  338. }
  339. }
  340. .option-cont {
  341. display: flex;
  342. justify-content: center;
  343. align-items: center;
  344. .view-icon {
  345. width: 20px;
  346. height: 20px;
  347. background-image: url('/@/assets/images/dataCenter/infoCenter/view-icon.png');
  348. background-repeat: no-repeat;
  349. background-size: contain;
  350. background-position: center;
  351. }
  352. }
  353. }
  354. </style>