index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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">数据存储量(GB)</div>
  28. <div class="value status-normal">{{ deviceData.databaseDiskUsage.total_size_gb }}</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. import { useRouter } from 'vue-router';
  95. let mainTitle = ref('智能通风数据中心');
  96. let router = useRouter();
  97. //分页参数配置
  98. const pagination = reactive({
  99. current: 1, // 当前页码
  100. pageSize: 5, // 每页显示条数
  101. total: 0, // 总条目数,后端返回
  102. // showTotal: (total, range) => `${range[0]}-${range[1]} 条,总共 ${total} 条`, // 分页右下角显示信息
  103. });
  104. // 设备接入情况数据
  105. const accessStatusData = ref([]);
  106. // 数据中心首页设备数据
  107. const deviceData = ref({
  108. monitorParamsCount: 0,
  109. deviceCount: 0,
  110. databaseDiskUsage: {
  111. total_size_bytes: 0,
  112. total_size_mb: 0,
  113. total_size_gb: 0,
  114. },
  115. collectTotalNum: 0,
  116. summaryShareAPINum: 0,
  117. collectDataByStationList: [
  118. {
  119. sub_id: '1',
  120. strName: '测试分站',
  121. total_num: 0,
  122. },
  123. ],
  124. collectDataByDayList: [
  125. {
  126. day: '2025-10-29',
  127. total_count: 0,
  128. },
  129. ],
  130. collectGroupByDevKindList: [
  131. {
  132. devKind: 'bundletube',
  133. devNum: 0,
  134. dataCount: 0,
  135. },
  136. ],
  137. });
  138. // 查看数据
  139. function viewData(record) {
  140. console.log(record.devicekind, '设备类型');
  141. router.push(`/sjzx/deviceCenter/home?deviceType=${record.devicekind}`);
  142. }
  143. //分页切换
  144. const pageChange = async (val) => {
  145. pagination.current = val.current;
  146. pagination.pageSize = val.pageSize;
  147. const res = await getDeviceAll({
  148. pageNo: pagination.current,
  149. pageSize: pagination.pageSize,
  150. });
  151. accessStatusData.value = res.records; // 赋值给响应式变量
  152. pagination.total = res.total; // 更新总条数
  153. };
  154. // 获取设备数据接口
  155. const fetchDeviceData = async () => {
  156. try {
  157. const summaryRes = await getHomepageSummaryIndexes();
  158. deviceData.value = summaryRes;
  159. } catch (error) {
  160. console.error('获取首页汇总指标数据失败:', error);
  161. }
  162. try {
  163. const deviceRes = await getDeviceAll({
  164. pageNo: pagination.current,
  165. pageSize: pagination.pageSize,
  166. });
  167. accessStatusData.value = deviceRes.records;
  168. pagination.total = deviceRes.total;
  169. } catch (error) {
  170. console.error('获取设备接入情况数据失败:', error);
  171. }
  172. };
  173. // 数字千位分隔格式化函数
  174. const formatNumber = (num: number | string): string => {
  175. // 处理非数字或空值的情况
  176. if (!num && num !== 0) return '0';
  177. // 转换为数字后再处理,避免字符串类型的数字出现问题
  178. const number = typeof num === 'number' ? num : parseFloat(num);
  179. // 利用正则表达式实现千位分隔
  180. return number.toLocaleString('zh-CN');
  181. };
  182. // 页面挂载时调用接口获取数据
  183. onMounted(async () => {
  184. await fetchDeviceData();
  185. });
  186. </script>
  187. <style lang="less" scoped>
  188. @font-face {
  189. font-family: 'douyuFont';
  190. src: url('@/assets/font/douyuFont.otf');
  191. }
  192. .company-home {
  193. width: 100%;
  194. height: 100%;
  195. position: relative;
  196. :deep(.vent-home-header) {
  197. height: 50px;
  198. background: url('@/assets/images/vent/home/modal-top.png') no-repeat center;
  199. background-size: 100% 100%;
  200. }
  201. .company-content {
  202. position: absolute;
  203. left: 0;
  204. width: 100%;
  205. height: calc(100% - 50px);
  206. padding: 20px 20px 10px 20px;
  207. --image-border1: url('/@/assets/images/dataCenter/infoCenter/info-border1.png');
  208. --image-border2: url('/@/assets/images/dataCenter/infoCenter/info-border2.png');
  209. --image-border3: url('/@/assets/images/dataCenter/infoCenter/info-border3.png');
  210. --image-border4: url('/@/assets/images/dataCenter/infoCenter/info-border4.png');
  211. --image-split-line: url('/@/assets/images/dataCenter/infoCenter/split-line.png');
  212. --image-rank: url('/@/assets/images/dataCenter/infoCenter/rank-bg.png');
  213. .content-item {
  214. width: 100%;
  215. overflow: hidden;
  216. padding-bottom: 20px;
  217. .content-wrapper {
  218. width: 100% !important; // 强制撑满父容器
  219. height: 100% !important;
  220. padding: 0 !important; // 抵消默认内边距(如果 infoBox 有内边距,这里需对应调整)
  221. box-sizing: border-box; // 避免 padding 挤压宽度
  222. }
  223. }
  224. .item-1 {
  225. height: 20%;
  226. }
  227. .item-2 {
  228. height: 40%;
  229. grid-template-columns: 6fr 4fr;
  230. gap: 20px;
  231. :deep(table) {
  232. border-collapse: separate !important;
  233. border-spacing: 0 10px !important;
  234. .zxm-table-thead {
  235. height: 35px;
  236. background-color: unset !important;
  237. .zxm-table-cell {
  238. color: #66ffff !important;
  239. }
  240. }
  241. .zxm-table-tbody {
  242. background-color: unset !important;
  243. }
  244. .zxm-table-cell {
  245. border: none !important;
  246. background: none !important;
  247. padding: 0px;
  248. }
  249. tr {
  250. background: var(--image-rank) no-repeat !important;
  251. background-size: 100% 100% !important;
  252. }
  253. }
  254. .infoBox2 {
  255. :deep(.box-container) {
  256. padding: 5px 0px 5px 5px !important;
  257. }
  258. }
  259. }
  260. .item-3 {
  261. height: 40%;
  262. padding-bottom: 0;
  263. :deep(table) {
  264. border-collapse: collapse !important;
  265. // border-spacing: 0 10px !important;
  266. .zxm-table-thead {
  267. height: 35px;
  268. background-color: #0b2542 !important;
  269. border: 1px solid #1f7eb5;
  270. .zxm-table-cell {
  271. border: none !important;
  272. color: #37e0eb !important;
  273. }
  274. }
  275. .zxm-table-tbody {
  276. .zxm-table-row:nth-child(odd) {
  277. background-color: #0e3455;
  278. }
  279. /* 偶数行背景色 */
  280. .zxm-table-row:nth-child(even) {
  281. background-color: #114268 !important;
  282. }
  283. .zxm-table-cell {
  284. border: none !important;
  285. background: none !important;
  286. }
  287. }
  288. }
  289. .box-container {
  290. overflow: hidden;
  291. }
  292. }
  293. .infoBox1 {
  294. background-color: var(--image-border1) no-repeat;
  295. }
  296. .infoBox2 {
  297. background-color: var(--image-border2) no-repeat;
  298. }
  299. .infoBox3 {
  300. background-color: var(--image-border3) no-repeat;
  301. }
  302. .infoBox4 {
  303. background-color: var(--image-border4) no-repeat;
  304. }
  305. }
  306. .wrapper-1 {
  307. grid-template-columns: repeat(5, 1fr);
  308. .data-item {
  309. display: flex;
  310. align-items: center;
  311. justify-content: center;
  312. position: relative;
  313. &::after {
  314. position: absolute;
  315. right: 1px;
  316. top: 5px;
  317. display: block;
  318. width: 2px;
  319. height: 100%;
  320. background: var(--image-split-line);
  321. content: '';
  322. }
  323. &:last-child::after {
  324. display: none;
  325. }
  326. .value {
  327. font-family: 'douyuFont';
  328. color: #66ffff;
  329. margin-top: 20px;
  330. max-width: 200px; // 限制最大宽度
  331. white-space: normal;
  332. word-break: break-all; // 强制长内容换行(包括数字/字母)
  333. text-align: center; // 保持文字居中对齐
  334. }
  335. .item-icon {
  336. width: 80px;
  337. height: 80px;
  338. background-size: 100% 100%;
  339. margin-right: 15px;
  340. }
  341. .icon1 {
  342. background-image: url('/@/assets/images/dataCenter/infoCenter/icon1.png');
  343. }
  344. .icon2 {
  345. background-image: url('/@/assets/images/dataCenter/infoCenter/icon2.png');
  346. }
  347. .icon3 {
  348. background-image: url('/@/assets/images/dataCenter/infoCenter/icon3.png');
  349. }
  350. .icon4 {
  351. background-image: url('/@/assets/images/dataCenter/infoCenter/icon4.png');
  352. }
  353. .icon5 {
  354. background-image: url('/@/assets/images/dataCenter/infoCenter/icon5.png');
  355. }
  356. }
  357. }
  358. .option-cont {
  359. display: flex;
  360. justify-content: center;
  361. align-items: center;
  362. .view-icon {
  363. width: 20px;
  364. height: 20px;
  365. background-image: url('/@/assets/images/dataCenter/infoCenter/view-icon.png');
  366. background-repeat: no-repeat;
  367. background-size: contain;
  368. background-position: center;
  369. }
  370. }
  371. }
  372. </style>