rhkb.vue 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354
  1. <template>
  2. <div class="page-container">
  3. <el-row :gutter="16" class="summary">
  4. <!-- 原有的统计卡片部分保持不变 -->
  5. <el-col :sm="3" :xs="12">
  6. <SummaryCard
  7. :value="device.total || 0"
  8. icon="fa-solid:project-diagram"
  9. icon-bg-color="text-blue-500"
  10. icon-color="bg-blue-100"
  11. :title="t('stat.deviceCount')"
  12. />
  13. </el-col>
  14. <el-col :sm="3" :xs="12">
  15. <SummaryCard
  16. :value="maintain.total || 0"
  17. icon="fa-solid:list"
  18. icon-bg-color="text-pink-500"
  19. icon-color="bg-blue-100"
  20. :title="t('stat.repairOrder')"
  21. />
  22. </el-col>
  23. <el-col :sm="3" :xs="12">
  24. <SummaryCard
  25. :value="fill.unfilledCount || 0"
  26. icon="fa-solid:times-circle"
  27. icon-bg-color="text-purple-500"
  28. icon-color="bg-purple-100"
  29. :title="t('stat.operationNotFilled')"
  30. />
  31. </el-col>
  32. <el-col :sm="3" :xs="12">
  33. <SummaryCard
  34. :value="fill.filledCount || 0"
  35. icon="fa-solid:award"
  36. icon-bg-color="text-purple-500"
  37. icon-color="bg-purple-100"
  38. :title="t('stat.operationFilled')"
  39. />
  40. </el-col>
  41. <el-col :sm="3" :xs="12">
  42. <SummaryCard
  43. :value="by.todo || 0"
  44. icon="fa-solid:times-circle"
  45. icon-bg-color="text-green-500"
  46. icon-color="bg-green-100"
  47. :title="t('stat.notMaintained')"
  48. />
  49. </el-col>
  50. <el-col :sm="3" :xs="12">
  51. <SummaryCard
  52. :value="by.finished || 0"
  53. icon="fa-solid:award"
  54. icon-bg-color="text-green-500"
  55. icon-color="bg-green-100"
  56. :title="t('stat.maintained')"
  57. />
  58. </el-col>
  59. <el-col :sm="3" :xs="12">
  60. <SummaryCard
  61. :value="inspectt.todo || 0"
  62. icon="fa-solid:times-circle"
  63. icon-bg-color="text-yellow-500"
  64. icon-color="bg-yellow-100"
  65. :title="t('stat.notInspected')"
  66. />
  67. </el-col>
  68. <el-col :sm="3" :xs="12">
  69. <SummaryCard
  70. :value="inspectt.finished || 0"
  71. icon="fa-solid:award"
  72. icon-bg-color="text-yellow-500"
  73. icon-color="bg-yellow-100"
  74. :title="t('stat.inspected')"
  75. />
  76. </el-col>
  77. <!-- 其他统计卡片... -->
  78. </el-row>
  79. <!-- 第二行:图表行 -->
  80. <el-row :gutter="16" class="mb-4 mt-3">
  81. <el-col :span="6">
  82. <el-card class="chart-card" shadow="never">
  83. <template #header>
  84. <div class="flex items-center">
  85. <span class="text-base font-medium " style="color: #b6c8da">{{t('stat.deviceStatus')}}</span>
  86. </div>
  87. </template>
  88. <div ref="statusChartRef" class="h-[290px]"></div>
  89. </el-card>
  90. </el-col>
  91. <el-col :span="10">
  92. <el-card class="chart-card" shadow="never" >
  93. <template #header>
  94. <div class="flex items-center">
  95. <span class="text-base font-medium " style="color: #b6c8da">{{t('stat.deviceClassifyTop5')}}</span>
  96. </div>
  97. </template>
  98. <div ref="topContainer" class="h-[290px]"></div>
  99. </el-card>
  100. </el-col>
  101. <el-col :span="8">
  102. <el-card class="chart-card" shadow="never">
  103. <template #header>
  104. <div class="flex items-center justify-between">
  105. <span class="text-base font-medium " style="color: #b6c8da">{{t('stat.operationCost')}}</span>
  106. </div>
  107. </template>
  108. <div ref="chartContainer" class="h-[290px]"></div>
  109. </el-card>
  110. </el-col>
  111. </el-row>
  112. <!-- 第三行:消息统计行 -->
  113. <el-row :gutter="16" class="mb-1">
  114. <el-col :span="12">
  115. <el-card class="chart-card" shadow="never">
  116. <template #header>
  117. <div style="display: flex; flex-direction: row; justify-content: space-between">
  118. <span class="text-base font-medium " style="color: #b6c8da">{{t('stat.deviceRate')}}</span>
  119. <div>
  120. <el-date-picker
  121. v-model="rateQueryParams.createTime"
  122. value-format="YYYY-MM-DD HH:mm:ss"
  123. type="daterange"
  124. start-placeholder="开始日期"
  125. end-placeholder="结束日期"
  126. :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
  127. class="!w-220px"
  128. @change="handleDateChange"
  129. />
  130. </div>
  131. </div>
  132. </template>
  133. <!-- <div ref="materialChartRef" class="h-[320px]"></div>-->
  134. <div class="table-container">
  135. <el-table
  136. :data="materialTableData"
  137. border
  138. @row-click="handleRowClick"
  139. style="width: 100%"
  140. :header-cell-style="{
  141. 'background-color': '#2196df',
  142. 'color': 'white',
  143. 'border-color': '#457794'
  144. }"
  145. :cell-style="{
  146. 'border-color': '#457794',
  147. 'background-color': '#284D72',
  148. 'color':'#F1D209'
  149. }"
  150. >
  151. <el-table-column
  152. prop="projectDeptName"
  153. label="项目部"
  154. align="center"
  155. />
  156. <el-table-column
  157. prop="teamCount"
  158. label="队伍数量"
  159. align="center"
  160. />
  161. <el-table-column
  162. prop="cumulativeDays"
  163. label="累计天数"
  164. align="center"
  165. />
  166. <el-table-column
  167. prop="constructionDays"
  168. label="施工天数"
  169. align="center"
  170. />
  171. <el-table-column
  172. prop="gasInjection"
  173. :formatter="gasInjectionFormatter"
  174. label="注气量(万方)"
  175. align="center"
  176. />
  177. <el-table-column
  178. prop="utilizationRate"
  179. label="设备利用率"
  180. align="center"
  181. :formatter="formatRate"
  182. />
  183. </el-table>
  184. </div>
  185. </el-card>
  186. </el-col>
  187. <el-col :span="12">
  188. <el-card class="chart-card" shadow="never">
  189. <template #header>
  190. <div class="flex items-center justify-between">
  191. <span class="text-base font-medium " style="color: #b6c8da">{{t('stat.orderCount')}}</span>
  192. </div>
  193. </template>
  194. <div ref="qxRef" class="h-[320px]"></div>
  195. </el-card>
  196. </el-col>
  197. </el-row>
  198. <el-row :gutter="16" class="mb-1 mt-4">
  199. <el-col :span="12">
  200. <el-card class="chart-card" shadow="never">
  201. <template #header>
  202. <div class="flex items-center justify-between">
  203. <span class="text-base font-medium " style="color: #b6c8da">{{t('stat.dailyGasWater')}}</span>
  204. </div>
  205. </template>
  206. <div ref="todayZqlRef" class="h-[300px]"></div>
  207. </el-card>
  208. </el-col>
  209. <el-col :span="12">
  210. <el-card class="chart-card" shadow="never">
  211. <template #header>
  212. <div class="flex items-center justify-between">
  213. <span class="text-base font-medium " style="color: #b6c8da">{{t('stat.gasWater')}}</span>
  214. </div>
  215. </template>
  216. <div ref="zqlChartRef" class="h-[300px]"></div>
  217. </el-card>
  218. </el-col>
  219. </el-row>
  220. </div>
  221. <el-dialog
  222. v-model="teamDialogVisible"
  223. :title="t('stat.teamDetail')"
  224. width="80vh"
  225. :before-close="handleDialogClose"
  226. class="custom-scroll-dialog"
  227. >
  228. <div class="dialog-scroll-content">
  229. <el-table
  230. :data="teamTableData"
  231. border
  232. style="width: 100%;"
  233. :header-cell-style="{
  234. 'background-color': 'rgba(0, 0, 0, 0.2)',
  235. 'color': 'black',
  236. 'border-color': '#457794'
  237. }"
  238. :cell-style="{
  239. 'border-color': '#457794',
  240. 'background-color': 'transparent'
  241. }"
  242. >
  243. <el-table-column
  244. prop="teamName"
  245. label="队伍名称"
  246. align="center"
  247. />
  248. <el-table-column
  249. prop="cumulativeDays"
  250. label="累计天数"
  251. align="center"
  252. />
  253. <el-table-column
  254. prop="constructionDays"
  255. label="施工天数"
  256. align="center"
  257. />
  258. <el-table-column
  259. prop="utilizationRate"
  260. label="设备利用率"
  261. align="center"
  262. :formatter="formatRate"
  263. />
  264. </el-table>
  265. </div>
  266. </el-dialog>
  267. </template>
  268. <script setup lang="ts" name="Index">
  269. import * as echarts from 'echarts/core'
  270. import { BarChart, GaugeChart, LineChart, PieChart } from 'echarts/charts' // 显式导入柱状图模块
  271. import {
  272. GridComponent,
  273. LegendComponent,
  274. TitleComponent,
  275. ToolboxComponent,
  276. TooltipComponent
  277. } from 'echarts/components'
  278. import { LabelLayout, UniversalTransition } from 'echarts/features'
  279. import { CanvasRenderer } from 'echarts/renderers'
  280. import { useElementSize } from '@vueuse/core'
  281. import { IotStatApi } from '@/api/pms/stat'
  282. import SummaryCard from '@/components/SummaryCard/index.vue'
  283. import { reactive, ref } from 'vue'
  284. import {useLocaleStore} from "@/store/modules/locale";
  285. /** IoT 首页 */
  286. defineOptions({ name: 'IotRhStat' })
  287. echarts.use([
  288. TooltipComponent,
  289. LegendComponent,
  290. PieChart,
  291. CanvasRenderer,
  292. LabelLayout,
  293. TitleComponent,
  294. ToolboxComponent,
  295. GridComponent,
  296. LineChart,
  297. UniversalTransition,
  298. GaugeChart,
  299. BarChart
  300. ])
  301. const teamDialogVisible = ref(false)
  302. const teamTableData = ref([])
  303. const currentDeptId = ref('')
  304. const currentDateRange = ref([])
  305. const materialTableData = ref([])
  306. const queryParams = reactive({
  307. createTime: [],
  308. })
  309. const handleRowClick = (row, column, event) => {
  310. console.log('点击的行数据:', row);
  311. currentDeptId.value = row.deptId // 假设行数据中包含deptId字段
  312. currentDateRange.value = rateQueryParams.createTime
  313. // 打开弹窗并加载队伍详情数据
  314. teamDialogVisible.value = true
  315. // fetchTeamDetailData(row.deptId, rateQueryParams.createTime)
  316. const teamParams = {
  317. deptId: row.projectDeptId,
  318. createTime: rateQueryParams.createTime
  319. }
  320. IotStatApi.getRhTeamRate(teamParams).then(res => {
  321. teamTableData.value = res
  322. })
  323. };
  324. const handleDialogClose = () => {
  325. teamDialogVisible.value = false
  326. teamTableData.value = [] // 清空表格数据
  327. }
  328. // 格式化利用率为百分比
  329. const formatRate = (row) => {
  330. return (row.utilizationRate * 100).toFixed(2) + '%'
  331. }
  332. // 注气量格式化函数(单位转换:方 -> 万方)
  333. const gasInjectionFormatter = (row: any, column: any, cellValue: any, index: number | null) => {
  334. if (cellValue === null || cellValue === undefined || cellValue === '') return ''
  335. // 将方转换为万方,保留两位小数
  336. const value = parseFloat(cellValue)
  337. return (value / 10000).toFixed(2)
  338. }
  339. const by = ref({
  340. todo: undefined,
  341. finished: undefined
  342. })
  343. const fill = ref({
  344. filledCount: undefined,
  345. unfilledCount: undefined
  346. })
  347. const inspectt = ref({
  348. finished: 0,
  349. todo: 0
  350. })
  351. const rateQueryParams = reactive({
  352. createTime: [],
  353. })
  354. const backendData = ref([])
  355. const statusChartRef = ref() // 设备数量统计的图表
  356. const materialChartRef = ref() // 设备数量统计的图表
  357. const zqlChartRef = ref() // 注气量统计的图表
  358. const todayZqlRef = ref() // 注气量统计的图表
  359. const { t } = useI18n() // 国际化
  360. const device = ref({
  361. total: undefined,
  362. today: undefined
  363. })
  364. const maintain = ref({
  365. total: undefined,
  366. today: undefined
  367. })
  368. const work = ref({
  369. total: undefined,
  370. today: undefined
  371. })
  372. const inspect = ref({
  373. total: undefined,
  374. today: undefined
  375. })
  376. const status = ref({
  377. finished: 0,
  378. todo: 0
  379. })
  380. const todayStatus = ref({
  381. finished: 0,
  382. todo: 0
  383. })
  384. const handleDateChange = () => {
  385. IotStatApi.getRhRate(rateQueryParams).then((res) =>{
  386. materialTableData.value = res
  387. })
  388. }
  389. const typeData = ref({})
  390. const materialData = ref({})
  391. const orderSevenData = ref({})
  392. const ywcbSevenData = ref({})
  393. const zqlData = ref({})
  394. const zqlTodayData = ref({})
  395. /** 获取统计数据 */
  396. const getStats = () => {
  397. initYwcbChart()
  398. // 获取基础统计数据
  399. IotStatApi.getDeviceCount('rh').then((res) => {
  400. device.value = res
  401. })
  402. IotStatApi.getMaintainCount('rh').then((res) => {
  403. maintain.value = res
  404. })
  405. IotStatApi.getMainWorkCount("").then((res) => {
  406. work.value = res
  407. })
  408. IotStatApi.getInspectCount("").then((res) => {
  409. inspect.value = res
  410. })
  411. // IotStatApi.getMaintenanceStatus("").then((res) => {
  412. // status.value = res
  413. // // initCharts()
  414. // })
  415. IotStatApi.getMaintenanceTodayStatus("").then((res) => {
  416. todayStatus.value = res
  417. initTopChart()
  418. })
  419. IotStatApi.getDeviceStatusCount('rh').then((res) => {
  420. typeData.value = res
  421. initDeviceStatusCharts()
  422. })
  423. // IotStatApi.getSafeCount().then((res) => {
  424. // safe.value = res
  425. // })
  426. IotStatApi.getMaterial().then((res) => {
  427. materialData.value = res
  428. initMaterials()
  429. })
  430. IotStatApi.getOrderSeven('rh').then((res) => {
  431. orderSevenData.value = res
  432. initQxChart()
  433. })
  434. IotStatApi.getOrderYwcb('rh').then((res) => {
  435. ywcbSevenData.value = res
  436. initYwcbChart()
  437. })
  438. IotStatApi.getMaintenanceStatus('rh').then((res) => {
  439. by.value = res
  440. })
  441. IotStatApi.getRhZqlGases('rh').then((res) => {
  442. zqlData.value = res
  443. const localeStore = useLocaleStore()
  444. const lang = localeStore.getCurrentLocale.lang
  445. if (lang==='zh-CN') {
  446. initZqlChart('累计注气量','累计注水量')
  447. } else if (lang==='en') {
  448. initZqlChart('gas','water')
  449. }
  450. })
  451. IotStatApi.getRhZqlDaily('rh').then((res) => {
  452. zqlTodayData.value = res
  453. const localeStore = useLocaleStore()
  454. const lang = localeStore.getCurrentLocale.lang
  455. if (lang==='zh-CN') {
  456. initTodayZqlChart('当日注气量','当日注水量')
  457. } else if (lang==='en') {
  458. initTodayZqlChart('gas','water')
  459. }
  460. })
  461. const fillQueryParams = reactive({
  462. startTime: Date.now() - 7 * 24 * 60 * 60 * 1000, // 设置默认开始时间为 7 天前
  463. endTime: Date.now(), // 设置默认结束时间为当前时间
  464. createTime: [],
  465. deptId: '', // 选中的部门ID
  466. status: null // 填写状态
  467. })
  468. IotStatApi.getInspectStatuss(fillQueryParams, 'rh').then((res) => {
  469. inspectt.value = res
  470. })
  471. fillQueryParams.deptId = '157'
  472. IotStatApi.getDeptStatistics(fillQueryParams).then((res) => {
  473. fill.value = res.totalList[0] || []
  474. })
  475. // 计算近一周时间
  476. const end = new Date();
  477. const start = new Date();
  478. start.setTime(start.getTime() - 7 * 24 * 60 * 60 * 1000);
  479. // 格式化日期为后端需要的格式
  480. const formatDate = (date) => {
  481. const year = date.getFullYear();
  482. const month = String(date.getMonth() + 1).padStart(2, '0');
  483. const day = String(date.getDate()).padStart(2, '0');
  484. const hours = String(date.getHours()).padStart(2, '0');
  485. const minutes = String(date.getMinutes()).padStart(2, '0');
  486. const seconds = String(date.getSeconds()).padStart(2, '0');
  487. return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  488. };
  489. rateQueryParams.createTime = [formatDate(start), formatDate(end)];
  490. IotStatApi.getRhRate(rateQueryParams).then((res) =>{
  491. materialTableData.value = res
  492. })
  493. }
  494. let materialInstance;
  495. const initMaterials = () => {
  496. if (!materialChartRef.value) return
  497. const option = {
  498. tooltip: {
  499. trigger: 'item'
  500. },
  501. legend: {
  502. orient: 'horizontal', // 水平排列图例项
  503. bottom: '0%', // 放置在底部
  504. icon: 'circle',
  505. textStyle: {
  506. color:'#B6C8DA'
  507. }
  508. },
  509. series: [
  510. {
  511. name: '',
  512. type: 'pie',
  513. radius: ['50%', '80%'],
  514. avoidLabelOverlap: false,
  515. center: ['50%', '44%'],
  516. label: {
  517. show: false,
  518. position: 'outside',
  519. color:'#B6C8DA'
  520. },
  521. emphasis: {
  522. label: {
  523. show: true,
  524. fontSize: 15,
  525. fontWeight: 'bold'
  526. }
  527. },
  528. labelLine: {
  529. show: false
  530. },
  531. data: materialData.value
  532. }
  533. ]
  534. }
  535. // 初始化图表
  536. materialInstance = echarts.init(materialChartRef.value)
  537. materialInstance.setOption(option)
  538. // 窗口缩放监听
  539. window.addEventListener('resize', handleMaterialResize)
  540. handleMaterialResize()
  541. }
  542. let zqlTodayInstance = null
  543. const initTodayZqlChart = async (gas:any,water:any) => {
  544. if (!todayZqlRef.value) return
  545. zqlTodayInstance = echarts.init(todayZqlRef.value)
  546. const option = {
  547. tooltip: {
  548. trigger: 'axis',
  549. axisPointer: {
  550. type: 'cross',
  551. label: {
  552. backgroundColor: '#6a7985'
  553. }
  554. }
  555. },
  556. legend: {
  557. data: zqlTodayData.value.series.map((item) => item.name),
  558. top: 30,
  559. textStyle: {
  560. color: '#B6C8DA'
  561. }
  562. },
  563. grid: {
  564. left: '3%',
  565. right: '4%',
  566. bottom: '3%',
  567. containLabel: true
  568. },
  569. xAxis: {
  570. type: 'category',
  571. boundaryGap: false,
  572. data: zqlTodayData.value.xAxis,
  573. axisLine: {
  574. lineStyle: {
  575. color: '#B6C8DA' // X轴线白色半透明
  576. }
  577. },
  578. axisLabel: {
  579. color: '#B6C8DA',
  580. formatter: (value) => value.split('-').join('/') // 显示为 2023/01
  581. }
  582. },
  583. yAxis: [
  584. {
  585. type: 'value',
  586. name:gas+'(m³)',
  587. axisLabel: {
  588. color: '#B6C8DA',
  589. formatter: '{value}'
  590. },
  591. splitLine: {
  592. show: true, // 显示水平网格线(默认显示)
  593. lineStyle: {
  594. // 水平网格线颜色(可设置为纯色或带透明度的颜色)
  595. color: '#457794', // 浅灰色半透明
  596. // 可选:设置线条类型(实线/虚线/点线)
  597. type: 'dashed'
  598. }
  599. },
  600. axisLine: {
  601. lineStyle: {
  602. color: '#B6C8DA'
  603. }
  604. },
  605. position: 'left' // 左侧 Y 轴
  606. },
  607. // {
  608. // type: 'value',
  609. // name:water+'(m³)',
  610. // axisLabel: {
  611. // color: '#B6C8DA',
  612. // formatter: '{value}'
  613. // },
  614. // splitLine: {
  615. // show: true, // 显示水平网格线(默认显示)
  616. // lineStyle: {
  617. // // 水平网格线颜色(可设置为纯色或带透明度的颜色)
  618. // color: '#457794', // 浅灰色半透明
  619. // // 可选:设置线条类型(实线/虚线/点线)
  620. // type: 'dashed'
  621. // }
  622. // },
  623. // axisLine: {
  624. // lineStyle: {
  625. // color: '#B6C8DA'
  626. // }
  627. // },
  628. // position: 'right', // 右侧 Y 轴
  629. // splitLine: {
  630. // show: false // 隐藏右侧 Y 轴的分割线
  631. // }
  632. // }
  633. ],
  634. series: zqlTodayData.value.series.map((item, index) => {
  635. // 假设前两条曲线使用左侧 Y 轴,后两条曲线使用右侧 Y 轴
  636. // const yAxisIndex = index < 1 ? 0 : 1
  637. return {
  638. name: item.name,
  639. type: 'line',
  640. smooth: true,
  641. symbol: 'circle',
  642. symbolSize: 8,
  643. itemStyle: {
  644. color: ['#5470c6', '#f1d209'][index]
  645. },
  646. areaStyle: {
  647. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  648. { offset: 0, color: 'rgba(84,112,198,0.4)' },
  649. { offset: 1, color: 'rgba(84,112,198,0.1)' }
  650. ])
  651. },
  652. data: item.data,
  653. // yAxisIndex: yAxisIndex // 指定使用的 Y 轴
  654. }
  655. })
  656. }
  657. zqlTodayInstance.setOption(option)
  658. // 窗口缩放监听
  659. window.addEventListener('resize', handleZqlTodayResize)
  660. handleZqlTodayResize()
  661. }
  662. /** 初始化图表 */
  663. const initDeviceStatusCharts = () => {
  664. // 设备数量统计
  665. echarts.init(statusChartRef.value).setOption({
  666. tooltip: {
  667. trigger: 'item'
  668. },
  669. legend: {
  670. orient: 'horizontal', // 水平排列图例项
  671. bottom: '0%', // 放置在底部
  672. icon: 'circle',
  673. textStyle: {
  674. color: '#B6C8DA'
  675. }
  676. },
  677. series: [
  678. {
  679. name: '',
  680. type: 'pie',
  681. radius: ['50%', '80%'],
  682. avoidLabelOverlap: false,
  683. center: ['50%', '44%'],
  684. label: {
  685. show: false,
  686. position: 'outside',
  687. color: 'white'
  688. },
  689. emphasis: {
  690. label: {
  691. show: true,
  692. fontSize: 15,
  693. fontWeight: 'bold'
  694. }
  695. },
  696. labelLine: {
  697. show: false
  698. },
  699. data: typeData.value
  700. }
  701. ]
  702. })
  703. }
  704. /** 初始化消息统计图表 */
  705. const chartContainer = ref(null)
  706. let chartInstance;
  707. // 模拟数据获取
  708. const fetchChartData = async () => {
  709. // 模拟异步请求
  710. return new Promise((resolve) => {
  711. setTimeout(() => {
  712. resolve({
  713. months: ['空压机', '增压机', '提纯撬'],
  714. repairs: [10, 30, 90]
  715. })
  716. }, 300)
  717. })
  718. }
  719. // 初始化图表配置
  720. const initYwcbChart = async () => {
  721. if (!chartContainer.value) return
  722. // 获取数据
  723. const option = {
  724. tooltip: {
  725. trigger: 'axis',
  726. axisPointer: {
  727. type: 'shadow'
  728. },
  729. // formatter: (params) => {
  730. // return `${params[0].axisValue}<br/>
  731. // ${params[0].marker} ${params[0].seriesName}: ${params[0].value}`
  732. // }
  733. },
  734. // legend: {
  735. // data: ['当日运维成本'],
  736. // top: 1,
  737. // textStyle: {
  738. // color: '#B6C8DA'
  739. // }
  740. // },
  741. grid: {
  742. left: '3%',
  743. right: '4%',
  744. bottom: '1%',
  745. containLabel: true
  746. },
  747. xAxis: {
  748. type: 'category',
  749. data: ywcbSevenData.value.xAxis,
  750. axisLabel: {
  751. color: '#B6C8DA',
  752. formatter: (value) => value.split('-').join('/')
  753. },
  754. axisLine: {
  755. lineStyle: {
  756. color: '#B6C8DA' // X轴线白色半透明
  757. }
  758. },
  759. },
  760. yAxis: {
  761. type: 'value',
  762. axisLabel: {
  763. color: '#B6C8DA',
  764. // formatter: (value) => Math.floor(value).toString()
  765. },
  766. splitLine: {
  767. show: true, // 显示水平网格线(默认显示)
  768. lineStyle: {
  769. // 水平网格线颜色(可设置为纯色或带透明度的颜色)
  770. color: '#457794', // 浅灰色半透明
  771. // 可选:设置线条类型(实线/虚线/点线)
  772. type: 'dashed'
  773. }
  774. },
  775. axisLine: {
  776. lineStyle: {
  777. color: '#B6C8DA'
  778. }
  779. }
  780. },
  781. series: [
  782. {
  783. name: '当日运维成本',
  784. type: 'bar',
  785. itemStyle: {
  786. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: '#f69606' }])
  787. },
  788. emphasis: {
  789. focus: 'series'
  790. },
  791. data: ywcbSevenData.value.series
  792. }
  793. ]
  794. }
  795. // 初始化图表
  796. chartInstance = echarts.init(chartContainer.value)
  797. chartInstance.setOption(option)
  798. // 窗口缩放监听
  799. window.addEventListener('resize', handleResize)
  800. handleResize()
  801. }
  802. // 自适应调整
  803. const handleResize = () => {
  804. chartInstance?.resize()
  805. }
  806. // 自适应调整
  807. const handleQxResize = () => {
  808. qxInstance?.resize()
  809. }
  810. const handleZqlResize = () => {
  811. zqlInstance?.resize()
  812. }
  813. const handleZqlTodayResize = () => {
  814. zqlTodayInstance?.resize()
  815. }
  816. const handleMaterialResize = () => {
  817. materialInstance?.resize()
  818. }
  819. const topContainer = ref(null)
  820. let topInstance;
  821. // 响应式容器尺寸
  822. const { width, height } = useElementSize(topContainer)
  823. // 初始化图表配置
  824. const getTopOption = () => {
  825. // backendData.value = data
  826. const data = backendData.value.sort((a, b) => a.value - b.value)
  827. return {
  828. tooltip: {
  829. trigger: 'axis',
  830. axisPointer: { type: 'shadow' },
  831. formatter: (params) => {
  832. const item = params[0]
  833. return `${item.name}<br/>${item.marker} ${item.value.toLocaleString()}`
  834. }
  835. },
  836. grid: {
  837. height: '200px',
  838. left: '6%',
  839. right: '6%',
  840. bottom: '18%',
  841. containLabel: true
  842. },
  843. xAxis: {
  844. type: 'value',
  845. axisLabel: {
  846. color: '#B6C8DA',
  847. formatter: (value) => {
  848. if (value >= 10000) return `${(value / 10000).toFixed(1)}万`
  849. return value.toLocaleString()
  850. }
  851. },
  852. axisLine: {
  853. lineStyle: {
  854. color: '#B6C8DA' // X轴线白色半透明
  855. }
  856. },
  857. splitLine: {
  858. show: true, // 显示水平网格线(默认显示)
  859. lineStyle: {
  860. // 水平网格线颜色(可设置为纯色或带透明度的颜色)
  861. color: '#457794', // 浅灰色半透明
  862. // 可选:设置线条类型(实线/虚线/点线)
  863. type: 'dashed'
  864. }
  865. }
  866. },
  867. yAxis: {
  868. type: 'category',
  869. data: data.map((item) => item.category),
  870. axisTick: { show: false },
  871. axisLabel: { color: '#B6C8DA' },
  872. axisLine: {
  873. lineStyle: {
  874. color: '#B6C8DA' // X轴线白色半透明
  875. }
  876. }
  877. },
  878. series: [
  879. {
  880. type: 'bar',
  881. data: data.map((item) => item.value),
  882. itemStyle: {
  883. color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [
  884. { offset: 0, color: '#83bff6' },
  885. { offset: 0.7, color: '#188df0' },
  886. { offset: 1, color: '#188df0' }
  887. ]),
  888. borderRadius: [0, 8, 8, 0]
  889. },
  890. label: {
  891. show: true,
  892. position: 'right',
  893. formatter: '{@value}',
  894. color: '#B6C8DA',
  895. fontWeight: 'bold'
  896. },
  897. emphasis: {
  898. itemStyle: {
  899. shadowBlur: 10,
  900. shadowColor: 'rgba(0, 0, 0, 0.5)'
  901. }
  902. }
  903. }
  904. ]
  905. }
  906. }
  907. // 初始化图表
  908. const initTopChart = async () => {
  909. await IotStatApi.getDeviceTypeCount('rh').then((res) => {
  910. backendData.value = res
  911. })
  912. if (!topContainer.value) return
  913. topInstance = echarts.init(topContainer.value)
  914. updateTopChart()
  915. }
  916. // 更新图表
  917. const updateTopChart = () => {
  918. if (!topInstance) return
  919. topInstance.setOption(getTopOption())
  920. }
  921. // 自适应调整
  922. watch([width, height], () => {
  923. topInstance?.resize()
  924. })
  925. // 监听数据变化
  926. watch(
  927. backendData,
  928. () => {
  929. updateTopChart()
  930. },
  931. { deep: true }
  932. )
  933. const qxRef = ref(null)
  934. let qxInstance;
  935. let zqlInstance;
  936. const initZqlChart = (gas:any,water:any) => {
  937. if (!zqlChartRef.value) return
  938. // 获取数据
  939. // ECharts配置
  940. const option = {
  941. tooltip: {
  942. trigger: 'axis',
  943. axisPointer: {
  944. type: 'shadow',
  945. label: {
  946. backgroundColor: '#6a7985'
  947. }
  948. }
  949. // trigger: 'axis',
  950. // axisPointer: {
  951. // type: 'shadow'
  952. // },
  953. // formatter: (params) => {
  954. // return `${params[0].axisValue}<br/>
  955. // ${params[0].marker} ${params[0].seriesName}: ${params[0].value}`
  956. // }
  957. },
  958. legend: {
  959. data: zqlData.value.series.map((item) => item.name),
  960. top: 30,
  961. textStyle: {
  962. color: '#B6C8DA'
  963. }
  964. },
  965. grid: {
  966. left: '3%',
  967. right: '4%',
  968. bottom: '3%',
  969. containLabel: true
  970. },
  971. xAxis: {
  972. type: 'category',
  973. data: zqlData.value.xAxis,
  974. axisLine: {
  975. lineStyle: {
  976. color: '#B6C8DA' // X轴线白色半透明
  977. }
  978. },
  979. axisLabel: {
  980. color: '#B6C8DA',
  981. formatter: (value) => value.split('-').join('/')
  982. }
  983. },
  984. yAxis: [
  985. {
  986. type: 'value',
  987. name: gas+'(m³)',
  988. axisLabel: {
  989. color: '#B6C8DA',
  990. formatter: '{value}'
  991. },
  992. splitLine: {
  993. show: true, // 显示水平网格线(默认显示)
  994. lineStyle: {
  995. // 水平网格线颜色(可设置为纯色或带透明度的颜色)
  996. color: '#457794', // 浅灰色半透明
  997. // 可选:设置线条类型(实线/虚线/点线)
  998. type: 'dashed'
  999. }
  1000. },
  1001. axisLine: {
  1002. lineStyle: {
  1003. color: '#B6C8DA'
  1004. }
  1005. },
  1006. position: 'left' // 左侧 Y 轴
  1007. },
  1008. ],
  1009. series: zqlData.value.series.map((item, index) => {
  1010. // 假设前两条曲线使用左侧 Y 轴,后两条曲线使用右侧 Y 轴
  1011. return {
  1012. name: item.name,
  1013. type: 'bar',
  1014. smooth: true,
  1015. symbol: 'circle',
  1016. symbolSize: 8,
  1017. itemStyle: {
  1018. color: [ '#91cc75','#f1d209'][index]
  1019. },
  1020. areaStyle: {
  1021. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  1022. { offset: 0, color: 'rgba(84,112,198,0.4)' },
  1023. { offset: 1, color: 'rgba(84,112,198,0.1)' }
  1024. ])
  1025. },
  1026. data: item.data,
  1027. }
  1028. })
  1029. }
  1030. // 初始化图表
  1031. zqlInstance = echarts.init(zqlChartRef.value)
  1032. zqlInstance.setOption(option)
  1033. // 窗口缩放监听
  1034. window.addEventListener('resize', handleZqlResize)
  1035. handleZqlResize()
  1036. }
  1037. const initQxChart = () => {
  1038. if (!qxRef.value) return
  1039. qxInstance = echarts.init(qxRef.value)
  1040. const option = {
  1041. tooltip: {
  1042. trigger: 'axis',
  1043. axisPointer: {
  1044. type: 'cross',
  1045. label: {
  1046. backgroundColor: '#6a7985'
  1047. }
  1048. }
  1049. },
  1050. legend: {
  1051. data: orderSevenData.value.series.map((item) => item.name),
  1052. top: 30,
  1053. textStyle: {
  1054. color:'#B6C8DA'
  1055. }
  1056. },
  1057. grid: {
  1058. left: '3%',
  1059. right: '4%',
  1060. bottom: '3%',
  1061. containLabel: true
  1062. },
  1063. xAxis: {
  1064. type: 'category',
  1065. boundaryGap: false,
  1066. data: orderSevenData.value.xAxis,
  1067. axisLabel: {
  1068. color: '#B6C8DA',
  1069. formatter: (value) => value.split('-').join('/')
  1070. },
  1071. axisLine: {
  1072. lineStyle: {
  1073. color: '#B6C8DA' // X轴线白色半透明
  1074. }
  1075. },
  1076. },
  1077. yAxis: [
  1078. {
  1079. type: 'value',
  1080. axisLabel: {
  1081. color: '#B6C8DA',
  1082. formatter: '{value}'
  1083. },
  1084. splitLine: {
  1085. show: true, // 显示水平网格线(默认显示)
  1086. lineStyle: {
  1087. // 水平网格线颜色(可设置为纯色或带透明度的颜色)
  1088. color: '#457794', // 浅灰色半透明
  1089. // 可选:设置线条类型(实线/虚线/点线)
  1090. type: 'dashed'
  1091. }
  1092. },
  1093. axisLine: {
  1094. lineStyle: {
  1095. color: '#B6C8DA'
  1096. }
  1097. },
  1098. position: 'left' // 左侧 Y 轴
  1099. },
  1100. {
  1101. type: 'value',
  1102. axisLabel: {
  1103. color: '#B6C8DA',
  1104. formatter: '{value}'
  1105. },
  1106. splitLine: {
  1107. show: true, // 显示水平网格线(默认显示)
  1108. lineStyle: {
  1109. // 水平网格线颜色(可设置为纯色或带透明度的颜色)
  1110. color: '#457794', // 浅灰色半透明
  1111. // 可选:设置线条类型(实线/虚线/点线)
  1112. type: 'dashed'
  1113. }
  1114. },
  1115. axisLine: {
  1116. lineStyle: {
  1117. color: '#B6C8DA'
  1118. }
  1119. },
  1120. position: 'right', // 右侧 Y 轴
  1121. splitLine: {
  1122. show: false // 隐藏右侧 Y 轴的分割线
  1123. }
  1124. }
  1125. ],
  1126. series: orderSevenData.value.series.map((item, index) => {
  1127. // 假设前两条曲线使用左侧 Y 轴,后两条曲线使用右侧 Y 轴
  1128. const yAxisIndex = index < 2 ? 0 : 1
  1129. return {
  1130. name: item.name,
  1131. type: 'line',
  1132. smooth: true,
  1133. symbol: 'circle',
  1134. symbolSize: 8,
  1135. itemStyle: {
  1136. color: ['#5470c6', '#f1d209', '#e14f0f', '#91cc75'][index]
  1137. },
  1138. areaStyle: {
  1139. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  1140. { offset: 0, color: 'rgba(84,112,198,0.4)' },
  1141. { offset: 1, color: 'rgba(84,112,198,0.1)' }
  1142. ])
  1143. },
  1144. data: item.data,
  1145. yAxisIndex: yAxisIndex // 指定使用的 Y 轴
  1146. }
  1147. })
  1148. }
  1149. qxInstance.setOption(option)
  1150. // 窗口缩放监听
  1151. window.addEventListener('resize', handleQxResize)
  1152. handleQxResize()
  1153. }
  1154. // 响应式调整
  1155. const resizeQxChart = () => qxInstance?.resize()
  1156. const resizeZqlChart = () => zqlInstance?.resize()
  1157. const resizeZqlTodayChart = () => zqlTodayInstance?.resize()
  1158. const resizeMaterialChart = () => materialInstance?.resize()
  1159. /** 初始化 */
  1160. onMounted(() => {
  1161. getStats()
  1162. // initChart()
  1163. // initTopChart()
  1164. // initActiveChart()
  1165. // initQxChart()
  1166. window.addEventListener('resize', resizeQxChart)
  1167. // fetchTop()
  1168. window.addEventListener('resize', () => topInstance?.resize())
  1169. })
  1170. onBeforeUnmount(() => {
  1171. chartInstance?.dispose()
  1172. window.removeEventListener('resize', () => chartInstance?.resize())
  1173. topInstance?.dispose()
  1174. window.removeEventListener('resize', handleResize)
  1175. qxInstance?.dispose()
  1176. window.removeEventListener('resize', resizeQxChart)
  1177. zqlInstance?.dispose()
  1178. window.removeEventListener('resize', resizeZqlChart)
  1179. zqlTodayInstance?.dispose()
  1180. window.removeEventListener('resize', resizeZqlTodayChart)
  1181. materialInstance?.dispose()
  1182. window.removeEventListener('resize', resizeMaterialChart)
  1183. })
  1184. </script>
  1185. <style lang="scss" scoped>
  1186. .page-container {
  1187. background-color: #3a6fa3;
  1188. min-height: 100vh;
  1189. padding: 20px;
  1190. }
  1191. .summary {
  1192. margin-bottom: 20px;
  1193. }
  1194. ::v-deep .chart-card {
  1195. background-color: rgba(0, 0, 0, 0.3);
  1196. border-radius: 8px;
  1197. box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  1198. transition: all 0.3s ease;
  1199. border: none;
  1200. &:hover {
  1201. box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  1202. }
  1203. }
  1204. .safety-days-card {
  1205. .safety-days-content {
  1206. display: flex;
  1207. flex-direction: column;
  1208. align-items: center;
  1209. justify-content: center;
  1210. height: 150px;
  1211. position: relative;
  1212. .days-number {
  1213. font-size: 58px;
  1214. font-weight: bold;
  1215. color: darkorange;
  1216. line-height: 1;
  1217. transition: all 0.3s ease;
  1218. }
  1219. .days-number:hover {
  1220. transform: scale(1.05);
  1221. }
  1222. .days-label {
  1223. font-size: 20px;
  1224. color: white;
  1225. margin-top: 8px;
  1226. }
  1227. .safety-desc {
  1228. font-size: 14px;
  1229. color: #999;
  1230. position: absolute;
  1231. bottom: 10px;
  1232. text-align: center;
  1233. width: 90%;
  1234. }
  1235. }
  1236. }
  1237. @media (max-width: 768px) {
  1238. .page-container {
  1239. padding: 10px;
  1240. }
  1241. }
  1242. ::v-deep .el-card__header {
  1243. border-bottom: none !important;
  1244. padding-bottom: 0;
  1245. }
  1246. .table-container {
  1247. padding: 16px;
  1248. height: 320px;
  1249. box-sizing: border-box;
  1250. overflow: auto;
  1251. // 滚动条样式优化
  1252. &::-webkit-scrollbar {
  1253. width: 6px;
  1254. height: 6px;
  1255. }
  1256. &::-webkit-scrollbar-thumb {
  1257. background-color: rgba(255, 255, 255, 0.2);
  1258. border-radius: 3px;
  1259. }
  1260. &::-webkit-scrollbar-track {
  1261. background-color: transparent;
  1262. }
  1263. }
  1264. // 修复表格hover样式
  1265. ::v-deep .el-table__row:hover > td {
  1266. background-color: rgba(255, 255, 255, 0.05) !important;
  1267. }
  1268. .custom-scroll-dialog {
  1269. /* 可选:限制对话框整体最大高度(避免超出屏幕) */
  1270. max-height: 90vh;
  1271. overflow: hidden; /* 隐藏整体溢出,避免出现双重滚动条 */
  1272. }
  1273. /* 滚动内容容器:核心样式 */
  1274. .dialog-scroll-content {
  1275. max-height: 60vh; /* 固定最大高度(可根据需求调整,如500px) */
  1276. overflow-y: auto; /* 垂直方向溢出时显示滚动条 */
  1277. padding-right: 8px; /* 避免滚动条遮挡内容(可选) */
  1278. }
  1279. /* 优化滚动条样式(可选,提升UI体验) */
  1280. .dialog-scroll-content::-webkit-scrollbar {
  1281. width: 6px; /* 滚动条宽度 */
  1282. }
  1283. .dialog-scroll-content::-webkit-scrollbar-thumb {
  1284. background-color: #e5e7eb; /* 滚动条滑块颜色 */
  1285. border-radius: 3px; /* 滚动条圆角 */
  1286. }
  1287. .dialog-scroll-content::-webkit-scrollbar-thumb:hover {
  1288. background-color: #d1d5db; /* hover时滑块颜色 */
  1289. }
  1290. </style>