gaoluyang
15 小时以前 5c1e0a47eea514f59f697133fe8a01bcbf6f7a78
src/views/dashboard/analytics/index.vue
@@ -4,9 +4,11 @@
import { Page } from '@vben/common-ui';
import { Card, Col, Row } from 'ant-design-vue';
import { Col, Row } from 'ant-design-vue';
import { getHomeSummary } from '#/api/mes/home';
import { useHomeAccess } from '#/utils/use-home-access';
import { defaultSummary } from './data';
import AiInsights from './modules/ai-insights.vue';
@@ -20,6 +22,38 @@
const router = useRouter();
const summary = ref(defaultSummary);
const { canQuery, canSeeMenu } = useHomeAccess();
/** 首页各模块的接口权限都是 mes:home:query,取不到数就先别请求(否则弹「没有该操作权限」) */
const canViewSummary = computed(() => canQuery('mes:home:query'));
/** MES 生产 KPI:数据取自首页汇总接口,且对应菜单开着才渲染 */
const showKpi = computed(
  () =>
    canViewSummary.value &&
    ['MesProWorkOrder', 'MesProFeedback', 'MesQcIqc', 'MesDvMachinery'].some(
      (name) => canSeeMenu(name),
    ),
);
/** 生产趋势:数据来自生产报工 */
const showTrend = computed(
  () => canViewSummary.value && canSeeMenu('MesProFeedback'),
);
/** 工单状态分布 + 维修预警 */
const showAlert = computed(
  () =>
    canViewSummary.value &&
    (canSeeMenu('MesProWorkOrder') || canSeeMenu('MesDvRepair')),
);
/** 生产趋势和预警面板同一行,两块都没开就整行不渲染 */
const showMonitorRow = computed(() => showTrend.value || showAlert.value);
/** AI 分析块里「N 个工单可分析」取的也是首页汇总接口,取不到数就别显示这个假数字 */
const showAiInsights = computed(() => canViewSummary.value);
const greeting = computed(() => {
  const hour = new Date().getHours();
@@ -42,6 +76,7 @@
}
async function loadSummary() {
  if (!canViewSummary.value) return;
  summary.value = await getHomeSummary();
}
@@ -72,20 +107,29 @@
    </div>
    <!-- MES 生产 KPI -->
    <KpiCards :summary="summary" @navigate="handleNavigate" />
    <KpiCards v-if="showKpi" :summary="summary" @navigate="handleNavigate" />
    <!-- ERP/WMS/BPM 经营 KPI -->
    <BizCards @navigate="handleNavigate" />
    <!-- AI 智能分析 -->
    <AiInsights
      v-if="showAiInsights"
      :active-order-count="summary.workOrderActiveCount"
      @navigate="handleNavigate"
    />
    <!-- 生产趋势 + 预警面板 -->
    <Row :gutter="16" class="mb-4">
      <Col :lg="14" :md="24" :sm="24" :xl="14" :xs="24" class="mb-4">
    <Row v-if="showMonitorRow" :gutter="16" class="mb-4">
      <Col
        v-if="showTrend"
        :lg="showAlert ? 14 : 24"
        :md="24"
        :sm="24"
        :xl="showAlert ? 14 : 24"
        :xs="24"
        class="mb-4"
      >
        <div class="glass-card rounded-2xl p-5">
          <h3 class="mb-4 text-base font-semibold text-gray-800 dark:text-gray-100">
            生产趋势(近7天)
@@ -93,7 +137,15 @@
          <ProductionTrend />
        </div>
      </Col>
      <Col :lg="10" :md="24" :sm="24" :xl="10" :xs="24" class="mb-4">
      <Col
        v-if="showAlert"
        :lg="showTrend ? 10 : 24"
        :md="24"
        :sm="24"
        :xl="showTrend ? 10 : 24"
        :xs="24"
        class="mb-4"
      >
        <AlertPanel
          :repair-active-count="summary.repairActiveCount"
          @navigate="handleNavigate"