Bladeren bron

成本报表

tanzx 1 week geleden
bovenliggende
commit
214e3232bf

+ 524 - 0
src/views/reportForms/finishedGoodsCostLedger/index.vue

@@ -0,0 +1,524 @@
+<!--
+  完工产品成本台账(成本管理 · 存货与在产品)
+  表格 16 列严格复刻原始原型「完工产品成本台账.html」:
+  序号 / 月份 / 产品名称 / 总成本 / 生产批次 / 单位成本 / 成本中心 / 所属车间 /
+  实际耗用成本 / 本月完工入库数量 / 直接材料成本 / 制造费用成本 / 直接人工成本 /
+  期初在制品成本 / 期末在制品成本 / 计价方式。
+  原型表格没有操作列,「订单明细」是查询区的独立按钮(u4422);
+  需求说明书补全但原型未列出的字段(规格 / 状态 / 所属部门)放到「订单明细」弹窗。
+-->
+<template>
+  <div class="ele-body">
+    <el-card shadow="never">
+      <el-row :gutter="15">
+        <el-col v-for="item in summaryCards" :key="item.label" :span="6">
+          <div class="cost-report-card">
+            <div class="cost-report-card-label">{{ item.label }}</div>
+            <div class="cost-report-card-value">{{ item.value }}</div>
+          </div>
+        </el-col>
+      </el-row>
+      <el-row :gutter="15" style="margin-top: 12px">
+        <el-col :span="8">
+          <div class="cost-report-chart-title">料工费成本构成</div>
+          <v-chart :option="pieOption" autoresize style="height: 220px" />
+        </el-col>
+        <el-col :span="8">
+          <div class="cost-report-chart-title">各季节成本情况占比</div>
+          <v-chart :option="quarterOption" autoresize style="height: 220px" />
+        </el-col>
+        <el-col :span="8">
+          <div class="cost-report-chart-title">各月份订单总成本情况</div>
+          <v-chart :option="barOption" autoresize style="height: 220px" />
+        </el-col>
+      </el-row>
+    </el-card>
+
+    <el-card shadow="never" style="margin-top: 10px">
+      <seekPage :seekList="seekList" :formLength="4" @search="reload" />
+      <ele-pro-table
+        ref="table"
+        :columns="columns"
+        :datasource="datasource"
+        row-key="rowKey"
+        height="calc(100vh - 620px)"
+        :page-size="20"
+        :cache-key="'cost-finished-goods-ledger'"
+      >
+        <template v-slot:toolbar>
+          <el-button
+            size="small"
+            icon="el-icon-tickets"
+            @click="openOrderDetail"
+          >
+            订单明细
+          </el-button>
+          <el-button
+            size="small"
+            type="primary"
+            icon="el-icon-upload2"
+            :loading="exporting"
+            @click="doExport"
+          >
+            excel导出
+          </el-button>
+        </template>
+      </ele-pro-table>
+    </el-card>
+
+    <!-- 原型 u4422「订单明细」按钮弹窗:明细行 + 成本项目构成 + 各季度成本占比 + 核算口径 -->
+    <el-dialog
+      :title="detail.title || '订单明细'"
+      :visible.sync="detailVisible"
+      width="1000px"
+      append-to-body
+    >
+      <div class="cost-report-dialog-title">订单明细</div>
+      <el-table :data="detail.rows || []" size="small" border max-height="240">
+        <el-table-column prop="batchNo" label="生产批次" min-width="130" />
+        <el-table-column
+          prop="workOrderNo"
+          label="生产工单号"
+          min-width="140"
+        />
+        <el-table-column prop="productName" label="产品名称" min-width="120" />
+        <el-table-column prop="spec" label="规格" min-width="100" />
+        <el-table-column label="状态" width="130" align="center">
+          <template v-slot="{ row }">{{ statusName(row.status) }}</template>
+        </el-table-column>
+        <el-table-column prop="deptName" label="所属部门" min-width="110" />
+        <el-table-column label="总成本" min-width="130" align="right">
+          <template v-slot="{ row }">{{ money(row.totalCost) }}</template>
+        </el-table-column>
+        <el-table-column label="单位成本" min-width="120" align="right">
+          <template v-slot="{ row }">{{ money(row.unitCost) }}</template>
+        </el-table-column>
+        <el-table-column
+          prop="valuationMethod"
+          label="计价方式"
+          min-width="110"
+        />
+      </el-table>
+
+      <el-row :gutter="15" style="margin-top: 14px">
+        <el-col :span="12">
+          <div class="cost-report-dialog-title">成本项目构成</div>
+          <el-table :data="detail.items || []" size="small" border>
+            <el-table-column prop="name" label="成本项目" min-width="120" />
+            <el-table-column label="金额" align="right" min-width="140">
+              <template v-slot="{ row }">{{ money(row.value) }}</template>
+            </el-table-column>
+            <el-table-column label="占比" align="right" min-width="90">
+              <template v-slot="{ row }">{{ percent(row.rate) }}</template>
+            </el-table-column>
+          </el-table>
+        </el-col>
+        <el-col :span="12">
+          <div class="cost-report-dialog-title">各季度成本占比</div>
+          <el-table :data="quarterTrend" size="small" border>
+            <el-table-column prop="name" label="季度" min-width="120" />
+            <el-table-column label="金额" align="right" min-width="130">
+              <template v-slot="{ row }">{{ money(row.value) }}</template>
+            </el-table-column>
+            <el-table-column label="占比" align="right" min-width="90">
+              <template v-slot="{ row }">{{ percent(row.rate) }}</template>
+            </el-table-column>
+          </el-table>
+        </el-col>
+      </el-row>
+
+      <div class="cost-report-dialog-title" style="margin-top: 14px">
+        核算口径说明
+      </div>
+      <div class="cost-report-formula">{{ detail.formulaNote }}</div>
+      <template v-slot:footer>
+        <el-button @click="detailVisible = false">关闭</el-button>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+  import { use } from 'echarts/core';
+  import { CanvasRenderer } from 'echarts/renderers';
+  import { PieChart, BarChart } from 'echarts/charts';
+  import {
+    GridComponent,
+    TooltipComponent,
+    LegendComponent
+  } from 'echarts/components';
+  import VChart from 'vue-echarts';
+  import {
+    pageFinishedGoods,
+    summaryFinishedGoods,
+    detailFinishedGoods,
+    exportFinishedGoods,
+    normalizePeriodWhere
+  } from '@/api/reportForms/costReport';
+
+  use([
+    CanvasRenderer,
+    PieChart,
+    BarChart,
+    GridComponent,
+    TooltipComponent,
+    LegendComponent
+  ]);
+
+  // 原型 u4418 状态下拉:已完工已入库 / 已完工未入库;「全部」为必要增强(否则无法查全量)
+  const STATUS_OPTIONS = [
+    { label: '全部', value: '' },
+    { label: '已完工已入库', value: 2 },
+    { label: '已完工未入库', value: 1 }
+  ];
+
+  export default {
+    name: 'FinishedGoodsCostLedger',
+    components: { VChart },
+    data() {
+      return {
+        searchParams: {},
+        summary: {},
+        exporting: false,
+        detailVisible: false,
+        detail: {},
+        seekList: [
+          {
+            label: '产品名称:',
+            value: 'productName',
+            type: 'input',
+            placeholder: '支持名称模糊查询'
+          },
+          {
+            label: '统计时间:',
+            value: 'statDate',
+            type: 'date',
+            dateType: 'daterange',
+            valueAr: ['startDate', 'endDate'],
+            width: 380
+          },
+          {
+            label: '状态:',
+            value: 'status',
+            type: 'select',
+            placeholder: '请选择状态',
+            planList: STATUS_OPTIONS
+          },
+          {
+            label: '批次号:',
+            value: 'batchNo',
+            type: 'input',
+            placeholder: '请输入生产批次'
+          }
+        ],
+        // 列名、列序与原型表头逐字对齐,共 16 列、无操作列
+        columns: [
+          {
+            prop: 'serialNumber',
+            label: '序号',
+            width: 70,
+            align: 'center',
+            fixed: 'left'
+          },
+          { prop: 'periodMonth', label: '月份', width: 90, align: 'center' },
+          {
+            prop: 'productName',
+            label: '产品名称',
+            minWidth: 130,
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'totalCost',
+            label: '总成本',
+            minWidth: 140,
+            align: 'right',
+            formatter: (row) => this.money(row.totalCost)
+          },
+          {
+            prop: 'batchNo',
+            label: '生产批次',
+            minWidth: 130,
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'unitCost',
+            label: '单位成本',
+            minWidth: 120,
+            align: 'right',
+            formatter: (row) => this.money(row.unitCost)
+          },
+          {
+            prop: 'costCenter',
+            label: '成本中心',
+            minWidth: 110,
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'workshopName',
+            label: '所属车间',
+            minWidth: 110,
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'actualUsedCost',
+            label: '实际耗用成本',
+            minWidth: 140,
+            align: 'right',
+            formatter: (row) => this.money(row.actualUsedCost)
+          },
+          {
+            prop: 'finishedQty',
+            label: '本月完工入库数量',
+            minWidth: 150,
+            align: 'right',
+            formatter: (row) => this.qty(row.finishedQty)
+          },
+          {
+            prop: 'materialCost',
+            label: '直接材料成本',
+            minWidth: 140,
+            align: 'right',
+            formatter: (row) => this.money(row.materialCost)
+          },
+          {
+            prop: 'overheadCost',
+            label: '制造费用成本',
+            minWidth: 140,
+            align: 'right',
+            formatter: (row) => this.money(row.overheadCost)
+          },
+          {
+            prop: 'laborCost',
+            label: '直接人工成本',
+            minWidth: 140,
+            align: 'right',
+            formatter: (row) => this.money(row.laborCost)
+          },
+          {
+            prop: 'openingWipCost',
+            label: '期初在制品成本',
+            minWidth: 140,
+            align: 'right',
+            formatter: (row) => this.money(row.openingWipCost)
+          },
+          {
+            prop: 'closingWipCost',
+            label: '期末在制品成本',
+            minWidth: 140,
+            align: 'right',
+            formatter: (row) => this.money(row.closingWipCost)
+          },
+          {
+            prop: 'valuationMethod',
+            label: '计价方式',
+            width: 110,
+            align: 'center'
+          }
+        ]
+      };
+    },
+    computed: {
+      summaryCards() {
+        return [
+          { label: '成本总额', value: this.money(this.summary.totalCost) },
+          {
+            label: '本月完工入库数量',
+            value: this.qty(this.summary.finishedQty)
+          },
+          {
+            label: '加权平均单位成本',
+            value: this.money(this.summary.avgUnitCost)
+          },
+          {
+            label: '直接材料成本',
+            value: this.money(this.summary.materialCost)
+          }
+        ];
+      },
+      quarterTrend() {
+        return (this.detail.summary && this.detail.summary.quarterTrend) || [];
+      },
+      pieOption() {
+        const data = (this.summary.costStructure || []).map((i) => ({
+          name: i.name,
+          value: Number(i.value || 0)
+        }));
+        return {
+          tooltip: { trigger: 'item', formatter: '{b}: {c} ({d}%)' },
+          legend: { bottom: 0, left: 'center' },
+          series: [{ type: 'pie', radius: ['38%', '62%'], data }]
+        };
+      },
+      quarterOption() {
+        const data = (this.summary.quarterTrend || []).map((i) => ({
+          name: i.name,
+          value: Number(i.rate || 0)
+        }));
+        return {
+          tooltip: { trigger: 'item', formatter: '{b}: {c}%' },
+          legend: { bottom: 0, left: 'center' },
+          series: [{ type: 'pie', radius: ['38%', '62%'], data }]
+        };
+      },
+      barOption() {
+        const monthly = this.summary.monthlyTrend || [];
+        return {
+          tooltip: { trigger: 'axis' },
+          grid: { left: 70, right: 20, top: 24, bottom: 36 },
+          xAxis: {
+            type: 'category',
+            data: monthly.map((i) => this.monthLabel(i.name))
+          },
+          yAxis: { type: 'value' },
+          series: [
+            {
+              type: 'bar',
+              barMaxWidth: 36,
+              itemStyle: { color: '#409EFF' },
+              data: monthly.map((i) => Number(i.value || 0))
+            }
+          ]
+        };
+      }
+    },
+    created() {
+      this.loadSummary({});
+    },
+    methods: {
+      monthLabel(period) {
+        if (!period || period.length < 6) {
+          return period || '-';
+        }
+        const month = Number(period.slice(4, 6));
+        return `${month}月`;
+      },
+      statusName(status) {
+        return Number(status) === 2 ? '已完工已入库' : '已完工未入库';
+      },
+      money(value) {
+        if (value === null || value === undefined || value === '') {
+          return '-';
+        }
+        const n = Number(value);
+        return isNaN(n)
+          ? '-'
+          : n.toLocaleString('zh-CN', {
+              minimumFractionDigits: 2,
+              maximumFractionDigits: 2
+            });
+      },
+      qty(value) {
+        if (value === null || value === undefined || value === '') {
+          return '-';
+        }
+        const n = Number(value);
+        return isNaN(n)
+          ? '-'
+          : n.toLocaleString('zh-CN', { maximumFractionDigits: 4 });
+      },
+      percent(value) {
+        if (value === null || value === undefined || value === '') {
+          return '-';
+        }
+        const n = Number(value);
+        return isNaN(n) ? '-' : `${n.toFixed(2)}%`;
+      },
+      cleanWhere(where) {
+        const params = normalizePeriodWhere(where || {});
+        if (params.status === '' || params.status === undefined) {
+          delete params.status;
+        }
+        return params;
+      },
+      datasource({ page, limit, where, order }) {
+        const params = this.cleanWhere(where);
+        this.searchParams = params;
+        return pageFinishedGoods({
+          ...params,
+          ...order,
+          pageNum: page,
+          size: limit
+        });
+      },
+      reload(where) {
+        const params = this.cleanWhere(where);
+        this.searchParams = params;
+        this.loadSummary(params);
+        this.$refs.table.reload({ page: 1, where });
+      },
+      async loadSummary(params) {
+        try {
+          this.summary = (await summaryFinishedGoods(params)) || {};
+        } catch (e) {
+          this.$message.error(e.message || '汇总加载失败');
+        }
+      },
+      async doExport() {
+        this.exporting = true;
+        try {
+          await exportFinishedGoods({ ...this.searchParams });
+        } catch (e) {
+          this.$message.error(e.message || '导出失败');
+        } finally {
+          this.exporting = false;
+        }
+      },
+      async openOrderDetail() {
+        try {
+          this.detail = await detailFinishedGoods({
+            productName: this.searchParams.productName,
+            batchNo: this.searchParams.batchNo,
+            status: this.searchParams.status,
+            periodStart: this.searchParams.periodStart,
+            periodEnd: this.searchParams.periodEnd
+          });
+          this.detailVisible = true;
+        } catch (e) {
+          this.$message.error(e.message || '订单明细加载失败');
+        }
+      }
+    }
+  };
+</script>
+
+<style scoped>
+  .cost-report-card {
+    padding: 14px 16px;
+    border: 1px solid #ebeef5;
+    border-radius: 4px;
+    background: #fafafa;
+  }
+  .cost-report-card-label {
+    font-size: 13px;
+    color: #909399;
+  }
+  .cost-report-card-value {
+    margin-top: 8px;
+    font-size: 22px;
+    font-weight: 600;
+    color: #303133;
+  }
+  .cost-report-chart-title,
+  .cost-report-dialog-title {
+    font-size: 13px;
+    font-weight: 600;
+    color: #606266;
+    margin-bottom: 6px;
+  }
+  .cost-report-note {
+    margin-top: 12px;
+    font-size: 12px;
+    line-height: 1.8;
+    color: #909399;
+  }
+  .cost-report-formula {
+    padding: 10px 12px;
+    border: 1px solid #ebeef5;
+    border-radius: 4px;
+    background: #fafafa;
+    font-size: 12px;
+    line-height: 1.9;
+    color: #606266;
+    white-space: pre-line;
+  }
+</style>

+ 370 - 0
src/views/reportForms/salesMarginReport/index.vue

@@ -0,0 +1,370 @@
+<!--
+  销售收入毛利报表(成本管理 · 分析类报表)
+  表格 16 列严格复刻原始原型「销售收入毛利报表.html」:
+  序号 / 月份 / 产品 / 所属部门 / 所属车间 / 规格 / 包装单位 / 计量单位 / 批次号 /
+  销售数量 / 销售成本 / 销售收入 / 分摊总成本 / 毛利润成本 / 毛利润率 / 操作。
+  例外:原型「毛利润成本」为笔误,按需求说明书 V2.0 §7.7 / F15 显示为「毛利润」。
+  需求说明书补全但原型表格未列出的字段(项目名称、不含税单价、出库单位成本、产品编码),
+  放在「查看」弹窗里展示,不占用原型列位。
+-->
+<template>
+  <div class="ele-body">
+    <el-card shadow="never">
+      <div class="cost-report-note">
+        销售毛利 = 销售收入 − 销售成本;销售毛利率 = 销售毛利 ÷ 销售收入 ×
+        100%。 销售收入 = 销售数量 × 不含税销售单价(原型「销售成本 ÷
+        13%」为错误口径,已按需求说明书 V2.0 §7.7
+        修正)。点击行尾「查看」可查看完整基础公式与核算流程。
+      </div>
+    </el-card>
+
+    <el-card shadow="never" style="margin-top: 10px">
+      <seekPage :seekList="seekList" :formLength="4" @search="reload" />
+      <ele-pro-table
+        ref="table"
+        :columns="columns"
+        :datasource="datasource"
+        row-key="rowKey"
+        height="calc(100vh - 380px)"
+        :page-size="20"
+        :cache-key="'cost-sales-margin-report'"
+      >
+        <template v-slot:toolbar>
+          <el-button
+            size="small"
+            type="primary"
+            icon="el-icon-upload2"
+            :loading="exporting"
+            @click="doExport"
+          >
+            excel导出
+          </el-button>
+        </template>
+        <template v-slot:action="{ row }">
+          <el-link type="primary" :underline="false" @click="openDetail(row)">
+            查看
+          </el-link>
+        </template>
+      </ele-pro-table>
+    </el-card>
+
+    <!-- 原型 u8884:查看弹出的口径说明浮层 + 该行补充字段 -->
+    <el-dialog
+      :title="detail.title || '销售收入毛利 · 口径说明'"
+      :visible.sync="detailVisible"
+      width="780px"
+      append-to-body
+    >
+      <div class="cost-report-dialog-title">1. 基础公式与核算流程</div>
+      <div class="cost-report-formula">{{ detail.formulaNote }}</div>
+
+      <div class="cost-report-dialog-title"
+        >2. 本行明细(原型表格未列出的补充字段)</div
+      >
+      <el-table :data="detailFields" size="small" border>
+        <el-table-column prop="label" label="字段" min-width="150" />
+        <el-table-column
+          prop="value"
+          label="数值"
+          min-width="220"
+          align="right"
+        />
+      </el-table>
+
+      <div class="cost-report-dialog-title">3. 金额构成</div>
+      <el-table :data="detail.items || []" size="small" border>
+        <el-table-column prop="name" label="项目" min-width="140" />
+        <el-table-column label="金额" align="right" min-width="160">
+          <template v-slot="{ row }">{{ money(row.value) }}</template>
+        </el-table-column>
+        <el-table-column label="占销售收入" align="right" min-width="120">
+          <template v-slot="{ row }">{{ percent(row.rate) }}</template>
+        </el-table-column>
+      </el-table>
+      <template v-slot:footer>
+        <el-button @click="detailVisible = false">关闭</el-button>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+  import {
+    pageSalesMargin,
+    detailSalesMargin,
+    exportSalesMargin,
+    normalizePeriodWhere
+  } from '@/api/reportForms/costReport';
+
+  // 原型 u8879 所属部门下拉选项
+  const DEPT_OPTIONS = [
+    { label: '全部', value: '' },
+    { label: '生产部门', value: '生产部门' },
+    { label: '研发部门', value: '研发部门' },
+    { label: '仓库部门', value: '仓库部门' },
+    { label: '行政部门', value: '行政部门' },
+    { label: '销售部门', value: '销售部门' }
+  ];
+
+  export default {
+    name: 'SalesMarginReport',
+    data() {
+      return {
+        searchParams: {},
+        exporting: false,
+        detailVisible: false,
+        detail: {},
+        seekList: [
+          {
+            label: '产品名称:',
+            value: 'productName',
+            type: 'input',
+            placeholder: '支持名称模糊查询'
+          },
+          {
+            label: '统计时间:',
+            value: 'statDate',
+            type: 'date',
+            dateType: 'daterange',
+            valueAr: ['startDate', 'endDate'],
+            width: 380
+          },
+          {
+            label: '所属部门:',
+            value: 'deptName',
+            type: 'select',
+            placeholder: '请选择所属部门',
+            planList: DEPT_OPTIONS
+          },
+          {
+            label: '项目名称:',
+            value: 'projectName',
+            type: 'input',
+            placeholder: '请输入项目名称'
+          }
+        ],
+        // 列顺序、列名与原型表头逐字对齐(仅「毛利润成本」按需求说明书纠为「毛利润」)
+        columns: [
+          {
+            prop: 'serialNumber',
+            label: '序号',
+            width: 70,
+            align: 'center',
+            fixed: 'left'
+          },
+          { prop: 'periodMonth', label: '月份', width: 90, align: 'center' },
+          {
+            prop: 'productName',
+            label: '产品',
+            minWidth: 130,
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'deptName',
+            label: '所属部门',
+            minWidth: 110,
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'workshopName',
+            label: '所属车间',
+            minWidth: 110,
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'spec',
+            label: '规格',
+            minWidth: 110,
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'packageUnit',
+            label: '包装单位',
+            width: 90,
+            align: 'center'
+          },
+          {
+            prop: 'measureUnit',
+            label: '计量单位',
+            width: 90,
+            align: 'center'
+          },
+          {
+            prop: 'batchNo',
+            label: '批次号',
+            minWidth: 130,
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'saleQty',
+            label: '销售数量',
+            minWidth: 120,
+            align: 'right',
+            formatter: (row) => this.qty(row.saleQty)
+          },
+          {
+            prop: 'saleCost',
+            label: '销售成本',
+            minWidth: 140,
+            align: 'right',
+            formatter: (row) => this.money(row.saleCost)
+          },
+          {
+            prop: 'saleRevenue',
+            label: '销售收入',
+            minWidth: 140,
+            align: 'right',
+            formatter: (row) => this.money(row.saleRevenue)
+          },
+          {
+            prop: 'allocatedTotalCost',
+            label: '分摊总成本',
+            minWidth: 140,
+            align: 'right',
+            formatter: (row) => this.money(row.allocatedTotalCost)
+          },
+          {
+            prop: 'grossProfit',
+            label: '毛利润',
+            minWidth: 140,
+            align: 'right',
+            formatter: (row) => this.money(row.grossProfit)
+          },
+          {
+            prop: 'grossMarginRate',
+            label: '毛利润率',
+            width: 110,
+            align: 'right',
+            formatter: (row) => this.percent(row.grossMarginRate)
+          },
+          {
+            columnKey: 'action',
+            label: '操作',
+            width: 90,
+            align: 'center',
+            fixed: 'right',
+            slot: 'action',
+            resizable: false
+          }
+        ]
+      };
+    },
+    computed: {
+      detailFields() {
+        const row = this.detail.row || {};
+        return [
+          { label: '产品编码', value: row.productCode || '-' },
+          { label: '项目名称', value: row.projectName || '-' },
+          { label: '不含税单价', value: this.money(row.taxExclusivePrice) },
+          { label: '出库单位成本', value: this.money(row.outboundUnitCost) },
+          { label: '销售数量', value: this.qty(row.saleQty) },
+          { label: '销售成本', value: this.money(row.saleCost) },
+          { label: '销售收入', value: this.money(row.saleRevenue) },
+          { label: '分摊总成本', value: this.money(row.allocatedTotalCost) },
+          { label: '毛利润', value: this.money(row.grossProfit) },
+          { label: '毛利润率', value: this.percent(row.grossMarginRate) }
+        ];
+      }
+    },
+    methods: {
+      money(value) {
+        if (value === null || value === undefined || value === '') {
+          return '-';
+        }
+        const n = Number(value);
+        return isNaN(n)
+          ? '-'
+          : n.toLocaleString('zh-CN', {
+              minimumFractionDigits: 2,
+              maximumFractionDigits: 2
+            });
+      },
+      qty(value) {
+        if (value === null || value === undefined || value === '') {
+          return '-';
+        }
+        const n = Number(value);
+        return isNaN(n)
+          ? '-'
+          : n.toLocaleString('zh-CN', { maximumFractionDigits: 4 });
+      },
+      percent(value) {
+        if (value === null || value === undefined || value === '') {
+          return '-';
+        }
+        const n = Number(value);
+        return isNaN(n) ? '-' : `${n.toFixed(2)}%`;
+      },
+      cleanWhere(where) {
+        const params = normalizePeriodWhere(where || {});
+        // 下拉「全部」与空串都不应作为过滤条件
+        if (params.deptName === '全部' || params.deptName === '') {
+          delete params.deptName;
+        }
+        return params;
+      },
+      datasource({ page, limit, where, order }) {
+        const params = this.cleanWhere(where);
+        this.searchParams = params;
+        return pageSalesMargin({
+          ...params,
+          ...order,
+          pageNum: page,
+          size: limit
+        });
+      },
+      reload(where) {
+        this.searchParams = this.cleanWhere(where);
+        this.$refs.table.reload({ page: 1, where });
+      },
+      async doExport() {
+        this.exporting = true;
+        try {
+          await exportSalesMargin({ ...this.searchParams });
+        } catch (e) {
+          this.$message.error(e.message || '导出失败');
+        } finally {
+          this.exporting = false;
+        }
+      },
+      async openDetail(row) {
+        try {
+          // 报表行是实时聚合结果、没有物理主键,按「产品 + 期间 + 批次」这组聚合维度下钻
+          this.detail = await detailSalesMargin({
+            productName: row.productName,
+            periodMonth: row.periodMonth,
+            batchNo: row.batchNo
+          });
+          this.detailVisible = true;
+        } catch (e) {
+          this.$message.error(e.message || '明细加载失败');
+        }
+      }
+    }
+  };
+</script>
+
+<style scoped>
+  .cost-report-note {
+    font-size: 12px;
+    line-height: 1.8;
+    color: #909399;
+  }
+  .cost-report-dialog-title {
+    font-size: 13px;
+    font-weight: 600;
+    color: #303133;
+    margin: 4px 0 8px;
+  }
+  .cost-report-formula {
+    margin-bottom: 16px;
+    padding: 10px 12px;
+    border: 1px solid #ebeef5;
+    border-radius: 4px;
+    background: #fafafa;
+    font-size: 12px;
+    line-height: 1.9;
+    color: #606266;
+    white-space: pre-line;
+  }
+</style>

+ 479 - 0
src/views/reportForms/workshopCostSummary/index.vue

@@ -0,0 +1,479 @@
+<!--
+  成本车间汇总报表(成本管理 · 分析类报表)
+  表格 17 列严格复刻原始原型「成本车间汇总报表.html」:
+  序号 / 月份 / 成本中心 / 所属车间 / 总成本 / 单位成本 / 包材 / 原料 / 辅材 /
+  燃料费用 / 动力费用 / 设备维修 / 设备折旧 / 电成本 / 其他成本 / 员工薪酬 / 福利。
+  原型无操作列,查询区为「成本中心 + 统计时间 + 车间」,工具栏为 excel导出。
+
+  数据来源(实时聚合业务单据,不读成本结果表):
+  包材/原料/辅材/燃料/动力/电 ← 领料单 t_mes_pick_out_in × 出库单价,按物料根分类与名称关键字拆列;
+  员工薪酬 ← 报工单 t_mes_work_report.work_fee;
+  设备维修/设备折旧/福利/其他 ← 费用申请单 t_eom_fin_fee_apply(审核通过),按费用类型名称归类。
+-->
+<template>
+  <div class="ele-body">
+    <el-card shadow="never">
+      <el-row :gutter="15">
+        <el-col v-for="item in summaryCards" :key="item.label" :span="6">
+          <div class="cost-report-card">
+            <div class="cost-report-card-label">{{ item.label }}</div>
+            <div class="cost-report-card-value">{{ item.value }}</div>
+          </div>
+        </el-col>
+      </el-row>
+      <el-row :gutter="15" style="margin-top: 12px">
+        <el-col :span="8">
+          <div class="cost-report-chart-title">成本构成</div>
+          <v-chart :option="pieOption" autoresize style="height: 220px" />
+        </el-col>
+        <el-col :span="8">
+          <div class="cost-report-chart-title">各季节成本情况占比</div>
+          <v-chart :option="quarterOption" autoresize style="height: 220px" />
+        </el-col>
+        <el-col :span="8">
+          <div class="cost-report-chart-title">各月份成本总额</div>
+          <v-chart :option="barOption" autoresize style="height: 220px" />
+        </el-col>
+      </el-row>
+      <div class="cost-report-note">
+        总成本 = 包材 + 原料 + 辅材 + 燃料 + 动力 + 电 + 设备维修 + 设备折旧 +
+        员工薪酬 + 福利 + 其他;单位成本 = 总成本 ÷ 完工数量。
+        数据实时取自领料、报工、完工入库与费用申请单, 详见「核算口径」。
+        <el-link type="primary" :underline="false" @click="openNote">
+          核算口径
+        </el-link>
+      </div>
+    </el-card>
+
+    <el-card shadow="never" style="margin-top: 10px">
+      <seekPage :seekList="seekList" :formLength="3" @search="reload" />
+      <ele-pro-table
+        ref="table"
+        :columns="columns"
+        :datasource="datasource"
+        row-key="rowKey"
+        height="calc(100vh - 620px)"
+        :page-size="20"
+        :cache-key="'cost-workshop-summary'"
+      >
+        <template v-slot:toolbar>
+          <el-button
+            size="small"
+            type="primary"
+            icon="el-icon-upload2"
+            :loading="exporting"
+            @click="doExport"
+          >
+            excel导出
+          </el-button>
+        </template>
+      </ele-pro-table>
+    </el-card>
+
+    <!-- 原型页面底部 1~8 条核算说明 -->
+    <el-dialog
+      :title="detail.title || '成本车间汇总 · 核算口径'"
+      :visible.sync="detailVisible"
+      width="820px"
+      append-to-body
+    >
+      <div class="cost-report-dialog-title">核算口径</div>
+      <div class="cost-report-formula">{{ detail.formulaNote }}</div>
+      <div class="cost-report-dialog-title" style="margin-top: 12px">
+        本期间成本构成
+      </div>
+      <el-table :data="detail.items || []" size="small" border>
+        <el-table-column prop="name" label="成本项" min-width="140" />
+        <el-table-column label="金额" align="right" min-width="160">
+          <template v-slot="{ row }">{{ money(row.value) }}</template>
+        </el-table-column>
+        <el-table-column label="占比" align="right" min-width="100">
+          <template v-slot="{ row }">{{ percent(row.rate) }}</template>
+        </el-table-column>
+      </el-table>
+      <template v-slot:footer>
+        <el-button @click="detailVisible = false">关闭</el-button>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+  import { use } from 'echarts/core';
+  import { CanvasRenderer } from 'echarts/renderers';
+  import { PieChart, BarChart } from 'echarts/charts';
+  import {
+    GridComponent,
+    TooltipComponent,
+    LegendComponent
+  } from 'echarts/components';
+  import VChart from 'vue-echarts';
+  import {
+    pageWorkshopSummary,
+    summaryWorkshopSummary,
+    detailWorkshopSummary,
+    exportWorkshopSummary,
+    normalizePeriodWhere
+  } from '@/api/reportForms/costReport';
+
+  use([
+    CanvasRenderer,
+    PieChart,
+    BarChart,
+    GridComponent,
+    TooltipComponent,
+    LegendComponent
+  ]);
+
+  // 原型查询区「成本中心」下拉选项(原型示例值为部门名)
+  const COST_CENTER_OPTIONS = [
+    { label: '全部', value: '' },
+    { label: '生产部门', value: '生产部门' },
+    { label: '研发部门', value: '研发部门' },
+    { label: '仓库', value: '仓库' },
+    { label: '行政部门', value: '行政部门' },
+    { label: '销售部门', value: '销售部门' }
+  ];
+
+  export default {
+    name: 'WorkshopCostSummary',
+    components: { VChart },
+    data() {
+      return {
+        searchParams: {},
+        summary: {},
+        exporting: false,
+        detailVisible: false,
+        detail: {},
+        seekList: [
+          {
+            label: '成本中心:',
+            value: 'costCenter',
+            type: 'select',
+            placeholder: '请选择成本中心',
+            planList: COST_CENTER_OPTIONS
+          },
+          {
+            label: '统计时间:',
+            value: 'statDate',
+            type: 'date',
+            dateType: 'daterange',
+            valueAr: ['startDate', 'endDate'],
+            width: 380
+          },
+          {
+            label: '车间:',
+            value: 'workshopName',
+            type: 'input',
+            placeholder: '支持车间名称模糊查询'
+          }
+        ],
+        // 列名、列序与原型表头逐字对齐,共 17 列、无操作列
+        columns: [
+          {
+            prop: 'serialNumber',
+            label: '序号',
+            width: 70,
+            align: 'center',
+            fixed: 'left'
+          },
+          { prop: 'periodMonth', label: '月份', width: 90, align: 'center' },
+          {
+            prop: 'costCenter',
+            label: '成本中心',
+            minWidth: 120,
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'workshopName',
+            label: '所属车间',
+            minWidth: 120,
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'totalCost',
+            label: '总成本',
+            minWidth: 140,
+            align: 'right',
+            formatter: (row) => this.money(row.totalCost)
+          },
+          {
+            prop: 'unitCost',
+            label: '单位成本',
+            minWidth: 120,
+            align: 'right',
+            formatter: (row) => this.money(row.unitCost)
+          },
+          {
+            prop: 'packageCost',
+            label: '包材',
+            minWidth: 110,
+            align: 'right',
+            formatter: (row) => this.money(row.packageCost)
+          },
+          {
+            prop: 'rawCost',
+            label: '原料',
+            minWidth: 110,
+            align: 'right',
+            formatter: (row) => this.money(row.rawCost)
+          },
+          {
+            prop: 'auxiliaryCost',
+            label: '辅材',
+            minWidth: 110,
+            align: 'right',
+            formatter: (row) => this.money(row.auxiliaryCost)
+          },
+          {
+            prop: 'fuelCost',
+            label: '燃料费用',
+            minWidth: 110,
+            align: 'right',
+            formatter: (row) => this.money(row.fuelCost)
+          },
+          {
+            prop: 'powerCost',
+            label: '动力费用',
+            minWidth: 110,
+            align: 'right',
+            formatter: (row) => this.money(row.powerCost)
+          },
+          {
+            prop: 'repairCost',
+            label: '设备维修',
+            minWidth: 110,
+            align: 'right',
+            formatter: (row) => this.money(row.repairCost)
+          },
+          {
+            prop: 'depreciationCost',
+            label: '设备折旧',
+            minWidth: 110,
+            align: 'right',
+            formatter: (row) => this.money(row.depreciationCost)
+          },
+          {
+            prop: 'electricCost',
+            label: '电成本',
+            minWidth: 110,
+            align: 'right',
+            formatter: (row) => this.money(row.electricCost)
+          },
+          {
+            prop: 'otherCost',
+            label: '其他成本',
+            minWidth: 110,
+            align: 'right',
+            formatter: (row) => this.money(row.otherCost)
+          },
+          {
+            prop: 'laborCost',
+            label: '员工薪酬',
+            minWidth: 120,
+            align: 'right',
+            formatter: (row) => this.money(row.laborCost)
+          },
+          {
+            prop: 'welfareCost',
+            label: '福利',
+            minWidth: 110,
+            align: 'right',
+            formatter: (row) => this.money(row.welfareCost)
+          }
+        ]
+      };
+    },
+    computed: {
+      summaryCards() {
+        return [
+          { label: '成本总额', value: this.money(this.summary.totalCost) },
+          {
+            label: '完工数量',
+            value: this.qty(this.summary.finishedQty)
+          },
+          { label: '直接材料', value: this.money(this.summary.materialCost) },
+          { label: '员工薪酬', value: this.money(this.summary.laborCost) }
+        ];
+      },
+      pieOption() {
+        const data = (this.summary.costStructure || []).map((i) => ({
+          name: i.name,
+          value: Number(i.value || 0)
+        }));
+        return {
+          tooltip: { trigger: 'item', formatter: '{b}: {c} ({d}%)' },
+          legend: { bottom: 0, left: 'center' },
+          series: [{ type: 'pie', radius: ['38%', '62%'], data }]
+        };
+      },
+      quarterOption() {
+        const data = (this.summary.quarterTrend || []).map((i) => ({
+          name: i.name,
+          value: Number(i.rate || 0)
+        }));
+        return {
+          tooltip: { trigger: 'item', formatter: '{b}: {c}%' },
+          legend: { bottom: 0, left: 'center' },
+          series: [{ type: 'pie', radius: ['38%', '62%'], data }]
+        };
+      },
+      barOption() {
+        const monthly = this.summary.monthlyTrend || [];
+        return {
+          tooltip: { trigger: 'axis' },
+          grid: { left: 70, right: 20, top: 24, bottom: 36 },
+          xAxis: {
+            type: 'category',
+            data: monthly.map((i) => this.monthLabel(i.name))
+          },
+          yAxis: { type: 'value' },
+          series: [
+            {
+              type: 'bar',
+              barMaxWidth: 36,
+              itemStyle: { color: '#409EFF' },
+              data: monthly.map((i) => Number(i.value || 0))
+            }
+          ]
+        };
+      }
+    },
+    created() {
+      this.loadSummary({});
+    },
+    methods: {
+      monthLabel(period) {
+        if (!period || period.length < 6) {
+          return period || '-';
+        }
+        const month = Number(period.slice(4, 6));
+        return `${month}月`;
+      },
+      money(value) {
+        if (value === null || value === undefined || value === '') {
+          return '-';
+        }
+        const n = Number(value);
+        return isNaN(n)
+          ? '-'
+          : n.toLocaleString('zh-CN', {
+              minimumFractionDigits: 2,
+              maximumFractionDigits: 2
+            });
+      },
+      qty(value) {
+        if (value === null || value === undefined || value === '') {
+          return '-';
+        }
+        const n = Number(value);
+        return isNaN(n)
+          ? '-'
+          : n.toLocaleString('zh-CN', { maximumFractionDigits: 4 });
+      },
+      percent(value) {
+        if (value === null || value === undefined || value === '') {
+          return '-';
+        }
+        const n = Number(value);
+        return isNaN(n) ? '-' : `${n.toFixed(2)}%`;
+      },
+      cleanWhere(where) {
+        const params = normalizePeriodWhere(where || {});
+        ['costCenter', 'workshopName'].forEach((key) => {
+          if (params[key] === '' || params[key] === undefined) {
+            delete params[key];
+          }
+        });
+        return params;
+      },
+      datasource({ page, limit, where, order }) {
+        const params = this.cleanWhere(where);
+        this.searchParams = params;
+        return pageWorkshopSummary({
+          ...params,
+          ...order,
+          pageNum: page,
+          size: limit
+        });
+      },
+      reload(where) {
+        const params = this.cleanWhere(where);
+        this.searchParams = params;
+        this.loadSummary(params);
+        this.$refs.table.reload({ page: 1, where });
+      },
+      async loadSummary(params) {
+        try {
+          this.summary = (await summaryWorkshopSummary(params)) || {};
+        } catch (e) {
+          this.$message.error(e.message || '汇总加载失败');
+        }
+      },
+      async doExport() {
+        this.exporting = true;
+        try {
+          await exportWorkshopSummary({ ...this.searchParams });
+        } catch (e) {
+          this.$message.error(e.message || '导出失败');
+        } finally {
+          this.exporting = false;
+        }
+      },
+      async openNote() {
+        try {
+          this.detail =
+            (await detailWorkshopSummary({
+              periodStart: this.searchParams.periodStart,
+              periodEnd: this.searchParams.periodEnd
+            })) || {};
+          this.detailVisible = true;
+        } catch (e) {
+          this.$message.error(e.message || '核算口径加载失败');
+        }
+      }
+    }
+  };
+</script>
+
+<style scoped>
+  .cost-report-card {
+    padding: 14px 16px;
+    border: 1px solid #ebeef5;
+    border-radius: 4px;
+    background: #fafafa;
+  }
+  .cost-report-card-label {
+    font-size: 13px;
+    color: #909399;
+  }
+  .cost-report-card-value {
+    margin-top: 8px;
+    font-size: 22px;
+    font-weight: 600;
+    color: #303133;
+  }
+  .cost-report-chart-title,
+  .cost-report-dialog-title {
+    font-size: 13px;
+    font-weight: 600;
+    color: #606266;
+    margin-bottom: 6px;
+  }
+  .cost-report-note {
+    margin-top: 12px;
+    font-size: 12px;
+    line-height: 1.8;
+    color: #909399;
+  }
+  .cost-report-formula {
+    padding: 10px 12px;
+    border: 1px solid #ebeef5;
+    border-radius: 4px;
+    background: #fafafa;
+    font-size: 12px;
+    line-height: 1.9;
+    color: #606266;
+    white-space: pre-line;
+  }
+</style>