yyb
14 小时以前 5470429a79313630a7ddef601de1d89e7dada754
src/views/index.vue
@@ -1,156 +1,321 @@
<template>
  <div class="dashboard">
    <!-- 顶部横向两栏 -->
    <div class="dashboard-top">
      <!-- 左:企业信息+三大数据卡片(上下排列) -->
      <div class="top-left">
        <div class="company-info">
          <!-- 顶部问候条 -->
          <div class="welcome-banner">
            <div class="welcome-title">
              <span class="welcome-user">{{ userStore.nickName || '系统管理员' }}</span>
              <span> 您好!祝您开心每一天</span>
            </div>
            <div class="welcome-time">登录于: {{ userStore.currentLoginTime }}</div>
  <div class="dashboard-cockpit">
    <section class="cockpit-panel welcome-panel">
      <div class="welcome-user">
        <el-avatar :src="welcomeAvatar" class="avatar" @error="handleWelcomeAvatarError">
          <el-icon><UserFilled /></el-icon>
        </el-avatar>
        <div class="welcome-text">
          <div class="welcome-title">
            {{ greetingText }},{{ userStore.nickName || userStore.name || "超级管理员" }} 👋
          </div>
          <div class="welcome-subtitle">专注工业数字化,助力智造升级</div>
        </div>
      </div>
      <div class="welcome-meta">
        <div class="meta-time digital-number">{{ nowTime }}</div>
        <div class="meta-tip">MES / MOM 生产运营驾驶舱</div>
      </div>
    </section>
          <!-- 用户信息卡片 -->
          <div class="user-card">
            <img :src="userStore.avatar" class="avatar" alt="" />
            <div class="user-card-main">
              <div class="user-name">{{ userStore.name }}</div>
              <div class="user-role">{{ userStore.roleName }}</div>
              <div class="user-meta">
                <span>{{ userStore.phoneNumber || '123456789' }}</span>
                <span class="sep">|</span>
                <span>{{ userStore.deptName || '组织架构' }}</span>
                <span class="sep">|</span>
                <span>{{ userStore.postName || '岗位名' }}</span>
    <section v-if="dashboardCards.length > 0" class="top-row">
      <div class="stats-grid">
        <article
            v-for="card in dashboardCards"
            :key="card.key"
            class="stat-card"
            :class="card.key"
        >
          <div class="stat-header">
            <div class="stat-title-wrap">
              <div class="stat-title">{{ card.title }}</div>
              <div class="stat-desc">{{ card.desc }}</div>
            </div>
            <div class="stat-icon-orb">
              <el-icon>
                <component :is="card.icon" />
              </el-icon>
            </div>
          </div>
          <div class="stat-value digital-number">{{ card.value }}</div>
          <div class="stat-footer">
            <span>{{ card.subLabel }}</span>
            <strong class="digital-number">{{ card.subValue }}</strong>
          </div>
          <div class="stat-trend">{{ card.trend }}</div>
          <div class="stat-wave" aria-hidden="true"></div>
        </article>
      </div>
    </section>
    <section v-if="hasVisiblePanels" class="main-grid">
      <div v-if="hasLeftPanels" class="left-column">
        <div v-if="visiblePanels.process" class="cockpit-panel process-panel">
          <div class="panel-title-row">
            <div class="panel-title">工序数据生产统计明细</div>
            <div class="panel-actions">
              <el-button type="primary" size="small" plain @click="openProcessDialog">选择工序</el-button>
              <el-button size="small" plain @click="resetProcessFilter">重置</el-button>
              <el-radio-group v-model="processRange" size="small" @change="refreshProcessStats">
                <el-radio-button :value="1">日</el-radio-button>
                <el-radio-button :value="2">周</el-radio-button>
                <el-radio-button :value="3">月</el-radio-button>
              </el-radio-group>
            </div>
          </div>
          <div class="process-body">
            <div class="process-chart" :class="{ empty: !hasProcessData }">
              <Echarts
                  :options="chartBaseOptions"
                  :chartStyle="{ width: '100%', height: '100%' }"
                  :grid="processGrid"
                  :series="processSeries"
                  :tooltip="processTooltip"
                  :xAxis="processXAxis"
                  :yAxis="processYAxis"
                  :style="{ height: hasProcessData ? '340px' : '280px' }"
                  @click="handleChartClick"
              />
              <div v-if="!hasProcessData" class="chart-empty">
                <el-icon><DataAnalysis /></el-icon>
                <div class="chart-empty-title">暂无工序数据</div>
                <div class="chart-empty-desc">等待生产报工数据接入后自动生成统计图表</div>
                <div class="chart-empty-actions">
                  <el-button size="small" @click="refreshProcessStats">刷新数据</el-button>
                  <el-button size="small" type="primary" plain @click="openProcessDialog">选择工序</el-button>
                </div>
              </div>
            </div>
            <div class="process-aside">
              <div class="process-legend">
                <div class="process-name">{{ processAside.processName }}</div>
                <div class="process-legend-item"><span class="dot dot-blue"></span>投入量</div>
                <div class="process-legend-item"><span class="dot dot-orange"></span>报废量</div>
                <div class="process-legend-item"><span class="dot dot-cyan"></span>产出量</div>
              </div>
              <div class="process-card">
                <div class="process-label">累计总投入</div>
                <div class="process-value digital-number">{{ formatAmount(processAside.totalInput) }}</div>
              </div>
              <div class="process-card">
                <div class="process-label">累计总报废</div>
                <div class="process-value digital-number">{{ formatAmount(processAside.totalScrap) }}</div>
              </div>
              <div class="process-card">
                <div class="process-label">累计总产出</div>
                <div class="process-value digital-number">{{ formatAmount(processAside.totalOutput) }}</div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="data-cards">
        <div class="data-card sales">
          <div class="data-title">销售数据</div>
          <div class="data-num">
            <div>
              <div class="data-desc">本月销售额/元</div>
              <div class="data-value">{{ businessInfo.monthSaleMoney }}</div>
            </div>
            <div>
              <div class="data-desc">未开票金额/元</div>
              <div class="data-value">{{ businessInfo.monthSaleHaveMoney }}</div>
            </div>
          </div>
        </div>
        <div class="data-card purchase">
          <div class="data-title">采购数据</div>
          <div class="data-num">
            <div>
              <div class="data-desc">本月采购额/元</div>
              <div class="data-value">{{ businessInfo.monthPurchaseMoney }}</div>
            </div>
            <div>
              <div class="data-desc">待付款金额/元</div>
              <div class="data-value">{{ businessInfo.monthPurchaseHaveMoney }}</div>
            </div>
          </div>
        </div>
        <div class="data-card inventory">
          <div class="data-title">库存数据</div>
          <div class="data-num">
            <div>
              <div class="data-desc">当前库存总量/件</div>
              <div class="data-value">{{ businessInfo.inventoryNum }}</div>
            </div>
            <div>
              <div class="data-desc">今日入库/件</div>
              <div class="data-value">{{ businessInfo.todayInventoryNum }}</div>
            </div>
          </div>
        </div>
      </div>
      <!-- 右:待办事项 -->
      <div class="todo-panel">
        <div class="section-title">待办事项</div>
        <ul class="todo-list" v-if="todoList.length > 0">
          <li v-for="item in todoList" :key="item.id">
            <div style="display: flex;flex-direction: column;justify-content: space-between;width: 100%;gap: 20px">
              <div style="display: flex;justify-content: space-between;align-items: center;">
                <div class="todo-title">待办编号:{{ item.approveId }}</div>
                <div class="todo-division">部门:{{ item.approveDeptName }}</div>
                <div class="todo-time">{{ item.approveTime }}</div>
              </div>
              <div class="todo-division">待办事由:{{ item.approveReason }}</div>
            </div>
          </li>
        </ul>
        <div v-else style="text-align: center">
          暂无数据
        </div>
      </div>
    </div>
    <div class="dashboard-row">
      <div class="main-panel process-panel">
        <div class="process-panel__header">
          <div class="section-title">工序数据生产统计明细</div>
          <div style="display: flex; gap: 10px; align-items: center;">
            <el-button type="primary" size="small" plain icon="Filter" @click="openProcessDialog">选择工序</el-button>
            <el-button type="info" size="small" plain icon="Refresh" @click="resetProcessFilter">重置</el-button>
            <el-radio-group v-model="processRange" size="small" @change="refreshProcessStats">
              <el-radio-button :value="1">日</el-radio-button>
              <el-radio-button :value="2">周</el-radio-button>
              <el-radio-button :value="3">月</el-radio-button>
        <div v-if="visiblePanels.order" class="cockpit-panel order-panel">
          <div class="panel-title-row">
            <div class="panel-title">生产订单进度</div>
            <el-radio-group v-model="orderFilter" size="small">
              <el-radio-button label="all">全部({{ orderProgressMeta.total }})</el-radio-button>
              <el-radio-button label="waiting">待开始({{ orderProgressMeta.waitingCount }})</el-radio-button>
              <el-radio-button label="inProgress">进行中({{ orderProgressMeta.inProgressCount }})</el-radio-button>
              <el-radio-button label="completed">已完成({{ orderProgressMeta.completedCount }})</el-radio-button>
              <el-radio-button label="paused">已暂停({{ orderProgressMeta.pausedCount }})</el-radio-button>
            </el-radio-group>
          </div>
          <el-table :data="filteredOrders" stripe>
            <el-table-column prop="orderNo" label="订单编号" min-width="150" />
            <el-table-column prop="productName" label="产品名称" min-width="120" />
            <el-table-column prop="planQty" label="计划数量" min-width="90" />
            <el-table-column prop="completedQty" label="已完成" min-width="90" />
            <el-table-column label="完成率" min-width="180">
              <template #default="{ row }">
                <div class="table-progress">
                  <el-progress
                      :stroke-width="8"
                      :percentage="row.completionRate"
                      :show-text="false"
                      status="success"
                  />
                  <span>{{ row.completionRate }}%</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column prop="deliveryDate" label="交期" min-width="110" />
            <el-table-column label="状态" min-width="90">
              <template #default="{ row }">
                <el-tag :type="getOrderStatusType(row.status)" effect="light">
                  {{ row.statusLabel || getOrderStatusText(row.status) }}
                </el-tag>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div class="process-panel__body">
          <div class="process-panel__chart">
            <Echarts :chartStyle="{ width: '100%', height: '100%' }" :grid="processGrid" :series="processSeries"
              :tooltip="processTooltip" :xAxis="processXAxis" :yAxis="processYAxis" style="height: 100%"
              @click="handleChartClick" />
          </div>
          <div class="process-panel__aside">
            <div class="process-legend">
              <div class="process-legend__item">
                <span class="dot dot-blue"></span><span>投入量</span>
              </div>
              <div class="process-legend__item">
                <span class="dot dot-yellow"></span><span>报废量</span>
              </div>
              <div class="process-legend__item">
                <span class="dot dot-teal"></span><span>产出量</span>
        <div v-if="visiblePanels.contract" class="cockpit-panel contract-panel">
          <div class="panel-title">客户合同金额分析</div>
          <div class="contract-summary">
            <div class="contract-card">
              <div class="contract-name">总合同金额(元)</div>
              <div class="contract-main digital-number">{{ formatNumber(sum) }}</div>
              <div class="contract-compare">
                同比
                <span class="rise">{{ trendText(yny) }}</span>
                环比
                <span class="rise">{{ trendText(chain) }}</span>
              </div>
            </div>
            <div class="process-card process-card--name">{{ processAside.processName }}</div>
            <div class="process-card">
              <div class="process-card__label">累计总投入</div>
              <div class="process-card__value">{{ formatAmount(processAside.totalInput) }}
              </div>
            </div>
            <div class="process-card">
              <div class="process-card__label">累计总报废</div>
              <div class="process-card__value">{{ formatAmount(processAside.totalScrap) }}
              </div>
            </div>
            <div class="process-card">
              <div class="process-card__label">累计总产出</div>
              <div class="process-card__value">{{ formatAmount(processAside.totalOutput) }}
              </div>
            <div class="contract-chart-wrap">
              <Echarts
                  :options="chartBaseOptions"
                  :legend="pieLegend"
                  :chartStyle="chartStylePie"
                  :series="materialPieSeries"
                  :tooltip="pieTooltip"
              />
            </div>
          </div>
          <ul class="contract-list">
            <li v-for="item in materialPieSeries[0].data" :key="item.name">
              <span class="legend-dot" :style="{ backgroundColor: item.itemStyle?.color }"></span>
              <span class="contract-item-name">{{ item.name }}</span>
              <span class="contract-item-rate">{{ item.rate }}%</span>
              <span class="contract-item-value digital-number">¥{{ formatNumber(item.value) }}</span>
            </li>
          </ul>
        </div>
        <div v-if="visiblePanels.quality" class="cockpit-panel quality-panel">
          <div class="panel-title-row">
            <div class="panel-title">质量统计</div>
            <el-radio-group v-model="qualityRange" size="small" @change="qualityStatisticsInfo">
              <el-radio-button :value="1">周</el-radio-button>
              <el-radio-button :value="2">月</el-radio-button>
              <el-radio-button :value="3">季度</el-radio-button>
            </el-radio-group>
          </div>
          <div class="quality-cards">
            <div class="quality-card one">原材料已检数量 <span>{{ qualityStatisticsObject.supplierNum }}件</span></div>
            <div class="quality-card two">过程检验数量 <span>{{ qualityStatisticsObject.processNum }}件</span></div>
            <div class="quality-card three">出厂已检数量 <span>{{ qualityStatisticsObject.factoryNum }}件</span></div>
          </div>
          <Echarts
              :options="chartBaseOptions"
              :chartStyle="chartStyle"
              :grid="grid"
              :legend="barLegend"
              :series="barSeries1"
              :tooltip="tooltip"
              :xAxis="xAxis1"
              :yAxis="yAxis1"
              style="height: 270px"
          />
        </div>
      </div>
    </div>
    <!-- 工序选择弹窗 -->
      <div v-if="hasRightPanels" class="right-column">
        <div v-if="visiblePanels.todo" class="cockpit-panel todo-panel">
          <div class="panel-title-row">
            <div class="panel-title">待办事项</div>
            <span class="panel-more">更多</span>
          </div>
          <ul class="todo-list" v-if="todoList.length > 0">
            <li v-for="item in todoList" :key="item.id" class="todo-item">
              <div class="todo-head">
                <span class="todo-no">待办编号:{{ item.approveId }}</span>
                <span class="todo-time">{{ item.approveTime }}</span>
              </div>
              <div class="todo-desc">部门:{{ item.approveDeptName }}</div>
              <div class="todo-desc">事由:{{ item.approveReason }}</div>
            </li>
          </ul>
          <div v-else class="panel-empty">暂无数据</div>
        </div>
        <div v-if="visiblePanels.realtime" class="cockpit-panel realtime-panel">
          <div class="panel-title-row">
            <div class="panel-title">生产实时看板</div>
            <span class="panel-more">更多</span>
          </div>
          <div class="realtime-grid">
            <div class="realtime-item" v-for="item in realtimeBoard" :key="item.key">
              <el-progress
                  type="circle"
                  :percentage="item.percent"
                  :stroke-width="10"
                  :width="94"
                  :color="item.color"
              >
                <template #default>
                  <div class="realtime-value digital-number">{{ item.display }}</div>
                </template>
              </el-progress>
              <div class="realtime-label">{{ item.label }}</div>
              <div class="realtime-delta" :class="item.trend">{{ item.delta }}</div>
            </div>
          </div>
        </div>
        <div v-if="visiblePanels.quick" class="cockpit-panel quick-panel">
          <div class="panel-title-row">
            <div class="panel-title">快捷功能</div>
          </div>
          <div class="quick-grid">
            <button
                v-for="item in quickEntries"
                :key="item.label"
                class="quick-item"
                type="button"
                @click="goToQuick(item.path)"
            >
              <span class="quick-icon">
                <el-icon>
                  <component :is="item.icon" />
                </el-icon>
              </span>
              <span>{{ item.label }}</span>
            </button>
          </div>
        </div>
        <div v-if="visiblePanels.plan" class="cockpit-panel plan-panel">
          <div class="panel-title-row">
            <div class="panel-title">今日生产计划</div>
            <span class="panel-more">{{ todayPlanTotal }}项</span>
          </div>
          <ul class="plan-list">
            <li v-for="item in todayPlanList" :key="item.orderNo" class="plan-item">
              <div class="plan-main">
                <span class="plan-order">{{ item.orderNo }}</span>
                <span class="plan-name">{{ item.productName }}</span>
              </div>
              <div class="plan-meta">
                <span>计划 {{ item.planQty }}</span>
                <span>交期 {{ item.deliveryDate }}</span>
              </div>
            </li>
          </ul>
        </div>
        <div v-if="visiblePanels.receipt" class="cockpit-panel receipt-panel">
          <div class="panel-title">回款与开票分析</div>
          <Echarts
              :options="chartBaseOptions"
              :chartStyle="chartStyle"
              :grid="grid"
              :legend="lineLegend"
              :series="lineSeries"
              :tooltip="tooltipLine"
              :xAxis="xAxis2"
              :yAxis="yAxis2"
              style="height: 300px"
          />
        </div>
      </div>
    </section>
    <section v-else class="cockpit-panel empty-home-panel">
      当前账号没有可展示的首页模块
    </section>
    <el-dialog v-model="processDialogVisible" title="选择工序" width="500px" append-to-body>
      <div class="process-selection-wrapper">
        <el-checkbox-group v-model="tempProcessIds">
@@ -168,105 +333,99 @@
        </span>
      </template>
    </el-dialog>
    <!-- 中部横向两栏 -->
    <div class="dashboard-row">
      <div class="main-panel">
        <div class="section-title">客户合同金额分析</div>
        <div class="contract-summary">
          <div class="contract-info">
            <img src="../assets/images/khtitle.png" alt="" style="width: 42px" />
            <div class="contract-card">
              <div class="contract-name">总合同金额(元)</div>
              <div class="contract-meta">
                <div class="main-amount">{{ sum }}</div>
                <div>周同比: <span class="up">{{ yny }}% </span> 日环比: <span class="up">{{ chain }}% </span></div>
              </div>
            </div>
          </div>
        </div>
        <div
          style="display: flex;align-items: center;gap: 20px;justify-content: space-evenly;height: 180px;margin-top: 20px">
          <div>
            <Echarts ref="chart" :legend="pieLegend" :chartStyle="chartStylePie" :series="materialPieSeries"
              :tooltip="pieTooltip"></Echarts>
          </div>
          <ul class="contract-list">
            <li v-for="item in materialPieSeries[0].data" :key="item.name">
              <div style="display: flex;align-items: center;justify-content: space-between;width: 100%">
                <div class="line" :style="{ color: item.itemStyle.color }">●{{ item.name }}</div>
                <div style="width: 70px">{{ item.rate }}%</div>
                <div>¥{{ item.value }}</div>
              </div>
            </li>
          </ul>
        </div>
      </div>
      <div class="main-panel">
        <div style="display: flex;justify-content: space-between;">
          <div class="section-title">应收应付统计</div>
          <!--               <el-radio-group v-model="radio1" size="large" @change="statisticsReceivable">-->
          <!--                  <el-radio-button label="按周" :value="1" />-->
          <!--                  <el-radio-button label="按月" :value="2" />-->
          <!--                  <el-radio-button label="按季度" :value="3" />-->
          <!--               </el-radio-group>-->
        </div>
        <Echarts ref="chart" :color="barColors2" :chartStyle="chartStyle" :grid="grid" :series="barSeries"
          :tooltip="tooltip" :xAxis="xAxis" :yAxis="yAxis" style="height: 260px"></Echarts>
      </div>
    </div>
    <!-- 底部横向两栏 -->
    <div class="dashboard-row">
      <div class="main-panel">
        <div style="display: flex;justify-content: space-between;align-items: center;margin-bottom: 10px;">
          <div class="section-title" style="margin-bottom: 0;">质量统计</div>
          <el-radio-group v-model="qualityRange" size="small" @change="qualityStatisticsInfo">
            <el-radio-button :value="1">周</el-radio-button>
            <el-radio-button :value="2">月</el-radio-button>
            <el-radio-button :value="3">季度</el-radio-button>
          </el-radio-group>
        </div>
        <div class="quality-cards">
          <div class="quality-card one">原材料已检测数 <span>{{ qualityStatisticsObject.supplierNum }}件</span></div>
          <div class="quality-card two">过程检验数量 <span>{{ qualityStatisticsObject.processNum }}件</span></div>
          <div class="quality-card three">出厂已检数量 <span>{{ qualityStatisticsObject.factoryNum }}件</span></div>
        </div>
        <Echarts ref="chart" :chartStyle="chartStyle" :grid="grid" :legend="barLegend" :series="barSeries1"
          :tooltip="tooltip" :xAxis="xAxis1" :yAxis="yAxis1" style="height: 260px"></Echarts>
      </div>
      <div class="main-panel">
        <div class="section-title">回款与开票分析</div>
        <Echarts ref="invoiceChart" :chartStyle="chartStyle" :grid="grid" :legend="lineLegend" :series="lineSeries"
          :tooltip="tooltipLine" :xAxis="xAxis2" :yAxis="yAxis2" style="height: 270px;" />
      </div>
    </div>
  </div>
</template>
<script setup>
import { ref, onMounted, computed, reactive } from 'vue'
import { ref, onMounted, onUnmounted, computed, reactive, watch } from "vue";
import { useRouter } from "vue-router";
import dayjs from "dayjs";
import * as echarts from "echarts";
import {
  Box,
  Calendar,
  Checked,
  DataAnalysis,
  DataLine,
  EditPen,
  Operation,
  Search,
  ShoppingCartFull,
  Tickets,
  Tools,
  UserFilled,
} from "@element-plus/icons-vue";
import Echarts from "@/components/Echarts/echarts.vue";
import * as echarts from 'echarts';
import usePermissionStore from "@/store/modules/permission";
import useUserStore from "@/store/modules/user.js";
import {
  analysisCustomerContractAmounts, getAmountHalfYear,
  analysisCustomerContractAmounts,
  getAmountHalfYear,
  getBusiness,
  homeTodos,
  processDataProductionStatistics,
  productionOrderProgress,
  productionOverview,
  productionRealtimeBoard,
  qualityInspectionStatistics,
  statisticsReceivablePayable,
  qualityInspectionStatistics
  todayProductionPlan,
} from "@/api/viewIndex.js";
import { list } from '@/api/productionManagement/productionProcess';
import { list } from "@/api/productionManagement/productionProcess";
const router = useRouter();
const userStore = useUserStore();
const permissionStore = usePermissionStore();
const defaultWelcomeAvatar = new URL("../assets/images/profile.jpg", import.meta.url).href;
const userStore = useUserStore()
const nowTime = ref("");
const welcomeAvatarLoadFailed = ref(false);
let clockTimer = null;
const weatherText = "多云 28°C";
const processOptions = ref([])
const selectedProcessIds = ref([])
const tempProcessIds = ref([])
const processDialogVisible = ref(false)
const activeProcessIndex = ref(0)
const nowDate = computed(() => (nowTime.value ? nowTime.value.slice(0, 10) : dayjs().format("YYYY-MM-DD")));
const greetingText = computed(() => {
  const hour = dayjs().hour();
  if (hour < 6) return "凌晨好";
  if (hour < 9) return "早上好";
  if (hour < 12) return "上午好";
  if (hour < 14) return "中午好";
  if (hour < 18) return "下午好";
  return "晚上好";
});
const welcomeAvatar = computed(() =>
    welcomeAvatarLoadFailed.value || !userStore.avatar ? defaultWelcomeAvatar : userStore.avatar
);
const handleWelcomeAvatarError = () => {
  if (welcomeAvatar.value !== defaultWelcomeAvatar) {
    welcomeAvatarLoadFailed.value = true;
  }
};
watch(
    () => userStore.avatar,
    () => {
      welcomeAvatarLoadFailed.value = false;
    }
);
const axisTextColor = "#5f6f86";
const axisLineColor = "rgba(148, 163, 184, 0.45)";
const splitLineColor = "rgba(148, 163, 184, 0.18)";
const chartBaseOptions = reactive({
  backgroundColor: "transparent",
  textStyle: { color: axisTextColor },
});
const processOptions = ref([]);
const selectedProcessIds = ref([]);
const tempProcessIds = ref([]);
const processDialogVisible = ref(false);
const activeProcessIndex = ref(0);
const businessInfo = ref({
  inventoryNum: 0,
@@ -275,988 +434,2033 @@
  monthSaleHaveMoney: 0,
  monthSaleMoney: 0,
  todayInventoryNum: 0,
})
});
const qualityStatisticsObject = ref({
  supplierNum: 0,
  processNum: 0,
  factoryNum: 0,
})
const sum = ref(0)
const yny = ref(0)
const chain = ref(0)
});
const pieLegend = reactive({
  show: false,
})
const productionOverviewData = ref({
  totalOutput: 0,
  totalScrap: 0,
  yieldRate: 0,
});
const realtimeBoardData = ref({
  deviceOee: { value: 0, compareYesterday: 0 },
  orderAchievementRate: { value: 0, compareYesterday: 0 },
  defectRate: { value: 0, compareYesterday: 0 },
});
const orderProgressMeta = ref({
  status: "all",
  tab: "all",
  bizDate: null,
  total: 0,
  pageNum: 1,
  pageSize: 10,
  waitingCount: 0,
  inProgressCount: 0,
  completedCount: 0,
  pausedCount: 0,
});
const todayPlanList = ref([]);
const todayPlanTotal = ref(0);
const sum = ref(0);
const yny = ref(0);
const chain = ref(0);
const pieLegend = reactive({ show: false });
const piePalette = ["#2563eb", "#14b8a6", "#7c3aed", "#f97316", "#38bdf8", "#f43f5e"];
const chartStyle = {
  width: "100%",
  height: "100%",
};
const chartStylePie = {
  width: "100%",
  height: "200px",
};
const grid = {
  left: "3%",
  right: "4%",
  bottom: "2%",
  top: "12%",
  containLabel: true,
};
const tooltip = {
  trigger: "axis",
  axisPointer: { type: "shadow" },
  backgroundColor: "rgba(255, 255, 255, 0.97)",
  borderColor: "rgba(148, 163, 184, 0.26)",
  textStyle: { color: "#334155" },
};
const barColors2 = ["#2563eb", "#14b8a6"];
const xAxis = [
  {
    type: "value",
    axisLine: { lineStyle: { color: axisLineColor } },
    splitLine: { lineStyle: { color: splitLineColor } },
    axisLabel: { color: axisTextColor },
  },
];
const yAxis = [
  {
    type: "category",
    data: ["应付账款", "应收账款"],
    axisTick: { show: false },
    axisLine: { lineStyle: { color: axisLineColor } },
    axisLabel: { color: axisTextColor },
  },
];
const barSeries = ref([
  {
    type: 'bar',
    type: "bar",
    barWidth: 22,
    itemStyle: { borderRadius: [0, 8, 8, 0] },
    label: { show: true, position: "right", color: "#334155" },
    data: [],
    label: {
      show: true,
    }
  },
])
]);
const barLegend = {
  show: true,
  textStyle: { color: axisTextColor },
  data: ["原材料不合格数", "过程不合格数", "出厂不合格数"],
};
const xAxis1 = ref([
  {
    type: "category",
    axisTick: { show: false },
    axisLine: { lineStyle: { color: axisLineColor } },
    axisLabel: { color: axisTextColor },
    data: [],
  },
]);
const yAxis1 = [
  {
    type: "value",
    splitLine: { lineStyle: { color: splitLineColor } },
    axisLine: { lineStyle: { color: axisLineColor } },
    axisLabel: { color: axisTextColor },
  },
];
const barSeries1 = ref([
  {
    name: '原材料不合格数',
    type: 'bar',
    name: "原材料不合格数",
    type: "bar",
    barGap: 0,
    emphasis: {
      focus: 'series'
    },
    data: []
    itemStyle: { color: "#2563eb", borderRadius: [6, 6, 0, 0] },
    emphasis: { focus: "series" },
    data: [],
  },
  {
    name: '过程不合格数',
    type: 'bar',
    emphasis: {
      focus: 'series'
    },
    data: []
    name: "过程不合格数",
    type: "bar",
    itemStyle: { color: "#14b8a6", borderRadius: [6, 6, 0, 0] },
    emphasis: { focus: "series" },
    data: [],
  },
  {
    name: '出厂不合格数',
    type: 'bar',
    emphasis: {
      focus: 'series'
    },
    data: []
    name: "出厂不合格数",
    type: "bar",
    itemStyle: { color: "#f59e0b", borderRadius: [6, 6, 0, 0] },
    emphasis: { focus: "series" },
    data: [],
  },
])
const chartStyle = {
  width: '100%',
  height: '100%' // 设置图表容器的高度
}
const chartStylePie = {
  width: '140%',
  height: '140%' // 设置图表容器的高度
}
const grid = {
  left: '3%',
  right: '4%',
  bottom: '3%',
  containLabel: true
}
const barLegend = {
  show: true,
  data: ['原材料不合格数', '过程不合格数', '出厂不合格数']
}
const barLegend1 = {
  show: true,
  data: ['预付账款', '应付账款', '预收账款', '应收账款']
}
]);
const lineLegend = {
  show: true,
  data: ['开票', '回款']
}
const tooltip = {
  trigger: 'axis',
  axisPointer: {
    type: 'shadow'
  }
}
const xAxis = [{
  type: 'value',
}]
const xAxis1 = ref([{
  type: 'category',
  axisTick: { show: false },
  data: []
}])
const yAxis = [{
  type: 'category',
  data: ['应付账款', '应收账款',]
}]
const yAxis1 = [{
  type: 'value'
}]
const pieTooltip = reactive({
  trigger: 'item',
  formatter: function (params) {
    // 动态生成提示信息,基于数据项的 name 属性
    const description = params.name === '本月回款金额' ? '本月回款金额' : '应收款金额';
    return `${description} ${formatNumber(params.value)}元 ${params.percent}%`;
  },
  position: 'right'
})
const materialPieSeries = ref([
  {
    type: 'pie',
    radius: ['66%', '90%'],
    avoidLabelOverlap: false,
    itemStyle: {
      borderColor: '#fff',
      borderWidth: 2
    },
    label: {
      show: false
    },
    data: []
  }
])
const lineSeries = ref([
  {
    type: 'line',
    data: [],
    label: {
      show: true
    },
    showSymbol: true, // 显示圆点
  },
])
const tooltipLine = {
  trigger: 'axis',
}
const yAxis2 = ref([
  {
    type: 'value',
  }
])
  textStyle: { color: axisTextColor },
  data: ["开票", "回款"],
};
const xAxis2 = ref([
  {
    type: 'category',
    type: "category",
    data: [],
    axisLine: { lineStyle: { color: axisLineColor } },
    axisLabel: {
      color: axisTextColor,
      interval: 0,
      formatter: function (value) {
        return value.replace(/~/g, '\n');
      },
    }
  }
])
// 待办事项
const todoList = ref([])
const radio1 = ref(1)
const qualityRange = ref(1)
// 图表引用
const barChart = ref(null)
const lineChart = ref(null)
const barColors2 = ['#5181DB', '#D369E0', '#F2CA6D', '#60CCA8']
// 随机颜色生成函数
const getRandomColor = () => {
  return '#' + Math.floor(Math.random() * 0xffffff).toString(16).padStart(6, '0');
}
onMounted(() => {
  getBusinessData()
  analysisCustomer()
  todoInfoS()
  statisticsReceivable()
  qualityStatisticsInfo()
  getAmountHalfYearNum()
  getProcessList()
})
// 数据统计
const getBusinessData = () => {
  getBusiness().then((res) => {
    businessInfo.value = { ...res.data }
  })
}
// 合同金额
const analysisCustomer = () => {
  analysisCustomerContractAmounts().then((res) => {
    sum.value = res.data.sum
    yny.value = res.data.yny
    chain.value = res.data.chain
    // 为每个数据项分配随机颜色
    materialPieSeries.value[0].data = res.data.item.map(item => ({
      ...item,
      itemStyle: { color: getRandomColor() }
    }))
  })
}
// 待办事项
const todoInfoS = () => {
  homeTodos().then((res) => {
    todoList.value = res.data
  })
}
// 获取工序列表
const getProcessList = () => {
  list().then(res => {
    processOptions.value = res.data.records
  })
}
const openProcessDialog = () => {
  tempProcessIds.value = [...selectedProcessIds.value]
  processDialogVisible.value = true
}
const handleProcessDialogConfirm = () => {
  selectedProcessIds.value = [...tempProcessIds.value]
  processDialogVisible.value = false
  refreshProcessStats()
}
const resetProcessFilter = () => {
  selectedProcessIds.value = []
  tempProcessIds.value = []
  refreshProcessStats()
}
const handleChartClick = (params) => {
  if (params && params.dataIndex !== undefined) {
    activeProcessIndex.value = params.dataIndex
  }
}
// 应付应收统计
const statisticsReceivable = () => {
  statisticsReceivablePayable({ type: radio1.value }).then((res) => {
    barSeries.value[0].data = [
      // { value: res.data.prepayMoney, itemStyle: { color: barColors2[0] } },
      { value: res.data.payableMoney, itemStyle: { color: barColors2[0] } },
      // { value: res.data.advanceMoney, itemStyle: { color: barColors2[2] } },
      { value: res.data.receivableMoney, itemStyle: { color: barColors2[1] } }
    ]
  })
}
// 质检统计
const qualityStatisticsInfo = () => {
  qualityInspectionStatistics({ type: qualityRange.value }).then((res) => {
    xAxis1.value[0].data = []
    barSeries1.value[0].data = []
    barSeries1.value[1].data = []
    barSeries1.value[2].data = []
    res.data.item.forEach(item => {
      xAxis1.value[0].data.push(item.date)
      barSeries1.value[0].data.push(item.supplierNum)
      barSeries1.value[1].data.push(item.processNum)
      barSeries1.value[2].data.push(item.factoryNum)
    })
    qualityStatisticsObject.value.supplierNum = res.data.supplierNum
    qualityStatisticsObject.value.processNum = res.data.processNum
    qualityStatisticsObject.value.factoryNum = res.data.factoryNum
  })
}
const getAmountHalfYearNum = async () => {
  const res = await getAmountHalfYear()
  console.log(res)
  const monthName = []
  const receiptAmount = []
  const invoiceAmount = []
  res.data.forEach(item => {
    monthName.push(item.month)
    receiptAmount.push(item.receiptAmount)
    invoiceAmount.push(item.invoiceAmount)
  })
  // 正确响应式赋值:创建新的 xAxis 和 series 对象
  xAxis2.value[0].data = monthName
  xAxis2.value[0].data = monthName.map(item => item.replace(/~/g, '\n~'));
  lineSeries.value = [
    {
      name: '开票',
      type: 'line',
      data: invoiceAmount,
      stack: 'Total',
      areaStyle: {
        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
          {
            offset: 0,
            color: 'rgba(131, 207, 255, 1)'
          },
          {
            offset: 1,
            color: 'rgba(186, 228, 255, 1)'
          }
        ])
      },
      itemStyle: {
        color: '#2D99FF',
        borderColor: '#2D99FF'
      },
      emphasis: {
        focus: 'series'
      },
      lineStyle: {
        width: 0
      },
      showSymbol: true,
      formatter: (value) => value.replace(/~/g, "\n"),
    },
    {
      name: '回款',
      type: 'line',
      data: receiptAmount,
      stack: 'Total',
      lineStyle: {
        width: 0
      },
      itemStyle: {
        color: '#83CFFF',
        borderColor: '#83CFFF'
      },
      showSymbol: true,
      areaStyle: {
        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
          {
            offset: 0,
            color: 'rgba(54, 153, 255, 1)'
          },
          {
            offset: 1,
            color: 'rgba(89, 169, 254, 1)'
          }
        ])
      },
      emphasis: {
        focus: 'series'
      },
    }
  ]
}
  },
]);
// 工序数据生产统计明细(假数据 + 图表)
const processRange = ref(1)
const processChartData = ref([])
const yAxis2 = ref([
  {
    type: "value",
    splitLine: { lineStyle: { color: splitLineColor } },
    axisLine: { lineStyle: { color: axisLineColor } },
    axisLabel: { color: axisTextColor },
  },
]);
const tooltipLine = {
  trigger: "axis",
  backgroundColor: "rgba(255, 255, 255, 0.97)",
  borderColor: "rgba(148, 163, 184, 0.26)",
  textStyle: { color: "#334155" },
};
const lineSeries = ref([
  {
    name: "开票",
    type: "line",
    data: [],
    smooth: true,
    itemStyle: { color: "#2563eb" },
    lineStyle: { width: 2, color: "#2563eb" },
    showSymbol: true,
    areaStyle: {
      color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
        { offset: 0, color: "rgba(37, 99, 235, 0.24)" },
        { offset: 1, color: "rgba(37, 99, 235, 0.02)" },
      ]),
    },
  },
  {
    name: "回款",
    type: "line",
    data: [],
    smooth: true,
    itemStyle: { color: "#14b8a6" },
    lineStyle: { width: 2, color: "#14b8a6" },
    showSymbol: true,
    areaStyle: {
      color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
        { offset: 0, color: "rgba(20, 184, 166, 0.2)" },
        { offset: 1, color: "rgba(20, 184, 166, 0.02)" },
      ]),
    },
  },
]);
const pieTooltip = reactive({
  trigger: "item",
  backgroundColor: "rgba(255, 255, 255, 0.97)",
  borderColor: "rgba(148, 163, 184, 0.26)",
  textStyle: { color: "#334155" },
  formatter: (params) => `${params.name} ${formatNumber(params.value)}元 ${params.percent}%`,
});
const materialPieSeries = ref([
  {
    type: "pie",
    radius: ["62%", "88%"],
    avoidLabelOverlap: false,
    itemStyle: {
      borderColor: "rgba(255, 255, 255, 0.95)",
      borderWidth: 2,
    },
    label: { show: false },
    data: [],
  },
]);
const todoList = ref([]);
const qualityRange = ref(1);
const processRange = ref(1);
const processChartData = ref([]);
const processXAxis = ref([
  {
    nameTextStyle: { color: 'rgba(0,0,0,0.35)', fontSize: 12 },
    axisLabel: { color: 'rgba(0,0,0,0.35)' },
    splitLine: { lineStyle: { color: 'rgba(0,0,0,0.06)', type: 'dashed' } },
    type: "value",
    axisLine: { lineStyle: { color: axisLineColor } },
    splitLine: { lineStyle: { color: splitLineColor, type: "dashed" } },
    axisLabel: { color: axisTextColor },
  },
])
]);
const processYAxis = ref([
  {
    type: 'category',
    type: "category",
    axisTick: { show: false },
    axisLine: { show: false },
    axisLabel: { color: 'rgba(0,0,0,0.45)' },
    axisLabel: { color: axisTextColor },
    data: [],
  },
])
]);
const processGrid = reactive({ left: 0, right: 100, top: 30, bottom: 20, containLabel: true })
const processGrid = reactive({ left: "4%", right: "4%", top: 20, bottom: 18, containLabel: true });
const processTooltip = reactive({
  trigger: 'axis',
  axisPointer: { type: 'shadow' },
  trigger: "axis",
  axisPointer: { type: "shadow" },
  backgroundColor: "rgba(255, 255, 255, 0.97)",
  borderColor: "rgba(148, 163, 184, 0.26)",
  textStyle: { color: "#334155" },
  formatter: (params) => {
    const name = params?.[0]?.name ?? ''
    const list = Array.isArray(params) ? params : []
    const name = params?.[0]?.name ?? "";
    const list = Array.isArray(params) ? params : [];
    const lines = list
      .map((p) => {
        const colorBox = `<span style="display:inline-block;margin-right:6px;border-radius:2px;width:10px;height:10px;background:${p.color}"></span>`
        return `${colorBox}${p.seriesName} <b style="float:right;">${Number(p.value || 0).toFixed(2)}</b>`
      })
      .join('<br/>')
    return `<div style="min-width:140px;"><div style="font-weight:700;margin-bottom:6px;">${name}</div>${lines}</div>`
        .map((p) => {
          const colorBox = `<span style="display:inline-block;margin-right:6px;border-radius:2px;width:10px;height:10px;background:${p.color}"></span>`;
          return `${colorBox}${p.seriesName}<b style="float:right;">${Number(p.value || 0).toFixed(2)}</b>`;
        })
        .join("<br/>");
    return `<div style="min-width:140px;"><div style="font-weight:700;margin-bottom:6px;">${name}</div>${lines}</div>`;
  },
})
});
const processSeries = computed(() => {
  const input = processChartData.value.map((i) => i.input)
  const scrap = processChartData.value.map((i) => i.scrap)
  const output = processChartData.value.map((i) => i.output)
  const input = processChartData.value.map((item) => item.input);
  const scrap = processChartData.value.map((item) => item.scrap);
  const output = processChartData.value.map((item) => item.output);
  return [
    {
      name: '投入量',
      type: 'bar',
      stack: 'total',
      barWidth: 22,
      itemStyle: { color: '#1E5BFF', borderRadius: [6, 0, 0, 6] },
      name: "投入量",
      type: "bar",
      stack: "total",
      barWidth: 18,
      itemStyle: { color: "#2563eb", borderRadius: [8, 0, 0, 8] },
      data: input,
    },
    {
      name: '报废量',
      type: 'bar',
      stack: 'total',
      barWidth: 22,
      itemStyle: { color: '#F7B500' },
      name: "报废量",
      type: "bar",
      stack: "total",
      barWidth: 18,
      itemStyle: { color: "#f59e0b" },
      data: scrap,
    },
    {
      name: '产出量',
      type: 'bar',
      stack: 'total',
      barWidth: 22,
      itemStyle: { color: '#19C6C6', borderRadius: [0, 6, 6, 0] },
      name: "产出量",
      type: "bar",
      stack: "total",
      barWidth: 18,
      itemStyle: { color: "#14b8a6", borderRadius: [0, 8, 8, 0] },
      data: output,
    },
  ]
})
  ];
});
const processAside = computed(() => {
  const list = processChartData.value
  const item = list[activeProcessIndex.value] || {}
  const listData = processChartData.value;
  const item = listData[activeProcessIndex.value] || {};
  return {
    processName: item.name || '暂无数据',
    processName: item.name || "暂无数据",
    totalInput: item.input || 0,
    totalScrap: item.scrap || 0,
    totalOutput: item.output || 0,
  };
});
const processTotals = computed(() =>
    processChartData.value.reduce(
        (acc, cur) => {
          acc.input += Number(cur.input || 0);
          acc.scrap += Number(cur.scrap || 0);
          acc.output += Number(cur.output || 0);
          return acc;
        },
        { input: 0, scrap: 0, output: 0 }
    )
);
const hasProcessData = computed(() => {
  if (!processChartData.value.length) return false;
  return processChartData.value.some((item) => {
    const input = Number(item.input || 0);
    const scrap = Number(item.scrap || 0);
    const output = Number(item.output || 0);
    return input > 0 || scrap > 0 || output > 0;
  });
});
const dashboardCards = computed(() => [
  {
    key: "sales",
    title: "销售数据",
    desc: "本月销售额(元)",
    value: formatNumber(businessInfo.value.monthSaleMoney),
    subLabel: "未开票金额",
    subValue: formatNumber(businessInfo.value.monthSaleHaveMoney),
    trend: `占比 ${ratioText(businessInfo.value.monthSaleHaveMoney, businessInfo.value.monthSaleMoney)}`,
    icon: DataLine,
    visible: visibleModules.value.sales,
  },
  {
    key: "purchase",
    title: "采购数据",
    desc: "本月采购额(元)",
    value: formatNumber(businessInfo.value.monthPurchaseMoney),
    subLabel: "待付款金额",
    subValue: formatNumber(businessInfo.value.monthPurchaseHaveMoney),
    trend: `占比 ${ratioText(
        businessInfo.value.monthPurchaseHaveMoney,
        businessInfo.value.monthPurchaseMoney
    )}`,
    icon: ShoppingCartFull,
    visible: visibleModules.value.procurement,
  },
  {
    key: "inventory",
    title: "库存数据",
    desc: "当前库存总量(件)",
    value: formatNumber(businessInfo.value.inventoryNum),
    subLabel: "今日入库",
    subValue: formatNumber(businessInfo.value.todayInventoryNum),
    trend: "库存结构持续优化",
    icon: Box,
    visible: visibleModules.value.inventory,
  },
  {
    key: "production",
    title: "生产总览",
    desc: "累计产出(件)",
    value: formatNumber(productionOverviewData.value.totalOutput),
    subLabel: "累计报废",
    subValue: formatNumber(productionOverviewData.value.totalScrap),
    trend: `良率 ${Number(productionOverviewData.value.yieldRate || 0).toFixed(2)}%`,
    icon: Operation,
    visible: visibleModules.value.production,
  },
].filter((item) => item.visible));
const productionOrders = ref([]);
const orderFilterOptions = ["all", "waiting", "inProgress", "completed", "paused"];
const orderFilterAliasMap = {
  1: "waiting",
  2: "inProgress",
  3: "completed",
  4: "paused",
};
const orderFilter = ref("all");
const filteredOrders = computed(() => productionOrders.value);
const normalizeOrderFilter = (value, fallback = "all") => {
  const safeFallback = orderFilterOptions.includes(fallback) ? fallback : "all";
  const text = String(value ?? "").trim();
  if (orderFilterAliasMap[text]) {
    return orderFilterAliasMap[text];
  }
})
  return orderFilterOptions.includes(text) ? text : safeFallback;
};
const formatAmount = (n) => {
  const num = Number(n || 0)
  return num.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })
}
const parseCount = (value) => {
  if (value === null || value === undefined || value === "") return null;
  const num = Number(value);
  return Number.isFinite(num) ? num : null;
};
const refreshProcessStats = () => {
  processDataProductionStatistics({
const resolveProgressCount = (rawValue, currentStatus, targetStatus, total) => {
  const count = parseCount(rawValue);
  if (count !== null) return count;
  return currentStatus === targetStatus ? total : 0;
};
const getCompareTrend = (value) => {
  const num = Number(value || 0);
  if (num > 0) return "up";
  if (num < 0) return "down";
  return "flat";
};
const getCompareText = (value) => {
  const num = Number(value || 0);
  const abs = Math.abs(num).toFixed(2);
  if (num > 0) return `较昨日 ↑ ${abs}%`;
  if (num < 0) return `较昨日 ↓ ${abs}%`;
  return "较昨日 持平";
};
const realtimeBoard = computed(() => {
  const oee = Number(realtimeBoardData.value.deviceOee?.value || 0);
  const orderAchievement = Number(realtimeBoardData.value.orderAchievementRate?.value || 0);
  const defectRate = Number(realtimeBoardData.value.defectRate?.value || 0);
  const oeeCompare = Number(realtimeBoardData.value.deviceOee?.compareYesterday || 0);
  const orderCompare = Number(realtimeBoardData.value.orderAchievementRate?.compareYesterday || 0);
  const defectCompare = Number(realtimeBoardData.value.defectRate?.compareYesterday || 0);
  return [
    {
      key: "oee",
      label: "设备 OEE",
      percent: clampPercent(oee),
      display: `${oee.toFixed(2)}%`,
      delta: getCompareText(oeeCompare),
      trend: getCompareTrend(oeeCompare),
      color: "#2d8cff",
    },
    {
      key: "order",
      label: "订单达成率",
      percent: clampPercent(orderAchievement),
      display: `${orderAchievement.toFixed(2)}%`,
      delta: getCompareText(orderCompare),
      trend: getCompareTrend(orderCompare),
      color: "#31d2ff",
    },
    {
      key: "defect",
      label: "不良率",
      percent: clampPercent(defectRate),
      display: `${defectRate.toFixed(2)}%`,
      delta: getCompareText(defectCompare),
      trend: getCompareTrend(defectCompare),
      color: "#f6a23f",
    },
  ];
});
const warningList = ref([
  {
    id: 1,
    level: "device",
    title: "设备预警",
    desc: "CNC-001 设备振动异常",
    time: "10:24:32",
  },
  {
    id: 2,
    level: "quality",
    title: "质量预警",
    desc: "订单 SO-20260517 不良率超标",
    time: "09:15:47",
  },
  {
    id: 3,
    level: "material",
    title: "物料预警",
    desc: "物料 1002001 库存不足",
    time: "08:47:21",
  },
]);
const quickEntryConfigs = [
  { label: "主生产计划", icon: Calendar, titles: ["主生产计划"], fallbackPath: "/productionPlan/productionPlan" },
  { label: "生产订单", icon: Tickets, titles: ["生产订单"], fallbackPath: "/productionManagement/productionOrder" },
  { label: "生产报工", icon: EditPen, titles: ["生产报工"], fallbackPath: "/productionManagement/productionReporting" },
  { label: "设备台账", icon: Tools, titles: ["设备台账"], fallbackPath: "/equipmentManagement/ledger" },
  { label: "销售台账", icon: DataLine, titles: ["销售台账"], fallbackPath: "/salesManagement/salesLedger" },
  { label: "采购台账", icon: ShoppingCartFull, titles: ["采购台账"], fallbackPath: "/procurementManagement/procurementLedger" },
  { label: "员工台账", icon: UserFilled, titles: ["员工台账", "在职员工台账"], fallbackPath: "/personnelManagement/employeeRecord" },
  { label: "库存管理", icon: Box, titles: ["库存管理"], fallbackPath: "/inventoryManagement/stockManage" },
];
const normalizeMenuTitle = (title) => String(title || "").replace(/\s+/g, "").trim();
const normalizeRoutePath = (path) =>
    String(path || "")
        .trim()
        .replace(/\/+/g, "/")
        .replace(/\/$/, "")
        .toLowerCase();
const resolveRoutePath = (route, parentPath = "") => {
  const currentPath = String(route?.path || "").trim();
  if (!currentPath) return parentPath || "";
  if (/^(https?:)?\/\//.test(currentPath)) return currentPath;
  if (currentPath.startsWith("/")) return currentPath;
  const basePath = parentPath && parentPath !== "/" ? parentPath.replace(/\/$/, "") : "";
  return `${basePath}/${currentPath}`.replace(/\/+/g, "/");
};
const collectAccessibleRoutes = (routes = [], parentPath = "") => {
  const items = [];
  (routes || []).forEach((route) => {
    if (!route) return;
    const fullPath = resolveRoutePath(route, parentPath);
    const title = route.meta?.title ?? route.title ?? "";
    if (title && fullPath && !String(route.redirect || "").includes("noRedirect")) {
      items.push({
        title: normalizeMenuTitle(title),
        path: normalizeRoutePath(fullPath),
      });
    }
    if (Array.isArray(route.children) && route.children.length > 0) {
      items.push(...collectAccessibleRoutes(route.children, fullPath));
    }
  });
  return items;
};
const accessibleMenuRoutes = computed(() => {
  const routePool =
      permissionStore.defaultRoutes?.length > 0
          ? permissionStore.defaultRoutes
          : permissionStore.sidebarRouters?.length > 0
              ? permissionStore.sidebarRouters
              : permissionStore.routes;
  return collectAccessibleRoutes(routePool || []);
});
const moduleAccessConfig = {
  sales: {
    titles: ["销售管理", "销售台账"],
    pathPrefixes: ["/salesmanagement"],
  },
  procurement: {
    titles: ["采购管理", "采购台账"],
    pathPrefixes: ["/procurementmanagement"],
  },
  inventory: {
    titles: ["库存管理"],
    pathPrefixes: ["/inventorymanagement"],
  },
  production: {
    titles: ["生产管理", "主生产计划", "生产订单", "生产报工"],
    pathPrefixes: ["/productionmanagement", "/productionplan"],
  },
  quality: {
    titles: ["质量管理"],
    pathPrefixes: ["/qualitymanagement"],
  },
  equipment: {
    titles: ["设备管理", "设备台账"],
    pathPrefixes: ["/equipmentmanagement"],
  },
  personnel: {
    titles: ["人事管理", "员工台账", "在职员工台账"],
    pathPrefixes: ["/personnelmanagement"],
  },
  approval: {
    titles: ["协同审批", "待办事项"],
    pathPrefixes: ["/collaborativeapproval"],
  },
  finance: {
    titles: ["财务管理", "财务分析", "回款管理", "开票管理"],
    pathPrefixes: ["/financesuite", "/financialmanagement"],
  },
};
const hasModuleAccess = (config) =>
    accessibleMenuRoutes.value.some((route) => {
      const matchedTitle = (config.titles || []).some((title) => route.title === normalizeMenuTitle(title));
      const matchedPath = (config.pathPrefixes || []).some(
          (prefix) => route.path === prefix || route.path.startsWith(`${prefix}/`)
      );
      return matchedTitle || matchedPath;
    });
const visibleModules = computed(() => ({
  sales: hasModuleAccess(moduleAccessConfig.sales),
  procurement: hasModuleAccess(moduleAccessConfig.procurement),
  inventory: hasModuleAccess(moduleAccessConfig.inventory),
  production: hasModuleAccess(moduleAccessConfig.production),
  quality: hasModuleAccess(moduleAccessConfig.quality),
  equipment: hasModuleAccess(moduleAccessConfig.equipment),
  personnel: hasModuleAccess(moduleAccessConfig.personnel),
  approval: hasModuleAccess(moduleAccessConfig.approval),
  finance: hasModuleAccess(moduleAccessConfig.finance),
}));
const visiblePanels = computed(() => ({
  process: visibleModules.value.production,
  order: visibleModules.value.production,
  contract: visibleModules.value.sales,
  quality: visibleModules.value.quality,
  todo: visibleModules.value.approval,
  realtime: visibleModules.value.production,
  quick: quickEntries.value.length > 0,
  plan: visibleModules.value.production,
  receipt: visibleModules.value.sales || visibleModules.value.finance,
}));
const hasLeftPanels = computed(
    () => visiblePanels.value.process || visiblePanels.value.order || visiblePanels.value.contract || visiblePanels.value.quality
);
const hasRightPanels = computed(
    () => visiblePanels.value.todo || visiblePanels.value.realtime || visiblePanels.value.quick || visiblePanels.value.plan || visiblePanels.value.receipt
);
const hasVisiblePanels = computed(() => hasLeftPanels.value || hasRightPanels.value);
const quickEntries = computed(() =>
    quickEntryConfigs
        .map((item) => {
          const targetRoute = accessibleMenuRoutes.value.find((route) =>
              item.titles.some((title) => route.title === normalizeMenuTitle(title))
          );
          const resolvedPath = targetRoute?.path || "";
          return resolvedPath
              ? {
                label: item.label,
                icon: item.icon,
                path: resolvedPath,
              }
              : null;
        })
        .filter(Boolean)
);
const updateNowTime = () => {
  nowTime.value = dayjs().format("YYYY-MM-DD HH:mm:ss");
};
const formatNumber = (value) => {
  const num = Number(value || 0);
  return num.toLocaleString(undefined, {
    minimumFractionDigits: 2,
    maximumFractionDigits: 2,
  });
};
const formatAmount = (value) => {
  const num = Number(value || 0);
  return num.toLocaleString(undefined, {
    minimumFractionDigits: 2,
    maximumFractionDigits: 2,
  });
};
const trendText = (value) => {
  const num = Number(value || 0);
  const flag = num >= 0 ? "↑" : "↓";
  return `${flag} ${Math.abs(num).toFixed(1)}%`;
};
const ratioNumber = (numerator, denominator) => {
  const n = Number(numerator || 0);
  const d = Number(denominator || 0);
  if (!d) return 0;
  return (n / d) * 100;
};
const ratioText = (numerator, denominator) => `${ratioNumber(numerator, denominator).toFixed(1)}%`;
const clampPercent = (val) => Math.max(0, Math.min(100, Number(val || 0)));
const getOrderStatusText = (status) => {
  const mapping = {
    1: "待开始",
    2: "进行中",
    3: "已完成",
    4: "已暂停",
  };
  return mapping[status] || "未知";
};
const getOrderStatusType = (status) => {
  const mapping = {
    1: "info",
    2: "success",
    3: "primary",
    4: "warning",
  };
  return mapping[status] || "info";
};
const formatDueDate = (value) => {
  if (!value) return "--";
  const date = dayjs(value);
  return date.isValid() ? date.format("YYYY-MM-DD") : "--";
};
const mapOrderProgressRecord = (item = {}) => ({
  orderNo: item.orderNo || "--",
  productName: item.productName || "--",
  planQty: Number(item.plannedQuantity || 0),
  completedQty: Number(item.completedQuantity || 0),
  completionRate: clampPercent(Number(item.completionRate || 0)),
  deliveryDate: formatDueDate(item.dueDate),
  status: Number(item.status || 0),
  statusLabel: item.statusLabel || "",
});
const mapTodayPlanRecord = (item = {}) => ({
  orderNo: item.orderNo || "--",
  productName: item.productName || "--",
  planQty: Number(item.plannedQuantity || 0),
  deliveryDate: formatDueDate(item.dueDate),
  status: Number(item.status || 0),
  statusLabel: item.statusLabel || "",
});
const refreshProductionOverview = async () => {
  try {
    const res = await productionOverview();
    const data = res?.data || {};
    productionOverviewData.value = {
      totalOutput: Number(data.totalOutput || 0),
      totalScrap: Number(data.totalScrap || 0),
      yieldRate: Number(data.yieldRate || 0),
    };
  } catch {
    productionOverviewData.value = {
      totalOutput: 0,
      totalScrap: 0,
      yieldRate: 0,
    };
  }
};
const refreshProductionRealtimeBoard = async () => {
  try {
    const res = await productionRealtimeBoard();
    const data = res?.data || {};
    realtimeBoardData.value = {
      deviceOee: {
        value: Number(data.deviceOee?.value || 0),
        compareYesterday: Number(data.deviceOee?.compareYesterday || 0),
      },
      orderAchievementRate: {
        value: Number(data.orderAchievementRate?.value || 0),
        compareYesterday: Number(data.orderAchievementRate?.compareYesterday || 0),
      },
      defectRate: {
        value: Number(data.defectRate?.value || 0),
        compareYesterday: Number(data.defectRate?.compareYesterday || 0),
      },
    };
  } catch {
    realtimeBoardData.value = {
      deviceOee: { value: 0, compareYesterday: 0 },
      orderAchievementRate: { value: 0, compareYesterday: 0 },
      defectRate: { value: 0, compareYesterday: 0 },
    };
  }
};
const refreshProductionOrderProgress = async () => {
  try {
    const res = await productionOrderProgress({
      status: orderFilter.value,
      tab: orderFilter.value,
      pageNum: 1,
      pageSize: 10,
    });
    const data = res?.data || {};
    const statusValue = normalizeOrderFilter(data.status, orderFilter.value);
    const total = Number(data.total || 0);
    orderProgressMeta.value = {
      status: statusValue,
      tab: data.tab || orderFilter.value,
      bizDate: data.bizDate || null,
      total,
      pageNum: Number(data.pageNum || 1),
      pageSize: Number(data.pageSize || 10),
      waitingCount: resolveProgressCount(data.waitingCount, statusValue, "waiting", total),
      inProgressCount: resolveProgressCount(data.inProgressCount, statusValue, "inProgress", total),
      completedCount: resolveProgressCount(data.completedCount, statusValue, "completed", total),
      pausedCount: resolveProgressCount(data.pausedCount, statusValue, "paused", total),
    };
    productionOrders.value = (data.records || []).map(mapOrderProgressRecord);
  } catch {
    orderProgressMeta.value = {
      status: orderFilter.value,
      tab: orderFilter.value,
      bizDate: null,
      total: 0,
      pageNum: 1,
      pageSize: 10,
      waitingCount: 0,
      inProgressCount: 0,
      completedCount: 0,
      pausedCount: 0,
    };
    productionOrders.value = [];
  }
};
const refreshTodayProductionPlan = async () => {
  try {
    const res = await todayProductionPlan({
      limit: 4,
      planDate: nowDate.value,
    });
    const data = res?.data || {};
    todayPlanTotal.value = Number(data.total || 0);
    todayPlanList.value = (data.records || []).map(mapTodayPlanRecord);
  } catch {
    todayPlanTotal.value = 0;
    todayPlanList.value = [];
  }
};
const getBusinessData = async () => {
  const res = await getBusiness();
  businessInfo.value = { ...res.data };
};
const analysisCustomer = async () => {
  const res = await analysisCustomerContractAmounts();
  sum.value = res.data.sum;
  yny.value = res.data.yny;
  chain.value = res.data.chain;
  materialPieSeries.value[0].data = (res.data.item || []).map((item, index) => ({
    ...item,
    rate: Number(item.rate || 0),
    itemStyle: { color: piePalette[index % piePalette.length] },
  }));
};
const todoInfoS = async () => {
  const res = await homeTodos();
  todoList.value = res.data || [];
};
const statisticsReceivable = async () => {
  const res = await statisticsReceivablePayable({ type: 1 });
  barSeries.value[0].data = [
    { value: res.data.payableMoney, itemStyle: { color: barColors2[0] } },
    { value: res.data.receivableMoney, itemStyle: { color: barColors2[1] } },
  ];
};
const qualityStatisticsInfo = async () => {
  const res = await qualityInspectionStatistics({ type: qualityRange.value });
  xAxis1.value[0].data = [];
  barSeries1.value[0].data = [];
  barSeries1.value[1].data = [];
  barSeries1.value[2].data = [];
  (res.data.item || []).forEach((item) => {
    xAxis1.value[0].data.push(item.date);
    barSeries1.value[0].data.push(item.supplierNum);
    barSeries1.value[1].data.push(item.processNum);
    barSeries1.value[2].data.push(item.factoryNum);
  });
  qualityStatisticsObject.value.supplierNum = res.data.supplierNum;
  qualityStatisticsObject.value.processNum = res.data.processNum;
  qualityStatisticsObject.value.factoryNum = res.data.factoryNum;
};
const getAmountHalfYearNum = async () => {
  const res = await getAmountHalfYear();
  const monthName = [];
  const receiptAmount = [];
  const invoiceAmount = [];
  (res.data || []).forEach((item) => {
    monthName.push(item.month);
    receiptAmount.push(item.receiptAmount);
    invoiceAmount.push(item.invoiceAmount);
  });
  xAxis2.value[0].data = monthName.map((item) => item.replace(/~/g, "\n~"));
  lineSeries.value[0].data = invoiceAmount;
  lineSeries.value[1].data = receiptAmount;
};
const getProcessList = async () => {
  const res = await list();
  processOptions.value = res.data.records || [];
};
const refreshProcessStats = async () => {
  const res = await processDataProductionStatistics({
    type: processRange.value,
    processIds: selectedProcessIds.value.length > 0 ? selectedProcessIds.value.join(',') : null
  }).then(res => {
    processChartData.value = res.data.map(item => ({
      name: item.processName,
      input: item.totalInput,
      scrap: item.totalScrap,
      output: item.totalOutput
    }))
    processYAxis.value[0].data = processChartData.value.map((i) => i.name)
    activeProcessIndex.value = 0
  })
}
    processIds: selectedProcessIds.value.length > 0 ? selectedProcessIds.value.join(",") : null,
  });
  processChartData.value = (res.data || []).map((item) => ({
    name: item.processName,
    input: item.totalInput,
    scrap: item.totalScrap,
    output: item.totalOutput,
  }));
  processYAxis.value[0].data = processChartData.value.map((item) => item.name);
  activeProcessIndex.value = 0;
};
const openProcessDialog = () => {
  tempProcessIds.value = [...selectedProcessIds.value];
  processDialogVisible.value = true;
};
const handleProcessDialogConfirm = () => {
  selectedProcessIds.value = [...tempProcessIds.value];
  processDialogVisible.value = false;
  refreshProcessStats();
};
const resetProcessFilter = () => {
  selectedProcessIds.value = [];
  tempProcessIds.value = [];
  refreshProcessStats();
};
const handleChartClick = (params) => {
  if (params && params.dataIndex !== undefined) {
    activeProcessIndex.value = params.dataIndex;
  }
};
const goToQuick = (path) => {
  if (!path) return;
  router.push(path).catch(() => {});
};
watch(orderFilter, () => {
  if (visiblePanels.value.order) {
    refreshProductionOrderProgress();
  }
});
onMounted(() => {
  getBusinessData()
  analysisCustomer()
  todoInfoS()
  statisticsReceivable()
  qualityStatisticsInfo()
  getAmountHalfYearNum()
  refreshProcessStats()
})
  updateNowTime();
  clockTimer = setInterval(updateNowTime, 1000);
  if (dashboardCards.value.length > 0) {
    getBusinessData();
  }
  if (visibleModules.value.production) {
    refreshProductionOverview();
  }
  if (visiblePanels.value.contract) {
    analysisCustomer();
  }
  if (visiblePanels.value.todo) {
    todoInfoS();
  }
  if (visiblePanels.value.quality) {
    qualityStatisticsInfo();
  }
  if (visiblePanels.value.receipt) {
    statisticsReceivable();
    getAmountHalfYearNum();
  }
  if (visiblePanels.value.process) {
    getProcessList();
    refreshProcessStats();
  }
  if (visiblePanels.value.order) {
    refreshProductionOrderProgress();
  }
  if (visiblePanels.value.realtime) {
    refreshProductionRealtimeBoard();
  }
  if (visiblePanels.value.plan) {
    refreshTodayProductionPlan();
  }
});
onUnmounted(() => {
  if (clockTimer) {
    clearInterval(clockTimer);
  }
});
</script>
<style scoped>
.dashboard {
  min-height: 100vh;
  padding: 20px;
  box-sizing: border-box;
}
.dashboard-top {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  align-items: flex-start;
  justify-content: space-evenly;
}
.company-info {
.dashboard-cockpit {
  min-height: calc(100vh - var(--topbar-height) - var(--tagsbar-height));
  width: 100%;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border-radius: 12px;
  background: #fff;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-x: clip;
  margin-top: 10px;
}
.welcome-banner {
  padding: 10px 10px;
  background: linear-gradient(135deg, rgba(229, 240, 255, 0.9), rgba(214, 232, 255, 0.7), rgba(207, 236, 255, 0.9));
.digital-number {
  font-family: "DIN Alternate Bold", "Segoe UI", "PingFang SC", sans-serif;
  letter-spacing: 0;
}
.welcome-title {
  font-size: 18px;
  font-weight: 700;
  color: #222;
  line-height: 1.3;
.cockpit-panel {
  position: relative;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.06);
  backdrop-filter: blur(12px);
  padding: 16px;
}
.welcome-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 92px;
  padding: 18px 22px;
  background:
      radial-gradient(circle at 8% 20%, rgba(59, 130, 246, 0.12), transparent 32%),
      linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(239, 246, 255, 0.88));
}
.welcome-user {
  margin-right: 6px;
}
.welcome-time {
  margin-top: 10px;
  font-size: 16px;
  color: rgba(0, 0, 0, 0.55);
}
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 22px;
}
.user-card-main {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.user-name {
  font-size: 16px;
  font-weight: bold;
  color: #111;
  letter-spacing: 1px;
}
.user-role {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  padding: 5px 10px;
  background: rgba(245, 246, 248, 1);
  color: #333;
  width: fit-content;
  font-weight: 600;
}
.user-meta {
  font-size: 12px;
  color: rgba(0, 0, 0, 0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-meta .sep {
  margin: 0 10px;
  color: rgba(0, 0, 0, 0.25);
  gap: 12px;
}
.avatar {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(147, 197, 253, 0.42);
  background: linear-gradient(145deg, #ffffff, #eef5ff);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.14);
}
.avatar :deep(img) {
  width: 100%;
  height: 100%;
  object-fit: cover;
  flex: 0 0 auto;
}
.data-cards {
  width: 50%;
  display: flex;
  gap: 16px;
  justify-content: flex-start;
  background: #ffffff;
  border-radius: 12px;
  padding: 20px;
.avatar :deep(.el-icon) {
  font-size: 24px;
  color: #3b82f6;
}
.data-title {
.welcome-title {
  font-size: 28px;
  font-weight: 700;
  font-size: 26px;
  color: #FFFFFF;
  color: #1e3a5f;
  line-height: 1.08;
}
.data-num {
.welcome-subtitle {
  margin-top: 6px;
  color: #64748b;
  font-size: 14px;
}
.welcome-meta {
  text-align: right;
}
.meta-time {
  font-size: 28px;
  color: #1f3658;
  font-weight: 700;
}
.meta-extra {
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
  gap: 14px;
  color: #64748b;
  font-size: 13px;
}
.meta-tip {
  margin-top: 4px;
  color: #7a8ca6;
  font-size: 13px;
}
.top-row {
  display: block;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.stat-card {
  position: relative;
  border-radius: 18px;
  padding: 18px 20px 22px;
  min-height: 182px;
  height: auto;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 40px rgba(37, 99, 235, 0.1);
}
.stat-card.sales {
  background: linear-gradient(135deg, #ffffff 0%, #eaf3ff 100%);
}
.stat-card.purchase {
  background: linear-gradient(135deg, #ffffff 0%, #e8fffb 100%);
}
.stat-card.inventory {
  background: linear-gradient(135deg, #ffffff 0%, #f2edff 100%);
}
.stat-card.production {
  background: linear-gradient(135deg, #ffffff 0%, #fff4e6 100%);
}
.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  position: relative;
  z-index: 2;
}
.stat-title {
  font-size: 16px;
  font-weight: 700;
}
.stat-card.sales .stat-title {
  color: #1d4ed8;
}
.stat-card.purchase .stat-title {
  color: #0f766e;
}
.stat-card.inventory .stat-title {
  color: #6d28d9;
}
.stat-card.production .stat-title {
  color: #c2410c;
}
.stat-desc {
  margin-top: 6px;
  color: #64748b;
  font-size: 13px;
}
.stat-icon-orb {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  justify-content: center;
  font-size: 22px;
  color: #fff;
}
.data-card {
  background: #fff;
  border-radius: 12px;
  padding: 14px 10px 10px 10px;
  min-width: 160px;
  box-shadow: 0 2px 8px #eee;
  display: flex;
  flex-direction: column;
  width: 32%;
  height: 140px;
.stat-card.sales .stat-icon-orb {
  background: linear-gradient(135deg, #2563eb, #60a5fa);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.32);
}
.data-card.sales {
  background-image: url("../assets/images/xioashoushuju.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
.stat-card.purchase .stat-icon-orb {
  background: linear-gradient(135deg, #14b8a6, #5eead4);
  box-shadow: 0 10px 24px rgba(20, 184, 166, 0.3);
}
.data-card.purchase {
  background-image: url("../assets/images/caigou.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
.stat-card.inventory .stat-icon-orb {
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  box-shadow: 0 10px 24px rgba(124, 58, 237, 0.28);
}
.data-card.inventory {
  background-image: url("../assets/images/kucun.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
.stat-card.production .stat-icon-orb {
  background: linear-gradient(135deg, #f97316, #fdba74);
  box-shadow: 0 10px 24px rgba(249, 115, 22, 0.3);
}
.data-desc {
  font-weight: 500;
.stat-value {
  margin-top: 14px;
  font-size: 30px;
  line-height: 1.08;
  font-weight: 700;
  color: #0f172a;
  position: relative;
  z-index: 2;
}
.stat-footer {
  margin-top: 8px;
  color: #64748b;
  font-size: 13px;
  color: #FFFFFF;
}
.data-value {
  font-size: 18px;
  font-weight: 500;
  margin: 10px 0;
  color: #FFFFFF;
}
.top-left {
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 180px;
  width: 20%;
  justify-content: space-between;
  align-items: center;
  position: relative;
  z-index: 2;
}
.stat-trend {
  margin-top: 6px;
  color: #0ea5a4;
  font-size: 13px;
  line-height: 1.25;
  font-weight: 600;
  position: relative;
  z-index: 2;
}
.stat-wave {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 6px;
  height: 30px;
  opacity: 0.62;
  z-index: 1;
  pointer-events: none;
  background:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 340 40' preserveAspectRatio='none'%3E%3Cpath d='M0 31C20 16 44 36 66 24C87 12 107 31 129 18C148 8 169 28 193 16C214 5 237 25 259 14C280 3 306 19 340 8' fill='none' stroke='%236ea4ee' stroke-width='1.5'/%3E%3C/svg%3E")
      center / 100% 100% no-repeat;
}
.todo-panel {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  height: 180px;
  width: 30%;
  padding: 12px;
}
.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.panel-title {
  font-size: 18px;
  font-weight: 700;
  color: #1f3658;
  position: relative;
  padding-left: 12px;
}
.panel-title::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 18px;
  border-radius: 4px;
  background: linear-gradient(180deg, #2563eb, #38bdf8);
}
.panel-more {
  font-size: 14px;
  color: #2563eb;
  cursor: pointer;
}
.todo-list {
  height: 100px;
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  margin: 0;
  font-size: 15px;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 230px;
  overflow-y: auto;
}
.todo-list li {
  border-radius: 8px;
  margin-bottom: 12px;
  padding: 8px 20px;
  height: 74px;
.todo-item {
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  background: #f7fbff;
  padding: 10px 12px;
}
.todo-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(225, 227, 250, 0.62);
}
.todo-title {
  font-weight: 400;
  font-size: 12px;
  color: #000000;
  position: relative;
}
.todo-title::before {
  content: '';
  /* 必需,表示这里有一个内容 */
  position: absolute;
  left: -10px;
  /* 定位到左侧 */
  top: 50%;
  /* 垂直居中 */
  transform: translateY(-50%);
  /* 微调垂直居中 */
  width: 6px;
  /* 圆的直径 */
  height: 6px;
  /* 圆的直径 */
  background: #498CEB;
  border-radius: 50%;
  /* 让其变成圆形 */
}
.todo-division {
  font-weight: 400;
  font-size: 12px;
  color: #000000;
}
.todo-time {
  font-weight: 400;
  font-size: 12px;
  color: #000000;
}
.todo-meta {
  color: #888;
  gap: 10px;
  color: #334155;
  font-size: 13px;
}
.dashboard-row {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
}
.main-panel {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.section-title {
  position: relative;
  font-size: 18px;
  color: #333;
  padding-left: 10px;
  margin-bottom: 10px;
  font-weight: 700;
}
.section-title::before {
  position: absolute;
  left: 0;
  top: 4px;
  content: '';
  width: 4px;
  height: 18px;
  background-color: #002FA7;
  border-radius: 2px;
}
.contract-info {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 90px;
  background: rgba(245, 245, 245, 0.59);
  width: 100%;
  border-radius: 10px;
  padding: 10px 30px;
}
.contract-summary {
  display: flex;
  align-items: center;
  gap: 30px;
}
.contract-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.contract-name {
  font-weight: 400;
  font-size: 14px;
  color: #050505;
}
.contract-meta {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 80px;
}
.main-amount {
  font-size: 24px;
  color: rgba(51, 50, 50, 0.85);
}
.up {
  color: #e57373;
}
.contract-list {
  margin-top: 16px;
  font-size: 14px;
  color: #666;
  list-style: none;
  padding: 0;
  height: 190px;
  overflow-y: auto;
  width: 460px;
}
.line {
  position: relative;
  width: 230px;
}
.line::after {
  content: '';
  position: absolute;
  right: 2px;
  top: 0;
  bottom: 0;
  width: 1px;
  background-color: #C9C5C5;
  border-radius: 2px;
}
.contract-list li {
  margin-top: 10px;
}
.quality-cards {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}
.quality-card {
  border-radius: 8px;
  padding: 15px 10px 10px 50px;
  font-weight: 400;
.todo-desc {
  margin-top: 6px;
  color: #64748b;
  font-size: 12px;
  color: rgba(0, 0, 0, 0.67);
  width: 236px;
  height: 49px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  line-height: 1.45;
}
.quality-card.one {
  background-image: url("../assets/images/yuancailiao.png");
.todo-no {
  color: #1f3658;
  font-weight: 600;
}
.quality-card.two {
  background-image: url("../assets/images/guocheng.png");
.panel-empty {
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
}
.quality-card.three {
  background-image: url("../assets/images/chuchang.png");
.empty-home-panel {
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  font-size: 14px;
}
.quality-card span {
  color: #4fc3f7;
  font-weight: bold;
  margin-left: 6px;
.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 16px;
  align-items: start;
}
.chart {
  width: 100%;
  height: 220px;
  margin-top: 10px;
.left-column,
.right-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.process-panel {
  padding-bottom: 10px;
  padding-bottom: 12px;
}
.process-panel__header {
.panel-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.process-panel__body {
  display: flex;
  gap: 24px;
  align-items: stretch;
.process-body {
  margin-top: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 232px;
  gap: 12px;
  align-items: stretch;
  min-height: 0;
}
.process-panel__chart {
  flex: 1;
  min-width: 0;
  padding: 6px 0;
.process-chart {
  position: relative;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 14px;
  background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(244, 249, 255, 0.9)),
      repeating-linear-gradient(
          to right,
          rgba(148, 163, 184, 0.07) 0,
          rgba(148, 163, 184, 0.07) 1px,
          transparent 1px,
          transparent 48px
      ),
      repeating-linear-gradient(
          to bottom,
          rgba(148, 163, 184, 0.06) 0,
          rgba(148, 163, 184, 0.06) 1px,
          transparent 1px,
          transparent 34px
      );
  overflow: hidden;
  padding: 10px;
}
.process-panel__aside {
  width: 260px;
.process-chart.empty :deep(canvas) {
  opacity: 0.2;
}
.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #64748b;
  font-size: 14px;
  text-align: center;
  pointer-events: auto;
  padding: 12px;
}
.chart-empty .el-icon {
  color: #2563eb;
  font-size: 28px;
}
.chart-empty-title {
  font-size: 16px;
  font-weight: 700;
  color: #334155;
}
.chart-empty-desc {
  font-size: 13px;
  color: #64748b;
}
.chart-empty-actions {
  margin-top: 4px;
  display: flex;
  gap: 8px;
}
.process-aside {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.process-legend,
.process-card {
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.84);
  padding: 10px 12px;
}
.process-card {
  min-height: 74px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.process-legend {
  min-height: 74px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 6px;
  gap: 6px;
  justify-content: center;
}
.process-legend__item {
.process-legend-item {
  color: #475569;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: rgba(0, 0, 0, 0.55);
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  border-radius: 3px;
  display: inline-block;
}
.dot-blue {
  background: #1E5BFF;
  background: #2563eb;
}
.dot-yellow {
  background: #F7B500;
.dot-orange {
  background: #f59e0b;
}
.dot-teal {
  background: #19C6C6;
.dot-cyan {
  background: #14b8a6;
}
.process-card {
  background: rgba(245, 247, 250, 0.9);
  border-radius: 10px;
  padding: 16px 16px;
}
.process-card--name {
  background: rgba(235, 242, 255, 1);
  color: #1E5BFF;
  font-weight: 800;
.process-name {
  color: #2563eb;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
  margin-bottom: 2px;
}
.process-card__label {
  font-size: 13px;
  color: rgba(0, 0, 0, 0.55);
  margin-bottom: 10px;
}
.process-card__value {
  font-size: 24px;
  font-weight: 800;
  color: rgba(0, 0, 0, 0.8);
}
.process-card__value .unit {
.process-label {
  font-size: 12px;
  color: #64748b;
}
.process-value {
  margin-top: 4px;
  font-size: 24px;
  color: #0f172a;
  font-weight: 700;
}
.chart-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.contract-summary {
  display: grid;
  grid-template-columns: 1fr 190px;
  gap: 12px;
  align-items: center;
  margin-top: 8px;
}
.contract-card {
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: #f8fbff;
  padding: 12px;
}
.contract-name {
  color: #64748b;
  font-size: 13px;
}
.contract-main {
  margin-top: 8px;
  font-size: 34px;
  font-weight: 700;
  color: #0f172a;
}
.contract-compare {
  margin-top: 8px;
  font-size: 13px;
  color: #64748b;
  display: flex;
  gap: 10px;
}
.rise {
  color: #0ea5a4;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.45);
}
.contract-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.contract-list li {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) 56px auto;
  align-items: center;
  gap: 8px;
  color: #475569;
  font-size: 13px;
}
.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.contract-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contract-item-rate {
  text-align: right;
  color: #64748b;
}
.contract-item-value {
  color: #1f3658;
  text-align: right;
}
.quality-cards {
  margin: 8px 0 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.quality-card {
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  padding: 10px 12px;
  color: #475569;
  font-size: 13px;
}
.quality-card.one {
  background: linear-gradient(135deg, #ffffff, #edf4ff);
}
.quality-card.two {
  background: linear-gradient(135deg, #ffffff, #ebfffc);
}
.quality-card.three {
  background: linear-gradient(135deg, #ffffff, #fff3e6);
}
.quality-card span {
  color: #0f172a;
  font-weight: 700;
  margin-left: 6px;
}
@media (max-width: 1200px) {
  .process-panel__body {
    flex-direction: column;
  }
.realtime-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
  .process-panel__aside {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
  }
.realtime-item {
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  background: #f8fbff;
  padding: 10px 8px;
  text-align: center;
}
  .process-card {
    flex: 1;
    min-width: 220px;
  }
.realtime-value {
  font-size: 26px;
  color: #0f172a;
  font-weight: 700;
}
.realtime-label {
  margin-top: 8px;
  font-size: 12px;
  color: #475569;
}
.realtime-delta {
  margin-top: 4px;
  font-size: 12px;
}
.realtime-delta.up {
  color: #0ea5a4;
}
.realtime-delta.down {
  color: #f59e0b;
}
.realtime-delta.flat {
  color: #64748b;
}
.warning-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
}
.warning-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) 72px;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  background: #f8fbff;
  padding: 10px;
}
.warning-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: block;
}
.warning-dot.device {
  background: #ef4444;
}
.warning-dot.quality {
  background: #f59e0b;
}
.warning-dot.material {
  background: #3b82f6;
}
.warning-title {
  color: #334155;
  font-size: 13px;
  font-weight: 600;
}
.warning-desc {
  color: #64748b;
  font-size: 12px;
  margin-top: 4px;
}
.warning-time {
  color: #64748b;
  font-size: 12px;
  text-align: right;
}
.order-panel {
  min-height: 0;
}
.quick-panel {
  min-height: 0;
}
.table-progress {
  display: flex;
  align-items: center;
  gap: 10px;
}
.table-progress span {
  font-size: 12px;
  color: #475569;
}
.quick-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 58px;
  gap: 10px;
}
.quick-item {
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 12px;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  font-size: 12px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.plan-panel {
  min-height: 236px;
}
.quality-panel {
  min-height: 0;
}
.receipt-panel {
  min-height: 340px;
}
.plan-list {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.plan-item {
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 12px;
  background: #f8fbff;
  padding: 10px 12px;
}
.plan-main {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}
.plan-order {
  font-size: 13px;
  color: #1f3658;
  font-weight: 600;
}
.plan-name {
  font-size: 13px;
  color: #334155;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.plan-meta {
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: #64748b;
}
.quick-item:hover {
  transform: translateY(-2px);
  border-color: rgba(96, 165, 250, 0.45);
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.1);
}
.quick-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2563eb, #38bdf8);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #fff;
}
.quick-item:nth-child(2) .quick-icon,
.quick-item:nth-child(6) .quick-icon {
  background: linear-gradient(135deg, #14b8a6, #5eead4);
}
.quick-item:nth-child(3) .quick-icon,
.quick-item:nth-child(5) .quick-icon {
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
}
.quick-item:nth-child(4) .quick-icon,
.quick-item:nth-child(7) .quick-icon {
  background: linear-gradient(135deg, #f97316, #fdba74);
}
.process-selection-wrapper {
  max-height: 400px;
  overflow-y: auto;
  padding: 10px;
  padding: 8px;
}
.process-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  gap: 10px;
}
:deep(.el-checkbox.is-bordered) {
  margin-left: 0 !important;
  width: 100%;
}
</style>
:deep(.el-radio-button__inner) {
  border-radius: 10px !important;
  background: #f8fbff;
  border-color: rgba(148, 163, 184, 0.22) !important;
  color: #475569 !important;
}
:deep(.el-radio-button__original-radio:checked + .el-radio-button__inner) {
  background: linear-gradient(135deg, #2f80ff, #38bdf8) !important;
  border-color: transparent !important;
  color: #fff !important;
}
:deep(.el-progress-circle__track) {
  stroke: rgba(148, 163, 184, 0.3);
}
:deep(.el-progress-bar__outer) {
  background-color: rgba(148, 163, 184, 0.2);
}
:deep(.order-panel .el-progress-bar__inner) {
  background: linear-gradient(90deg, #2563eb, #38bdf8) !important;
}
:deep(.order-panel .el-table) {
  border-radius: 14px;
}
:deep(.order-panel .el-table th.el-table__cell) {
  background: #f2f7ff !important;
}
:deep(.order-panel .el-table__body tr:hover > td.el-table__cell) {
  background: #f8fbff !important;
}
:deep(.order-panel .el-tag--success) {
  color: #0f766e;
  background: #e9fdf7;
  border-color: #b7f2e0;
}
:deep(.order-panel .el-tag--warning) {
  color: #b45309;
  background: #fff6e8;
  border-color: #fde0b8;
}
:deep(.order-panel .el-tag--primary) {
  color: #2563eb;
  background: #eaf2ff;
  border-color: #b8d2ff;
}
@media (max-width: 1600px) {
  .main-grid {
    grid-template-columns: minmax(0, 1fr) 380px;
  }
}
@media (max-width: 1366px) {
  .main-grid {
    grid-template-columns: minmax(0, 1fr) 340px;
  }
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 1200px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
  .right-column {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }
  .chart-row {
    grid-template-columns: 1fr;
  }
  .process-body {
    grid-template-columns: 1fr;
  }
  .realtime-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .quality-cards {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 768px) {
  .welcome-panel {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .welcome-meta {
    text-align: left;
  }
  .meta-extra {
    justify-content: flex-start;
  }
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .right-column {
    grid-template-columns: 1fr;
  }
  .realtime-grid {
    grid-template-columns: 1fr;
  }
}
</style>