Browse Source

瑞都看板改了俩

yanghao 1 week ago
parent
commit
6220fd3505
1 changed files with 38 additions and 12 deletions
  1. 38 12
      src/views/pms/stat/rdkb.vue

+ 38 - 12
src/views/pms/stat/rdkb.vue

@@ -366,15 +366,7 @@
         :data="teamTableData"
         border
         style="width: 100%"
-        :header-cell-style="{
-          'background-color': 'transparent',
-          color: 'black',
-          'border-color': '#457794'
-        }"
-        :cell-style="{
-          'border-color': '#457794',
-          'background-color': 'transparent'
-        }"
+        :header-cell-style="{ 'background-color': 'transparent' }"
       >
         <el-table-column prop="teamName" label="队伍名称" align="center" />
         <el-table-column prop="cumulativeDays" label="累计天数" align="center" />
@@ -999,6 +991,7 @@ const initSparePartChart = (count: any, amount: any, spare: {}) => {
 // 设备利用率柱状图
 const utilizationRef = ref(null)
 let utilizationInstance: any = null
+const lastHoveredIndex = ref<number | null>(null)
 
 const initUtilizationChart = () => {
   if (!utilizationRef.value) return
@@ -1009,9 +1002,11 @@ const initUtilizationChart = () => {
     }
   } catch (e) {}
   utilizationInstance = echarts.init(utilizationRef.value)
-  const xData = materialTableData.value.map((it) => it.projectDeptName || it.dept || it.projectDept)
-  const seriesData = materialTableData.value.map((it) => {
-    const v = it.utilizationRate
+  const xData = (materialTableData.value as any[]).map(
+    (it) => it.projectDeptName || it.dept || it.projectDept
+  )
+  const seriesData = (materialTableData.value as any[]).map((it) => {
+    const v = (it as any).utilizationRate
     // 只保留整数部分(百分比的整数),例如 0.528 -> 52
     return v == null ? 0 : Math.trunc(Number(v) * 100)
   })
@@ -1044,6 +1039,34 @@ const initUtilizationChart = () => {
     ]
   }
   utilizationInstance.setOption(option)
+  // 鼠标悬停时展示队伍详情弹窗
+  try {
+    // 移除旧的监听,防止重复绑定
+    if (utilizationInstance.off) utilizationInstance.off('mouseover')
+    utilizationInstance.on('mouseover', (params: any) => {
+      try {
+        if (!params) return
+        // 仅处理柱状图系列的悬停
+        if (params.componentType !== 'series' || params.seriesType !== 'bar') return
+        const idx = params.dataIndex
+        if (idx == null) return
+        // 防止重复请求
+        if (lastHoveredIndex.value === idx && teamDialogVisible.value) return
+        lastHoveredIndex.value = idx
+        const row = ((materialTableData.value as any[])[idx] || {}) as any
+        const teamParams: any = {
+          deptId: row.projectDeptId || row.deptId || row.dept || row.projectDept,
+          createTime: rateQueryParams.createTime
+        }
+        teamDialogVisible.value = true
+        teamTableData.value = []
+        IotStatApi.getRdTeamRate(teamParams).then((res) => {
+          teamTableData.value = res
+        })
+      } catch (e) {}
+    })
+  } catch (e) {}
+
   window.addEventListener('resize', () => {
     try {
       utilizationInstance && utilizationInstance.resize()
@@ -1066,6 +1089,9 @@ onMounted(() => {
 onUnmounted(() => {
   try {
     if (utilizationInstance) {
+      try {
+        if (utilizationInstance.off) utilizationInstance.off('mouseover')
+      } catch (e) {}
       utilizationInstance.dispose()
       utilizationInstance = null
     }