index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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="260px" width="100%" />
  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. .content-wrapper {
  215. width: 100% !important; // 强制撑满父容器
  216. height: 100% !important;
  217. padding: 0 !important; // 抵消默认内边距(如果 infoBox 有内边距,这里需对应调整)
  218. box-sizing: border-box; // 避免 padding 挤压宽度
  219. }
  220. }
  221. .item-1 {
  222. height: 20%;
  223. }
  224. .item-2 {
  225. height: 40%;
  226. grid-template-columns: 6fr 4fr;
  227. gap: 20px;
  228. :deep(table) {
  229. border-collapse: separate !important;
  230. border-spacing: 0 10px !important;
  231. .zxm-table-thead {
  232. height: 35px;
  233. background-color: unset !important;
  234. .zxm-table-cell {
  235. color: #66ffff !important;
  236. }
  237. }
  238. .zxm-table-tbody {
  239. background-color: unset !important;
  240. }
  241. .zxm-table-cell {
  242. border: none !important;
  243. background: none !important;
  244. padding: 0px;
  245. }
  246. tr {
  247. background: var(--image-rank) no-repeat !important;
  248. background-size: 100% 100% !important;
  249. }
  250. }
  251. .infoBox2 {
  252. :deep(.box-container) {
  253. // width: 100% !important;
  254. // height: 100% !important;
  255. padding: 5px 0px 5px 20px !important;
  256. }
  257. }
  258. }
  259. .item-3 {
  260. height: 40%;
  261. padding-bottom: 0;
  262. :deep(table) {
  263. border-collapse: collapse !important;
  264. // border-spacing: 0 10px !important;
  265. .zxm-table-thead {
  266. height: 35px;
  267. background-color: #0b2542 !important;
  268. border: 1px solid #1f7eb5;
  269. .zxm-table-cell {
  270. border: none !important;
  271. color: #37e0eb !important;
  272. }
  273. }
  274. .zxm-table-tbody {
  275. .zxm-table-row:nth-child(odd) {
  276. background-color: #0e3455;
  277. }
  278. /* 偶数行背景色 */
  279. .zxm-table-row:nth-child(even) {
  280. background-color: #114268 !important;
  281. }
  282. .zxm-table-cell {
  283. border: none !important;
  284. background: none !important;
  285. }
  286. }
  287. }
  288. .box-container {
  289. overflow: hidden;
  290. }
  291. }
  292. .infoBox1 {
  293. background-color: var(--image-border1) no-repeat;
  294. }
  295. .infoBox2 {
  296. background-color: var(--image-border2) no-repeat;
  297. }
  298. .infoBox3 {
  299. background-color: var(--image-border3) no-repeat;
  300. }
  301. .infoBox4 {
  302. background-color: var(--image-border4) no-repeat;
  303. }
  304. }
  305. .wrapper-1 {
  306. grid-template-columns: repeat(5, 1fr);
  307. .data-item {
  308. display: flex;
  309. align-items: center;
  310. justify-content: center;
  311. position: relative;
  312. &::after {
  313. position: absolute;
  314. right: 1px;
  315. top: 5px;
  316. display: block;
  317. width: 2px;
  318. height: 100%;
  319. background: var(--image-split-line);
  320. content: '';
  321. }
  322. &:last-child::after {
  323. display: none;
  324. }
  325. .value {
  326. font-family: 'douyuFont';
  327. color: #66ffff;
  328. margin-top: 20px;
  329. max-width: 200px; // 限制最大宽度
  330. white-space: normal;
  331. word-break: break-all; // 强制长内容换行(包括数字/字母)
  332. text-align: center; // 保持文字居中对齐
  333. }
  334. .item-icon {
  335. width: 80px;
  336. height: 80px;
  337. background-size: 100% 100%;
  338. margin-right: 15px;
  339. }
  340. .icon1 {
  341. background-image: url('/@/assets/images/dataCenter/infoCenter/icon1.png');
  342. }
  343. .icon2 {
  344. background-image: url('/@/assets/images/dataCenter/infoCenter/icon2.png');
  345. }
  346. .icon3 {
  347. background-image: url('/@/assets/images/dataCenter/infoCenter/icon3.png');
  348. }
  349. .icon4 {
  350. background-image: url('/@/assets/images/dataCenter/infoCenter/icon4.png');
  351. }
  352. .icon5 {
  353. background-image: url('/@/assets/images/dataCenter/infoCenter/icon5.png');
  354. }
  355. }
  356. }
  357. .option-cont {
  358. display: flex;
  359. justify-content: center;
  360. align-items: center;
  361. .view-icon {
  362. width: 20px;
  363. height: 20px;
  364. background-image: url('/@/assets/images/dataCenter/infoCenter/view-icon.png');
  365. background-repeat: no-repeat;
  366. background-size: contain;
  367. background-position: center;
  368. }
  369. }
  370. }
  371. </style>