|
|
@@ -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>
|