feat(报表): 添加月视图折线图并优化分条线显示逻辑
添加月视图日数据趋势折线图展示产出和消耗数据 优化分条信息统计组件仅在分条线时显示 在日视图中添加昨日数据对比显示 重构日期选择逻辑支持多种视图模式
This commit is contained in:
@@ -1,15 +1,39 @@
|
||||
<template>
|
||||
<div class="app-container" v-loading="loading">
|
||||
<!-- 对日期的筛选另起一行 -->
|
||||
<div style="margin-bottom: 10px;">
|
||||
<!-- 单选按钮,用于切换视图,可以使用日视图、月视图、年视图、自定义, 默认使用自定义日期 -->
|
||||
<!-- 日视图时选择一天, 月视图时选择一个月, 年视图时选择一年, 自定义时选择自定义时间范围 -->
|
||||
<el-radio-group v-model="viewType" @change="handleViewTypeChange">
|
||||
<el-radio-button label="day">日视图</el-radio-button>
|
||||
<el-radio-button label="month">月视图</el-radio-button>
|
||||
<el-radio-button label="year">年视图</el-radio-button>
|
||||
<el-radio-button label="custom">自定义</el-radio-button>
|
||||
</el-radio-group>
|
||||
|
||||
<!-- 日视图日期选择器 -->
|
||||
<el-date-picker v-if="viewType === 'day'" style="width: 200px; margin-left: 10px;" v-model="dayDate" type="date"
|
||||
value-format="yyyy-MM-dd" placeholder="选择日期" @change="handleDayDateChange" />
|
||||
|
||||
<!-- 月视图日期选择器 -->
|
||||
<el-date-picker v-if="viewType === 'month'" style="width: 200px; margin-left: 10px;" v-model="monthDate"
|
||||
type="month" value-format="yyyy-MM" placeholder="选择月份" @change="handleMonthDateChange" />
|
||||
|
||||
<!-- 年视图日期选择器 -->
|
||||
<el-date-picker v-if="viewType === 'year'" style="width: 200px; margin-left: 10px;" v-model="yearDate" type="year"
|
||||
value-format="yyyy" placeholder="选择年份" @change="handleYearDateChange" />
|
||||
|
||||
<!-- 自定义日期选择器 -->
|
||||
<span v-if="viewType === 'custom'" style="margin-left: 10px;">
|
||||
<el-date-picker style="width: 200px;" v-model="queryParams.byCreateTimeStart"
|
||||
type="date" value-format="yyyy-MM-dd" placeholder="选择开始日期"></el-date-picker>
|
||||
至
|
||||
<el-date-picker style="width: 200px;" v-model="queryParams.byCreateTimeEnd"
|
||||
type="date" value-format="yyyy-MM-dd" placeholder="选择结束日期"></el-date-picker>
|
||||
</span>
|
||||
</div>
|
||||
<el-row>
|
||||
<el-form label-width="80px" inline>
|
||||
<el-form-item label="开始时间" prop="startDate">
|
||||
<el-date-picker style="width: 200px;" v-model="queryParams.byCreateTimeStart" type="date" value-format="yyyy-MM-dd"
|
||||
placeholder="选择开始日期" @change="handleDateChange"></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="结束时间" prop="endDate">
|
||||
<el-date-picker style="width: 200px;" v-model="queryParams.byCreateTimeEnd" type="date" value-format="yyyy-MM-dd"
|
||||
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" />
|
||||
@@ -36,7 +60,8 @@
|
||||
placeholder="请选择材质" clearable multiple />
|
||||
</el-form-item>
|
||||
<el-form-item label="厂家" prop="itemManufacturer">
|
||||
<dict-select style="width: 200px;" v-model="queryParams.itemManufacturer" dictType="coil_manufacturer" placeholder="请选择厂家" clearable multiple />
|
||||
<dict-select style="width: 200px;" v-model="queryParams.itemManufacturer" dictType="coil_manufacturer"
|
||||
placeholder="请选择厂家" clearable multiple />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleQuery">查询</el-button>
|
||||
@@ -50,26 +75,26 @@
|
||||
</el-row>
|
||||
|
||||
<el-descriptions title="统计信息" :column="3" border>
|
||||
<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.outCount }}<span v-if="viewType === 'day' && yesterdaySummary.outCount" style="margin-left: 10px; font-size: 12px; color: #999;">(昨日: {{ yesterdaySummary.outCount }})</span></el-descriptions-item>
|
||||
<el-descriptions-item label="产出总重">{{ summary.outTotalWeight }}t<span v-if="viewType === 'day' && yesterdaySummary.outTotalWeight" style="margin-left: 10px; font-size: 12px; color: #999;">(昨日: {{ yesterdaySummary.outTotalWeight }}t)</span></el-descriptions-item>
|
||||
<el-descriptions-item label="产出均重">{{ summary.outAvgWeight }}t<span v-if="viewType === 'day' && yesterdaySummary.outAvgWeight" style="margin-left: 10px; font-size: 12px; color: #999;">(昨日: {{ yesterdaySummary.outAvgWeight }}t)</span></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>
|
||||
<el-descriptions-item label="消耗数量">{{ summary.lossCount }}<span v-if="viewType === 'day' && yesterdaySummary.lossCount" style="margin-left: 10px; font-size: 12px; color: #999;">(昨日: {{ yesterdaySummary.lossCount }})</span></el-descriptions-item>
|
||||
<el-descriptions-item label="消耗总重">{{ summary.lossTotalWeight }}t<span v-if="viewType === 'day' && yesterdaySummary.lossTotalWeight" style="margin-left: 10px; font-size: 12px; color: #999;">(昨日: {{ yesterdaySummary.lossTotalWeight }}t)</span></el-descriptions-item>
|
||||
<el-descriptions-item label="消耗均重">{{ summary.lossAvgWeight }}t<span v-if="viewType === 'day' && yesterdaySummary.lossAvgWeight" style="margin-left: 10px; font-size: 12px; color: #999;">(昨日: {{ yesterdaySummary.lossAvgWeight }}t)</span></el-descriptions-item>
|
||||
|
||||
<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.countDiff }}<span v-if="viewType === 'day' && yesterdaySummary.countDiff" style="margin-left: 10px; font-size: 12px; color: #999;">(昨日: {{ yesterdaySummary.countDiff }})</span></el-descriptions-item>
|
||||
<el-descriptions-item label="总重差值">{{ summary.weightDiff }}<span v-if="viewType === 'day' && yesterdaySummary.weightDiff" style="margin-left: 10px; font-size: 12px; color: #999;">(昨日: {{ yesterdaySummary.weightDiff }})</span></el-descriptions-item>
|
||||
<el-descriptions-item label="均重差值">{{ summary.avgWeightDiff }}t<span v-if="viewType === 'day' && yesterdaySummary.avgWeightDiff" style="margin-left: 10px; font-size: 12px; color: #999;">(昨日: {{ yesterdaySummary.avgWeightDiff }}t)</span></el-descriptions-item>
|
||||
<!-- <el-descriptions-item label="合计均重">{{ summary.totalAvgWeight }}t</el-descriptions-item> -->
|
||||
|
||||
<!-- 成品率 -->
|
||||
<el-descriptions-item label="成品率">{{ summary.passRate }}</el-descriptions-item>
|
||||
<el-descriptions-item label="损耗率">{{ summary.lossRate }}</el-descriptions-item>
|
||||
<el-descriptions-item label="成品率">{{ summary.passRate }}<span v-if="viewType === 'day' && yesterdaySummary.passRate" style="margin-left: 10px; font-size: 12px; color: #999;">(昨日: {{ yesterdaySummary.passRate }})</span></el-descriptions-item>
|
||||
<el-descriptions-item label="损耗率">{{ summary.lossRate }}<span v-if="viewType === 'day' && yesterdaySummary.lossRate" style="margin-left: 10px; font-size: 12px; color: #999;">(昨日: {{ yesterdaySummary.lossRate }})</span></el-descriptions-item>
|
||||
<!-- 异常率 -->
|
||||
<el-descriptions-item label="异常率">{{ summary.abRate }}</el-descriptions-item>
|
||||
<el-descriptions-item label="异常率">{{ summary.abRate }}<span v-if="viewType === 'day' && yesterdaySummary.abRate" style="margin-left: 10px; font-size: 12px; color: #999;">(昨日: {{ yesterdaySummary.abRate }})</span></el-descriptions-item>
|
||||
<!-- 正品率 -->
|
||||
<el-descriptions-item label="正品率">{{ summary.passRate2 }}</el-descriptions-item>
|
||||
<el-descriptions-item label="正品率">{{ summary.passRate2 }}<span v-if="viewType === 'day' && yesterdaySummary.passRate2" style="margin-left: 10px; font-size: 12px; color: #999;">(昨日: {{ yesterdaySummary.passRate2 }})</span></el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<!-- 已处理M统计信息 -->
|
||||
@@ -100,8 +125,21 @@
|
||||
}}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<!-- 月视图日数据折线图 -->
|
||||
<div v-if="viewType === 'month'" 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>
|
||||
|
||||
<!-- 分条信息统计 -->
|
||||
<split-summary :origin-outputlist="list" :origin-loss-list="lossList" :common-coil-ids="commonCoilIds"></split-summary>
|
||||
<split-summary v-if="productionLine == '分条线'" :origin-outputlist="list" :origin-loss-list="lossList"
|
||||
:common-coil-ids="commonCoilIds"></split-summary>
|
||||
|
||||
<el-descriptions title="明细信息" :column="3" border>
|
||||
</el-descriptions>
|
||||
@@ -140,6 +178,8 @@ import ColumnsSetting from "@/views/wms/report/components/setting/columns.vue";
|
||||
import CoilTable from "@/views/wms/report/components/coilTable/index.vue";
|
||||
import SplitSummary from "@/views/wms/report/components/summary/splitSummary.vue";
|
||||
import { saveReportFile } from "@/views/wms/report/js/reportFile";
|
||||
import * as echarts from 'echarts';
|
||||
import { fetchLossList, fetchOutputList } from "@/views/wms/report/js/fetch";
|
||||
|
||||
export default {
|
||||
name: 'ComprehensiveTemplate',
|
||||
@@ -231,6 +271,14 @@ export default {
|
||||
settingVisible: false,
|
||||
list: [],
|
||||
lossList: [],
|
||||
// 视图类型:day(日视图), month(月视图), year(年视图), custom(自定义)
|
||||
viewType: 'custom',
|
||||
// 日视图日期
|
||||
dayDate: currentDate.split('-').length === 3 ? currentDate : `${currentDate}-01`,
|
||||
// 月视图日期
|
||||
monthDate: currentDate,
|
||||
// 年视图日期
|
||||
yearDate: currentDate.split('-')[0],
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 99999,
|
||||
@@ -263,6 +311,10 @@ export default {
|
||||
outputColumns: [],
|
||||
|
||||
actionIds: '',
|
||||
// 昨日数据
|
||||
yesterdaySummary: {},
|
||||
// 折线图实例
|
||||
monthChart: null,
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -290,12 +342,12 @@ export default {
|
||||
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 => {
|
||||
@@ -313,22 +365,108 @@ export default {
|
||||
this.lossColumns = JSON.parse(localStorage.getItem('preference-tableColumns-coil-report-loss') || '[]') || []
|
||||
this.outputColumns = JSON.parse(localStorage.getItem('preference-tableColumns-coil-report-output') || '[]') || []
|
||||
},
|
||||
// 视图类型变更处理
|
||||
handleViewTypeChange() {
|
||||
switch (this.viewType) {
|
||||
case 'day':
|
||||
// 切换到日视图时,默认选中今天
|
||||
const today = new Date();
|
||||
const year = today.getFullYear();
|
||||
const month = String(today.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(today.getDate()).padStart(2, '0');
|
||||
this.dayDate = `${year}-${month}-${day}`;
|
||||
this.handleDayDateChange();
|
||||
break;
|
||||
case 'month':
|
||||
this.handleMonthDateChange();
|
||||
break;
|
||||
case 'year':
|
||||
this.handleYearDateChange();
|
||||
break;
|
||||
case 'custom':
|
||||
// 自定义视图保持当前日期范围
|
||||
break;
|
||||
}
|
||||
},
|
||||
// 日视图日期变更处理
|
||||
handleDayDateChange() {
|
||||
if (this.dayDate) {
|
||||
const { start, end } = this.getDayTimeRange(this.dayDate);
|
||||
this.queryParams.byCreateTimeStart = start;
|
||||
this.queryParams.byCreateTimeEnd = end;
|
||||
this.handleQuery();
|
||||
}
|
||||
},
|
||||
// 月视图日期变更处理
|
||||
handleMonthDateChange() {
|
||||
if (this.monthDate) {
|
||||
const { start, end } = this.getDayTimeRange(this.monthDate);
|
||||
this.queryParams.byCreateTimeStart = start;
|
||||
this.queryParams.byCreateTimeEnd = end;
|
||||
this.handleQuery();
|
||||
}
|
||||
},
|
||||
// 年视图日期变更处理
|
||||
handleYearDateChange() {
|
||||
if (this.yearDate) {
|
||||
// 年视图:1月1日到12月31日
|
||||
this.queryParams.byCreateTimeStart = `${this.yearDate}-01-01 00:00:00`;
|
||||
this.queryParams.byCreateTimeEnd = `${this.yearDate}-12-31 23:59:59`;
|
||||
this.handleQuery();
|
||||
}
|
||||
},
|
||||
// 日期变更处理:更新开始/结束时间
|
||||
handleDateChange() {
|
||||
if (this.queryParams.startDate && this.queryParams.endDate) {
|
||||
this.queryParams.byCreateTimeStart = `${this.queryParams.startDate} 00:00:00`
|
||||
this.queryParams.byCreateTimeEnd = `${this.queryParams.endDate} 23:59:59`
|
||||
// 日期变更后自动查询
|
||||
this.handleQuery()
|
||||
if (this.viewType === 'custom') {
|
||||
// 自定义视图下,使用开始和结束日期
|
||||
if (this.queryParams.byCreateTimeStart && this.queryParams.byCreateTimeEnd) {
|
||||
// 确保时间格式正确
|
||||
if (!this.queryParams.byCreateTimeStart.includes(' ')) {
|
||||
this.queryParams.byCreateTimeStart = `${this.queryParams.byCreateTimeStart} 00:00:00`;
|
||||
}
|
||||
if (!this.queryParams.byCreateTimeEnd.includes(' ')) {
|
||||
this.queryParams.byCreateTimeEnd = `${this.queryParams.byCreateTimeEnd} 23:59:59`;
|
||||
}
|
||||
// 日期变更后自动查询
|
||||
this.handleQuery();
|
||||
}
|
||||
}
|
||||
},
|
||||
// 统一查询入口(兼容回车和按钮点击)
|
||||
handleQuery() {
|
||||
this.getList()
|
||||
},
|
||||
// 核心查询逻辑
|
||||
getList() {
|
||||
this.loading = true
|
||||
Promise.all([
|
||||
fetchLossList(this.actionTypes, {
|
||||
...this.queryParams,
|
||||
...this.actionQueryParams,
|
||||
}, (ids) => { this.actionIds = ids }),
|
||||
fetchOutputList({
|
||||
...this.queryParams,
|
||||
...this.baseQueryParams,
|
||||
warehouseIds: this.warehouseIds.join(','),
|
||||
}),
|
||||
]).then(([lossList, outputList]) => {
|
||||
this.lossList = lossList
|
||||
this.list = outputList
|
||||
if (this.viewType == 'day') {
|
||||
this.getYesterdayData()
|
||||
}
|
||||
if (this.viewType == 'month') {
|
||||
this.initMonthChart()
|
||||
}
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
// 获取昨日数据
|
||||
getYesterdayData() {
|
||||
const yesterday = new Date(this.dayDate)
|
||||
yesterday.setDate(yesterday.getDate() - 1)
|
||||
const year = yesterday.getFullYear()
|
||||
const month = String(yesterday.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(yesterday.getDate()).padStart(2, '0')
|
||||
const yesterdayDate = `${year}-${month}-${day}`
|
||||
const { start, end } = this.getDayTimeRange(yesterdayDate)
|
||||
|
||||
Promise.all([
|
||||
listCoilWithIds({
|
||||
selectType: 'raw_material',
|
||||
@@ -336,6 +474,8 @@ export default {
|
||||
warehouseIds: this.warehouseIds.join(','),
|
||||
...this.queryParams,
|
||||
...this.baseQueryParams,
|
||||
byCreateTimeStart: start,
|
||||
byCreateTimeEnd: end,
|
||||
}),
|
||||
listCoilWithIds({
|
||||
selectType: 'product',
|
||||
@@ -343,68 +483,176 @@ export default {
|
||||
warehouseIds: this.warehouseIds.join(','),
|
||||
...this.queryParams,
|
||||
...this.baseQueryParams,
|
||||
byCreateTimeStart: start,
|
||||
byCreateTimeEnd: end,
|
||||
}),
|
||||
]).then((resList) => {
|
||||
console.log(resList)
|
||||
const list = resList.flatMap(res => res.rows)
|
||||
// 按照createTime 降序排序
|
||||
this.list = list.sort(
|
||||
const yesterdayList = list.sort(
|
||||
(a, b) => new Date(b.createTime) - new Date(a.createTime)
|
||||
).map(item => {
|
||||
// 计算宽度和厚度,将规格按照*分割,*前的是厚度,*后的是宽度
|
||||
const [thickness, width] = item.specification.split('*')
|
||||
return {
|
||||
...item,
|
||||
computedThickness: parseFloat(thickness),
|
||||
computedWidth: parseFloat(width),
|
||||
// 确保每个项目都有 selectType 字段
|
||||
if (!item.selectType) {
|
||||
item.selectType = item.itemType === 'product' ? 'product' : 'raw_material'
|
||||
}
|
||||
return item
|
||||
})
|
||||
|
||||
// 获取昨日消耗数据
|
||||
Promise.all(this.actionTypes.map(actionType => {
|
||||
return listPendingAction({
|
||||
actionStatus: 2,
|
||||
warehouseId: this.queryParams.planId,
|
||||
actionType,
|
||||
pageSize: 99999,
|
||||
pageNum: 1,
|
||||
startTime: start,
|
||||
endTime: end,
|
||||
...this.actionQueryParams,
|
||||
})
|
||||
})).then((lossResList) => {
|
||||
const lossActions = lossResList.flatMap(item => item.rows)
|
||||
const lossCoilIds = lossActions.map(item => item.coilId).join(',')
|
||||
|
||||
if (lossCoilIds) {
|
||||
listCoilWithIds({
|
||||
...this.queryParams,
|
||||
byCreateTimeStart: undefined,
|
||||
byCreateTimeEnd: undefined,
|
||||
coilIds: lossCoilIds,
|
||||
}).then(res => {
|
||||
const yesterdayLossList = res.rows
|
||||
this.yesterdaySummary = calcSummary(yesterdayList, yesterdayLossList)
|
||||
})
|
||||
} else {
|
||||
this.yesterdaySummary = calcSummary(yesterdayList, [])
|
||||
}
|
||||
})
|
||||
this.getLossList()
|
||||
})
|
||||
},
|
||||
async getLossList() {
|
||||
this.loading = true
|
||||
const resultList = await Promise.all(this.actionTypes.map(actionType => {
|
||||
return listPendingAction({
|
||||
actionStatus: 2,
|
||||
warehouseId: this.queryParams.planId,
|
||||
actionType,
|
||||
pageSize: 99999,
|
||||
pageNum: 1,
|
||||
startTime: this.queryParams.byCreateTimeStart,
|
||||
endTime: this.queryParams.byCreateTimeEnd,
|
||||
...this.actionQueryParams,
|
||||
})
|
||||
}))
|
||||
const actions = resultList.flatMap(item => item.rows)
|
||||
this.actionIds = actions.map(item => item.actionId).join(',')
|
||||
const coilIds = actions.map(item => item.coilId).join(',')
|
||||
console.log(coilIds)
|
||||
if (!coilIds) {
|
||||
this.$message({
|
||||
message: '暂无数据',
|
||||
type: 'warning',
|
||||
})
|
||||
this.lossList = []
|
||||
this.loading = false
|
||||
return
|
||||
// 初始化月视图折线图
|
||||
initMonthChart() {
|
||||
if (!this.$refs.monthChart) return
|
||||
|
||||
// 销毁旧的图表实例
|
||||
if (this.monthChart) {
|
||||
this.monthChart.dispose()
|
||||
}
|
||||
listCoilWithIds({
|
||||
...this.queryParams,
|
||||
byCreateTimeStart: undefined,
|
||||
byCreateTimeEnd: undefined,
|
||||
coilIds: coilIds,
|
||||
}).then(res => {
|
||||
this.lossList = res.rows.map(item => {
|
||||
// 计算宽度和厚度,将规格按照*分割,*前的是厚度,*后的是宽度
|
||||
const [thickness, width] = item.specification.split('*')
|
||||
return {
|
||||
...item,
|
||||
computedThickness: parseFloat(thickness),
|
||||
computedWidth: parseFloat(width),
|
||||
|
||||
// 创建新的图表实例
|
||||
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,
|
||||
}
|
||||
})
|
||||
this.loading = false
|
||||
}
|
||||
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()
|
||||
})
|
||||
},
|
||||
// 导出
|
||||
@@ -413,18 +661,24 @@ export default {
|
||||
this.$message.warning('暂无数据可导出')
|
||||
return
|
||||
}
|
||||
// 格式化日期用于文件名
|
||||
const startDate = this.queryParams.byCreateTimeStart.split(' ')[0];
|
||||
const endDate = this.queryParams.byCreateTimeEnd.split(' ')[0];
|
||||
this.download('wms/materialCoil/export', {
|
||||
coilIds: this.list.map(item => item.coilId).join(',')
|
||||
}, `materialCoil_${this.queryParams.startDate}_${this.queryParams.endDate}_${new Date().getTime()}.xlsx`)
|
||||
}, `materialCoil_${startDate}_${endDate}_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
exportLossData() {
|
||||
if (this.lossList.length === 0) {
|
||||
this.$message.warning('暂无数据可导出')
|
||||
return
|
||||
}
|
||||
// 格式化日期用于文件名
|
||||
const startDate = this.queryParams.byCreateTimeStart.split(' ')[0];
|
||||
const endDate = this.queryParams.byCreateTimeEnd.split(' ')[0];
|
||||
this.download('wms/materialCoil/export', {
|
||||
coilIds: this.lossList.map(item => item.coilId).join(',')
|
||||
}, `materialCoil_${this.queryParams.startDate}_${this.queryParams.endDate}_${new Date().getTime()}.xlsx`)
|
||||
}, `materialCoil_${startDate}_${endDate}_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
// 保存产出报表
|
||||
saveOutputReport() {
|
||||
@@ -470,7 +724,7 @@ export default {
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.getList()
|
||||
this.handleQuery()
|
||||
this.loadColumns()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<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="date" value-format="yyyy-MM-dd"
|
||||
<el-date-picker style="width: 200px;" v-model="dayDate" type="date" value-format="yyyy-MM-dd"
|
||||
placeholder="选择日期" @change="handleDateChange"></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="入场钢卷号" prop="enterCoilNo">
|
||||
@@ -47,26 +47,26 @@
|
||||
</el-row>
|
||||
|
||||
<el-descriptions title="统计信息" :column="3" border>
|
||||
<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.outCount }}<span v-if="yesterdaySummary.outCount" style="margin-left: 10px; font-size: 12px; color: #999;">(昨日: {{ yesterdaySummary.outCount }})</span></el-descriptions-item>
|
||||
<el-descriptions-item label="产出总重">{{ summary.outTotalWeight }}t<span v-if="yesterdaySummary.outTotalWeight" style="margin-left: 10px; font-size: 12px; color: #999;">(昨日: {{ yesterdaySummary.outTotalWeight }}t)</span></el-descriptions-item>
|
||||
<el-descriptions-item label="产出均重">{{ summary.outAvgWeight }}t<span v-if="yesterdaySummary.outAvgWeight" style="margin-left: 10px; font-size: 12px; color: #999;">(昨日: {{ yesterdaySummary.outAvgWeight }}t)</span></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>
|
||||
<el-descriptions-item label="消耗数量">{{ summary.lossCount }}<span v-if="yesterdaySummary.lossCount" style="margin-left: 10px; font-size: 12px; color: #999;">(昨日: {{ yesterdaySummary.lossCount }})</span></el-descriptions-item>
|
||||
<el-descriptions-item label="消耗总重">{{ summary.lossTotalWeight }}t<span v-if="yesterdaySummary.lossTotalWeight" style="margin-left: 10px; font-size: 12px; color: #999;">(昨日: {{ yesterdaySummary.lossTotalWeight }}t)</span></el-descriptions-item>
|
||||
<el-descriptions-item label="消耗均重">{{ summary.lossAvgWeight }}t<span v-if="yesterdaySummary.lossAvgWeight" style="margin-left: 10px; font-size: 12px; color: #999;">(昨日: {{ yesterdaySummary.lossAvgWeight }}t)</span></el-descriptions-item>
|
||||
|
||||
<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.countDiff }}<span v-if="yesterdaySummary.countDiff" style="margin-left: 10px; font-size: 12px; color: #999;">(昨日: {{ yesterdaySummary.countDiff }})</span></el-descriptions-item>
|
||||
<el-descriptions-item label="总重差值">{{ summary.weightDiff }}<span v-if="yesterdaySummary.weightDiff" style="margin-left: 10px; font-size: 12px; color: #999;">(昨日: {{ yesterdaySummary.weightDiff }})</span></el-descriptions-item>
|
||||
<el-descriptions-item label="均重差值">{{ summary.avgWeightDiff }}t<span v-if="yesterdaySummary.avgWeightDiff" style="margin-left: 10px; font-size: 12px; color: #999;">(昨日: {{ yesterdaySummary.avgWeightDiff }}t)</span></el-descriptions-item>
|
||||
<!-- <el-descriptions-item label="合计均重">{{ summary.totalAvgWeight }}t</el-descriptions-item> -->
|
||||
|
||||
<!-- 成品率 -->
|
||||
<el-descriptions-item label="成品率">{{ summary.passRate }}</el-descriptions-item>
|
||||
<el-descriptions-item label="损耗率">{{ summary.lossRate }}</el-descriptions-item>
|
||||
<el-descriptions-item label="成品率">{{ summary.passRate }}<span v-if="yesterdaySummary.passRate" style="margin-left: 10px; font-size: 12px; color: #999;">(昨日: {{ yesterdaySummary.passRate }})</span></el-descriptions-item>
|
||||
<el-descriptions-item label="损耗率">{{ summary.lossRate }}<span v-if="yesterdaySummary.lossRate" style="margin-left: 10px; font-size: 12px; color: #999;">(昨日: {{ yesterdaySummary.lossRate }})</span></el-descriptions-item>
|
||||
<!-- 异常率 -->
|
||||
<el-descriptions-item label="异常率">{{ summary.abRate }}</el-descriptions-item>
|
||||
<el-descriptions-item label="异常率">{{ summary.abRate }}<span v-if="yesterdaySummary.abRate" style="margin-left: 10px; font-size: 12px; color: #999;">(昨日: {{ yesterdaySummary.abRate }})</span></el-descriptions-item>
|
||||
<!-- 正品率 -->
|
||||
<el-descriptions-item label="正品率">{{ summary.passRate2 }}</el-descriptions-item>
|
||||
<el-descriptions-item label="正品率">{{ summary.passRate2 }}<span v-if="yesterdaySummary.passRate2" style="margin-left: 10px; font-size: 12px; color: #999;">(昨日: {{ yesterdaySummary.passRate2 }})</span></el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<!-- 已处理M统计信息 -->
|
||||
@@ -98,7 +98,7 @@
|
||||
</el-descriptions>
|
||||
|
||||
<!-- 分条信息统计 -->
|
||||
<split-summary :origin-outputlist="list" :origin-loss-list="lossList" :common-coil-ids="commonCoilIds"></split-summary>
|
||||
<split-summary v-if="productionLine == '分条线'" :origin-outputlist="list" :origin-loss-list="lossList" :common-coil-ids="commonCoilIds"></split-summary>
|
||||
|
||||
<el-descriptions title="明细信息" :column="3" border>
|
||||
</el-descriptions>
|
||||
@@ -122,6 +122,10 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listCoilWithIds } from "@/api/wms/coil";
|
||||
import {
|
||||
listPendingAction,
|
||||
} from '@/api/wms/pendingAction';
|
||||
import ProductInfo from "@/components/KLPService/Renderer/ProductInfo";
|
||||
import RawMaterialInfo from "@/components/KLPService/Renderer/RawMaterialInfo";
|
||||
import CoilNo from "@/components/KLPService/Renderer/CoilNo.vue";
|
||||
@@ -180,13 +184,43 @@ export default {
|
||||
const now = new Date()
|
||||
const currentDate = `${now.getFullYear()}-${addZero(now.getMonth() + 1)}-${addZero(now.getDate())}`
|
||||
|
||||
// 生成指定日期的 00:00:00 和 23:59:59 时间字符串
|
||||
/**
|
||||
* 生成指定日期/月份的时间范围字符串
|
||||
* @param {string} dateStr - 支持格式:yyyy-MM(月份) 或 yyyy-MM-dd(具体日期)
|
||||
* @returns {object} 包含start(开始时间)和end(结束时间)的对象
|
||||
*/
|
||||
const getDayTimeRange = (dateStr) => {
|
||||
return {
|
||||
start: `${dateStr} 00:00:00`,
|
||||
end: `${dateStr} 23:59:59`
|
||||
// 先校验输入格式是否合法
|
||||
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)
|
||||
|
||||
@@ -196,10 +230,11 @@ export default {
|
||||
settingVisible: false,
|
||||
list: [],
|
||||
lossList: [],
|
||||
// 日视图日期
|
||||
dayDate: currentDate,
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 9999,
|
||||
// date: currentDate, // 绑定日期选择器的默认值(当天)
|
||||
byCreateTimeStart: start, // 默认当天0点
|
||||
byCreateTimeEnd: end, // 默认当天23:59:59
|
||||
enterCoilNo: '',
|
||||
@@ -226,6 +261,8 @@ export default {
|
||||
lossColumns: [],
|
||||
outputColumns: [],
|
||||
actionIds: '',
|
||||
// 昨日数据
|
||||
yesterdaySummary: {},
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -277,9 +314,9 @@ export default {
|
||||
this.outputColumns = JSON.parse(localStorage.getItem('preference-tableColumns-coil-report-output') || '[]') || []
|
||||
},
|
||||
// 日期变更处理:更新开始/结束时间
|
||||
handleDateChange(date) {
|
||||
if (!date) return
|
||||
const { start, end } = this.getDayTimeRange(date)
|
||||
handleDateChange() {
|
||||
if (!this.dayDate) return
|
||||
const { start, end } = this.getDayTimeRange(this.dayDate)
|
||||
this.queryParams.byCreateTimeStart = start
|
||||
this.queryParams.byCreateTimeEnd = end
|
||||
// 日期变更后自动查询
|
||||
@@ -301,6 +338,7 @@ export default {
|
||||
]).then(([lossList, outputList]) => {
|
||||
this.lossList = lossList
|
||||
this.list = outputList
|
||||
this.getYesterdayData()
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
@@ -310,18 +348,98 @@ export default {
|
||||
this.$message.warning('暂无数据可导出')
|
||||
return
|
||||
}
|
||||
// 格式化日期用于文件名
|
||||
const startDate = this.queryParams.byCreateTimeStart.split(' ')[0];
|
||||
const endDate = this.queryParams.byCreateTimeEnd.split(' ')[0];
|
||||
this.download('wms/materialCoil/export', {
|
||||
coilIds: this.list.map(item => item.coilId).join(',')
|
||||
}, `materialCoil_${this.queryParams.date}_${new Date().getTime()}.xlsx`)
|
||||
}, `materialCoil_${startDate}_${endDate}_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
exportLossData() {
|
||||
if (this.lossList.length === 0) {
|
||||
this.$message.warning('暂无数据可导出')
|
||||
return
|
||||
}
|
||||
// 格式化日期用于文件名
|
||||
const startDate = this.queryParams.byCreateTimeStart.split(' ')[0];
|
||||
const endDate = this.queryParams.byCreateTimeEnd.split(' ')[0];
|
||||
this.download('wms/materialCoil/export', {
|
||||
actionIds: this.actionIds
|
||||
}, `materialCoil_${this.queryParams.date}_${new Date().getTime()}.xlsx`)
|
||||
}, `materialCoil_${startDate}_${endDate}_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
// 获取昨日数据
|
||||
getYesterdayData() {
|
||||
const yesterday = new Date(this.dayDate)
|
||||
yesterday.setDate(yesterday.getDate() - 1)
|
||||
const year = yesterday.getFullYear()
|
||||
const month = String(yesterday.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(yesterday.getDate()).padStart(2, '0')
|
||||
const yesterdayDate = `${year}-${month}-${day}`
|
||||
const { start, end } = this.getDayTimeRange(yesterdayDate)
|
||||
|
||||
Promise.all([
|
||||
listCoilWithIds({
|
||||
selectType: 'raw_material',
|
||||
itemType: 'raw_material',
|
||||
warehouseIds: this.warehouseIds.join(','),
|
||||
...this.queryParams,
|
||||
...this.baseQueryParams,
|
||||
byCreateTimeStart: start,
|
||||
byCreateTimeEnd: end,
|
||||
}),
|
||||
listCoilWithIds({
|
||||
selectType: 'product',
|
||||
itemType: 'product',
|
||||
warehouseIds: this.warehouseIds.join(','),
|
||||
...this.queryParams,
|
||||
...this.baseQueryParams,
|
||||
byCreateTimeStart: start,
|
||||
byCreateTimeEnd: end,
|
||||
}),
|
||||
]).then((resList) => {
|
||||
const list = resList.flatMap(res => res.rows)
|
||||
// 按照createTime 降序排序
|
||||
const yesterdayList = list.sort(
|
||||
(a, b) => new Date(b.createTime) - new Date(a.createTime)
|
||||
).map(item => {
|
||||
// 确保每个项目都有 selectType 字段
|
||||
if (!item.selectType) {
|
||||
item.selectType = item.itemType === 'product' ? 'product' : 'raw_material'
|
||||
}
|
||||
return item
|
||||
})
|
||||
|
||||
// 获取昨日消耗数据
|
||||
Promise.all(this.actionTypes.map(actionType => {
|
||||
return listPendingAction({
|
||||
actionStatus: 2,
|
||||
warehouseId: this.queryParams.planId,
|
||||
actionType,
|
||||
pageSize: 99999,
|
||||
pageNum: 1,
|
||||
startTime: start,
|
||||
endTime: end,
|
||||
...this.actionQueryParams,
|
||||
})
|
||||
})).then((lossResList) => {
|
||||
const lossActions = lossResList.flatMap(item => item.rows)
|
||||
const lossCoilIds = lossActions.map(item => item.coilId).join(',')
|
||||
|
||||
if (lossCoilIds) {
|
||||
listCoilWithIds({
|
||||
...this.queryParams,
|
||||
byCreateTimeStart: undefined,
|
||||
byCreateTimeEnd: undefined,
|
||||
coilIds: lossCoilIds,
|
||||
}).then(res => {
|
||||
const yesterdayLossList = res.rows
|
||||
this.yesterdaySummary = calcSummary(yesterdayList, yesterdayLossList)
|
||||
})
|
||||
} else {
|
||||
this.yesterdaySummary = calcSummary(yesterdayList, [])
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
// 保存产出报表
|
||||
saveOutputReport() {
|
||||
|
||||
@@ -97,8 +97,20 @@
|
||||
}}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<!-- 月视图日数据折线图 -->
|
||||
<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>
|
||||
|
||||
<!-- 分条信息统计 -->
|
||||
<split-summary :origin-outputlist="list" :origin-loss-list="lossList" :common-coil-ids="commonCoilIds"></split-summary>
|
||||
<split-summary v-if="productionLine == '分条线'" :origin-outputlist="list" :origin-loss-list="lossList" :common-coil-ids="commonCoilIds"></split-summary>
|
||||
|
||||
<el-descriptions title="明细信息" :column="3" border>
|
||||
</el-descriptions>
|
||||
@@ -138,6 +150,7 @@ import CoilTable from "@/views/wms/report/components/coilTable/index.vue";
|
||||
import SplitSummary from "@/views/wms/report/components/summary/splitSummary.vue";
|
||||
import { fetchLossList, fetchOutputList } from "@/views/wms/report/js/fetch";
|
||||
import { saveReportFile } from "@/views/wms/report/js/reportFile";
|
||||
import * as echarts from 'echarts';
|
||||
|
||||
export default {
|
||||
name: 'MonthTemplate',
|
||||
@@ -260,6 +273,8 @@ export default {
|
||||
outputColumns: [],
|
||||
|
||||
actionIds: '',
|
||||
// 折线图实例
|
||||
monthChart: null,
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -400,9 +415,134 @@ export default {
|
||||
]).then(([lossList, outputList]) => {
|
||||
this.lossList = lossList
|
||||
this.list = outputList
|
||||
this.initMonthChart()
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
// 初始化月视图折线图
|
||||
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()
|
||||
})
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.loadColumns()
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
</el-descriptions>
|
||||
|
||||
<!-- 分条信息统计 -->
|
||||
<split-summary :origin-outputlist="list" :origin-loss-list="lossList" :common-coil-ids="commonCoilIds"></split-summary>
|
||||
<split-summary v-if="productionLine == '分条线'" :origin-outputlist="list" :origin-loss-list="lossList" :common-coil-ids="commonCoilIds"></split-summary>
|
||||
|
||||
<el-descriptions title="班组统计信息" :column="3" border>
|
||||
</el-descriptions>
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
</el-descriptions>
|
||||
|
||||
<!-- 分条信息统计 -->
|
||||
<split-summary :origin-outputlist="list" :origin-loss-list="lossList" :common-coil-ids="commonCoilIds"></split-summary>
|
||||
<split-summary v-if="productionLine == '分条线'" :origin-outputlist="list" :origin-loss-list="lossList" :common-coil-ids="commonCoilIds"></split-summary>
|
||||
|
||||
<el-descriptions title="明细信息" :column="3" border>
|
||||
</el-descriptions>
|
||||
|
||||
Reference in New Issue
Block a user