|
|
@@ -0,0 +1,2033 @@
|
|
|
+<template>
|
|
|
+ <div class="pos-page">
|
|
|
+ <!-- ===== 筛选栏 ===== -->
|
|
|
+ <div class="filter-card">
|
|
|
+ <el-form inline @submit.prevent="handleQuery">
|
|
|
+ <el-form-item label="统计年份">
|
|
|
+ <el-select v-model="query.year" style="width: 130px" :loading="yearsLoading" @change="handleYearChange">
|
|
|
+ <el-option v-for="y in yearOptions" :key="y" :label="`${y} 年`" :value="String(y)" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-input
|
|
|
+ v-model="query.keyword"
|
|
|
+ placeholder="订单编号 / 款号 / 生产款号 / 客户"
|
|
|
+ clearable
|
|
|
+ style="width: 320px"
|
|
|
+ @keyup.enter="handleQuery"
|
|
|
+ @clear="handleQuery"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" icon="Search" :loading="overviewLoading" @click="handleQuery">查询</el-button>
|
|
|
+ <el-button type="success" icon="Download" @click="openExportDialog">月度报表导出</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- ===== 左右主栏 ===== -->
|
|
|
+ <el-row :gutter="12" class="main-row">
|
|
|
+ <!-- 左:全年分析 -->
|
|
|
+ <el-col :xs="24" :md="12">
|
|
|
+ <div class="col-panel">
|
|
|
+ <div class="col-head">
|
|
|
+ <div class="col-title">全年分析</div>
|
|
|
+ <span class="col-sub">各工序车间全年产量与款数</span>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- 全年汇总:一眼看清全年做了多少款、多少件 -->
|
|
|
+ <div class="metric-row col-metrics">
|
|
|
+ <div class="metric-card">
|
|
|
+ <div class="metric-label">全年完成款数</div>
|
|
|
+ <div class="metric-value num">{{ formatNum(yearTotal.styles) }}<span class="unit">款</span></div>
|
|
|
+ </div>
|
|
|
+ <div class="metric-card">
|
|
|
+ <div class="metric-label">全年报工总数量</div>
|
|
|
+ <div class="metric-value num">{{ formatNum(yearTotal.qty) }}<span class="unit">件</span></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="panel-section chart-section">
|
|
|
+ <div class="section-title">各车间年度款数 / 数量</div>
|
|
|
+ <div ref="wsChartRef" class="trend-chart"></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <!-- 右:月度分析 -->
|
|
|
+ <el-col :xs="24" :md="12">
|
|
|
+ <div class="col-panel">
|
|
|
+ <div class="col-head">
|
|
|
+ <div class="col-title">月度分析</div>
|
|
|
+ <span class="col-sub">1-12 月产量与款数趋势</span>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- 月度汇总:当前有数据的月份合计 -->
|
|
|
+ <div class="metric-row col-metrics">
|
|
|
+ <div class="metric-card">
|
|
|
+ <div class="metric-label">{{ focusMonthLabel }}款数</div>
|
|
|
+ <div class="metric-value num">{{ formatNum(focusMonthStyles) }}<span class="unit">款</span></div>
|
|
|
+ </div>
|
|
|
+ <div class="metric-card">
|
|
|
+ <div class="metric-label">{{ focusMonthLabel }}报工数量</div>
|
|
|
+ <div class="metric-value num">{{ formatNum(focusMonthQty) }}<span class="unit">件</span></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="panel-section chart-section">
|
|
|
+ <div class="section-title">月度产量与款数趋势</div>
|
|
|
+ <div ref="chartRef" class="trend-chart"></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <!-- ===== 月度 × 车间 矩阵 ===== -->
|
|
|
+ <div class="panel">
|
|
|
+ <div class="panel-title">
|
|
|
+ <span>月度车间款式 / 产量明细</span>
|
|
|
+ <span class="hint">单元格上方为报工数量,下方为款数</span>
|
|
|
+ </div>
|
|
|
+ <div class="table-wrap">
|
|
|
+ <el-table
|
|
|
+ v-loading="overviewLoading"
|
|
|
+ :data="matrixRows"
|
|
|
+ border
|
|
|
+ size="small"
|
|
|
+ class="matrix-table"
|
|
|
+ show-summary
|
|
|
+ :summary-method="matrixSummary"
|
|
|
+ >
|
|
|
+ <el-table-column label="工序车间" width="82" fixed="left">
|
|
|
+ <template #default="{ row }">{{ row.workshop }}</template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ v-for="m in ALL_MONTHS"
|
|
|
+ :key="m"
|
|
|
+ :label="`${Number(m)}月`"
|
|
|
+ align="center"
|
|
|
+ min-width="84"
|
|
|
+ >
|
|
|
+ <template #default="{ row }">
|
|
|
+ <div v-if="hasMatrixCell(row.cells[m])" class="matrix-cell">
|
|
|
+ <div class="mc-qty">{{ row.cells[m].qty }}</div>
|
|
|
+ <div class="mc-style">{{ row.cells[m].styles }} 款</div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="年度合计" align="center" width="106" fixed="right">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <div class="matrix-cell matrix-total">
|
|
|
+ <div class="mc-qty">{{ row.yearQty }}</div>
|
|
|
+ <div class="mc-style">{{ row.yearStyles }} 款</div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- ===== 车间报工明细 ===== -->
|
|
|
+ <div class="panel">
|
|
|
+ <div class="panel-title panel-title-bar">
|
|
|
+ <span>报工明细追溯(款 → 车间 → 小组 → 员工)</span>
|
|
|
+ <span class="hint">{{ detailScopeText }}</span>
|
|
|
+ <!-- 汇总数字直接放在标题栏里,不再单独占一行指标卡 -->
|
|
|
+ <span class="inline-sum">
|
|
|
+ <span class="is-item">报工款数 <b class="num">{{ formatNum(detailTotal) }}</b> 款</span>
|
|
|
+ <span class="is-item">报工数量 <b class="num">{{ formatNum(detailTotalQty) }}</b> 件</span>
|
|
|
+ <span class="is-item">车间 <b class="num">{{ detailWorkshopCount }}</b> 个</span>
|
|
|
+ <span class="is-item">小组 <b class="num">{{ detailGroupCount }}</b> 组</span>
|
|
|
+ <span class="is-item">员工 <b class="num">{{ detailStaffCount }}</b> 人</span>
|
|
|
+ </span>
|
|
|
+ <!-- 明细专用筛选放在面板头部,就地操作不用回到顶部 -->
|
|
|
+ <div class="panel-tools">
|
|
|
+ <span class="tool-label">工序车间</span>
|
|
|
+ <el-select v-model="filter.workshop" style="width: 112px" size="small" @change="handleFilterChange">
|
|
|
+ <el-option label="全部车间" value="全部" />
|
|
|
+ <el-option v-for="w in WORKSHOPS" :key="w" :label="w" :value="w" />
|
|
|
+ </el-select>
|
|
|
+ <span class="tool-label">统计月份</span>
|
|
|
+ <el-select v-model="filter.month" style="width: 106px" size="small" placeholder="全部月份" @change="handleFilterChange">
|
|
|
+ <el-option label="全部月份" value="" />
|
|
|
+ <el-option v-for="m in ALL_MONTHS" :key="m" :label="`${Number(m)} 月`" :value="m" />
|
|
|
+ </el-select>
|
|
|
+ <el-button
|
|
|
+ v-if="filter.workshop !== '全部' || filter.month"
|
|
|
+ size="small"
|
|
|
+ text
|
|
|
+ @click="resetDetailFilter"
|
|
|
+ >重置</el-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="table-wrap">
|
|
|
+ <el-table
|
|
|
+ ref="detailTableRef"
|
|
|
+ v-loading="detailLoading"
|
|
|
+ :data="detailRows"
|
|
|
+ border
|
|
|
+ size="small"
|
|
|
+ show-summary
|
|
|
+ :summary-method="detailSummary"
|
|
|
+ show-overflow-tooltip
|
|
|
+ max-height="620"
|
|
|
+ row-key="款号"
|
|
|
+ @expand-change="onExpandChange"
|
|
|
+ @row-click="onRowClick"
|
|
|
+ >
|
|
|
+ <el-table-column type="expand" width="36">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <div class="order-box">
|
|
|
+ <div class="order-box-title">
|
|
|
+ <span class="obt-title">{{ row.款号 }} · 工序车间明细</span>
|
|
|
+ <span class="obt-sub">
|
|
|
+ {{ (row.车间明细 || []).length }} 个工序车间 ·
|
|
|
+ {{ countGroups(row) }} 个小组 · 点击行可展开收起
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ <!-- 一级:工序车间 -->
|
|
|
+ <el-table
|
|
|
+ ref="wsTableRef"
|
|
|
+ :data="row.车间明细 || []"
|
|
|
+ border
|
|
|
+ size="small"
|
|
|
+ class="order-table"
|
|
|
+ row-key="工序车间"
|
|
|
+ @expand-change="onWsExpandChange"
|
|
|
+ @row-click="onWsRowClick"
|
|
|
+ >
|
|
|
+ <el-table-column type="expand" width="30">
|
|
|
+ <template #default="{ row: w }">
|
|
|
+ <!-- 二级:小组明细(对应智能工分核算辅助的班组报工) -->
|
|
|
+ <div class="group-box">
|
|
|
+ <el-table
|
|
|
+ ref="groupTableRef"
|
|
|
+ :data="w.小组明细 || []"
|
|
|
+ border
|
|
|
+ size="small"
|
|
|
+ class="group-table"
|
|
|
+ row-key="小组"
|
|
|
+ @expand-change="onGroupExpandChange"
|
|
|
+ @row-click="onGroupRowClick"
|
|
|
+ >
|
|
|
+ <el-table-column type="expand" width="28">
|
|
|
+ <template #default="{ row: g }">
|
|
|
+ <!-- 三级:员工明细,可追溯到人 -->
|
|
|
+ <div class="staff-box">
|
|
|
+ <el-table
|
|
|
+ :data="g.员工明细 || []"
|
|
|
+ border
|
|
|
+ size="small"
|
|
|
+ class="staff-table"
|
|
|
+ >
|
|
|
+ <el-table-column label="员工编号" prop="员工编号" min-width="100" />
|
|
|
+ <el-table-column label="员工姓名" min-width="100">
|
|
|
+ <template #default="{ row: s }">
|
|
|
+ <span class="staff-name">{{ s.员工姓名 || '未填姓名' }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="报工数量" prop="报工数量" align="right" min-width="96">
|
|
|
+ <template #default="{ row: s }">
|
|
|
+ <span class="num-strong">{{ s.报工数量 }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="报工工序" min-width="230">
|
|
|
+ <template #default="{ row: s }">
|
|
|
+ <div class="proc-list">
|
|
|
+ <span
|
|
|
+ v-for="(p, pi) in (s.工序明细 || [])"
|
|
|
+ :key="pi"
|
|
|
+ class="proc-chip"
|
|
|
+ :title="`${p.工序编号} ${p.工序名称}`"
|
|
|
+ >
|
|
|
+ <span class="pc-code">{{ p.工序编号 }}</span>
|
|
|
+ <span class="pc-name">{{ p.工序名称 }}</span>
|
|
|
+ <span class="pc-num">{{ p.报工数量 }}</span>
|
|
|
+ </span>
|
|
|
+ <span v-if="!(s.工序明细 || []).length" class="mc-empty">无工序信息</span>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="小组" min-width="110">
|
|
|
+ <template #default="{ row: g }">
|
|
|
+ <span class="gp-badge">{{ g.小组 }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="报工数量" prop="报工数量" align="right" min-width="96">
|
|
|
+ <template #default="{ row: g }">
|
|
|
+ <span class="num-strong">{{ g.报工数量 }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="员工数" align="right" min-width="80">
|
|
|
+ <template #default="{ row: g }">{{ g.员工数 || 0 }}</template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <!--
|
|
|
+ 工序车间列不要 fixed。
|
|
|
+ Element Plus 固定列会单独渲染成一块浮层,
|
|
|
+ 展开箭头会被挤到「工序车间」名称的右边(视觉上变成 名称 → 箭头),
|
|
|
+ 去掉 fixed 后箭头就回到最左边,和外层表格、小组表的顺序一致。
|
|
|
+
|
|
|
+ 这里用 min-width(弹性列)而不是 width:
|
|
|
+ 所有列都写死 width 时,Element Plus 不会把表格撑满容器,
|
|
|
+ 展开区只有 298px 宽,下面的 小组表 / 员工表 会被挤掉一截
|
|
|
+ (报工工序那一列看不到)。改成 min-width 后表格铺满面板宽度。
|
|
|
+ -->
|
|
|
+ <el-table-column label="工序车间" min-width="92">
|
|
|
+ <template #default="{ row: w }">
|
|
|
+ <span class="ws-badge">{{ w.工序车间 }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="报工数量" prop="报工数量" align="right" min-width="96">
|
|
|
+ <template #default="{ row: w }">
|
|
|
+ <span class="num-strong">{{ w.报工数量 }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="小组数" align="right" min-width="80">
|
|
|
+ <template #default="{ row: w }">{{ (w.小组明细 || []).length }}</template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="订单编号" width="118">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <div class="ws-tags">
|
|
|
+ <span
|
|
|
+ v-for="o in (row.订单编号 || '').split('、').filter(Boolean)"
|
|
|
+ :key="o"
|
|
|
+ class="ord-tag"
|
|
|
+ >{{ o }}</span>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="款号" prop="款号" min-width="150" />
|
|
|
+ <el-table-column label="客户" prop="客户" width="76" />
|
|
|
+ <el-table-column label="款式" prop="款式" min-width="96" />
|
|
|
+ <el-table-column label="订单数量" prop="订单数量" align="right" width="88">
|
|
|
+ <template #default="{ row }">{{ row.订单数量 }}</template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="工序车间" min-width="300">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <!-- 工艺流程条:做了的车间亮绿色,没做的灰色,一眼看出走到哪一步 -->
|
|
|
+ <div class="flow-strip">
|
|
|
+ <span
|
|
|
+ v-for="w in WORKSHOPS"
|
|
|
+ :key="w"
|
|
|
+ class="flow-node"
|
|
|
+ :class="{ 'is-on': isWsActive(row, w), 'is-off': !isWsActive(row, w) }"
|
|
|
+ :title="isWsActive(row, w) ? `${w}:有报工` : `${w}:本款未报工`"
|
|
|
+ >
|
|
|
+ {{ w }}
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="小组数" align="right" width="76">
|
|
|
+ <template #default="{ row }">{{ row.小组数 || 0 }}</template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="员工数" align="right" width="76">
|
|
|
+ <template #default="{ row }">{{ row.员工数 || 0 }}</template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="报工数量" prop="报工数量" align="right" width="96">
|
|
|
+ <template #default="{ row }">{{ row.报工数量 }}</template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column :label="monthColLabel" min-width="150">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <div class="month-split">
|
|
|
+ <template v-if="showAllMonths">
|
|
|
+ <!-- 只显示月份,数量在左边「报工数量」列已有,这里不重复 -->
|
|
|
+ <span
|
|
|
+ v-for="m in Object.keys(row.月份数量表 || {}).sort()"
|
|
|
+ :key="m"
|
|
|
+ class="month-chip"
|
|
|
+ :title="`${Number(m)}月报工 ${row.月份数量表[m]}`"
|
|
|
+ >
|
|
|
+ <span class="mc-month">{{ Number(m) }}月</span>
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ <span
|
|
|
+ v-else-if="curMonthQty(row.月份数量表) !== null"
|
|
|
+ class="month-chip"
|
|
|
+ :title="`${curMonthNum}月报工 ${curMonthQty(row.月份数量表)}`"
|
|
|
+ >
|
|
|
+ <span class="mc-month">{{ curMonthNum }}月</span>
|
|
|
+ </span>
|
|
|
+ <span v-else class="mc-empty">当月无报工</span>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="pager">
|
|
|
+ <el-pagination
|
|
|
+ v-model:current-page="page"
|
|
|
+ v-model:page-size="pageSize"
|
|
|
+ :page-sizes="[10, 15, 20, 50]"
|
|
|
+ :total="detailTotal"
|
|
|
+ layout="total, sizes, prev, pager, next, jumper"
|
|
|
+ background
|
|
|
+ @current-change="loadDetail"
|
|
|
+ @size-change="handleSizeChange"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- ===== 月度报表导出 ===== -->
|
|
|
+ <el-dialog v-model="exportVisible" title="月度报表导出" width="460px" append-to-body>
|
|
|
+ <el-form label-width="90px">
|
|
|
+ <el-form-item label="统计年份">
|
|
|
+ <el-select v-model="exportForm.year" style="width: 100%">
|
|
|
+ <el-option v-for="y in yearOptions" :key="y" :label="`${y} 年`" :value="String(y)" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="导出月份">
|
|
|
+ <el-select v-model="exportForm.month" style="width: 100%" placeholder="请选择月份">
|
|
|
+ <el-option v-for="m in 12" :key="m" :label="`${m} 月`" :value="String(m)" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="关键词">
|
|
|
+ <el-input
|
|
|
+ v-model="exportForm.keyword"
|
|
|
+ placeholder="订单编号 / 款号 / 客户(选填)"
|
|
|
+ clearable
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+
|
|
|
+ <el-alert type="info" :closable="false" show-icon>
|
|
|
+ <template #title>
|
|
|
+ 导出内容:该月有报工的款号、订单数量、本月报工数量、累计报工数量
|
|
|
+ </template>
|
|
|
+ </el-alert>
|
|
|
+
|
|
|
+ <template #footer>
|
|
|
+ <el-button @click="exportVisible = false">取消</el-button>
|
|
|
+ <el-button type="primary" :loading="exportLoading" @click="handleExport">导出</el-button>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+import { ref, reactive, computed, onMounted, onUnmounted, watch, nextTick, h } from 'vue'
|
|
|
+import { ElMessage } from 'element-plus'
|
|
|
+import * as echarts from 'echarts'
|
|
|
+import * as XLSX from 'xlsx'
|
|
|
+import {
|
|
|
+ GetProcessOutputYears,
|
|
|
+ GetProcessOutputOverview,
|
|
|
+ GetProcessOutputDetail,
|
|
|
+ GetProcessOutputMonthlyReport,
|
|
|
+ GetProcessOutputTrace
|
|
|
+} from '@/api/mes/job'
|
|
|
+
|
|
|
+defineOptions({ name: 'ProcessOutputStatistics' })
|
|
|
+
|
|
|
+/* ==================== 常量 ==================== */
|
|
|
+const WORKSHOPS = ['裁剪', '车缝', '手工', '大烫', '总检', '包装']
|
|
|
+
|
|
|
+/**
|
|
|
+ * 小组名称排序用的「序号」提取器。
|
|
|
+ *
|
|
|
+ * 小组名一般是「工序车间 + 两位序号 + 组」的形式,例如:
|
|
|
+ * 裁剪01组、裁剪02组、裁剪04组
|
|
|
+ * 车缝01组、车缝02组
|
|
|
+ * 这种命名如果直接按字符串排序,「裁剪10组」会排在「裁剪02组」前面,
|
|
|
+ * 所以这里先把名字里的数字抠出来按数字排,抠不到数字的再按字符串排。
|
|
|
+ */
|
|
|
+function groupSeqNo(name) {
|
|
|
+ const m = String(name || '').match(/(\d+)/)
|
|
|
+ return m ? Number(m[1]) : null
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 小组按「组号」升序排(裁剪01组 → 裁剪02组 → 裁剪04组)。
|
|
|
+ * 组号相同时再按报工数量倒序,最后按名称兜底,保证顺序稳定。
|
|
|
+ */
|
|
|
+function sortGroups(list) {
|
|
|
+ return (list || []).slice().sort((a, b) => {
|
|
|
+ const na = groupSeqNo(a?.小组)
|
|
|
+ const nb = groupSeqNo(b?.小组)
|
|
|
+ if (na !== null && nb !== null && na !== nb) return na - nb
|
|
|
+ if (na !== null && nb === null) return -1
|
|
|
+ if (na === null && nb !== null) return 1
|
|
|
+ const qa = Number(a?.报工数量) || 0
|
|
|
+ const qb = Number(b?.报工数量) || 0
|
|
|
+ if (qa !== qb) return qb - qa
|
|
|
+ return String(a?.小组 || '').localeCompare(String(b?.小组 || ''), 'zh-CN')
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 把某个款号下的各个车间的小组明细按组号排好序,
|
|
|
+ * 方便展开后从 1 组开始往后找。
|
|
|
+ */
|
|
|
+function sortGroupsInRows(rows) {
|
|
|
+ for (const row of rows || []) {
|
|
|
+ for (const ws of row?.车间明细 || []) {
|
|
|
+ if (Array.isArray(ws.小组明细)) {
|
|
|
+ ws.小组明细 = sortGroups(ws.小组明细)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return rows
|
|
|
+}
|
|
|
+
|
|
|
+/* ==================== 状态 ==================== */
|
|
|
+const query = reactive({ year: '', keyword: '' })
|
|
|
+const filter = reactive({ workshop: '全部', month: '' })
|
|
|
+const page = ref(1)
|
|
|
+const pageSize = ref(15)
|
|
|
+
|
|
|
+/** 今天的年份 / 月份,作为「统计月份」的默认值 */
|
|
|
+const TODAY = new Date()
|
|
|
+const TODAY_YEAR = TODAY.getFullYear()
|
|
|
+const TODAY_MONTH = String(TODAY.getMonth() + 1).padStart(2, '0')
|
|
|
+
|
|
|
+/**
|
|
|
+ * 某个统计年份下默认的月份。
|
|
|
+ * - 查当前年份 → 默认当月(页面打开就是最新的这个月)
|
|
|
+ * - 查历史年份 → 默认空(看那一年的全部月份)
|
|
|
+ */
|
|
|
+function defaultMonthOf(year) {
|
|
|
+ return String(year) === String(TODAY_YEAR) ? TODAY_MONTH : ''
|
|
|
+}
|
|
|
+
|
|
|
+const yearsLoading = ref(false)
|
|
|
+const overviewLoading = ref(false)
|
|
|
+const detailLoading = ref(false)
|
|
|
+
|
|
|
+const yearOptions = ref([])
|
|
|
+
|
|
|
+/** 概览接口返回的原始数据 */
|
|
|
+const overview = ref({
|
|
|
+ months: [],
|
|
|
+ matrix: [],
|
|
|
+ workshops: [],
|
|
|
+ monthTotals: [],
|
|
|
+ yearTotal: { styles: 0, qty: 0 }
|
|
|
+})
|
|
|
+
|
|
|
+/** 明细接口返回 */
|
|
|
+const detailRows = ref([])
|
|
|
+const detailTotal = ref(0)
|
|
|
+const detailTotalQty = ref(0)
|
|
|
+const detailTotalOrdQty = ref(0)
|
|
|
+/** 明细口径下涉及的车间 / 小组 / 员工数(后端全量统计,不受分页影响) */
|
|
|
+const detailWorkshopCount = ref(0)
|
|
|
+const detailGroupCount = ref(0)
|
|
|
+const detailStaffCount = ref(0)
|
|
|
+/** 展开的款式(row-key = 款号),切换筛选时自动收起 */
|
|
|
+const expandedKeys = ref([])
|
|
|
+/** 明细表实例,用于手风琴式展开/收起 */
|
|
|
+const detailTableRef = ref(null)
|
|
|
+/** 嵌套层级:工序车间表 / 小组表实例,用于手风琴式展开/收起 */
|
|
|
+const wsTableRef = ref(null)
|
|
|
+const groupTableRef = ref(null)
|
|
|
+
|
|
|
+/* ==================== 概览计算属性 ==================== */
|
|
|
+/** 归一化月份为 '01'-'12' 字符串 */
|
|
|
+function normMonth(m) {
|
|
|
+ return String(m).padStart(2, '0')
|
|
|
+}
|
|
|
+
|
|
|
+/** 矩阵固定显示 1-12 月(无数据的月份留空) */
|
|
|
+const ALL_MONTHS = Array.from({ length: 12 }, (_, i) => String(i + 1).padStart(2, '0'))
|
|
|
+
|
|
|
+/** 有数据的月份 */
|
|
|
+const monthColumns = computed(() =>
|
|
|
+ (overview.value.months || []).map(normMonth).sort()
|
|
|
+)
|
|
|
+
|
|
|
+/** 各车间年度汇总(按固定车间顺序排列) */
|
|
|
+const workshopRows = computed(() => {
|
|
|
+ const map = {}
|
|
|
+ for (const w of overview.value.workshops || []) {
|
|
|
+ map[w.ws] = { workshop: w.ws, styles: Number(w.styles) || 0, qty: Number(w.qty) || 0 }
|
|
|
+ }
|
|
|
+ return WORKSHOPS.map((w) => map[w] || { workshop: w, styles: 0, qty: 0 })
|
|
|
+})
|
|
|
+
|
|
|
+/** 全年合计 */
|
|
|
+const yearTotal = computed(() => ({
|
|
|
+ styles: Number(overview.value.yearTotal?.styles) || 0,
|
|
|
+ qty: Number(overview.value.yearTotal?.qty) || 0
|
|
|
+}))
|
|
|
+
|
|
|
+/** 月度汇总 */
|
|
|
+const monthTotals = computed(() =>
|
|
|
+ (overview.value.monthTotals || []).map((t) => ({
|
|
|
+ ...t,
|
|
|
+ month: normMonth(t.month)
|
|
|
+ }))
|
|
|
+)
|
|
|
+
|
|
|
+/**
|
|
|
+ * 月度序列:固定 1-12 月,与矩阵表格保持一致。
|
|
|
+ * 某月没有报工数据时补 0,这样趋势图的 X 轴始终是完整的 12 个月,
|
|
|
+ * 不会因为当前只报了 5-11 月就只画 7 根柱子。
|
|
|
+ */
|
|
|
+const monthSeries = computed(() => {
|
|
|
+ const map = {}
|
|
|
+ for (const t of monthTotals.value) {
|
|
|
+ map[t.month] = { month: t.month, styles: Number(t.styles) || 0, qty: Number(t.qty) || 0 }
|
|
|
+ }
|
|
|
+ return ALL_MONTHS.map((m) => map[m] || { month: m, styles: 0, qty: 0 })
|
|
|
+})
|
|
|
+
|
|
|
+/** 矩阵:行 = 车间,列 = 月份 */
|
|
|
+const matrixRows = computed(() => {
|
|
|
+ const wsMap = {}
|
|
|
+ for (const w of overview.value.workshops || []) {
|
|
|
+ wsMap[w.ws] = { styles: Number(w.styles) || 0, qty: Number(w.qty) || 0 }
|
|
|
+ }
|
|
|
+ const src = overview.value.matrix || []
|
|
|
+ const byWs = {}
|
|
|
+ for (const row of src) {
|
|
|
+ byWs[row.ws] = row
|
|
|
+ }
|
|
|
+ return WORKSHOPS.map((w) => {
|
|
|
+ const src2 = byWs[w]
|
|
|
+ const cells = {}
|
|
|
+ if (src2 && src2.cells) {
|
|
|
+ for (const m of Object.keys(src2.cells)) {
|
|
|
+ cells[normMonth(m)] = {
|
|
|
+ styles: Number(src2.cells[m].styles) || 0,
|
|
|
+ qty: Number(src2.cells[m].qty) || 0
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const total = wsMap[w] || { styles: 0, qty: 0 }
|
|
|
+ return {
|
|
|
+ workshop: w,
|
|
|
+ cells,
|
|
|
+ yearStyles: total.styles,
|
|
|
+ yearQty: total.qty
|
|
|
+ }
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
+/** 焦点月份:当年有数据的最大月份 */
|
|
|
+const focusMonth = computed(() => {
|
|
|
+ const cols = monthColumns.value
|
|
|
+ return cols.length ? cols[cols.length - 1] : ''
|
|
|
+})
|
|
|
+
|
|
|
+/**
|
|
|
+ * 月度分析面板的汇总口径。
|
|
|
+ * 当用户在「统计月份」下拉里选了某个月,就显示那个月;
|
|
|
+ * 没选时默认显示当年有数据的最后一个月份(即最新月份)。
|
|
|
+ */
|
|
|
+const focusMonthLabel = computed(() => {
|
|
|
+ if (filter.month) return `${Number(filter.month)}月`
|
|
|
+ return focusMonth.value ? `${Number(focusMonth.value)}月` : '累计'
|
|
|
+})
|
|
|
+
|
|
|
+/** 月度汇总 - 款数 */
|
|
|
+const focusMonthStyles = computed(() => {
|
|
|
+ const m = filter.month || focusMonth.value
|
|
|
+ if (!m) return 0
|
|
|
+ const hit = monthSeries.value.find((t) => t.month === m)
|
|
|
+ return hit ? Number(hit.styles) || 0 : 0
|
|
|
+})
|
|
|
+
|
|
|
+/** 月度汇总 - 报工数量 */
|
|
|
+const focusMonthQty = computed(() => {
|
|
|
+ const m = filter.month || focusMonth.value
|
|
|
+ if (!m) return 0
|
|
|
+ const hit = monthSeries.value.find((t) => t.month === m)
|
|
|
+ return hit ? Number(hit.qty) || 0 : 0
|
|
|
+})
|
|
|
+
|
|
|
+/** 数字千分位显示,便于快速读数 */
|
|
|
+function formatNum(n) {
|
|
|
+ const v = Number(n) || 0
|
|
|
+ return v.toLocaleString('zh-CN')
|
|
|
+}
|
|
|
+
|
|
|
+/* ==================== 月份列显示口径 ==================== */
|
|
|
+/**
|
|
|
+ * 「各月报工」列的显示口径,跟着「统计月份」筛选走,保证和「报工数量」列一致:
|
|
|
+ *
|
|
|
+ * - 选了某个月 → 明细接口只返回该月数据,列里就只显示该月(表头如「11月报工」);
|
|
|
+ * - 选了「全部月份」→ 明细接口返回全年数据,报工数量是全年累计,
|
|
|
+ * 这时列里就显示全年各月,避免「数量是全年、月份只显示一个月」的对不上。
|
|
|
+ *
|
|
|
+ * 默认情况下「统计月份」是当月(见 defaultMonthOf),所以打开页面看到的就是当月数据。
|
|
|
+ */
|
|
|
+const showAllMonths = computed(() => !filter.month)
|
|
|
+
|
|
|
+/** 当前聚焦的月份(两位字符串,如 '11') */
|
|
|
+const curMonthNum = computed(() => {
|
|
|
+ if (filter.month) return Number(filter.month)
|
|
|
+ return Number(focusMonth.value) || 0
|
|
|
+})
|
|
|
+
|
|
|
+/** 月份列的表头文字 */
|
|
|
+const monthColLabel = computed(() => {
|
|
|
+ if (showAllMonths.value) return '各月报工'
|
|
|
+ return curMonthNum.value ? `${curMonthNum.value}月报工` : '报工数量'
|
|
|
+})
|
|
|
+
|
|
|
+/**
|
|
|
+ * 取某个「月份数量表」里当月的数量。
|
|
|
+ * 返回 null 表示当月没有报工。
|
|
|
+ */
|
|
|
+function curMonthQty(monthMap) {
|
|
|
+ if (!monthMap || showAllMonths.value) return null
|
|
|
+ const m = curMonthNum.value
|
|
|
+ if (!m) return null
|
|
|
+ const key = String(m).padStart(2, '0')
|
|
|
+ const raw = monthMap[key] ?? monthMap[String(m)]
|
|
|
+ if (raw === undefined || raw === null || raw === '') return null
|
|
|
+ const v = Number(raw)
|
|
|
+ return Number.isFinite(v) ? v : null
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 明细表当前统计口径说明。
|
|
|
+ * 明细表默认是「全年」数据(各月报工列已经把每月数量都列出来了),
|
|
|
+ * 这里明确告诉用户当前看到的是哪个月份 / 哪个车间,避免不知道在看什么。
|
|
|
+ */
|
|
|
+const detailScopeText = computed(() => {
|
|
|
+ const parts = [`${query.year} 年`]
|
|
|
+ parts.push(filter.month ? `${Number(filter.month)} 月` : '全年')
|
|
|
+ if (filter.workshop !== '全部') parts.push(filter.workshop)
|
|
|
+ if (query.keyword.trim()) parts.push(`关键词「${query.keyword.trim()}」`)
|
|
|
+ return `当前统计范围:${parts.join(' · ')}`
|
|
|
+})
|
|
|
+
|
|
|
+/* ==================== 图表 ==================== */
|
|
|
+const chartRef = ref(null)
|
|
|
+const wsChartRef = ref(null)
|
|
|
+let chart = null
|
|
|
+let wsChart = null
|
|
|
+let resizeObserver = null
|
|
|
+let wsResizeObserver = null
|
|
|
+
|
|
|
+/** 左侧各车间年度柱状图 */
|
|
|
+function renderWsChart() {
|
|
|
+ if (!wsChartRef.value) return
|
|
|
+ if (!wsChart) wsChart = echarts.init(wsChartRef.value)
|
|
|
+
|
|
|
+ const rows = workshopRows.value
|
|
|
+ const qtyData = rows.map((r) => Number(r.qty) || 0)
|
|
|
+ const styleData = rows.map((r) => Number(r.styles) || 0)
|
|
|
+ const active = filter.workshop
|
|
|
+
|
|
|
+ wsChart.setOption(
|
|
|
+ {
|
|
|
+ tooltip: { trigger: 'axis', confine: true },
|
|
|
+ legend: { type: 'scroll', bottom: 0, itemWidth: 14, itemHeight: 8 },
|
|
|
+ grid: { left: 12, right: 28, top: 34, bottom: 36, containLabel: true },
|
|
|
+ xAxis: {
|
|
|
+ type: 'category',
|
|
|
+ data: rows.map((r) => r.workshop),
|
|
|
+ axisLine: { lineStyle: { color: '#dcdfe6' } },
|
|
|
+ axisLabel: { color: '#606266', interval: 0 }
|
|
|
+ },
|
|
|
+ yAxis: [
|
|
|
+ {
|
|
|
+ type: 'value',
|
|
|
+ name: '数量(件)',
|
|
|
+ nameGap: 8,
|
|
|
+ nameTextStyle: { color: '#909399', fontSize: 11 },
|
|
|
+ axisLabel: { color: '#606266' },
|
|
|
+ splitLine: { lineStyle: { color: '#ebeef2' } }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'value',
|
|
|
+ name: '款数(款)',
|
|
|
+ nameGap: 8,
|
|
|
+ nameTextStyle: { color: '#909399', fontSize: 11 },
|
|
|
+ axisLabel: { color: '#606266' },
|
|
|
+ splitLine: { show: false }
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ name: '报工数量',
|
|
|
+ type: 'bar',
|
|
|
+ barWidth: 18,
|
|
|
+ data: qtyData.map((v, i) => {
|
|
|
+ const isActive = !active || active === '全部' || rows[i]?.workshop === active
|
|
|
+ return {
|
|
|
+ value: v,
|
|
|
+ itemStyle: { color: isActive ? '#2f7bf0' : '#c8d9f7' }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '款数',
|
|
|
+ type: 'line',
|
|
|
+ yAxisIndex: 1,
|
|
|
+ data: styleData,
|
|
|
+ smooth: false,
|
|
|
+ itemStyle: { color: '#f5a623' },
|
|
|
+ lineStyle: { width: 2 },
|
|
|
+ symbolSize: 7
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ true
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+/** 点击车间柱状图 -> 联动筛选车间 */
|
|
|
+function onWsChartClick(params) {
|
|
|
+ if (params.dataIndex === undefined) return
|
|
|
+ const row = workshopRows.value[params.dataIndex]
|
|
|
+ if (!row) return
|
|
|
+ filter.workshop = filter.workshop === row.workshop ? '全部' : row.workshop
|
|
|
+ page.value = 1
|
|
|
+ loadDetail()
|
|
|
+}
|
|
|
+
|
|
|
+function renderChart() {
|
|
|
+ if (!chartRef.value) return
|
|
|
+ if (!chart) chart = echarts.init(chartRef.value)
|
|
|
+
|
|
|
+ const totals = monthSeries.value
|
|
|
+ const qtyData = totals.map((t) => Number(t.qty) || 0)
|
|
|
+ const styleData = totals.map((t) => Number(t.styles) || 0)
|
|
|
+
|
|
|
+ chart.setOption(
|
|
|
+ {
|
|
|
+ tooltip: { trigger: 'axis', confine: true },
|
|
|
+ legend: { type: 'scroll', bottom: 0, itemWidth: 14, itemHeight: 8 },
|
|
|
+ grid: { left: 12, right: 28, top: 34, bottom: 36, containLabel: true },
|
|
|
+ xAxis: {
|
|
|
+ type: 'category',
|
|
|
+ data: totals.map((t) => `${Number(t.month)}月`),
|
|
|
+ boundaryGap: true,
|
|
|
+ axisLine: { lineStyle: { color: '#dcdfe6' } },
|
|
|
+ axisLabel: { color: '#606266' }
|
|
|
+ },
|
|
|
+ yAxis: [
|
|
|
+ {
|
|
|
+ type: 'value',
|
|
|
+ name: '数量(件)',
|
|
|
+ nameGap: 8,
|
|
|
+ nameTextStyle: { color: '#909399', fontSize: 11 },
|
|
|
+ axisLabel: { color: '#606266' },
|
|
|
+ splitLine: { lineStyle: { color: '#ebeef2' } }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'value',
|
|
|
+ name: '款数(款)',
|
|
|
+ nameGap: 8,
|
|
|
+ nameTextStyle: { color: '#909399', fontSize: 11 },
|
|
|
+ axisLabel: { color: '#606266' },
|
|
|
+ splitLine: { show: false }
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ name: '报工数量',
|
|
|
+ type: 'bar',
|
|
|
+ data: qtyData,
|
|
|
+ barWidth: 16,
|
|
|
+ itemStyle: { color: '#2f7bf0' }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '款数',
|
|
|
+ type: 'line',
|
|
|
+ yAxisIndex: 1,
|
|
|
+ data: styleData,
|
|
|
+ smooth: false,
|
|
|
+ itemStyle: { color: '#f5a623' },
|
|
|
+ lineStyle: { width: 2 },
|
|
|
+ symbolSize: 7
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ true
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+/** 点击趋势图月份 -> 联动筛选 */
|
|
|
+function onChartClick(params) {
|
|
|
+ if (params.dataIndex === undefined) return
|
|
|
+ const month = monthSeries.value[params.dataIndex]?.month
|
|
|
+ if (!month) return
|
|
|
+ filter.month = filter.month === month ? '' : month
|
|
|
+ page.value = 1
|
|
|
+ expandedKeys.value = []
|
|
|
+ loadDetail()
|
|
|
+}
|
|
|
+
|
|
|
+/* ==================== 接口 ==================== */
|
|
|
+async function loadYears() {
|
|
|
+ yearsLoading.value = true
|
|
|
+ try {
|
|
|
+ const res = await GetProcessOutputYears()
|
|
|
+ if (res?.code === 0) {
|
|
|
+ const list = Array.isArray(res.data) ? res.data : res.data?.list ?? []
|
|
|
+ yearOptions.value = list.map((y) => String(y))
|
|
|
+ } else {
|
|
|
+ yearOptions.value = []
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.error(e)
|
|
|
+ yearOptions.value = []
|
|
|
+ ElMessage.error('加载统计年份失败')
|
|
|
+ } finally {
|
|
|
+ yearsLoading.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+async function loadOverview() {
|
|
|
+ if (!query.year) {
|
|
|
+ overview.value = { months: [], matrix: [], workshops: [], monthTotals: [], yearTotal: { styles: 0, qty: 0 } }
|
|
|
+ renderChart()
|
|
|
+ renderWsChart()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ overviewLoading.value = true
|
|
|
+ try {
|
|
|
+ const params = { year: query.year }
|
|
|
+ if (query.keyword.trim()) params.search = query.keyword.trim()
|
|
|
+ const res = await GetProcessOutputOverview(params)
|
|
|
+ if (res?.code === 0) {
|
|
|
+ const d = res.data || {}
|
|
|
+ overview.value = {
|
|
|
+ months: d.months || [],
|
|
|
+ matrix: d.matrix || [],
|
|
|
+ workshops: d.workshops || [],
|
|
|
+ monthTotals: d.monthTotals || [],
|
|
|
+ yearTotal: d.yearTotal || { styles: 0, qty: 0 }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ overview.value = { months: [], matrix: [], workshops: [], monthTotals: [], yearTotal: { styles: 0, qty: 0 } }
|
|
|
+ ElMessage.warning(res?.msg || '加载统计数据失败')
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.error(e)
|
|
|
+ overview.value = { months: [], matrix: [], workshops: [], monthTotals: [], yearTotal: { styles: 0, qty: 0 } }
|
|
|
+ ElMessage.error('加载统计数据失败')
|
|
|
+ } finally {
|
|
|
+ overviewLoading.value = false
|
|
|
+ renderChart()
|
|
|
+ renderWsChart()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+async function loadDetail() {
|
|
|
+ if (!query.year) {
|
|
|
+ resetDetailData()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ detailLoading.value = true
|
|
|
+ try {
|
|
|
+ const params = {
|
|
|
+ year: query.year,
|
|
|
+ page: page.value,
|
|
|
+ limit: pageSize.value
|
|
|
+ }
|
|
|
+ if (query.keyword.trim()) params.search = query.keyword.trim()
|
|
|
+ if (filter.workshop && filter.workshop !== '全部') params.workshop = filter.workshop
|
|
|
+ if (filter.month) params.month = filter.month
|
|
|
+
|
|
|
+ const res = await GetProcessOutputDetail(params)
|
|
|
+ if (res?.code === 0) {
|
|
|
+ const d = res.data || {}
|
|
|
+ detailRows.value = sortGroupsInRows(Array.isArray(d.list) ? d.list : d.list ?? [])
|
|
|
+ detailTotal.value = Number(d.total) || 0
|
|
|
+ detailTotalQty.value = Number(d.totalQty) || 0
|
|
|
+ detailTotalOrdQty.value = Number(d.totalOrdQty) || 0
|
|
|
+ detailWorkshopCount.value = Number(d.workshopCount) || 0
|
|
|
+ detailGroupCount.value = Number(d.groupCount) || 0
|
|
|
+ detailStaffCount.value = Number(d.staffCount) || 0
|
|
|
+ } else {
|
|
|
+ resetDetailData()
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.error(e)
|
|
|
+ resetDetailData()
|
|
|
+ ElMessage.error('加载明细数据失败')
|
|
|
+ } finally {
|
|
|
+ detailLoading.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/** 清空明细相关状态 */
|
|
|
+function resetDetailData() {
|
|
|
+ detailRows.value = []
|
|
|
+ detailTotal.value = 0
|
|
|
+ detailTotalQty.value = 0
|
|
|
+ detailTotalOrdQty.value = 0
|
|
|
+ detailWorkshopCount.value = 0
|
|
|
+ detailGroupCount.value = 0
|
|
|
+ detailStaffCount.value = 0
|
|
|
+}
|
|
|
+
|
|
|
+/* ==================== 交互 ==================== */
|
|
|
+function handleQuery() {
|
|
|
+ page.value = 1
|
|
|
+ loadOverview()
|
|
|
+ loadDetail()
|
|
|
+}
|
|
|
+
|
|
|
+function handleYearChange() {
|
|
|
+ filter.workshop = '全部'
|
|
|
+ // 切换年份后重置月份:当前年份默认当月,历史年份看全年
|
|
|
+ filter.month = defaultMonthOf(query.year)
|
|
|
+ page.value = 1
|
|
|
+ loadOverview()
|
|
|
+ loadDetail()
|
|
|
+}
|
|
|
+
|
|
|
+function handleSizeChange() {
|
|
|
+ page.value = 1
|
|
|
+ loadDetail()
|
|
|
+}
|
|
|
+
|
|
|
+/** 车间 / 月份下拉筛选变化 */
|
|
|
+function handleFilterChange() {
|
|
|
+ page.value = 1
|
|
|
+ expandedKeys.value = []
|
|
|
+ loadDetail()
|
|
|
+}
|
|
|
+
|
|
|
+/** 重置明细筛选 */
|
|
|
+function resetDetailFilter() {
|
|
|
+ filter.workshop = '全部'
|
|
|
+ filter.month = defaultMonthOf(query.year)
|
|
|
+ page.value = 1
|
|
|
+ expandedKeys.value = []
|
|
|
+ loadDetail()
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 统计某款式下的小组总数(各车间小组之和)。
|
|
|
+ * 小组明细是嵌套在车间明细里的,需要逐个车间累加。
|
|
|
+ */
|
|
|
+function countGroups(row) {
|
|
|
+ let n = 0
|
|
|
+ for (const w of row?.车间明细 || []) {
|
|
|
+ n += (w.小组明细 || []).length
|
|
|
+ }
|
|
|
+ return n
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 展开行变化。
|
|
|
+ * Element Plus 的 expand-change 回调签名是 (row, expandedRows),
|
|
|
+ * 第二个参数是「当前所有展开行的数组」,不是布尔值。
|
|
|
+ * 之前误当成布尔值用,导致展开后无法收起。
|
|
|
+ *
|
|
|
+ * 这里同时实现手风琴:点图标展开新行时,自动把其它行收起。
|
|
|
+ */
|
|
|
+function onExpandChange(row, expandedRows) {
|
|
|
+ const rows = Array.isArray(expandedRows) ? expandedRows : []
|
|
|
+ const keys = rows.map((r) => r?.款号).filter(Boolean)
|
|
|
+ const table = detailTableRef.value
|
|
|
+
|
|
|
+ // 有多行同时展开时,收起除最后操作行以外的其它行
|
|
|
+ if (keys.length > 1 && table) {
|
|
|
+ const keep = keys[keys.length - 1]
|
|
|
+ for (const r of detailRows.value) {
|
|
|
+ if (r.款号 !== keep && keys.includes(r.款号)) {
|
|
|
+ table.toggleRowExpansion(r, false)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ expandedKeys.value = [keep]
|
|
|
+ return
|
|
|
+ }
|
|
|
+ expandedKeys.value = keys
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 点击整行也能展开 / 收起,并且同一时刻只展开一行(手风琴式)。
|
|
|
+ */
|
|
|
+function onRowClick(row, column, event) {
|
|
|
+ const target = event?.target
|
|
|
+ // 点在展开图标上时交给图标自己处理,避免重复切换
|
|
|
+ if (target && typeof target.closest === 'function' && target.closest('.el-table__expand-icon')) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ toggleRow(row)
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 展开 / 收起指定行(互斥模式,同一时刻只展开一行)。
|
|
|
+ * 直接按「目标展开的款号集合」重新设置每一行的展开状态。
|
|
|
+ * toggleRowExpansion 传入明确的布尔值时是幂等的(不会误改其它行),
|
|
|
+ * 所以这里统一对所有行下发一次目标状态,避免依赖内部状态查询。
|
|
|
+ */
|
|
|
+function toggleRow(row) {
|
|
|
+ const key = row?.款号
|
|
|
+ if (!key) return
|
|
|
+ const table = detailTableRef.value
|
|
|
+ if (!table) return
|
|
|
+
|
|
|
+ const isOpen = expandedKeys.value.includes(key)
|
|
|
+ // 手风琴:当前已展开则全部收起;否则只展开这一行
|
|
|
+ const targetKeys = isOpen ? [] : [key]
|
|
|
+ expandedKeys.value = targetKeys
|
|
|
+
|
|
|
+ for (const r of detailRows.value) {
|
|
|
+ table.toggleRowExpansion(r, targetKeys.includes(r.款号))
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/** 单元格是否有实际数据(款数 > 0 才算有数据,避免出现 0 款 / 0 件的空壳) */
|
|
|
+function hasMatrixCell(cell) {
|
|
|
+ return !!(cell && (Number(cell.styles) > 0 || Number(cell.qty) > 0))
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 判断某个工序车间对这一款是否有报工。
|
|
|
+ * 亮绿色 = 这个车间在做这个订单;灰色 = 这个车间没做这个订单。
|
|
|
+ */
|
|
|
+function isWsActive(row, wsName) {
|
|
|
+ const list = row?.工序车间
|
|
|
+ if (!list) return false
|
|
|
+ if (Array.isArray(list)) return list.includes(wsName)
|
|
|
+ return String(list).split('、').includes(wsName)
|
|
|
+}
|
|
|
+
|
|
|
+/* ==================== 嵌套层级手风琴 ==================== */
|
|
|
+/**
|
|
|
+ * 工序车间层级的手风琴:展开一个车间就收起上一个。
|
|
|
+ *
|
|
|
+ * Element Plus 的 expand-change 回调签名是 (row, expandedRows),
|
|
|
+ * expandedRows 是「当前所有展开行的数组」。这里取最后操作的那个行作为
|
|
|
+ * 保留项,把同级的其它行全部收起。
|
|
|
+ *
|
|
|
+ * 注意:嵌套表的 ref 在同一时刻只有一个有效实例(因为外层一次只展开一行),
|
|
|
+ * 所以这里直接用 ref 取到当前表即可。
|
|
|
+ */
|
|
|
+function onWsExpandChange(row, expandedRows) {
|
|
|
+ const rows = Array.isArray(expandedRows) ? expandedRows : []
|
|
|
+ if (rows.length <= 1) return
|
|
|
+ const keep = rows[rows.length - 1]
|
|
|
+ const table = wsTableRef.value
|
|
|
+ if (!table) return
|
|
|
+ const keepName = keep?.工序车间
|
|
|
+ for (const r of table.data || []) {
|
|
|
+ if (r?.工序车间 !== keepName) {
|
|
|
+ table.toggleRowExpansion(r, false)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 小组层级的手风琴:展开一个小组就收起上一个。
|
|
|
+ */
|
|
|
+function onGroupExpandChange(row, expandedRows) {
|
|
|
+ const rows = Array.isArray(expandedRows) ? expandedRows : []
|
|
|
+ if (rows.length <= 1) return
|
|
|
+ const keep = rows[rows.length - 1]
|
|
|
+ const table = groupTableRef.value
|
|
|
+ if (!table) return
|
|
|
+ const keepName = keep?.小组
|
|
|
+ for (const r of table.data || []) {
|
|
|
+ if (r?.小组 !== keepName) {
|
|
|
+ table.toggleRowExpansion(r, false)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 点击工序车间整行也能展开 / 收起(和最外层款式行一样)。
|
|
|
+ * 点在展开图标上时交给图标自己处理,避免重复切换。
|
|
|
+ */
|
|
|
+function onWsRowClick(row, column, event) {
|
|
|
+ const target = event?.target
|
|
|
+ if (target && typeof target.closest === 'function' && target.closest('.el-table__expand-icon')) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ toggleWsRow(row)
|
|
|
+}
|
|
|
+
|
|
|
+/** 展开 / 收起指定车间行(互斥模式) */
|
|
|
+function toggleWsRow(row) {
|
|
|
+ const table = wsTableRef.value
|
|
|
+ if (!table || !row) return
|
|
|
+ const keep = row?.工序车间
|
|
|
+ const isOpen = (table.data || []).some((r) => r?.工序车间 === keep && isRowExpanded(table, r))
|
|
|
+ for (const r of table.data || []) {
|
|
|
+ table.toggleRowExpansion(r, !isOpen && r?.工序车间 === keep)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 点击小组整行也能展开 / 收起。
|
|
|
+ */
|
|
|
+function onGroupRowClick(row, column, event) {
|
|
|
+ const target = event?.target
|
|
|
+ if (target && typeof target.closest === 'function' && target.closest('.el-table__expand-icon')) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ toggleGroupRow(row)
|
|
|
+}
|
|
|
+
|
|
|
+/** 展开 / 收起指定小组行(互斥模式) */
|
|
|
+function toggleGroupRow(row) {
|
|
|
+ const table = groupTableRef.value
|
|
|
+ if (!table || !row) return
|
|
|
+ const keep = row?.小组
|
|
|
+ const isOpen = (table.data || []).some((r) => r?.小组 === keep && isRowExpanded(table, r))
|
|
|
+ for (const r of table.data || []) {
|
|
|
+ table.toggleRowExpansion(r, !isOpen && r?.小组 === keep)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/** 判断某一行当前是否处于展开状态 */
|
|
|
+function isRowExpanded(table, row) {
|
|
|
+ try {
|
|
|
+ return !!(table?.store?.states?.expandedRows || []).includes(row)
|
|
|
+ } catch (e) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/* ==================== 合计行 ==================== */
|
|
|
+/**
|
|
|
+ * 合计行单元格与表体保持一致:上为报工数量、下为款数。
|
|
|
+ * Element Plus 的 summary-method 可以返回 VNode(见 table/defaults.d.ts 的
|
|
|
+ * SummaryMethod 类型定义),这里用 h() 构造两行结构,与表体的 .matrix-cell 相同。
|
|
|
+ */
|
|
|
+function matrixSummaryCell(qty, styles) {
|
|
|
+ return h('div', { class: 'mc-sum' }, [
|
|
|
+ h('div', { class: 'mc-sum-qty' }, String(qty)),
|
|
|
+ h('div', { class: 'mc-sum-style' }, `${styles} 款`)
|
|
|
+ ])
|
|
|
+}
|
|
|
+
|
|
|
+function matrixSummary({ columns }) {
|
|
|
+ const out = [h('div', { class: 'mc-sum-label' }, '全厂合计')]
|
|
|
+ for (let i = 1; i < columns.length; i++) {
|
|
|
+ const col = columns[i]
|
|
|
+ if (col.label === '年度合计') {
|
|
|
+ out.push(matrixSummaryCell(yearTotal.value.qty, yearTotal.value.styles))
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ // 矩阵固定 1-12 月,列索引对应月份
|
|
|
+ const m = ALL_MONTHS[i - 1]
|
|
|
+ const hit = m ? monthSeries.value.find((t) => t.month === m) : null
|
|
|
+ if (!hit) {
|
|
|
+ out.push('')
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ out.push(matrixSummaryCell(Number(hit.qty) || 0, Number(hit.styles) || 0))
|
|
|
+ }
|
|
|
+ return out
|
|
|
+}
|
|
|
+
|
|
|
+function detailSummary({ columns }) {
|
|
|
+ return columns.map((col) => {
|
|
|
+ if (col.property === '款号') return '合计'
|
|
|
+ if (col.property === '报工数量') return String(detailTotalQty.value)
|
|
|
+ if (col.property === '订单数量') return String(detailTotalOrdQty.value)
|
|
|
+ return ''
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+/* ==================== 月度报表导出 ==================== */
|
|
|
+const exportVisible = ref(false)
|
|
|
+const exportLoading = ref(false)
|
|
|
+const exportForm = reactive({
|
|
|
+ year: '',
|
|
|
+ month: '',
|
|
|
+ keyword: ''
|
|
|
+})
|
|
|
+
|
|
|
+/** 打开导出弹窗,默认带上年份与当前有数据的月份 */
|
|
|
+function openExportDialog() {
|
|
|
+ exportForm.year = query.year || yearOptions.value[0] || String(new Date().getFullYear())
|
|
|
+ exportForm.month = focusMonth.value || String(new Date().getMonth() + 1)
|
|
|
+ exportForm.keyword = query.keyword.trim()
|
|
|
+ exportVisible.value = true
|
|
|
+}
|
|
|
+
|
|
|
+/** 导出月度报表到 Excel */
|
|
|
+async function handleExport() {
|
|
|
+ if (!exportForm.year) {
|
|
|
+ ElMessage.warning('请选择统计年份')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!exportForm.month) {
|
|
|
+ ElMessage.warning('请选择导出月份')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ exportLoading.value = true
|
|
|
+ try {
|
|
|
+ const params = {
|
|
|
+ year: exportForm.year,
|
|
|
+ month: exportForm.month,
|
|
|
+ search: exportForm.keyword.trim() || undefined
|
|
|
+ }
|
|
|
+ const res = await GetProcessOutputMonthlyReport(params)
|
|
|
+ if (res?.code !== 0) {
|
|
|
+ ElMessage.error(res?.msg || '导出数据获取失败')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ const d = res.data || {}
|
|
|
+ const list = Array.isArray(d.list) ? d.list : []
|
|
|
+ if (!list.length) {
|
|
|
+ ElMessage.warning('该月份没有报工数据')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 组装导出数据(列顺序固定,数字保持整数)
|
|
|
+ const rows = list.map((r) => ({
|
|
|
+ '款号': r['款号'] || '',
|
|
|
+ '客户': r['客户'] || '',
|
|
|
+ '款式': r['款式'] || '',
|
|
|
+ '订单编号': r['订单编号'] || '',
|
|
|
+ '订单数量': Number(r['订单数量']) || 0,
|
|
|
+ '本月报工数量': Number(r['本月报工数量']) || 0,
|
|
|
+ '累计报工数量': Number(r['累计报工数量']) || 0,
|
|
|
+ '涉及工序车间': r['涉及工序车间'] || '',
|
|
|
+ '工序车间数': Number(r['工序车间数']) || 0
|
|
|
+ }))
|
|
|
+
|
|
|
+ // 合计行
|
|
|
+ const totalRow = {
|
|
|
+ '款号': '合计',
|
|
|
+ '客户': '',
|
|
|
+ '款式': '',
|
|
|
+ '订单编号': '',
|
|
|
+ '订单数量': rows.reduce((s, r) => s + r['订单数量'], 0),
|
|
|
+ '本月报工数量': rows.reduce((s, r) => s + r['本月报工数量'], 0),
|
|
|
+ '累计报工数量': rows.reduce((s, r) => s + r['累计报工数量'], 0),
|
|
|
+ '涉及工序车间': '',
|
|
|
+ '工序车间数': 0
|
|
|
+ }
|
|
|
+
|
|
|
+ const sheet = XLSX.utils.json_to_sheet([...rows, totalRow])
|
|
|
+ sheet['!cols'] = [
|
|
|
+ { wch: 22 }, // 款号
|
|
|
+ { wch: 12 }, // 客户
|
|
|
+ { wch: 20 }, // 款式
|
|
|
+ { wch: 20 }, // 订单编号
|
|
|
+ { wch: 10 }, // 订单数量
|
|
|
+ { wch: 14 }, // 本月报工数量
|
|
|
+ { wch: 14 }, // 累计报工数量
|
|
|
+ { wch: 24 }, // 涉及工序车间
|
|
|
+ { wch: 10 } // 工序车间数
|
|
|
+ ]
|
|
|
+
|
|
|
+ const wb = XLSX.utils.book_new()
|
|
|
+ XLSX.utils.book_append_sheet(wb, sheet, '月度产量报表')
|
|
|
+
|
|
|
+ // 追加「车间小组追溯」Sheet:款 → 车间 → 小组 → 员工
|
|
|
+ // 让审核统计时能直接看到每个组、每个人报了多少
|
|
|
+ try {
|
|
|
+ const traceRes = await GetProcessOutputTrace({
|
|
|
+ year: exportForm.year,
|
|
|
+ month: exportForm.month,
|
|
|
+ search: exportForm.keyword.trim() || undefined
|
|
|
+ })
|
|
|
+ if (traceRes?.code === 0) {
|
|
|
+ const tRows = []
|
|
|
+ for (const r of traceRes.data?.list || []) {
|
|
|
+ for (const w of r.车间 || []) {
|
|
|
+ for (const g of w.小组 || []) {
|
|
|
+ for (const s of g.员工 || []) {
|
|
|
+ // 有工序明细就按工序拆行,没有就保持原来的一行
|
|
|
+ const procs = s.工序明细 || []
|
|
|
+ if (procs.length) {
|
|
|
+ for (const p of procs) {
|
|
|
+ tRows.push({
|
|
|
+ '款号': r.款号 || '',
|
|
|
+ '订单编号': r.订单编号 || '',
|
|
|
+ '工序车间': w.工序车间 || '',
|
|
|
+ '小组': g.小组 || '',
|
|
|
+ '员工编号': s.员工编号 || '',
|
|
|
+ '员工姓名': s.员工姓名 || '',
|
|
|
+ '工序编号': Number(p.工序编号) || 0,
|
|
|
+ '工序名称': p.工序名称 || '',
|
|
|
+ '报工数量': Number(p.报工数量) || 0
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ tRows.push({
|
|
|
+ '款号': r.款号 || '',
|
|
|
+ '订单编号': r.订单编号 || '',
|
|
|
+ '工序车间': w.工序车间 || '',
|
|
|
+ '小组': g.小组 || '',
|
|
|
+ '员工编号': s.员工编号 || '',
|
|
|
+ '员工姓名': s.员工姓名 || '',
|
|
|
+ '工序编号': 0,
|
|
|
+ '工序名称': '',
|
|
|
+ '报工数量': Number(s.报工数量) || 0
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (tRows.length) {
|
|
|
+ const tSheet = XLSX.utils.json_to_sheet(tRows)
|
|
|
+ tSheet['!cols'] = [
|
|
|
+ { wch: 22 }, // 款号
|
|
|
+ { wch: 20 }, // 订单编号
|
|
|
+ { wch: 12 }, // 工序车间
|
|
|
+ { wch: 14 }, // 小组
|
|
|
+ { wch: 12 }, // 员工编号
|
|
|
+ { wch: 12 }, // 员工姓名
|
|
|
+ { wch: 10 }, // 工序编号
|
|
|
+ { wch: 24 }, // 工序名称
|
|
|
+ { wch: 12 } // 报工数量
|
|
|
+ ]
|
|
|
+ XLSX.utils.book_append_sheet(wb, tSheet, '车间小组追溯')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.error(e)
|
|
|
+ }
|
|
|
+
|
|
|
+ const filename = `${exportForm.year}年${Number(exportForm.month)}月车间工序产量明细.xlsx`
|
|
|
+ XLSX.writeFile(wb, filename)
|
|
|
+
|
|
|
+ ElMessage.success(`导出成功:${filename}(共 ${rows.length} 款)`)
|
|
|
+ exportVisible.value = false
|
|
|
+ } catch (e) {
|
|
|
+ console.error(e)
|
|
|
+ ElMessage.error('导出失败,请重试')
|
|
|
+ } finally {
|
|
|
+ exportLoading.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/* ==================== 生命周期 ==================== */
|
|
|
+onMounted(async () => {
|
|
|
+ await nextTick()
|
|
|
+ renderChart()
|
|
|
+ renderWsChart()
|
|
|
+ if (chart) chart.on('click', onChartClick)
|
|
|
+ if (wsChart) wsChart.on('click', onWsChartClick)
|
|
|
+ resizeObserver = new ResizeObserver(() => chart && chart.resize())
|
|
|
+ if (chartRef.value) resizeObserver.observe(chartRef.value)
|
|
|
+ wsResizeObserver = new ResizeObserver(() => wsChart && wsChart.resize())
|
|
|
+ if (wsChartRef.value) wsResizeObserver.observe(wsChartRef.value)
|
|
|
+
|
|
|
+ await loadYears()
|
|
|
+ query.year = yearOptions.value[0] || String(TODAY_YEAR)
|
|
|
+ // 默认聚焦当月:明细表打开就是「这个月做了多少款、多少件」
|
|
|
+ filter.month = defaultMonthOf(query.year)
|
|
|
+ await loadOverview()
|
|
|
+ await loadDetail()
|
|
|
+})
|
|
|
+
|
|
|
+onUnmounted(() => {
|
|
|
+ if (resizeObserver) resizeObserver.disconnect()
|
|
|
+ if (wsResizeObserver) wsResizeObserver.disconnect()
|
|
|
+ if (chart) {
|
|
|
+ chart.off('click', onChartClick)
|
|
|
+ chart.dispose()
|
|
|
+ chart = null
|
|
|
+ }
|
|
|
+ if (wsChart) {
|
|
|
+ wsChart.off('click', onWsChartClick)
|
|
|
+ wsChart.dispose()
|
|
|
+ wsChart = null
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+watch(
|
|
|
+ () => monthSeries.value,
|
|
|
+ () => {
|
|
|
+ renderChart()
|
|
|
+ },
|
|
|
+ { deep: true }
|
|
|
+)
|
|
|
+
|
|
|
+watch(
|
|
|
+ () => workshopRows.value,
|
|
|
+ () => {
|
|
|
+ renderWsChart()
|
|
|
+ },
|
|
|
+ { deep: true }
|
|
|
+)
|
|
|
+
|
|
|
+watch(
|
|
|
+ () => filter.workshop,
|
|
|
+ () => {
|
|
|
+ renderWsChart()
|
|
|
+ }
|
|
|
+)
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.pos-page {
|
|
|
+ padding: 10px 12px 16px;
|
|
|
+ background: #f0f2f5;
|
|
|
+ min-height: calc(100vh - 120px);
|
|
|
+ box-sizing: border-box;
|
|
|
+}
|
|
|
+
|
|
|
+.num {
|
|
|
+ font-variant-numeric: tabular-nums;
|
|
|
+}
|
|
|
+
|
|
|
+/* ===== 筛选栏 ===== */
|
|
|
+.filter-card {
|
|
|
+ background: #fff;
|
|
|
+ border: 1px solid #ebeef2;
|
|
|
+ border-radius: 4px;
|
|
|
+ padding: 8px 12px;
|
|
|
+ margin-bottom: 10px;
|
|
|
+}
|
|
|
+
|
|
|
+.filter-card :deep(.el-form-item) {
|
|
|
+ margin-bottom: 0;
|
|
|
+}
|
|
|
+
|
|
|
+/* ===== 主栏 ===== */
|
|
|
+.main-row {
|
|
|
+ margin-bottom: 10px;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * 左右两栏并排显示。
|
|
|
+ * Element Plus 的 el-col 断点里 md=768px,但实际内容区宽度常常小于视口宽度
|
|
|
+ * (左侧菜单会挤压),导致在 700~992px 之间两栏被拆成上下堆叠,页面变得很长。
|
|
|
+ * 这里用容器查询思路:只要容器够宽(>=640px)就强制并排。
|
|
|
+ */
|
|
|
+.main-row > .el-col-24 {
|
|
|
+ flex: 0 0 auto;
|
|
|
+ max-width: none;
|
|
|
+}
|
|
|
+
|
|
|
+.main-row > .el-col-md-12 {
|
|
|
+ width: 50%;
|
|
|
+}
|
|
|
+
|
|
|
+@media (max-width: 639px) {
|
|
|
+ .main-row > .el-col-md-12 {
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.col-panel {
|
|
|
+ background: #fff;
|
|
|
+ border: 1px solid #ebeef2;
|
|
|
+ border-radius: 4px;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ min-width: 0;
|
|
|
+ overflow: hidden;
|
|
|
+ height: 100%;
|
|
|
+}
|
|
|
+
|
|
|
+.col-head {
|
|
|
+ padding: 10px 12px 0;
|
|
|
+ display: flex;
|
|
|
+ align-items: baseline;
|
|
|
+ gap: 10px;
|
|
|
+}
|
|
|
+
|
|
|
+.col-title {
|
|
|
+ font-size: 14px;
|
|
|
+ font-weight: 700;
|
|
|
+ color: #303133;
|
|
|
+}
|
|
|
+
|
|
|
+.col-sub {
|
|
|
+ font-size: 12px;
|
|
|
+ color: #909399;
|
|
|
+ margin-top: 2px;
|
|
|
+}
|
|
|
+
|
|
|
+.metric-row {
|
|
|
+ display: grid;
|
|
|
+ grid-template-columns: 1fr 1fr;
|
|
|
+ gap: 8px;
|
|
|
+ padding: 10px 12px;
|
|
|
+}
|
|
|
+
|
|
|
+.metric-card {
|
|
|
+ background: #f7f9fc;
|
|
|
+ border-radius: 4px;
|
|
|
+ padding: 8px 12px;
|
|
|
+}
|
|
|
+
|
|
|
+.metric-label {
|
|
|
+ color: #909399;
|
|
|
+ font-size: 12px;
|
|
|
+ margin-bottom: 4px;
|
|
|
+}
|
|
|
+
|
|
|
+.metric-value {
|
|
|
+ font-size: 21px;
|
|
|
+ font-weight: 700;
|
|
|
+ color: #303133;
|
|
|
+ line-height: 1.15;
|
|
|
+}
|
|
|
+
|
|
|
+.metric-value .unit {
|
|
|
+ font-size: 12px;
|
|
|
+ font-weight: 400;
|
|
|
+ color: #909399;
|
|
|
+ margin-left: 5px;
|
|
|
+}
|
|
|
+
|
|
|
+/* 左右主栏的汇总卡片:紧凑一点,不喧宾夺主 */
|
|
|
+.col-metrics {
|
|
|
+ grid-template-columns: 1fr 1fr;
|
|
|
+ gap: 8px;
|
|
|
+ padding: 8px 12px 6px;
|
|
|
+}
|
|
|
+
|
|
|
+.col-metrics .metric-card {
|
|
|
+ padding: 6px 10px;
|
|
|
+}
|
|
|
+
|
|
|
+.col-metrics .metric-value {
|
|
|
+ font-size: 19px;
|
|
|
+}
|
|
|
+
|
|
|
+.panel-section {
|
|
|
+ padding: 0 12px 10px;
|
|
|
+}
|
|
|
+
|
|
|
+.chart-section {
|
|
|
+ flex: 1;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+}
|
|
|
+
|
|
|
+.section-title {
|
|
|
+ font-size: 12px;
|
|
|
+ font-weight: 600;
|
|
|
+ color: #606266;
|
|
|
+ margin: 2px 0 6px;
|
|
|
+}
|
|
|
+
|
|
|
+/* 固定高度,避免 flex:1 让整个左/右栏被图表撑高 */
|
|
|
+.trend-chart {
|
|
|
+ width: 100%;
|
|
|
+ height: 250px;
|
|
|
+}
|
|
|
+
|
|
|
+/* ===== 面板 ===== */
|
|
|
+.panel {
|
|
|
+ background: #fff;
|
|
|
+ border: 1px solid #ebeef2;
|
|
|
+ border-radius: 4px;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ min-width: 0;
|
|
|
+ margin-bottom: 10px;
|
|
|
+}
|
|
|
+
|
|
|
+.panel-title {
|
|
|
+ padding: 9px 12px 6px;
|
|
|
+ font-weight: 600;
|
|
|
+ color: #303133;
|
|
|
+ font-size: 13px;
|
|
|
+ display: flex;
|
|
|
+ align-items: baseline;
|
|
|
+ gap: 10px;
|
|
|
+}
|
|
|
+
|
|
|
+.panel-title .hint {
|
|
|
+ font-size: 12px;
|
|
|
+ font-weight: 400;
|
|
|
+ color: #909399;
|
|
|
+}
|
|
|
+
|
|
|
+/* 明细面板标题栏:左边标题,中间口径说明,右边就地筛选 */
|
|
|
+.panel-title-bar {
|
|
|
+ align-items: center;
|
|
|
+ border-bottom: 1px solid #f0f2f5;
|
|
|
+ padding-bottom: 8px;
|
|
|
+}
|
|
|
+
|
|
|
+.panel-tools {
|
|
|
+ margin-left: auto;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: 6px;
|
|
|
+}
|
|
|
+
|
|
|
+.panel-tools .tool-label {
|
|
|
+ font-size: 12px;
|
|
|
+ font-weight: 400;
|
|
|
+ color: #909399;
|
|
|
+ margin-left: 4px;
|
|
|
+}
|
|
|
+
|
|
|
+.panel-tools .tool-label:first-child {
|
|
|
+ margin-left: 0;
|
|
|
+}
|
|
|
+
|
|
|
+.table-wrap {
|
|
|
+ overflow-x: auto;
|
|
|
+ padding: 0 12px;
|
|
|
+}
|
|
|
+
|
|
|
+/* ===== 表格紧凑化 ===== */
|
|
|
+:deep(.el-table .el-table__cell) {
|
|
|
+ padding: 4px 0;
|
|
|
+}
|
|
|
+
|
|
|
+:deep(.el-table--small .el-table__cell) {
|
|
|
+ padding: 3px 0;
|
|
|
+}
|
|
|
+
|
|
|
+:deep(.el-table__footer-wrapper td.el-table__cell) {
|
|
|
+ padding: 3px 0;
|
|
|
+}
|
|
|
+
|
|
|
+:deep(.el-table .cell) {
|
|
|
+ line-height: 1.35;
|
|
|
+ padding-left: 8px;
|
|
|
+ padding-right: 8px;
|
|
|
+}
|
|
|
+
|
|
|
+/* ===== 矩阵 ===== */
|
|
|
+.matrix-cell {
|
|
|
+ line-height: 1.3;
|
|
|
+}
|
|
|
+
|
|
|
+.matrix-cell .mc-qty {
|
|
|
+ color: #303133;
|
|
|
+ font-weight: 600;
|
|
|
+ font-size: 13px;
|
|
|
+ font-variant-numeric: tabular-nums;
|
|
|
+}
|
|
|
+
|
|
|
+.matrix-cell .mc-style {
|
|
|
+ color: #909399;
|
|
|
+ font-size: 11px;
|
|
|
+ font-variant-numeric: tabular-nums;
|
|
|
+}
|
|
|
+
|
|
|
+/* 合计行单元格:与表体保持一致,上为数量、下为款数 */
|
|
|
+:deep(.mc-sum) {
|
|
|
+ line-height: 1.3;
|
|
|
+ text-align: center;
|
|
|
+}
|
|
|
+
|
|
|
+:deep(.mc-sum .mc-sum-qty) {
|
|
|
+ color: #303133;
|
|
|
+ font-weight: 600;
|
|
|
+ font-size: 13px;
|
|
|
+ font-variant-numeric: tabular-nums;
|
|
|
+}
|
|
|
+
|
|
|
+:deep(.mc-sum .mc-sum-style) {
|
|
|
+ color: #909399;
|
|
|
+ font-size: 11px;
|
|
|
+ font-variant-numeric: tabular-nums;
|
|
|
+}
|
|
|
+
|
|
|
+/* 合计行左侧「全厂合计」标签,垂直居中 */
|
|
|
+:deep(.mc-sum-label) {
|
|
|
+ text-align: left;
|
|
|
+ font-weight: 600;
|
|
|
+ color: #303133;
|
|
|
+ line-height: 1.35;
|
|
|
+}
|
|
|
+
|
|
|
+.matrix-total {
|
|
|
+ background: #fafafa;
|
|
|
+}
|
|
|
+
|
|
|
+/* ===== 工序车间标签 ===== */
|
|
|
+.ws-tags {
|
|
|
+ display: flex;
|
|
|
+ flex-wrap: wrap;
|
|
|
+ gap: 3px 4px;
|
|
|
+ align-items: center;
|
|
|
+}
|
|
|
+
|
|
|
+/* ===== 工艺流程条 ===== */
|
|
|
+/*
|
|
|
+ * 一行显示完整工艺路线:裁剪 → 车缝 → 手工 → 大烫 → 总检 → 包装。
|
|
|
+ * 做了的车间亮绿色,没做的灰色,一眼看出这个订单走到哪一步。
|
|
|
+ */
|
|
|
+.flow-strip {
|
|
|
+ display: flex;
|
|
|
+ flex-wrap: wrap;
|
|
|
+ gap: 4px;
|
|
|
+ align-items: center;
|
|
|
+}
|
|
|
+
|
|
|
+.flow-node {
|
|
|
+ display: inline-flex;
|
|
|
+ align-items: center;
|
|
|
+ padding: 1px 8px;
|
|
|
+ border-radius: 3px;
|
|
|
+ border: 1px solid transparent;
|
|
|
+ font-size: 12px;
|
|
|
+ line-height: 1.7;
|
|
|
+ white-space: nowrap;
|
|
|
+ font-weight: 600;
|
|
|
+}
|
|
|
+
|
|
|
+/* 亮绿色:这个车间在做这个订单 */
|
|
|
+.flow-node.is-on {
|
|
|
+ background: #e8f3ff;
|
|
|
+ border-color: #cfe3ff;
|
|
|
+ color: #2f7bf0;
|
|
|
+}
|
|
|
+
|
|
|
+/* 灰色:这个车间没做这个订单 */
|
|
|
+.flow-node.is-off {
|
|
|
+ background: #f4f4f5;
|
|
|
+ border-color: #e9e9eb;
|
|
|
+ color: #c0c4cc;
|
|
|
+ font-weight: 400;
|
|
|
+}
|
|
|
+
|
|
|
+.ws-tag {
|
|
|
+ display: inline-block;
|
|
|
+ padding: 0 5px;
|
|
|
+ border: 1px solid #d9ecff;
|
|
|
+ border-radius: 3px;
|
|
|
+ background: #ecf5ff;
|
|
|
+ color: #409eff;
|
|
|
+ font-size: 11px;
|
|
|
+ line-height: 1.7;
|
|
|
+ white-space: nowrap;
|
|
|
+}
|
|
|
+
|
|
|
+/* ===== 订单编号标签 ===== */
|
|
|
+.ord-tag {
|
|
|
+ display: inline-block;
|
|
|
+ padding: 0 5px;
|
|
|
+ border: 1px solid #e4e7ed;
|
|
|
+ border-radius: 3px;
|
|
|
+ background: #f7f8fa;
|
|
|
+ color: #606266;
|
|
|
+ font-size: 11px;
|
|
|
+ line-height: 1.7;
|
|
|
+ white-space: nowrap;
|
|
|
+ font-variant-numeric: tabular-nums;
|
|
|
+}
|
|
|
+
|
|
|
+/* ===== 展开的车间明细 ===== */
|
|
|
+.order-box {
|
|
|
+ padding: 10px 14px 12px;
|
|
|
+ background: #fafbfc;
|
|
|
+}
|
|
|
+
|
|
|
+.order-box-title {
|
|
|
+ display: flex;
|
|
|
+ align-items: baseline;
|
|
|
+ gap: 10px;
|
|
|
+ margin-bottom: 8px;
|
|
|
+}
|
|
|
+
|
|
|
+.obt-title {
|
|
|
+ font-size: 12px;
|
|
|
+ font-weight: 700;
|
|
|
+ color: #303133;
|
|
|
+}
|
|
|
+
|
|
|
+.obt-sub {
|
|
|
+ font-size: 12px;
|
|
|
+ color: #909399;
|
|
|
+}
|
|
|
+
|
|
|
+.order-table :deep(.el-table__cell) {
|
|
|
+ padding: 3px 0;
|
|
|
+}
|
|
|
+
|
|
|
+/* 工序车间徽标 */
|
|
|
+.ws-badge {
|
|
|
+ display: inline-block;
|
|
|
+ padding: 1px 8px;
|
|
|
+ border-radius: 10px;
|
|
|
+ background: #e8f3ff;
|
|
|
+ border: 1px solid #cfe3ff;
|
|
|
+ color: #2f7bf0;
|
|
|
+ font-size: 12px;
|
|
|
+ font-weight: 600;
|
|
|
+ line-height: 1.7;
|
|
|
+ white-space: nowrap;
|
|
|
+}
|
|
|
+
|
|
|
+/* 报工数量加粗 */
|
|
|
+.num-strong {
|
|
|
+ font-weight: 700;
|
|
|
+ color: #303133;
|
|
|
+ font-variant-numeric: tabular-nums;
|
|
|
+}
|
|
|
+
|
|
|
+/* ===== 小组 / 员工 层级 ===== */
|
|
|
+.group-box {
|
|
|
+ padding: 6px 8px;
|
|
|
+ background: #f7f9fc;
|
|
|
+}
|
|
|
+
|
|
|
+.group-table :deep(.el-table__cell) {
|
|
|
+ padding: 2px 0;
|
|
|
+}
|
|
|
+
|
|
|
+.staff-box {
|
|
|
+ padding: 5px 8px;
|
|
|
+ background: #f2f5fa;
|
|
|
+}
|
|
|
+
|
|
|
+.staff-table :deep(.el-table__cell) {
|
|
|
+ padding: 2px 0;
|
|
|
+}
|
|
|
+
|
|
|
+/* 小组徽标 */
|
|
|
+.gp-badge {
|
|
|
+ display: inline-block;
|
|
|
+ padding: 1px 8px;
|
|
|
+ border-radius: 10px;
|
|
|
+ background: #f0f9eb;
|
|
|
+ border: 1px solid #d5e8c8;
|
|
|
+ color: #67c23a;
|
|
|
+ font-size: 12px;
|
|
|
+ font-weight: 600;
|
|
|
+ line-height: 1.7;
|
|
|
+ white-space: nowrap;
|
|
|
+}
|
|
|
+
|
|
|
+/* 员工姓名 */
|
|
|
+.staff-name {
|
|
|
+ color: #303133;
|
|
|
+ font-weight: 500;
|
|
|
+}
|
|
|
+
|
|
|
+/* 带数量的车间标签 */
|
|
|
+.ws-tag-num {
|
|
|
+ font-variant-numeric: tabular-nums;
|
|
|
+}
|
|
|
+
|
|
|
+/* 明细面板标题栏里的汇总数字(横向紧凑排列) */
|
|
|
+.inline-sum {
|
|
|
+ display: inline-flex;
|
|
|
+ align-items: center;
|
|
|
+ flex-wrap: wrap;
|
|
|
+ gap: 4px 10px;
|
|
|
+ font-size: 12px;
|
|
|
+ color: #909399;
|
|
|
+}
|
|
|
+
|
|
|
+.inline-sum .is-item b {
|
|
|
+ color: #303133;
|
|
|
+ font-weight: 700;
|
|
|
+ font-size: 13px;
|
|
|
+ margin: 0 2px;
|
|
|
+}
|
|
|
+
|
|
|
+.inline-sum .is-item b.num {
|
|
|
+ font-variant-numeric: tabular-nums;
|
|
|
+}
|
|
|
+
|
|
|
+/* 明细面板的指标卡片 */
|
|
|
+.detail-metrics {
|
|
|
+ grid-template-columns: repeat(5, 1fr);
|
|
|
+ padding: 10px 12px;
|
|
|
+ border-bottom: 1px solid #f0f2f5;
|
|
|
+}
|
|
|
+
|
|
|
+@media (max-width: 992px) {
|
|
|
+ .detail-metrics {
|
|
|
+ grid-template-columns: repeat(2, 1fr);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/* ===== 各月报工 ===== */
|
|
|
+.month-split {
|
|
|
+ display: flex;
|
|
|
+ flex-wrap: wrap;
|
|
|
+ gap: 4px 6px;
|
|
|
+ align-items: center;
|
|
|
+}
|
|
|
+
|
|
|
+/* 单个月份的小标签:只显示月份,数量在左边「报工数量」列已有 */
|
|
|
+.month-chip {
|
|
|
+ display: inline-flex;
|
|
|
+ align-items: baseline;
|
|
|
+ gap: 3px;
|
|
|
+ padding: 1px 6px;
|
|
|
+ border: 1px solid #e4e7ed;
|
|
|
+ border-radius: 3px;
|
|
|
+ background: #f7f8fa;
|
|
|
+ white-space: nowrap;
|
|
|
+ font-size: 11px;
|
|
|
+ line-height: 1.6;
|
|
|
+ font-variant-numeric: tabular-nums;
|
|
|
+}
|
|
|
+
|
|
|
+.month-chip .mc-month {
|
|
|
+ color: #409eff;
|
|
|
+ font-weight: 600;
|
|
|
+}
|
|
|
+
|
|
|
+/* 当月没有报工时的占位文字 */
|
|
|
+.mc-empty {
|
|
|
+ color: #c0c4cc;
|
|
|
+ font-size: 11px;
|
|
|
+}
|
|
|
+
|
|
|
+/* ===== 员工报工工序 ===== */
|
|
|
+.proc-list {
|
|
|
+ display: flex;
|
|
|
+ flex-wrap: wrap;
|
|
|
+ gap: 3px 5px;
|
|
|
+ align-items: center;
|
|
|
+}
|
|
|
+
|
|
|
+.proc-chip {
|
|
|
+ display: inline-flex;
|
|
|
+ align-items: baseline;
|
|
|
+ gap: 4px;
|
|
|
+ padding: 1px 6px;
|
|
|
+ border: 1px solid #e4e7ed;
|
|
|
+ border-radius: 3px;
|
|
|
+ background: #f7f8fa;
|
|
|
+ white-space: nowrap;
|
|
|
+ font-size: 11px;
|
|
|
+ line-height: 1.6;
|
|
|
+ font-variant-numeric: tabular-nums;
|
|
|
+}
|
|
|
+
|
|
|
+.proc-chip .pc-code {
|
|
|
+ color: #909399;
|
|
|
+ font-weight: 600;
|
|
|
+}
|
|
|
+
|
|
|
+.proc-chip .pc-name {
|
|
|
+ color: #606266;
|
|
|
+ max-width: 130px;
|
|
|
+ overflow: hidden;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+}
|
|
|
+
|
|
|
+.proc-chip .pc-num {
|
|
|
+ color: #2f7bf0;
|
|
|
+ font-weight: 700;
|
|
|
+}
|
|
|
+
|
|
|
+/* ===== 分页 ===== */
|
|
|
+.pager {
|
|
|
+ display: flex;
|
|
|
+ justify-content: flex-end;
|
|
|
+ padding: 8px 12px;
|
|
|
+}
|
|
|
+
|
|
|
+@media (max-width: 992px) {
|
|
|
+ .metric-row {
|
|
|
+ grid-template-columns: 1fr 1fr;
|
|
|
+ gap: 8px;
|
|
|
+ }
|
|
|
+ .metric-value {
|
|
|
+ font-size: 18px;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|