diff --git a/src/views/screen/components/AlertList.vue b/src/views/screen/components/AlertList.vue index 72bc5ff..fd8db4e 100644 --- a/src/views/screen/components/AlertList.vue +++ b/src/views/screen/components/AlertList.vue @@ -5,32 +5,59 @@
- -
-
- {{ title.name }} -
-
- -
- + + + + +
@@ -51,6 +78,7 @@ interface TableTitle { } interface Props { + loading?: boolean title?: string listData: AlertItem[] maxHeight?: string @@ -313,4 +341,31 @@ onUnmounted(() => { } } } + +// 骨架屏样式 +.skeleton-pulse { + animation: skeleton-loading-alertlist 1.5s ease-in-out infinite; + background-color: #444; + border-radius: 4px; +} + +.skeleton-row { + margin-bottom: 4px; +} + +.skeleton-item { + margin-bottom: 4px; +} + +@keyframes skeleton-loading-alertlist { + 0% { + opacity: 1; + } + 50% { + opacity: 0.4; + } + 100% { + opacity: 1; + } +} diff --git a/src/views/screen/components/HiddenDangerPanel.vue b/src/views/screen/components/HiddenDangerPanel.vue index 5986464..b048e5b 100644 --- a/src/views/screen/components/HiddenDangerPanel.vue +++ b/src/views/screen/components/HiddenDangerPanel.vue @@ -10,11 +10,13 @@
重大 - {{ hiddenDangerData?.major || 0 }} +
+ {{ hiddenDangerData?.major || 0 }}
一般 - {{ hiddenDangerData?.general || 0 }} +
+ {{ hiddenDangerData?.general || 0 }}
@@ -30,7 +32,8 @@
- +
+
已逾期
已处理
@@ -41,7 +44,8 @@
- +
+
@@ -65,7 +69,8 @@

- {{ hiddenDangerData?.safetyIndex || 0 }} + + {{ hiddenDangerData?.safetyIndex || 0 }}
@@ -77,6 +82,7 @@ import echarts from '@/plugins/echarts' interface Props { + loading?: boolean hiddenDangerData?: { general: number major: number @@ -936,4 +942,32 @@ watch(() => props.hiddenDangerData?.top3Types, (newVal) => { .dot.blue { background-color: #3b82f6; } + +// 骨架屏动画 +.skeleton-pulse { + animation: skeleton-loading-hiddendanger 1.5s ease-in-out infinite; + background-color: #444; + border-radius: 4px; +} + +// 圆形饼图骨架屏 +.skeleton-chart-circle { + width: 120px; + height: 120px; + border-radius: 50%; + margin: 30px auto 50px auto; + background-color: #444; +} + +@keyframes skeleton-loading-hiddendanger { + 0% { + opacity: 1; + } + 50% { + opacity: 0.4; + } + 100% { + opacity: 1; + } +} diff --git a/src/views/screen/components/HighRiskAlertPanel.vue b/src/views/screen/components/HighRiskAlertPanel.vue index cc59a32..cb588fb 100644 --- a/src/views/screen/components/HighRiskAlertPanel.vue +++ b/src/views/screen/components/HighRiskAlertPanel.vue @@ -4,29 +4,37 @@
+ + +
- {{ alertData?.total || 0 }} +
+ {{ alertData?.total || 0 }}
告警总数 - {{ alertData?.total || 0 }} +
+ {{ alertData?.total || 0 }}
已处理 - {{ alertData?.processed || 0 }} +
+ {{ alertData?.processed || 0 }}
待处理 - {{ alertData?.pending || 0 }} +
+ {{ alertData?.pending || 0 }}
处理中 - {{ alertData?.processing }} +
+ {{ alertData?.processing }}
@@ -45,7 +53,7 @@
--> - + @@ -73,6 +81,7 @@ interface Props { alertDetails?: AlertItem[] sourceIndex?: number linkUrl?: string + loading?: boolean } // 默认值 @@ -84,7 +93,8 @@ const props = withDefaults(defineProps(), { processing: 0 }), alertDetails: () => [], - sourceIndex: 1 + sourceIndex: 1, + loading: false }) @@ -265,5 +275,104 @@ const props = withDefaults(defineProps(), { } } } + + // 骨架屏样式 + .skeleton-container { + .skeleton-tip-container { + position: relative; + width: 100%; + height: 70px; + + .skeleton-tip-image { + position: absolute; + top: -5px; + right: 10px; + z-index: 2; + + .skeleton-circle { + width: 80px; + height: 80px; + background-color: #3a3a3a; + border-radius: 50%; + } + + .skeleton-number { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + width: 30px; + height: 20px; + background-color: #3a3a3a; + border-radius: 4px; + } + } + + .skeleton-bg { + width: 100%; + height: 70px; + background-color: #3a3a3a; + border-radius: 4px; + } + + .skeleton-tip-content { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + display: flex; + flex-direction: column; + justify-content: space-around; + padding: 8px 15px; + + .skeleton-col-item { + display: flex; + align-items: center; + gap: 8px; + + .skeleton-icon { + width: 23px; + height: 23px; + background-color: #3a3a3a; + border-radius: 4px; + } + + .skeleton-text { + flex: 1; + height: 16px; + background-color: #3a3a3a; + border-radius: 4px; + } + + .skeleton-value { + width: 40px; + height: 18px; + background-color: #3a3a3a; + border-radius: 4px; + } + } + } + } + } + + // 骨架屏动画 + .skeleton-pulse { + animation: skeleton-loading-highrisk 1.5s ease-in-out infinite; + background-color: #444; + border-radius: 4px; + } + + @keyframes skeleton-loading-highrisk { + 0% { + opacity: 1; + } + 50% { + opacity: 0.4; + } + 100% { + opacity: 1; + } + } } diff --git a/src/views/screen/components/OverviewPanel.vue b/src/views/screen/components/OverviewPanel.vue index ce47b22..8ddf39b 100644 --- a/src/views/screen/components/OverviewPanel.vue +++ b/src/views/screen/components/OverviewPanel.vue @@ -3,7 +3,34 @@
人员管理
-
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
@@ -64,6 +91,7 @@ 各园区统计
+
@@ -74,6 +102,7 @@ import { ref, onMounted, watch, computed } from 'vue' import { rgbToHex } from '@/utils/color' interface Props { + loading?: boolean totalCount: number formalEmployeeCount: number externalStaffCount: number @@ -319,5 +348,141 @@ onMounted(() => { min-height: 17.5vh; } } + + // 骨架屏样式 + .skeleton-container { + .skeleton-card { + display: flex; + padding: 0 20px; + column-gap: 15px; + font-size: 0.8rem; + + .skeleton-left { + display: flex; + height: 12vh; + min-width: 15vw; + padding: 0 10px; + background-image: url('@/assets/imgs/total_count_card_bg.png'); + background-size: cover; + column-gap: 6px; + align-items: center; + + .skeleton-icon { + width: 33px; + height: 33px; + background-color: #3a3a3a; + border-radius: 4px; + } + + .skeleton-text { + background-color: #3a3a3a; + border-radius: 4px; + } + + .skeleton-numbers { + display: flex; + align-items: center; + gap: 2px; + font-size: 0.8rem; + + .skeleton-number { + width: 26px; + height: 50px; + background-color: #3a3a3a; + border-radius: 4px; + } + } + } + + .skeleton-right { + display: flex; + height: 12vh; + min-width: 20vw; + background-image: url('@/assets/imgs/staff_types_bg.png'); + background-position: top center; + background-size: cover; + flex-direction: column; + justify-content: center; + row-gap: 4px; + + .skeleton-item { + display: flex; + align-items: center; + column-gap: 5px; + padding: 0 10px; + + .skeleton-row { + display: flex; + align-items: center; + gap: 4px; + flex: 1; + + .skeleton-icon-small { + width: 18px; + height: 18px; + background-color: #3a3a3a; + border-radius: 4px; + } + + .skeleton-text { + height: 16px; + width: 60px; + background-color: #3a3a3a; + border-radius: 4px; + } + } + + .skeleton-numbers { + display: flex; + align-items: center; + gap: 2px; + font-size: 0.8rem; + + .skeleton-number-small { + width: 14px; + height: 25px; + background-color: #3a3a3a; + border-radius: 2px; + } + } + } + } + } + } + + // 骨架屏动画 + .skeleton-pulse { + animation: skeleton-loading-overview 1.5s ease-in-out infinite; + + } + + // 圆形饼图骨架屏 + .skeleton-chart-circle { + width: 120px; + height: 120px; + border-radius: 50%; + margin: 30px auto 50px auto; + background-color: #444; + } + + // 柱状图骨架屏 + // .skeleton-chart-bar { + // width: 100%; + // height: 17.5vh; + // background-color: #444; + // border-radius: 8px; + // } + + @keyframes skeleton-loading-overview { + 0% { + opacity: 1; + } + 50% { + opacity: 0.4; + } + 100% { + opacity: 1; + } + } } diff --git a/src/views/screen/components/RiskStatisticsPanel.vue b/src/views/screen/components/RiskStatisticsPanel.vue index 5de6bf4..f43cdb6 100644 --- a/src/views/screen/components/RiskStatisticsPanel.vue +++ b/src/views/screen/components/RiskStatisticsPanel.vue @@ -9,7 +9,31 @@
-
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
{{ item.title }}
@@ -40,7 +64,7 @@
-
+ @@ -85,6 +109,7 @@ const tabCharts = ref>({ }) const props = defineProps<{ + loading?: boolean riskStatistics?: Record }>() @@ -415,5 +440,122 @@ const handleTabClick = (tab: TabType) => { // padding: 5px; // } // } + +// 骨架屏样式 +.skeleton-container { + .skeleton-grid { + display: grid; + grid-template-columns: repeat(3, minmax(0, 1fr)); + gap: 10px; + + .skeleton-card { + background-image: url('@/assets/images/screen/left_top_2_img.png'), + url('@/assets/images/screen/left_center_img.png'), + url('@/assets/images/screen/left_bottom_img.png'); + background-position: top center, left center, bottom center; + background-repeat: no-repeat, no-repeat, no-repeat; + background-size: 100% 90px, cover, 100% 68px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + + .skeleton-title { + width: 120px; + height: 16px; + background-color: #3a3a3a; + border-radius: 4px; + margin-bottom: 10px; + } + + .skeleton-chart { + position: relative; + width: 100px; + height: 100px; + margin-bottom: 10px; + + .skeleton-chart-circle { + width: 100%; + height: 100%; + background-color: #3a3a3a; + border-radius: 50%; + } + + .skeleton-chart-center { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + text-align: center; + + .skeleton-text-small { + width: 40px; + height: 12px; + background-color: #3a3a3a; + border-radius: 4px; + margin-bottom: 4px; + } + + .skeleton-text-large { + width: 30px; + height: 16px; + background-color: #3a3a3a; + border-radius: 4px; + } + } + } + + .skeleton-legend { + width: 100%; + + .skeleton-legend-item { + display: flex; + align-items: center; + justify-content: space-between; + margin-bottom: 6px; + + .skeleton-dot { + width: 8px; + height: 8px; + background-color: #3a3a3a; + border-radius: 50%; + } + + .skeleton-text { + flex: 1; + height: 12px; + background-color: #3a3a3a; + border-radius: 4px; + margin: 0 8px; + } + + .skeleton-value { + width: 20px; + height: 12px; + background-color: #3a3a3a; + border-radius: 4px; + } + } + } + } + } +} + +// 骨架屏动画 +.skeleton-pulse { + animation: skeleton-loading-riskstats 1.5s ease-in-out infinite; +} + +@keyframes skeleton-loading-riskstats { + 0% { + opacity: 1; + } + 50% { + opacity: 0.4; + } + 100% { + opacity: 1; + } +} diff --git a/src/views/screen/components/TimeoutWorkOrderPanel.vue b/src/views/screen/components/TimeoutWorkOrderPanel.vue index 8dbbd71..860a3d2 100644 --- a/src/views/screen/components/TimeoutWorkOrderPanel.vue +++ b/src/views/screen/components/TimeoutWorkOrderPanel.vue @@ -3,17 +3,21 @@
超时工单
+ +
- {{ timeoutWorkOrders?.total || 0 }} +
+ {{ timeoutWorkOrders?.total || 0 }}
超时工单数 - {{ timeoutWorkOrders?.total || 0 }} +
+ {{ timeoutWorkOrders?.total || 0 }}
@@ -32,7 +36,7 @@ --> - + @@ -52,6 +56,7 @@ interface TimeoutWorkOrders { // Props定义 interface Props { + loading?: boolean timeoutWorkOrders?: TimeoutWorkOrders alertDetails?: AlertItem[] sourceIndex?: number @@ -247,5 +252,104 @@ const props = withDefaults(defineProps(), { } } } + + // 骨架屏样式 + .skeleton-container { + .skeleton-tip-container { + position: relative; + width: 100%; + height: 70px; + + .skeleton-tip-image { + position: absolute; + top: -5px; + right: 10px; + z-index: 2; + + .skeleton-circle { + width: 80px; + height: 80px; + background-color: #3a3a3a; + border-radius: 50%; + } + + .skeleton-number { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + width: 30px; + height: 20px; + background-color: #3a3a3a; + border-radius: 4px; + } + } + + .skeleton-bg { + width: 100%; + height: 70px; + background-color: #3a3a3a; + border-radius: 4px; + } + + .skeleton-tip-content { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + display: flex; + flex-direction: column; + justify-content: center; + padding: 8px 15px; + + .skeleton-col-item { + display: flex; + align-items: center; + gap: 8px; + + .skeleton-icon { + width: 23px; + height: 23px; + background-color: #3a3a3a; + border-radius: 4px; + } + + .skeleton-text { + flex: 1; + height: 16px; + background-color: #3a3a3a; + border-radius: 4px; + } + + .skeleton-value { + width: 40px; + height: 18px; + background-color: #3a3a3a; + border-radius: 4px; + } + } + } + } + } + + // 骨架屏动画 + .skeleton-pulse { + animation: skeleton-loading-timeout 1.5s ease-in-out infinite; + background-color: #444; + border-radius: 4px; + } + + @keyframes skeleton-loading-timeout { + 0% { + opacity: 1; + } + 50% { + opacity: 0.4; + } + 100% { + opacity: 1; + } + } } diff --git a/src/views/screen/mainScreen.vue b/src/views/screen/mainScreen.vue index 6022d15..a8bd78f 100644 --- a/src/views/screen/mainScreen.vue +++ b/src/views/screen/mainScreen.vue @@ -24,25 +24,28 @@
- -
- -
- +
@@ -100,6 +103,9 @@ const riskStatistics = ref({ }) const dangerDetail = ref() +// 加载状态 +const isFirstLoading = ref(true) + // 动画相关的状态 const isAnimating = ref(false) const animationDuration = 2000 // 动画持续时间(毫秒) @@ -332,6 +338,11 @@ onUnmounted(() => { let isFirstLoad = ref(true) // 数据初始化方法 const loadDashboardData = async (): Promise => { + // 第一次加载时显示骨架屏 + if (isFirstLoading.value) { + console.log('第一次加载,显示骨架屏'); + } + const data = await getDashboardData() if (isFirstLoad.value) { console.log('第一次加载'); @@ -340,8 +351,11 @@ const loadDashboardData = async (): Promise => { } console.log('dashboardData.value>>>>>>>>>>', dashboardData.value); - try { - // 获取总体概览数据 + // 收集所有异步请求 + const promises = [] + + // 获取总体概览数据 + promises.push( getTableList('generalTotal', query).then(generalTotal => { if (generalTotal.records && generalTotal.records.length > 0) { dashboardData.value.totalCount = Number(generalTotal.records[0].totalCount) @@ -355,13 +369,13 @@ const loadDashboardData = async (): Promise => { external: Number(dashboardData.value.externalStaffCount), visitor: Number(dashboardData.value.visitorCount) }) + }).catch(error => { + console.error('获取总体概览数据失败:', error) }) - } catch (error) { - console.error('获取总体概览数据失败:', error) - } + ) - try { - // 获取各园区统计数据 + // 获取各园区统计数据 + promises.push( getTableList('parkscreen_user_info', query).then(parkscreen_user_info => { if (parkscreen_user_info.records && parkscreen_user_info.records.length > 0) { dashboardData.value.parkStatistics = parkscreen_user_info.records.map(el => { @@ -373,13 +387,13 @@ const loadDashboardData = async (): Promise => { } }) } + }).catch(error => { + console.error('获取各园区统计数据失败:', error) }) - } catch (error) { - console.error('获取各园区统计数据失败:', error) - } + ) - try { - // 获取风险预警数据 + // 获取风险预警数据 + promises.push( getTableList('risk_alert_data', query).then(risk_alert_data => { if (risk_alert_data.records && risk_alert_data.records.length > 0) { dashboardData.value.alertData.total = risk_alert_data.records[0].total @@ -390,12 +404,10 @@ const loadDashboardData = async (): Promise => { }).catch(error => { console.error('获取风险预警数据失败:', error) }) - } catch (error) { - console.error('获取风险预警数据失败:', error) - } + ) - try { - // 获取风险预警详情数据 + // 获取风险预警详情数据 + promises.push( getTableList('risk_alert_detail', query).then(risk_alert_detail => { if (risk_alert_detail.records && risk_alert_detail.records.length > 0) { dashboardData.value.alertData.details = risk_alert_detail.records @@ -403,12 +415,10 @@ const loadDashboardData = async (): Promise => { }).catch(error => { console.error('获取风险预警详情数据失败:', error) }) - } catch (error) { - console.error('获取风险预警详情数据失败:', error) - } + ) - try { - // 获取超期工单数据 + // 获取超期工单数据 + promises.push( getTableList('timeout_work_order', query).then(timeout_work_order => { if (timeout_work_order.records && timeout_work_order.records.length >= 0) { dashboardData.value.timeoutWorkOrders.total = timeout_work_order.records.length @@ -417,180 +427,81 @@ const loadDashboardData = async (): Promise => { }).catch(error => { console.error('获取超期工单数据失败:', error) }) + ) + + // 处理风险统计和隐患数据(这些是异步的) + promises.push( + Promise.all([ + handleRiskTabChange('安全类事项'), + handleHiddenDangerPannelData(query) + ]).catch(error => { + console.error('处理风险统计和隐患数据失败:', error) + }) + ) + + // 等待所有异步操作完成 + try { + await Promise.all(promises) + console.log('所有数据加载完成') + + // 第一次加载完成后,隐藏骨架屏 + if (isFirstLoading.value) { + isFirstLoading.value = false + console.log('隐藏骨架屏') + } } catch (error) { - console.error('获取超期工单数据失败:', error) + console.error('数据加载过程中出现错误:', error) + // 即使出错也要隐藏骨架屏,避免界面一直处于加载状态 + if (isFirstLoading.value) { + isFirstLoading.value = false + } } - handleRiskTabChange('安全类事项') - handleHiddenDangerPannelData(query) - console.log('dashboardData.value>>>>>>>>>>', dashboardData.value); } -const handleHiddenDangerPannelData = (query) => { - let _data = { - flag: false, - general: 0, - major: 0, - overdue: 0, - processed: 0, - processing: 0, - pending: 0 - } +const handleHiddenDangerPannelData = async (query) => { + const promises = [] - let _data2 = { - flag: false, - general: 0, - major: 0, - overdue: 0, - processed: 0, - processing: 0, - pending: 0 - } - try { - // 获取隐患排查治理数据 + // 获取隐患排查治理数据 - 系统数据 + promises.push( getTableList('risk_level_count', query).then(res => { if (res.records && res.records.length > 0) { - _data.general = _data.general + Number(res.records[0].general_count) - _data.major = _data.major + Number(res.records[0].major_count) - // 获取隐患排查治理数据 - getTableList('risk_status_count', query).then(res => { - if (res.records && res.records.length > 0) { - // 接口返回的已经是百分比,直接使用 - const record = res.records[0] - _data.overdue = Number(record.overdueCnt) || 0 - _data.processed = Number(record.processedCnt) || 0 - _data.processing = Number(record.processingCnt) || 0 - _data.pending = 0 // 接口没有返回pending,设为0 - _data.flag = true - - console.log('risk_status_count 接口返回数据:', record) - console.log('处理后的 _data:', _data) - - _data2.flag = false - if (_data2.flag) { - // 合并数据 - console.log("请求系统和第三方成功,合并数据", _data, _data2); - let generalCnt = _data.general + _data2.general - let majorCnt = _data.major + _data2.major - dashboardData.value.hiddenDangerData.general = generalCnt - dashboardData.value.hiddenDangerData.major = majorCnt - - // 如果第三方数据也是百分比,需要合并;否则使用系统数据 - // 这里假设系统数据是百分比,第三方数据可能是数量或百分比 - let overdueCnt, processedCnt, processingCnt, pendingCnt - if (_data2.overdue > 1 || _data2.processed > 1 || _data2.processing > 1) { - // 第三方数据可能是百分比,直接使用系统数据(因为系统数据更准确) - overdueCnt = _data.overdue.toFixed(2) - processedCnt = _data.processed.toFixed(2) - processingCnt = _data.processing.toFixed(2) - pendingCnt = _data.pending.toFixed(2) - } else { - // 第三方数据可能是数量,需要计算百分比 - let totalCnt = generalCnt + majorCnt - overdueCnt = totalCnt > 0 ? ((_data.overdue + _data2.overdue) / totalCnt * 100).toFixed(2) : '0.00' - processedCnt = totalCnt > 0 ? ((_data.processed + _data2.processed) / totalCnt * 100).toFixed(2) : '0.00' - processingCnt = totalCnt > 0 ? ((_data.processing + _data2.processing) / totalCnt * 100).toFixed(2) : '0.00' - pendingCnt = totalCnt > 0 ? ((_data.pending + _data2.pending) / totalCnt * 100).toFixed(2) : '0.00' - } - - dashboardData.value.hiddenDangerData.progress = { - overdue: overdueCnt, - processed: processedCnt, - processing: processingCnt, - pending: pendingCnt, - } - console.log('合并后的 progress:', dashboardData.value.hiddenDangerData.progress) - } else { - console.log("请求系统成功,展示数据", _data, _data2); - dashboardData.value.hiddenDangerData.general = _data.general - dashboardData.value.hiddenDangerData.major = _data.major - - // 接口返回的已经是百分比,直接使用 - dashboardData.value.hiddenDangerData.progress = { - overdue: _data.overdue.toFixed(2), - processed: _data.processed.toFixed(2), - processing: _data.processing.toFixed(2), - pending: _data.pending.toFixed(2), - } - console.log('系统数据 progress:', dashboardData.value.hiddenDangerData.progress) - } - } - }) + dashboardData.value.hiddenDangerData.general = Number(res.records[0].general_count) + dashboardData.value.hiddenDangerData.major = Number(res.records[0].major_count) } - }) - - - // 获取隐患排查治理数据 - getTableList('hidden_danger_investigation', query).then(res => { + return getTableList('risk_status_count', query) + }).then(res => { if (res.records && res.records.length > 0) { - _data2.general = Number(res.records[0].general) - _data2.major = Number(res.records[0].major) - - // 安全指数另算,再起一个报表 - // dashboardData.value.hiddenDangerData.safetyIndex = res.records[0].safetyIndex - // 在这里添加获取安全指数的逻辑 - getTableList('hidden_danger_safety_index', query).then(res => { - if (res.records && res.records.length > 0) { - dashboardData.value.hiddenDangerData.safetyIndex = res.records[0].safetyIndex - } - }).catch(error => { - console.error('获取隐患排查治理数据失败:', error) - }) - - // 获取隐患排查治理处理进度数据 - getTableList('hidden_danger_process_progress', query).then(res => { - // if (res.records && res.records.length > 0) { - // _data2.flag = true - // _data2.overdue = Number(res.records[0].overdue) / 100 * (_data2.general + _data2.major) - // _data2.processed = Number(res.records[0].processed) / 100 * (_data2.general + _data2.major) - // _data2.processing = Number(res.records[0].processing) / 100 * (_data2.general + _data2.major) - // _data2.pending = Number(res.records[0].pending) / 100 * (_data2.general + _data2.major) - - // if (_data.flag) { - // console.log("请求第三方和系统成功,合并数据", _data, _data2); - // // 合并数据 - // let generalCnt = _data.general + _data2.general - // let majorCnt = _data.major + _data2.major - // dashboardData.value.hiddenDangerData.general = generalCnt - // dashboardData.value.hiddenDangerData.major = majorCnt - - // let totalCnt = generalCnt + majorCnt - // let overdueCnt = ((_data.overdue + _data2.overdue) / totalCnt * 100).toFixed(2) - // let processedCnt = ((_data.processed + _data2.processed) / totalCnt * 100).toFixed(2) - // let processingCnt = ((_data.processing + _data2.processing) / totalCnt * 100).toFixed(2) - // let pendingCnt = ((_data.pending + _data2.pending) / totalCnt * 100).toFixed(2) - // dashboardData.value.hiddenDangerData.progress = { - // overdue: overdueCnt, - // processed: processedCnt, - // processing: processingCnt, - // pending: pendingCnt, - // } - // } else { - // //显示三方数据 - // console.log("请求第三方成功,展示数据", _data, _data2); - // dashboardData.value.hiddenDangerData.general = _data2.general - // dashboardData.value.hiddenDangerData.major = _data2.major - - // dashboardData.value.hiddenDangerData.progress = { - // overdue: res.records[0].overdue, - // processed: res.records[0].processed, - // processing: res.records[0].processing, - // pending: res.records[0].pending, - // } - // } - // } - }).catch(error => { - console.error('获取隐患排查治理处理进度数据失败:', error) - }) + const record = res.records[0] + dashboardData.value.hiddenDangerData.progress = { + overdue: Number(record.overdueCnt).toFixed(2), + processed: Number(record.processedCnt).toFixed(2), + processing: Number(record.processingCnt).toFixed(2), + pending: '0.00' + } } }).catch(error => { - console.error('获取隐患排查治理数据失败:', error) + console.error('获取系统隐患数据失败:', error) }) - } catch (error) { - console.error('获取隐患排查治理数据失败:', error) - } + ) - try { - // 获取隐患排查治理TOP3类型数据 + // 获取第三方隐患排查治理数据 + promises.push( + getTableList('hidden_danger_investigation', query).then(res => { + if (res.records && res.records.length > 0) { + // 获取安全指数 + return getTableList('hidden_danger_safety_index', query) + } + }).then(res => { + if (res.records && res.records.length > 0) { + dashboardData.value.hiddenDangerData.safetyIndex = res.records[0].safetyIndex + } + }).catch(error => { + console.error('获取第三方隐患数据失败:', error) + }) + ) + + // 获取隐患排查治理TOP3类型数据 + promises.push( getTableList('hidden_danger_top', query).then(hidden_danger_top => { if (hidden_danger_top.records && hidden_danger_top.records.length > 0) { dashboardData.value.hiddenDangerData.top3Types = hidden_danger_top.records @@ -598,9 +509,9 @@ const handleHiddenDangerPannelData = (query) => { }).catch(error => { console.error('获取隐患排查治理TOP3类型数据失败:', error) }) - } catch (error) { - console.error('获取隐患排查治理TOP3类型数据失败:', error) - } + ) + + return Promise.all(promises) } // 处理风险统计tab切换