2026-03-18 15:41:09 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="app-container" v-loading="loading">
|
|
|
|
|
|
<el-row>
|
|
|
|
|
|
<el-form label-width="80px" inline>
|
|
|
|
|
|
<el-form-item label="日期" prop="date">
|
|
|
|
|
|
<el-date-picker style="width: 200px;" v-model="queryParams.date" type="month" value-format="yyyy-MM"
|
|
|
|
|
|
placeholder="选择日期" @change="handleDateChange"></el-date-picker>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="入场钢卷号" prop="enterCoilNo">
|
|
|
|
|
|
<el-input style="width: 200px; display: inline-block;" v-model="queryParams.enterCoilNo"
|
|
|
|
|
|
placeholder="请输入入场钢卷号" clearable @keyup.enter.native="handleQuery" />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="当前钢卷号" prop="currentCoilNo">
|
|
|
|
|
|
<el-input style="width: 200px;" v-model="queryParams.currentCoilNo" placeholder="请输入当前钢卷号" clearable
|
|
|
|
|
|
@keyup.enter.native="handleQuery" />
|
|
|
|
|
|
</el-form-item>
|
2026-05-19 16:42:16 +08:00
|
|
|
|
<!-- <el-form-item label="逻辑库位" prop="warehouseIds">
|
2026-03-18 15:41:09 +08:00
|
|
|
|
<el-select v-model="warehouseIds" collapse-tags multiple placeholder="请选择逻辑库位" style="width: 200px;">
|
|
|
|
|
|
<el-option v-for="item in warehouseOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
|
|
|
|
</el-select>
|
2026-05-19 16:42:16 +08:00
|
|
|
|
</el-form-item> -->
|
|
|
|
|
|
<el-form-item label="逻辑库位" prop="warehouseId">
|
|
|
|
|
|
<warehouse-select v-model="queryParams.warehouseId" placeholder="请选择仓库/库区/库位"
|
|
|
|
|
|
style="width: 100%; display: inline-block; width: 200px;" clearable />
|
2026-03-18 15:41:09 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="产品名称" prop="itemName">
|
|
|
|
|
|
<el-input style="width: 200px;" v-model="queryParams.itemName" placeholder="请输入产品名称" clearable
|
|
|
|
|
|
@keyup.enter.native="handleQuery" />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="规格" prop="itemSpecification">
|
|
|
|
|
|
<memo-input style="width: 200px;" v-model="queryParams.itemSpecification" storageKey="coilSpec"
|
|
|
|
|
|
placeholder="请选择规格" clearable @keyup.enter.native="handleQuery" />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="材质" prop="itemMaterial">
|
2026-04-02 09:10:58 +08:00
|
|
|
|
<dict-select style="width: 200px;" v-model="queryParams.itemMaterial" dict-type="coil_material"
|
|
|
|
|
|
placeholder="请选择材质" clearable @keyup.enter.native="handleQuery" multiple />
|
2026-03-18 15:41:09 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="厂家" prop="itemManufacturer">
|
2026-04-02 09:10:58 +08:00
|
|
|
|
<dict-select style="width: 200px;" v-model="queryParams.itemManufacturer" dict-type="coil_manufacturer"
|
|
|
|
|
|
placeholder="请选择厂家" clearable @keyup.enter.native="handleQuery" multiple />
|
2026-03-18 15:41:09 +08:00
|
|
|
|
</el-form-item>
|
2026-05-19 16:42:16 +08:00
|
|
|
|
<el-form-item label="品质" prop="qualityStatusCsv">
|
|
|
|
|
|
<muti-select v-model="queryParams.qualityStatusCsv" :options="dict.type.coil_quality_status"
|
|
|
|
|
|
placeholder="请选择品质" clearable @keyup.enter.native="handleQuery" multiple />
|
|
|
|
|
|
</el-form-item>
|
2026-03-18 15:41:09 +08:00
|
|
|
|
<el-form-item>
|
|
|
|
|
|
<el-button type="primary" @click="handleQuery">查询</el-button>
|
|
|
|
|
|
<el-button type="primary" @click="exportData">导出产出钢卷</el-button>
|
|
|
|
|
|
<el-button type="primary" @click="exportLossData">导出消耗钢卷</el-button>
|
2026-03-19 15:08:04 +08:00
|
|
|
|
<el-button type="primary" @click="settingVisible = true">列设置</el-button>
|
2026-04-11 15:36:50 +08:00
|
|
|
|
<el-button type="primary" @click="saveOutputReport">保存产出报表</el-button>
|
|
|
|
|
|
<el-button type="primary" @click="saveLossReport">保存消耗报表</el-button>
|
2026-03-18 15:41:09 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
|
2026-03-31 18:37:17 +08:00
|
|
|
|
<el-descriptions title="统计信息" :column="3" border>
|
2026-03-18 15:41:09 +08:00
|
|
|
|
<el-descriptions-item label="产出数量">{{ summary.outCount }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="产出总重">{{ summary.outTotalWeight }}t</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="产出均重">{{ summary.outAvgWeight }}t</el-descriptions-item>
|
|
|
|
|
|
|
|
|
|
|
|
<el-descriptions-item label="消耗数量">{{ summary.lossCount }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="消耗总重">{{ summary.lossTotalWeight }}t</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="消耗均重">{{ summary.lossAvgWeight }}t</el-descriptions-item>
|
|
|
|
|
|
|
2026-03-31 18:37:17 +08:00
|
|
|
|
<el-descriptions-item label="数量差值">{{ summary.countDiff }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="总重差值">{{ summary.weightDiff }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="均重差值">{{ summary.avgWeightDiff }}t</el-descriptions-item>
|
|
|
|
|
|
<!-- <el-descriptions-item label="合计均重">{{ summary.totalAvgWeight }}t</el-descriptions-item> -->
|
2026-03-18 15:41:09 +08:00
|
|
|
|
|
|
|
|
|
|
<!-- 成品率 -->
|
|
|
|
|
|
<el-descriptions-item label="成品率">{{ summary.passRate }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="损耗率">{{ summary.lossRate }}</el-descriptions-item>
|
|
|
|
|
|
<!-- 异常率 -->
|
|
|
|
|
|
<el-descriptions-item label="异常率">{{ summary.abRate }}</el-descriptions-item>
|
2026-03-20 10:33:51 +08:00
|
|
|
|
<!-- 正品率 -->
|
|
|
|
|
|
<el-descriptions-item label="正品率">{{ summary.passRate2 }}</el-descriptions-item>
|
2026-03-18 15:41:09 +08:00
|
|
|
|
</el-descriptions>
|
|
|
|
|
|
|
2026-03-20 13:34:56 +08:00
|
|
|
|
<!-- 已处理M统计信息 -->
|
|
|
|
|
|
<el-descriptions title="已处理M统计信息" :column="3" border>
|
|
|
|
|
|
<el-descriptions-item label="产出数量">{{ mSummary.outCount }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="产出总重">{{ mSummary.outTotalWeight }}t</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="产出均重">{{ mSummary.outAvgWeight }}t</el-descriptions-item>
|
|
|
|
|
|
|
|
|
|
|
|
<el-descriptions-item label="消耗数量">{{ mSummary.lossCount }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="消耗总重">{{ mSummary.lossTotalWeight }}t</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="消耗均重">{{ mSummary.lossAvgWeight }}t</el-descriptions-item>
|
|
|
|
|
|
|
2026-03-31 18:37:17 +08:00
|
|
|
|
<el-descriptions-item label="数量差值">{{ mSummary.countDiff }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="总重差值">{{ mSummary.weightDiff }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="均重差值">{{ mSummary.avgWeightDiff }}t</el-descriptions-item>
|
2026-03-20 13:34:56 +08:00
|
|
|
|
<!-- 成品率 -->
|
|
|
|
|
|
<el-descriptions-item label="成品率">{{ mSummary.passRate }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="损耗率">{{ mSummary.lossRate }}</el-descriptions-item>
|
|
|
|
|
|
<!-- 异常率 -->
|
|
|
|
|
|
<el-descriptions-item label="异常率">{{ mSummary.abRate }}</el-descriptions-item>
|
|
|
|
|
|
<!-- 正品率 -->
|
|
|
|
|
|
<el-descriptions-item label="正品率">{{ mSummary.passRate2 }}</el-descriptions-item>
|
|
|
|
|
|
</el-descriptions>
|
|
|
|
|
|
|
2026-03-18 15:41:09 +08:00
|
|
|
|
<!-- 异常统计 -->
|
|
|
|
|
|
<el-descriptions title="异常统计" :column="4" border>
|
|
|
|
|
|
<el-descriptions-item v-for="item in abSummary" :key="item.label" :label="item.label">{{ item.value
|
2026-03-27 16:37:59 +08:00
|
|
|
|
}}</el-descriptions-item>
|
2026-03-18 15:41:09 +08:00
|
|
|
|
</el-descriptions>
|
|
|
|
|
|
|
2026-04-15 14:07:42 +08:00
|
|
|
|
<!-- 月视图日数据折线图 -->
|
|
|
|
|
|
<div style="margin-top: 20px; height: 400px;">
|
|
|
|
|
|
<el-card>
|
|
|
|
|
|
<template slot="header">
|
|
|
|
|
|
<div class="clearfix">
|
|
|
|
|
|
<span>日数据趋势</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<div ref="monthChart" style="width: 100%; height: 350px;"></div>
|
|
|
|
|
|
</el-card>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2026-04-13 16:23:40 +08:00
|
|
|
|
<!-- 分条信息统计 -->
|
2026-04-15 14:07:42 +08:00
|
|
|
|
<split-summary v-if="productionLine == '分条线'" :origin-outputlist="list" :origin-loss-list="lossList" :common-coil-ids="commonCoilIds"></split-summary>
|
2026-04-13 16:23:40 +08:00
|
|
|
|
|
2026-03-18 15:41:09 +08:00
|
|
|
|
<el-descriptions title="明细信息" :column="3" border>
|
|
|
|
|
|
</el-descriptions>
|
|
|
|
|
|
<el-tabs v-model="activeTab">
|
|
|
|
|
|
<el-tab-pane label="产出钢卷" name="output">
|
2026-04-13 16:23:40 +08:00
|
|
|
|
<coil-table :columns="outputColumns" :data="list" :highlight-config="{ rows: commonCoilIds }"></coil-table>
|
2026-03-18 15:41:09 +08:00
|
|
|
|
</el-tab-pane>
|
2026-03-20 13:34:56 +08:00
|
|
|
|
<el-tab-pane label="投入钢卷" name="loss">
|
2026-04-13 16:23:40 +08:00
|
|
|
|
<coil-table :columns="lossColumns" :data="lossList" :highlight-config="{ rows: commonCoilIds }"></coil-table>
|
2026-03-20 13:34:56 +08:00
|
|
|
|
</el-tab-pane>
|
2026-03-18 15:41:09 +08:00
|
|
|
|
</el-tabs>
|
|
|
|
|
|
|
2026-03-19 15:08:04 +08:00
|
|
|
|
<el-dialog title="列设置" :visible.sync="settingVisible" width="50%">
|
|
|
|
|
|
<el-radio-group v-model="activeColumnConfig">
|
|
|
|
|
|
<el-radio-button label="coil-report-loss">投入明细配置</el-radio-button>
|
|
|
|
|
|
<el-radio-button label="coil-report-output">产出明细配置</el-radio-button>
|
|
|
|
|
|
</el-radio-group>
|
|
|
|
|
|
<columns-setting :reportType="activeColumnConfig"></columns-setting>
|
|
|
|
|
|
</el-dialog>
|
2026-03-18 15:41:09 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
import ProductInfo from "@/components/KLPService/Renderer/ProductInfo";
|
|
|
|
|
|
import RawMaterialInfo from "@/components/KLPService/Renderer/RawMaterialInfo";
|
|
|
|
|
|
import CoilNo from "@/components/KLPService/Renderer/CoilNo.vue";
|
|
|
|
|
|
import MemoInput from "@/components/MemoInput";
|
|
|
|
|
|
import MutiSelect from "@/components/MutiSelect";
|
|
|
|
|
|
import WarehouseSelect from "@/components/KLPService/WarehouseSelect";
|
2026-03-20 13:34:56 +08:00
|
|
|
|
import { calcSummary, calcAbSummary, calcMSummary } from "@/views/wms/report/js/calc";
|
2026-03-19 15:08:04 +08:00
|
|
|
|
import ColumnsSetting from "@/views/wms/report/components/setting/columns.vue";
|
|
|
|
|
|
import CoilTable from "@/views/wms/report/components/coilTable/index.vue";
|
2026-04-13 16:23:40 +08:00
|
|
|
|
import SplitSummary from "@/views/wms/report/components/summary/splitSummary.vue";
|
2026-03-27 16:37:59 +08:00
|
|
|
|
import { fetchLossList, fetchOutputList } from "@/views/wms/report/js/fetch";
|
2026-04-11 15:36:50 +08:00
|
|
|
|
import { saveReportFile } from "@/views/wms/report/js/reportFile";
|
2026-04-15 14:07:42 +08:00
|
|
|
|
import * as echarts from 'echarts';
|
2026-03-18 15:41:09 +08:00
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
|
name: 'MonthTemplate',
|
|
|
|
|
|
components: {
|
|
|
|
|
|
ProductInfo,
|
|
|
|
|
|
RawMaterialInfo,
|
|
|
|
|
|
CoilNo,
|
|
|
|
|
|
MemoInput,
|
|
|
|
|
|
MutiSelect,
|
|
|
|
|
|
WarehouseSelect,
|
2026-03-19 15:08:04 +08:00
|
|
|
|
ColumnsSetting,
|
|
|
|
|
|
CoilTable,
|
2026-04-13 16:23:40 +08:00
|
|
|
|
SplitSummary,
|
2026-03-18 15:41:09 +08:00
|
|
|
|
},
|
|
|
|
|
|
props: {
|
|
|
|
|
|
actionTypes: {
|
|
|
|
|
|
type: Array,
|
|
|
|
|
|
default: () => [],
|
|
|
|
|
|
},
|
|
|
|
|
|
actionQueryParams: {
|
|
|
|
|
|
type: Object,
|
|
|
|
|
|
default: () => { },
|
|
|
|
|
|
},
|
|
|
|
|
|
baseQueryParams: {
|
|
|
|
|
|
type: Object,
|
|
|
|
|
|
default: () => ({})
|
|
|
|
|
|
},
|
|
|
|
|
|
warehouseOptions: {
|
|
|
|
|
|
type: Array,
|
|
|
|
|
|
default: () => []
|
2026-04-11 15:36:50 +08:00
|
|
|
|
},
|
|
|
|
|
|
productionLine: {
|
|
|
|
|
|
type: String,
|
|
|
|
|
|
default: '',
|
|
|
|
|
|
},
|
2026-03-18 15:41:09 +08:00
|
|
|
|
},
|
2026-05-19 16:42:16 +08:00
|
|
|
|
dicts: ['product_coil_status', 'coil_material', 'coil_itemname', 'coil_manufacturer', 'coil_quality_status'],
|
2026-03-18 15:41:09 +08:00
|
|
|
|
data() {
|
|
|
|
|
|
// 工具函数:个位数补零
|
|
|
|
|
|
const addZero = (num) => num.toString().padStart(2, '0')
|
|
|
|
|
|
|
|
|
|
|
|
// 获取当前日期(默认选中当天)
|
|
|
|
|
|
const now = new Date()
|
|
|
|
|
|
const currentDate = `${now.getFullYear()}-${addZero(now.getMonth() + 1)}`
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 生成指定日期/月份的时间范围字符串
|
|
|
|
|
|
* @param {string} dateStr - 支持格式:yyyy-MM(月份) 或 yyyy-MM-dd(具体日期)
|
|
|
|
|
|
* @returns {object} 包含start(开始时间)和end(结束时间)的对象
|
|
|
|
|
|
*/
|
|
|
|
|
|
const getDayTimeRange = (dateStr) => {
|
|
|
|
|
|
// 先校验输入格式是否合法
|
|
|
|
|
|
const monthPattern = /^\d{4}-\d{2}$/; // yyyy-MM 正则
|
|
|
|
|
|
const dayPattern = /^\d{4}-\d{2}-\d{2}$/; // yyyy-MM-dd 正则
|
|
|
|
|
|
|
|
|
|
|
|
if (!monthPattern.test(dateStr) && !dayPattern.test(dateStr)) {
|
|
|
|
|
|
throw new Error('输入格式错误,请传入 yyyy-MM 或 yyyy-MM-dd 格式的字符串');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let startDate, endDate;
|
|
|
|
|
|
|
|
|
|
|
|
if (monthPattern.test(dateStr)) {
|
|
|
|
|
|
// 处理 yyyy-MM 格式:获取本月第一天和最后一天
|
|
|
|
|
|
const [year, month] = dateStr.split('-').map(Number);
|
|
|
|
|
|
// 月份是0基的(0=1月,1=2月...),所以要减1
|
|
|
|
|
|
// 第一天:yyyy-MM-01
|
|
|
|
|
|
startDate = `${dateStr}-01`;
|
|
|
|
|
|
// 最后一天:通过 new Date(year, month, 0) 计算(month是原始月份,比如2代表2月,传2则取3月0日=2月最后一天)
|
|
|
|
|
|
const lastDayOfMonth = new Date(year, month, 0).getDate();
|
|
|
|
|
|
endDate = `${dateStr}-${lastDayOfMonth.toString().padStart(2, '0')}`;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 处理 yyyy-MM-dd 格式:直接使用传入的日期
|
|
|
|
|
|
startDate = dateStr;
|
|
|
|
|
|
endDate = dateStr;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 拼接时间部分
|
|
|
|
|
|
return {
|
|
|
|
|
|
start: `${startDate} 00:00:00`,
|
|
|
|
|
|
end: `${endDate} 23:59:59`
|
|
|
|
|
|
};
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const { start, end } = getDayTimeRange(currentDate)
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
2026-03-20 13:34:56 +08:00
|
|
|
|
activeTab: 'output',
|
2026-03-19 15:08:04 +08:00
|
|
|
|
activeColumnConfig: 'coil-report-loss',
|
|
|
|
|
|
settingVisible: false,
|
2026-03-18 15:41:09 +08:00
|
|
|
|
list: [],
|
|
|
|
|
|
lossList: [],
|
|
|
|
|
|
queryParams: {
|
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
|
pageSize: 9999,
|
|
|
|
|
|
date: currentDate, // 绑定日期选择器的默认值(当天)
|
|
|
|
|
|
byCreateTimeStart: start, // 默认当天0点
|
|
|
|
|
|
byCreateTimeEnd: end, // 默认当天23:59:59
|
|
|
|
|
|
enterCoilNo: '',
|
|
|
|
|
|
currentCoilNo: '',
|
|
|
|
|
|
warehouseId: '',
|
|
|
|
|
|
itemName: '', // 修正原代码的productName为itemName(和表单绑定一致)
|
|
|
|
|
|
itemSpecification: '',
|
|
|
|
|
|
itemMaterial: '',
|
|
|
|
|
|
itemManufacturer: '',
|
|
|
|
|
|
},
|
|
|
|
|
|
loading: false,
|
|
|
|
|
|
warehouseIds: [
|
|
|
|
|
|
'1988150099140866050',
|
|
|
|
|
|
'1988150263284953089',
|
|
|
|
|
|
'1988150545175736322',
|
|
|
|
|
|
'1988150150521090049',
|
|
|
|
|
|
'2019583656787259393',
|
|
|
|
|
|
'2019583325311414274',
|
|
|
|
|
|
'2019583429955104769',
|
|
|
|
|
|
'2019583137616310273',
|
|
|
|
|
|
],
|
2026-03-19 15:08:04 +08:00
|
|
|
|
getDayTimeRange, // 挂载时间范围生成函数
|
|
|
|
|
|
|
|
|
|
|
|
lossColumns: [],
|
|
|
|
|
|
outputColumns: [],
|
2026-03-30 14:34:51 +08:00
|
|
|
|
|
|
|
|
|
|
actionIds: '',
|
2026-04-15 14:07:42 +08:00
|
|
|
|
// 折线图实例
|
|
|
|
|
|
monthChart: null,
|
2026-03-18 15:41:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
warehouseOptions: {
|
|
|
|
|
|
handler(newVal, oldVal) {
|
|
|
|
|
|
if (newVal !== oldVal) {
|
|
|
|
|
|
this.warehouseIds = newVal.map(item => item.value)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
computed: {
|
|
|
|
|
|
summary() {
|
|
|
|
|
|
return calcSummary(this.list, this.lossList)
|
|
|
|
|
|
},
|
|
|
|
|
|
abSummary() {
|
|
|
|
|
|
return calcAbSummary(this.list)
|
2026-03-20 13:34:56 +08:00
|
|
|
|
},
|
|
|
|
|
|
mSummary() {
|
|
|
|
|
|
return calcMSummary(this.list, this.lossList)
|
2026-04-13 16:23:40 +08:00
|
|
|
|
},
|
|
|
|
|
|
// 找出list和lossList中id相同的卷
|
|
|
|
|
|
commonCoilIds() {
|
|
|
|
|
|
if (this.productionLine !== '分条线') {
|
|
|
|
|
|
return []
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取list中的coilId集合
|
|
|
|
|
|
const outputCoilIds = new Set(this.list.map(item => item.coilId))
|
|
|
|
|
|
// 获取lossList中的coilId集合
|
|
|
|
|
|
const lossCoilIds = new Set(this.lossList.map(item => item.coilId))
|
|
|
|
|
|
|
|
|
|
|
|
// 找出两个集合中相同的coilId
|
|
|
|
|
|
const commonIds = []
|
|
|
|
|
|
outputCoilIds.forEach(id => {
|
|
|
|
|
|
if (lossCoilIds.has(id)) {
|
|
|
|
|
|
commonIds.push(id)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
return commonIds
|
|
|
|
|
|
},
|
2026-03-18 15:41:09 +08:00
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2026-03-19 15:08:04 +08:00
|
|
|
|
// 加载列设置
|
|
|
|
|
|
loadColumns() {
|
|
|
|
|
|
this.lossColumns = JSON.parse(localStorage.getItem('preference-tableColumns-coil-report-loss') || '[]') || []
|
|
|
|
|
|
this.outputColumns = JSON.parse(localStorage.getItem('preference-tableColumns-coil-report-output') || '[]') || []
|
|
|
|
|
|
},
|
2026-03-18 15:41:09 +08:00
|
|
|
|
// 日期变更处理:更新开始/结束时间
|
|
|
|
|
|
handleDateChange(date) {
|
|
|
|
|
|
if (!date) return
|
|
|
|
|
|
const { start, end } = this.getDayTimeRange(date)
|
|
|
|
|
|
this.queryParams.byCreateTimeStart = start
|
|
|
|
|
|
this.queryParams.byCreateTimeEnd = end
|
|
|
|
|
|
// 日期变更后自动查询
|
|
|
|
|
|
this.handleQuery()
|
|
|
|
|
|
},
|
|
|
|
|
|
// 统一查询入口(兼容回车和按钮点击)
|
|
|
|
|
|
handleQuery() {
|
2026-03-25 09:04:48 +08:00
|
|
|
|
this.fetchData()
|
2026-03-18 15:41:09 +08:00
|
|
|
|
},
|
|
|
|
|
|
// 导出
|
|
|
|
|
|
exportData() {
|
|
|
|
|
|
if (this.list.length === 0) {
|
|
|
|
|
|
this.$message.warning('暂无数据可导出')
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
this.download('wms/materialCoil/export', {
|
|
|
|
|
|
coilIds: this.list.map(item => item.coilId).join(',')
|
|
|
|
|
|
}, `materialCoil_${this.queryParams.date}_${new Date().getTime()}.xlsx`)
|
|
|
|
|
|
},
|
|
|
|
|
|
exportLossData() {
|
|
|
|
|
|
if (this.lossList.length === 0) {
|
|
|
|
|
|
this.$message.warning('暂无数据可导出')
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
this.download('wms/materialCoil/export', {
|
2026-03-30 14:34:51 +08:00
|
|
|
|
// coilIds: this.lossList.map(item => item.coilId).join(',')
|
|
|
|
|
|
actionIds: this.actionIds
|
2026-03-18 15:41:09 +08:00
|
|
|
|
}, `materialCoil_${this.queryParams.date}_${new Date().getTime()}.xlsx`)
|
|
|
|
|
|
},
|
2026-04-11 15:36:50 +08:00
|
|
|
|
// 保存产出报表
|
|
|
|
|
|
saveOutputReport() {
|
|
|
|
|
|
this.loading = true
|
|
|
|
|
|
saveReportFile(this.list.map(item => item.coilId).join(','), {
|
|
|
|
|
|
reportParams: this.queryParams,
|
|
|
|
|
|
reportType: '产出报表,月报表',
|
|
|
|
|
|
productionLine: this.productionLine,
|
|
|
|
|
|
}).then(res => {
|
|
|
|
|
|
this.$message({
|
|
|
|
|
|
message: '保存成功',
|
|
|
|
|
|
type: 'success',
|
|
|
|
|
|
})
|
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
|
this.$message({
|
|
|
|
|
|
message: '保存失败',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
|
this.loading = false
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
// 保存消耗报表
|
|
|
|
|
|
saveLossReport() {
|
|
|
|
|
|
this.loading = true
|
|
|
|
|
|
saveReportFile(this.lossList.map(item => item.coilId).join(','), {
|
|
|
|
|
|
reportParams: this.queryParams,
|
|
|
|
|
|
reportType: '消耗报表,月报表',
|
|
|
|
|
|
productionLine: this.productionLine,
|
|
|
|
|
|
}).then(res => {
|
|
|
|
|
|
this.$message({
|
|
|
|
|
|
message: '保存成功',
|
|
|
|
|
|
type: 'success',
|
|
|
|
|
|
})
|
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
|
this.$message({
|
|
|
|
|
|
message: '保存失败',
|
|
|
|
|
|
type: 'error',
|
|
|
|
|
|
})
|
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
|
this.loading = false
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2026-03-25 09:04:48 +08:00
|
|
|
|
fetchData() {
|
|
|
|
|
|
this.loading = true
|
|
|
|
|
|
Promise.all([
|
2026-03-27 16:37:59 +08:00
|
|
|
|
fetchLossList(this.actionTypes, {
|
|
|
|
|
|
...this.queryParams,
|
|
|
|
|
|
...this.actionQueryParams
|
2026-03-30 14:34:51 +08:00
|
|
|
|
}, (ids) => { this.actionIds = ids }),
|
2026-03-27 16:37:59 +08:00
|
|
|
|
fetchOutputList({
|
|
|
|
|
|
...this.queryParams,
|
|
|
|
|
|
...this.baseQueryParams,
|
2026-05-19 16:57:42 +08:00
|
|
|
|
// warehouseIds: this.warehouseIds.join(','),
|
2026-03-27 16:37:59 +08:00
|
|
|
|
}),
|
|
|
|
|
|
]).then(([lossList, outputList]) => {
|
|
|
|
|
|
this.lossList = lossList
|
|
|
|
|
|
this.list = outputList
|
2026-04-15 14:07:42 +08:00
|
|
|
|
this.initMonthChart()
|
2026-03-25 09:04:48 +08:00
|
|
|
|
this.loading = false
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2026-04-15 14:07:42 +08:00
|
|
|
|
// 初始化月视图折线图
|
|
|
|
|
|
initMonthChart() {
|
|
|
|
|
|
if (!this.$refs.monthChart) return
|
|
|
|
|
|
|
|
|
|
|
|
// 销毁旧的图表实例
|
|
|
|
|
|
if (this.monthChart) {
|
|
|
|
|
|
this.monthChart.dispose()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 创建新的图表实例
|
|
|
|
|
|
this.monthChart = echarts.init(this.$refs.monthChart)
|
|
|
|
|
|
|
|
|
|
|
|
// 处理数据,按日期分组
|
|
|
|
|
|
const dailyData = {}
|
|
|
|
|
|
this.list.forEach(item => {
|
|
|
|
|
|
const date = item.createTime.split(' ')[0]
|
|
|
|
|
|
if (!dailyData[date]) {
|
|
|
|
|
|
dailyData[date] = {
|
|
|
|
|
|
outCount: 0,
|
|
|
|
|
|
outTotalWeight: 0,
|
|
|
|
|
|
lossCount: 0,
|
|
|
|
|
|
lossTotalWeight: 0,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
dailyData[date].outCount++
|
|
|
|
|
|
dailyData[date].outTotalWeight += parseFloat(item.netWeight) || 0
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
this.lossList.forEach(item => {
|
|
|
|
|
|
const date = item.actionCompleteTime?.split(' ')[0]
|
|
|
|
|
|
if (!dailyData[date]) {
|
|
|
|
|
|
dailyData[date] = {
|
|
|
|
|
|
outCount: 0,
|
|
|
|
|
|
outTotalWeight: 0,
|
|
|
|
|
|
lossCount: 0,
|
|
|
|
|
|
lossTotalWeight: 0,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
dailyData[date].lossCount++
|
|
|
|
|
|
dailyData[date].lossTotalWeight += parseFloat(item.netWeight) || 0
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// 生成日期数组和数据数组
|
|
|
|
|
|
const dates = Object.keys(dailyData).sort()
|
|
|
|
|
|
const outCountData = dates.map(date => dailyData[date].outCount)
|
|
|
|
|
|
const outTotalWeightData = dates.map(date => dailyData[date].outTotalWeight.toFixed(2))
|
|
|
|
|
|
const lossCountData = dates.map(date => dailyData[date].lossCount)
|
|
|
|
|
|
const lossTotalWeightData = dates.map(date => dailyData[date].lossTotalWeight.toFixed(2))
|
|
|
|
|
|
|
|
|
|
|
|
// 配置项
|
|
|
|
|
|
const option = {
|
|
|
|
|
|
tooltip: {
|
|
|
|
|
|
trigger: 'axis',
|
|
|
|
|
|
axisPointer: {
|
|
|
|
|
|
type: 'cross',
|
|
|
|
|
|
label: {
|
|
|
|
|
|
backgroundColor: '#6a7985'
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
legend: {
|
|
|
|
|
|
data: ['产出数量', '产出总重', '消耗数量', '消耗总重']
|
|
|
|
|
|
},
|
|
|
|
|
|
grid: {
|
|
|
|
|
|
left: '3%',
|
|
|
|
|
|
right: '4%',
|
|
|
|
|
|
bottom: '3%',
|
|
|
|
|
|
containLabel: true
|
|
|
|
|
|
},
|
|
|
|
|
|
xAxis: [
|
|
|
|
|
|
{
|
|
|
|
|
|
type: 'category',
|
|
|
|
|
|
boundaryGap: false,
|
|
|
|
|
|
data: dates
|
|
|
|
|
|
}
|
|
|
|
|
|
],
|
|
|
|
|
|
yAxis: [
|
|
|
|
|
|
{
|
|
|
|
|
|
type: 'value',
|
|
|
|
|
|
name: '数量',
|
|
|
|
|
|
position: 'left',
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
type: 'value',
|
|
|
|
|
|
name: '重量(t)',
|
|
|
|
|
|
position: 'right',
|
|
|
|
|
|
}
|
|
|
|
|
|
],
|
|
|
|
|
|
series: [
|
|
|
|
|
|
{
|
|
|
|
|
|
name: '产出数量',
|
|
|
|
|
|
type: 'line',
|
|
|
|
|
|
data: outCountData,
|
|
|
|
|
|
yAxisIndex: 0,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: '产出总重',
|
|
|
|
|
|
type: 'line',
|
|
|
|
|
|
data: outTotalWeightData,
|
|
|
|
|
|
yAxisIndex: 1,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: '消耗数量',
|
|
|
|
|
|
type: 'line',
|
|
|
|
|
|
data: lossCountData,
|
|
|
|
|
|
yAxisIndex: 0,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: '消耗总重',
|
|
|
|
|
|
type: 'line',
|
|
|
|
|
|
data: lossTotalWeightData,
|
|
|
|
|
|
yAxisIndex: 1,
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 应用配置项
|
|
|
|
|
|
this.monthChart.setOption(option)
|
|
|
|
|
|
|
|
|
|
|
|
// 监听窗口大小变化
|
|
|
|
|
|
window.addEventListener('resize', () => {
|
|
|
|
|
|
this.monthChart.resize()
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2026-03-18 15:41:09 +08:00
|
|
|
|
},
|
|
|
|
|
|
mounted() {
|
2026-03-19 15:08:04 +08:00
|
|
|
|
this.loadColumns()
|
2026-03-25 09:04:48 +08:00
|
|
|
|
this.fetchData()
|
2026-03-18 15:41:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped></style>
|