This commit is contained in:
‘937886381’
2025-12-17 16:26:21 +08:00
parent 484ba6ca53
commit c86d94ac92
16 changed files with 9326 additions and 8961 deletions

BIN
dist.zip

Binary file not shown.

View File

@@ -49,7 +49,7 @@
"bpmn-js-token-simulation": "0.10.0", "bpmn-js-token-simulation": "0.10.0",
"chinese-lunar": "^0.1.4", "chinese-lunar": "^0.1.4",
"clipboard": "2.0.8", "clipboard": "2.0.8",
"code-brick-zj": "^1.0.2", "code-brick-zj": "^1.1.1",
"core-js": "^3.26.0", "core-js": "^3.26.0",
"crypto-js": "^4.0.0", "crypto-js": "^4.0.0",
"diagram-js": "^12.3.0", "diagram-js": "^12.3.0",

View File

@@ -102,3 +102,17 @@ export function getProcessAutoReportNew(data) {
data: data, data: data,
}); });
} }
export function getPLlistByFactory(data) {
return request({
url: 'base/production-line/listByFactory',
method: 'post',
data: data,
});
}
export function getProcessAutoReportLastGroup(data) {
return request({
url: '/monitoring/production-monitor/getProcessAutoReportLastGroup',
method: 'post',
data: data,
});
}

View File

@@ -141,7 +141,8 @@ export default {
type: 'select', type: 'select',
label: '产线', label: '产线',
selectOptions: [], selectOptions: [],
param: 'lineId', param: 'lineId',
collapseTags: true,
multiple: true, multiple: true,
}, },
{ {

View File

@@ -1,274 +1,261 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<search-bar <search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" />
:formConfigs="formConfig" <div v-if="tableData.length">
ref="searchBarForm" <base-table v-loading="dataListLoading" :table-props="tableProps" :max-height="tableH" :table-data="tableData" />
@headBtnClick="buttonClick" /> <SearchBar :formConfigs="[{ label: '产品产量对比图', type: 'title' }]" />
<div v-if="tableData.length"> <line-chart ref="lineChart" />
<base-table </div>
v-loading="dataListLoading" <div v-else class="no-data-bg"></div>
:table-props="tableProps" </div>
:max-height="tableH"
:table-data="tableData" />
<SearchBar :formConfigs="[{ label: '产品产量对比图', type: 'title' }]" />
<line-chart ref="lineChart" />
</div>
<div v-else class="no-data-bg"></div>
<!-- <pagination
:limit.sync="listQuery.pageSize"
:page.sync="listQuery.pageNo"
:total="listQuery.total"
@pagination="getDataList" /> -->
</div>
</template> </template>
<script> <script>
// import basicPage from '../../mixins/basic-page';
import { parseTime } from '../../mixins/code-filter'; import { parseTime } from '../../mixins/code-filter';
import { getYieldAnalysisPageData } from '@/api/core/analysis/index'; import { getYieldAnalysisPageData } from '@/api/core/analysis/index';
import { getProductionLinePage } from '@/api/core/base/productionLine'; import { getProductionLinePage } from '@/api/core/base/productionLine';
import lineChart from '../LineChart'; import lineChart from '../LineChart';
import tableHeightMixin from '@/mixins/lb/tableHeightMixin'; import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
// import { getWorkshopSectionPage } from '@/api/core/base/workshopSection';
// const tableProps = [
// // {
// // prop: 'lineName',
// // label: '产线',
// // align: 'center',
// // },
// // {
// // prop: 'sum',
// // label: '合计',
// // align: 'center',
// // },
// // {
// // prop: 'dynamicValue',
// // label: 'dynamicName',
// // align: 'center',
// // children:[
// // ]
// // }
// ];
export default { export default {
components: { components: {
lineChart, lineChart,
}, },
mixins: [tableHeightMixin], mixins: [tableHeightMixin],
data() { data() {
return { return {
urlOptions: { urlOptions: {
getDataListURL: getYieldAnalysisPageData, getDataListURL: getYieldAnalysisPageData,
}, },
tableProps: [], tableProps: [],
dataListLoading: false, dataListLoading: false,
tableData: [], tableData: [],
listQuery: { listQuery: {
lineIds: [], lineIds: [],
time: '', time: '', // 存储时间选择器的选中值(时间戳/格式化字符串,根据接口要求调整)
}, },
dateLabelList: [], dateLabelList: [],
optionArrUrl: [getProductionLinePage], optionArrUrl: [getProductionLinePage],
formConfig: [ formConfig: [
{ {
type: 'datePicker', type: 'datePicker',
label: '时间', label: '时间',
dateType: 'month', dateType: 'month', // 单个月份选择
format: 'yyyy-MM', format: 'yyyy-MM', // 显示格式
valueFormat: 'yyyy-MM-dd HH:mm:ss', valueFormat: 'yyyy-MM-dd HH:mm:ss', // 绑定值的格式
rangeSeparator: '-', param: 'time',
startPlaceholder: '开始时间', defaultSelect: '', // 新增:默认月份值
endPlaceholder: '结束时间',
param: 'time',
}, },
{ {
type: 'select', type: 'select',
label: '产线', label: '产线',
selectOptions: [], selectOptions: [],
param: 'lineIds', param: 'lineIds',
defaultSelect: [], defaultSelect: [], // 产线默认选择值(多选数组)
multiple: true, multiple: true,
collapseTags: true, collapseTags: true,
filterable: true, filterable: true,
width: 300, width: 300,
}, },
{ {
type: 'button', type: 'button',
btnName: '查询', btnName: '查询',
name: 'search', name: 'search',
color: 'primary', color: 'primary',
}, },
], ],
}; };
}, },
created() { mounted() {
this.getArr(); // 1. 初始化默认当月时间
}, this.initDefaultMonth();
methods: { // 2. 获取产线数据
getArr() { this.getArr();
const params = { },
page: 1, methods: {
limit: 500, /**
}; * 初始化默认当月时间(单个月份)
this.optionArrUrl.forEach((item, index) => { */
item(params).then((response) => { initDefaultMonth() {
this.formConfig[1].selectOptions = response.data.list; const now = new Date();
// this.formConfig[0].defaultSelect = response.data.list[0].id const year = now.getFullYear();
// this.$set(this.formConfig[0], 'defaultSelect', response.data.list[0].id) const month = now.getMonth(); // 月份从0开始直接使用取当月1号
}); // 创建当月1号0点0分0秒的日期对象
}); const firstDayOfMonth = new Date(year, month, 1, 0, 0, 0);
}, // 转换为时间戳(毫秒级)
getData() { const defaultTimeStamp = firstDayOfMonth.getTime();
// this.listQuery.lineIds = ['1672847052717821953'] // 给时间选择器赋值默认值
// this.listQuery.productId = val.productId; this.formConfig[0].defaultSelect = firstDayOfMonth;
// this.listQuery.time = '1694486098000'; // this.listQuery.time = defaultTimeStamp;
this.urlOptions.getDataListURL(this.listQuery).then((res) => { },
let arr = [ /**
{ * 获取产线数据
prop: 'lineName', */
label: '产线', getArr() {
fixed: 'left', const params = {
}, page: 1,
{ limit: 500,
prop: 'sum', };
label: '合计[片]', // 原代码forEach遍历冗余直接调用第一个方法即可
fixed: 'left', this.optionArrUrl[0](params)
}, .then((response) => {
{ const lineList = response.data.list;
prop: res.data ? res.data.nameData[0].name : undefined, this.formConfig[1].selectOptions = lineList;
label: res.data ? res.data.nameData[0].name : undefined, // 产线默认选择第一条数据(多选需用数组格式)
align: 'center', if (lineList.length > 0) {
children: [], const firstLineId = lineList[0].id;
}, this.formConfig[1].defaultSelect = [firstLineId];
]; // 给查询参数赋值
// console.log(res.data.nameData.slice(1)) this.listQuery.lineIds = [firstLineId];
let xData = []; }
let yAllData = []; })
let lineName = []; .catch((err) => {
if (res.data) { console.error('获取产线数据失败:', err);
let tempDateList = []; });
res.data.nameData.forEach((date) => { },
tempDateList.push(date.name); /**
}); * 获取产量分析数据
this.dateLabelList = Array.from(new Set(tempDateList)); */
getData() {
this.dataListLoading = true; // 开启加载状态
this.urlOptions.getDataListURL(this.listQuery)
.then((res) => {
let arr = [
{
prop: 'lineName',
label: '产线',
fixed: 'left',
},
{
prop: 'sum',
label: '合计[片]',
fixed: 'left',
},
{
prop: res.data ? res.data.nameData[0].name : undefined,
label: res.data ? res.data.nameData[0].name : undefined,
align: 'center',
children: [],
},
];
this.dateLabelList.forEach((item) => { let xData = [];
if (item.indexOf('年') === -1) { let yAllData = [];
// 构造表头 let lineName = [];
const props = { if (res.data) {
prop: item, // 处理日期标签去重
label: item, let tempDateList = [];
}; res.data.nameData.forEach((date) => {
arr[2].children.push(props); tempDateList.push(date.name);
});
this.dateLabelList = Array.from(new Set(tempDateList));
// 构造echarts横坐标 // 构造表头children和echarts横坐标
xData.push(item); this.dateLabelList.forEach((item) => {
} if (item.indexOf('年') === -1) {
}); arr[2].children.push({
// res.data.nameData.slice(1).forEach(item => { prop: item,
// const props = { label: item,
// 'prop': item.name, });
// 'label': item.name, xData.push(item);
// 'align': 'center' }
// } });
// arr[2].children.push(props)
// })
let tableDataArr = [];
res.data.data.forEach((item) => {
let obj = {};
(obj.lineName = item.lineName),
(obj.sum = item.sum),
item.data.forEach((ele, index) => {
// console.log(ele)
ele.children.forEach((e) => {
console.log(e.dynamicName);
obj['' + e.dynamicName + ''] = e.dynamicValue;
console.log(obj['' + e.dynamicName + '']);
});
});
tableDataArr.push(obj);
});
this.tableData = tableDataArr;
this.tableProps = arr;
// let tempList = [] // 构造表格数据
// res.data.nameData.slice(1).forEach(item => { let tableDataArr = [];
// tempList.push(item.name) res.data.data.forEach((item) => {
// // arr[2].children.push(props) let obj = {
// }) lineName: item.lineName,
// xData = Array.from(new Set(tempList)) sum: item.sum,
};
item.data.forEach((ele) => {
ele.children.forEach((e) => {
obj[e.dynamicName] = e.dynamicValue;
});
});
tableDataArr.push(obj);
});
this.tableData = tableDataArr;
this.tableProps = arr;
res.data.data.forEach((item) => { // 构造图表数据
let yData = []; res.data.data.forEach((item) => {
lineName.push(item.lineName); let yData = [];
// let obj = {} lineName.push(item.lineName);
// obj.lineName = item.lineName, item.data.forEach((ele) => {
// obj.sum = item.sum, ele.children.forEach((e) => {
item.data.forEach((ele, index) => { yData.push(e.dynamicValue);
// console.log(ele) });
ele.children.forEach((e) => { });
// let yData = [] yAllData.push(yData);
yData.push(e.dynamicValue); });
}); } else {
}); this.tableProps = arr;
yAllData.push(yData); this.tableData = [];
}); xData = [];
console.log(lineName); yAllData = [];
} else { lineName = [];
this.tableProps = arr; }
this.tableData = [];
xData = []; // 初始化图表
yAllData = []; this.$nextTick(() => {
lineName = []; this.$refs.lineChart.initChart(xData, yAllData, lineName);
} });
// res.data.data[0].data[0].children.forEach((item, index) => { })
// // console.log(item) .catch((err) => {
// yData.push(item.dynamicValue) console.error('获取产量数据失败:', err);
// // let data = 'data' + Number(index+1) this.tableData = [];
// // obj['' + item.dynamicName + ''] = item.dynamicValue })
// }) .finally(() => {
// console.log(this.yData) this.dataListLoading = false; // 关闭加载状态
this.$nextTick(() => { });
this.$refs.lineChart.initChart(xData, yAllData, lineName); },
}); /**
// this.total = response.data.total; * 搜索栏按钮点击事件
// this.dataListLoading = false; * @param {Object} val - 按钮/表单传递的参数
}); */
}, buttonClick(val) {
buttonClick(val) { switch (val.btnName) {
switch (val.btnName) { case 'search':
case 'search': // 处理产线参数避免undefined空值设为空数组
this.listQuery.lineIds = val.lineIds ? val.lineIds : undefined; this.listQuery.lineIds = val.lineIds || [];
// this.listQuery.productId = val.productId; // 处理时间参数:如果是时间字符串,可转换为时间戳(根据接口要求调整)
this.listQuery.time = val.time if (val.time) {
? new Date(val.time).getTime() // this.listQuery.time = val.time;
: undefined; // 若接口需要时间戳,取消下面注释:
// this.listQuery.pageNo = 1; this.listQuery.time = new Date(val.time).getTime();
// this.listQuery.pageSize = 10; } else {
if (val.time) { this.$message({
this.getData(); message: '请选择时间',
} else { type: 'warning',
this.$message({ });
message: '请选择时间', return;
type: 'warning', }
});
} // 验证产线是否选择(可选,根据业务需求调整)
break; if (this.listQuery.lineIds.length === 0) {
case 'reset': this.$message({
this.$refs.searchBarForm.resetForm(); message: '请选择至少一条产线',
this.listQuery = { type: 'warning',
pageSize: 10, });
pageNo: 1, return;
total: 1, }
};
this.getDataList(); this.getData();
break; break;
default: case 'reset':
console.log(val); // 重置表单
} this.$refs.searchBarForm.resetForm();
}, // 恢复默认值
}, this.listQuery = {
lineIds: this.formConfig[1].defaultSelect || [],
time: this.formConfig[0].defaultValue || '',
};
break;
default:
console.log(val);
}
},
},
}; };
</script> </script>

View File

@@ -80,7 +80,7 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row :gutter="20"> <!-- <el-row :gutter="20">
<el-col :span="12"> <el-col :span="12">
<el-form-item label=" 基板类型" prop="typeDictValue"> <el-form-item label=" 基板类型" prop="typeDictValue">
<el-select :disabled="isdetail" v-model="dataForm.typeDictValue" clearable <el-select :disabled="isdetail" v-model="dataForm.typeDictValue" clearable
@@ -89,7 +89,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row> -->
</el-form> </el-form>
<small-title style="margin: 16px 0; padding-left: 8px" :no-padding="true"> <small-title style="margin: 16px 0; padding-left: 8px" :no-padding="true">

View File

@@ -34,9 +34,9 @@
<el-tabs v-model="activeLabel" :stretch="true" @tab-click="handleTabClick"> <el-tabs v-model="activeLabel" :stretch="true" @tab-click="handleTabClick">
<el-tab-pane :label="'全部数据'" name="table"> <el-tab-pane :label="'全部数据'" name="table">
<base-table-s ref="lineCurrentShiftTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'" <base-table-s ref="lineCurrentShiftTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'"
:page="1" :limit="100" :table-props="tableProps" :table-data="tableData" :max-height="300" /> :page="1" :limit="100" :table-props="tableProps" :table-data="tableData" :max-height="220" />
</el-tab-pane> </el-tab-pane>
<el-tab-pane :label="'\u3000当天生产折线图\u3000'" name="graph"> <el-tab-pane :label="'\u3000生产折线图\u3000'" name="graph">
<div style="height: 230px;" v-if="activeLabel == 'graph'" class="graph"> <div style="height: 230px;" v-if="activeLabel == 'graph'" class="graph">
<barChart v-if="tableData && tableData.length > 0" ref="barChart" height="230px" <barChart v-if="tableData && tableData.length > 0" ref="barChart" height="230px"
:bar-data="tableData" /> :bar-data="tableData" />
@@ -59,7 +59,7 @@
<base-table-s ref="lineTodayTable" style="margin-bottom: 16px;" v-if="activeLabelDay == 'table'" <base-table-s ref="lineTodayTable" style="margin-bottom: 16px;" v-if="activeLabelDay == 'table'"
:page="1" :limit="100" :table-props="tableProps" :table-data="tableData2" :max-height="300" /> :page="1" :limit="100" :table-props="tableProps" :table-data="tableData2" :max-height="300" />
</el-tab-pane> </el-tab-pane>
<el-tab-pane :label="'\u3000当天生产折线图\u3000'" name="graph"> <el-tab-pane :label="'\u3000生产折线图\u3000'" name="graph">
<div style="height: 230px;" v-if="activeLabelDay == 'graph'" class="graph"> <div style="height: 230px;" v-if="activeLabelDay == 'graph'" class="graph">
<barChart v-if="tableData2 && tableData2.length > 0" ref="barChart" height="230px" <barChart v-if="tableData2 && tableData2.length > 0" ref="barChart" height="230px"
:bar-data="tableData2" /> :bar-data="tableData2" />
@@ -72,50 +72,30 @@
</div> </div>
</div> </div>
<div class="content-inner" v-if="listQuery.timeType === 3"> <div class="content-inner" v-if="listQuery.timeType === 3">
<!-- 当班数据占1/2剩余高度 -->
<div class="content-card energyOverlimitLog"> <div class="content-card energyOverlimitLog">
<span class="blue-block"></span> <span class="blue-block"></span>
<span class="tip">上一班数据</span> <span class="tip" v-if="listQuery.startTime && listQuery.endTime">
<el-row style="margin-top: 10px;"> <span>{{ reportTypeMap[listQuery.reportType] }}</span>
<el-col class="custom-tabs"> <span>
<el-tabs v-model="activeLabel" :stretch="true" @tab-click="handleTabClick"> {{ parseTime(listQuery.startTime) }} {{
<el-tab-pane :label="'全部数据'" name="table"> parseTime(listQuery.endTime) }}
<base-table-s ref="lineCurrentShiftTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'" </span>
:page="1" :limit="100" :table-props="tableProps" :table-data="tableData" :max-height="300" /> </span>
</el-tab-pane> <span class="tip" v-else>生产数据 </span>
<el-tab-pane :label="'\u3000当天生产折线图\u3000'" name="graph"> <div class="graph">
<div style="height: 230px;" v-if="activeLabel == 'graph'" class="graph"> <base-table-s ref="lineCustomTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'" :page="1"
<barChart v-if="tableData && tableData.length > 0" ref="barChart" height="230px" :limit="100" :table-props="tableProps" :max-height="300" :table-data="tableDataCustom" />
:bar-data="tableData" /> </div>
<div v-else class="no-data-bg"></div>
</div>
</el-tab-pane>
</el-tabs>
</el-col>
</el-row>
</div> </div>
<!-- 当天数据占1/2剩余高度 -->
<div class="content-card energyOverlimitLog"> <div class="content-card energyOverlimitLog">
<span class="blue-block"></span> <span class="blue-block"></span>
<span class="tip">当天数据</span> <span class="tip">生产折线图</span>
<el-row style="margin-top: 10px;"> <div style="width: 100%;height: 100%;" class="graph">
<el-col class="custom-tabs"> <barChart v-if="tableDataCustom && tableDataCustom.length > 0" ref="barChart"
<el-tabs v-model="activeLabelDay" :stretch="true" @tab-click="handleTabClick"> :bar-data="tableDataCustom" />
<el-tab-pane :label="'全部数据'" name="table"> <div v-else class="no-data-bg"></div>
<base-table-s ref="lineTodayTable" style="margin-bottom: 16px;" v-if="activeLabelDay == 'table'" </div>
:page="1" :limit="100" :table-props="tableProps" :table-data="tableData2" :max-height="300" />
</el-tab-pane>
<el-tab-pane :label="'\u3000当天生产折线图\u3000'" name="graph">
<div style="height: 230px;" v-if="activeLabelDay == 'graph'" class="graph">
<barChart v-if="tableData2 && tableData2.length > 0" ref="barChart" height="230px"
:bar-data="tableData2" />
<div v-else class="no-data-bg"></div>
</div>
</el-tab-pane>
</el-tabs>
</el-col>
</el-row>
</div> </div>
</div> </div>
<!-- 3.2 时间维度为自定义时的内容两个平分高度的div --> <!-- 3.2 时间维度为自定义时的内容两个平分高度的div -->
@@ -126,10 +106,10 @@
<span>{{ reportTypeMap[listQuery.reportType] }}</span> <span>{{ reportTypeMap[listQuery.reportType] }}</span>
<span> <span>
{{ parseTime(listQuery.startTime) }} {{ {{ parseTime(listQuery.startTime) }} {{
parseTime(listQuery.endTime) }} parseTime(listQuery.endTime) }}
</span> </span>
</span> </span>
<span class="tip" v-else>生产表格数据 </span> <span class="tip" v-else>生产数据 </span>
<div class="graph"> <div class="graph">
<base-table-s ref="lineCustomTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'" :page="1" <base-table-s ref="lineCustomTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'" :page="1"
:limit="100" :table-props="tableProps" :max-height="300" :table-data="tableDataCustom" /> :limit="100" :table-props="tableProps" :max-height="300" :table-data="tableDataCustom" />
@@ -183,10 +163,10 @@
<span>{{ reportTypeMap[listQuery.reportType] }}</span> <span>{{ reportTypeMap[listQuery.reportType] }}</span>
<span> <span>
{{ parseTime(listQuery.startTime) }} {{ {{ parseTime(listQuery.startTime) }} {{
parseTime(listQuery.endTime) }} parseTime(listQuery.endTime) }}
</span> </span>
</span> </span>
<span class="tip" v-else>生产表格数据 </span> <span class="tip" v-else>生产数据 </span>
<base-table-s ref="productCustomTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'" :page="1" <base-table-s ref="productCustomTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'" :page="1"
:limit="100" :table-props="productTableProps" :table-data="productTableData" :max-height="300" /> :limit="100" :table-props="productTableProps" :table-data="productTableData" :max-height="300" />
</div> </div>
@@ -199,7 +179,7 @@
<script> <script>
import { parseTime } from '@/filter/code-filter'; import { parseTime } from '@/filter/code-filter';
import { import {
getLineAuto, getPdList, getPdlAutoReportNewSearchNow, getProductAuto, getLineAuto, getPLlistByFactory, getPdlAutoReportNewSearchNow, getProcessAutoReportLastGroup,
getProcessAutoReportGroup, getProcessAutoReportDay, getProcessAutoReportNew, getPdlAutoReportNewSearchLastGroup getProcessAutoReportGroup, getProcessAutoReportDay, getProcessAutoReportNew, getPdlAutoReportNewSearchLastGroup
} from '@/api/core/monitoring/auto'; } from '@/api/core/monitoring/auto';
import { getFactoryPage } from '@/api/core/base/factory'; import { getFactoryPage } from '@/api/core/base/factory';
@@ -423,7 +403,8 @@ export default {
], ],
product: [ // 按产品监控(不含上一班) product: [ // 按产品监控(不含上一班)
{ id: 1, name: '当天' }, { id: 1, name: '当天' },
{ id: 2, name: '自定义' } { id: 2, name: '自定义' },
{ id: 3, name: '上一班' }
] ]
}, },
formConfig: [ formConfig: [
@@ -563,6 +544,13 @@ export default {
productTablePropsDay() { productTablePropsDay() {
// 当天数据的完整表头(基础列 + 当天动态表头) // 当天数据的完整表头(基础列 + 当天动态表头)
const baseColumns = [ const baseColumns = [
{
prop: 'sizes',
label: '规格',
width: 105,
showOverflowtooltip: true,
fixed: true
},
{ {
prop: 'process', prop: 'process',
label: '产品工艺', label: '产品工艺',
@@ -571,7 +559,7 @@ export default {
{ {
prop: 'processType', prop: 'processType',
label: '产品类型', label: '产品类型',
filter: (val) => (val != 1 ? '面板' : '背板'), filter: (val) => (val === 1 ? '面板' : '背板'),
sortable: true, sortable: true,
fixed: true fixed: true
}, },
@@ -681,7 +669,7 @@ export default {
); );
const timeLabel = { const timeLabel = {
type: 'label', type: 'label',
label: `刷新时间: ${this.formatCurrentTime()}`, label: `刷新时间: ${this.formatCurrentTime()}`,
}; };
if (timeItemIndex > -1) { if (timeItemIndex > -1) {
this.formConfig.splice(timeItemIndex, 1, timeLabel); this.formConfig.splice(timeItemIndex, 1, timeLabel);
@@ -702,16 +690,16 @@ export default {
type: 'label', type: 'label',
label: `刷新时间: ${this.formatCurrentTime()}`, label: `刷新时间: ${this.formatCurrentTime()}`,
}; };
this.listQuery.timeType = 1; this.listQuery.timeType = 3;
if (this.$refs.searchBarForm) { if (this.$refs.searchBarForm) {
this.$refs.searchBarForm.formInline.timeType = 1; this.$refs.searchBarForm.formInline.timeType = 3;
} }
if (timeItemIndex > -1) { if (timeItemIndex > -1) {
this.formConfig.splice(timeItemIndex, 1, timeLabel); this.formConfig.splice(timeItemIndex, 1, timeLabel);
} else { } else {
this.formConfig.push(timeLabel); this.formConfig.push(timeLabel);
} }
this.getProductList(); this.getProductLastList();
} }
}, },
@@ -924,7 +912,9 @@ export default {
}, },
// 获取产线和工厂列表 // 获取产线和工厂列表
getPdLineList() { getPdLineList() {
getPdList().then(res => { getPLlistByFactory({
factoryIds:this.listQuery.factoryIds
}).then(res => {
this.formConfig[3].selectOptions = res.data || []; this.formConfig[3].selectOptions = res.data || [];
}); });
@@ -1072,7 +1062,11 @@ export default {
this.getDataList(); this.getDataList();
} }
} else { } else {
this.getProductList(); if (this.listQuery.timeType === 3) {
this.getProductLastList();
} else {
this.getProductList();
}
} }
break; break;
case 'export': case 'export':
@@ -1162,6 +1156,9 @@ export default {
// 格式化数据lineDetList提取到外层键名加lineId前缀 // 格式化数据lineDetList提取到外层键名加lineId前缀
const formatData = (rawList) => { const formatData = (rawList) => {
if (!Array.isArray(rawList) || rawList.length === 0) {
return [];
}
return rawList.map(item => { return rawList.map(item => {
// 解构出 lineDetList 和其他字段rest // 解构出 lineDetList 和其他字段rest
const { lineDetList = [], ...rest } = item; const { lineDetList = [], ...rest } = item;
@@ -1210,6 +1207,9 @@ export default {
// 格式化数据lineDetList提取到外层键名加lineId前缀 // 格式化数据lineDetList提取到外层键名加lineId前缀
const formatData = (rawList) => { const formatData = (rawList) => {
if (!Array.isArray(rawList) || rawList.length === 0) {
return [];
}
return rawList.map(item => { return rawList.map(item => {
// 解构出 lineDetList 和其他字段rest // 解构出 lineDetList 和其他字段rest
const { lineDetList = [], ...rest } = item; const { lineDetList = [], ...rest } = item;
@@ -1270,7 +1270,72 @@ export default {
} }
}, },
async getProductLastList() {
console.log('last');
this.listQuery.pageNo = 1;
this.listQuery.pageSize = 10;
this.listQuery.factoryId = this.headFormValue.factoryId || []
this.listQuery.process = this.headFormValue.process ? this.headFormValue.process : [];
this.listQuery.lineId = undefined;
this.listQuery.processType = this.headFormValue.processType ? this.headFormValue.processType : [];
this.listQuery.reportType = this.headFormValue.reportType || undefined;
this.listQuery.timeType = this.headFormValue.timeType ? this.headFormValue.timeType : this.listQuery.timeType;
this.listQuery.searchType = this.headFormValue.searchType || undefined
if (this.listQuery.timeType === 3) {
const resGroup = await getProcessAutoReportLastGroup(this.listQuery);
console.log('resGroup', resGroup);
// 格式化数据lineDetList提取到外层键名加lineId前缀
const formatData = (rawList) => {
if (!Array.isArray(rawList) || rawList.length === 0) {
return [];
}
return rawList.map(item => {
// 解构出 lineDetList 和其他字段rest
const { lineDetList = [], ...rest } = item;
// 遍历 lineDetList 中的每一项,逐个格式化并合并
const formattedLineData = lineDetList.reduce((acc, lineData) => {
// 取当前 lineData 的 lineId 作为前缀(确保存在,否则用空字符串)
const lineIdPrefix = lineData.lineId ? String(lineData.lineId) : '';
// 为当前 lineData 的每个字段添加 lineId 前缀,合并到累加器中
Object.entries(lineData).forEach(([key, value]) => {
const newKey = lineIdPrefix ? `${lineIdPrefix}${key}` : key;
acc[newKey] = value;
});
return acc;
}, {}); // 初始值为空对象
// 合并外层字段和所有格式化后的 lineDetList 字段
return { ...rest, ...formattedLineData };
});
};
// 处理当班和当天数据(分别存储)
this.productTableData = formatData(resGroup.data.list); // 当班数据
console.log(this.productTableData, 'productTableData');
// --------------------------
// 生成当班数据的动态表头
// --------------------------
const groupLineDatas = [];
resGroup.data.list.forEach(item => {
if (item.lineDetList && item.lineDetList.length) {
groupLineDatas.push(...item.lineDetList);
}
});
// 去重当班数据的产线按lineId
const uniqueGroupLines = Array.from(
new Map(groupLineDatas.map(line => [line.lineId, line])).values()
);
// 生成当班数据的表头(一级:产线名,二级:指标)
this.factoryColumns = this.generateLineColumns(uniqueGroupLines);
}
},
// 生成动态表头:一级为产线名,二级为产线数据指标 // 生成动态表头:一级为产线名,二级为产线数据指标
generateLineColumns(lines) { generateLineColumns(lines) {
// lines为去重后的产线列表单个元素为一条产线数据 // lines为去重后的产线列表单个元素为一条产线数据
@@ -1366,8 +1431,8 @@ export default {
}, },
// 为当天时调用的接口 // 为当天时调用的接口
getLastDayDataList() { getLastDayDataList() {
getPdlAutoReportNewSearchLastGroup().then((response) => { getPdlAutoReportNewSearchLastGroup(this.listQuery).then((response) => {
this.tableData = response.data.classData.map((item, index) => { this.tableDataCustom = response.data.classData.map((item, index) => {
item.originalLossNum = item.original?.lossNum; item.originalLossNum = item.original?.lossNum;
item.originalLossArea = item.original?.lossArea; item.originalLossArea = item.original?.lossArea;
item.edgeLossNum = item.edge?.lossNum; item.edgeLossNum = item.edge?.lossNum;
@@ -1388,7 +1453,7 @@ export default {
}); });
}, },
getDayDataList() { getDayDataList() {
getPdlAutoReportNewSearchNow().then((response) => { getPdlAutoReportNewSearchNow(this.listQuery).then((response) => {
this.tableData = response.data.classData.map((item, index) => { this.tableData = response.data.classData.map((item, index) => {
item.originalLossNum = item.original?.lossNum; item.originalLossNum = item.original?.lossNum;
item.originalLossArea = item.original?.lossArea; item.originalLossArea = item.original?.lossArea;
@@ -1452,6 +1517,43 @@ export default {
// 搜索栏下拉选择变化 // 搜索栏下拉选择变化
handleSearchBarChanged({ param, value }) { handleSearchBarChanged({ param, value }) {
if (param === 'timeType') { if (param === 'timeType') {
this.tableData2 = []
this.tableDataCustom = []
this.tableData = []
const resetCommon = () => {
// 重置搜索表单的筛选条件
if (this.$refs.searchBarForm) {
const form = this.$refs.searchBarForm.formInline;
form.timeVal = undefined;
form.timeType = 1;
form.reportType = undefined;
form.searchType = undefined;
form.lineId = undefined;
form.factoryId = undefined;
form.process = undefined;
form.processType = undefined;
}
// 重置查询参数
this.listQuery = {
...this.listQuery, // 保留分页等基础参数
factoryId: undefined,
process: undefined,
lineId: undefined,
processType: undefined,
reportType: undefined,
timeType: 1,
searchType: undefined,
startTime: undefined,
endTime: undefined
};
// 重置表单配置中公共隐藏的项
this.formConfig[1].type = ''; // 隐藏查询类型
this.formConfig[6].type = ''; // 隐藏报表类型
this.formConfig[7].type = ''; // 隐藏时间范围
};
// 3. 执行公共重置
resetCommon();
this.listQuery.timeType = value; this.listQuery.timeType = value;
const timeItemIndex = this.formConfig.findIndex(item => const timeItemIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间') item.label?.includes('刷新时间')
@@ -1568,7 +1670,9 @@ export default {
// 切换工厂时刷新产线列表 // 切换工厂时刷新产线列表
this.listQuery.lineId = []; this.listQuery.lineId = [];
this.$refs.searchBarForm.formInline.lineId = undefined; this.$refs.searchBarForm.formInline.lineId = undefined;
getPdList(value).then(res => { getPLlistByFactory({
factoryIds:value
}).then(res => {
this.formConfig[3].selectOptions = res.data || []; this.formConfig[3].selectOptions = res.data || [];
}); });
} }

View File

@@ -101,7 +101,7 @@ const tableProps = [
}, },
{ {
prop: 'thick', prop: 'thick',
label: '玻璃度/mm' label: '玻璃度/mm'
}, },
]; ];

View File

@@ -358,8 +358,6 @@ export default {
handleExport() { handleExport() {
// 处理查询参数 // 处理查询参数
let params = { ...this.listQuery }; let params = { ...this.listQuery };
params.pageNo = undefined;
params.pageSize = undefined;
this.$modal.confirm('是否确认导出下片日志?').then(() => { this.$modal.confirm('是否确认导出下片日志?').then(() => {
this.exportLoading = true; this.exportLoading = true;
return exportDownLogData(params); return exportDownLogData(params);

View File

@@ -36,7 +36,7 @@
<base-table-s ref="lineCurrentShiftTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'" <base-table-s ref="lineCurrentShiftTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'"
:page="1" :limit="100" :table-props="tableProps" :table-data="tableData" :max-height="300" /> :page="1" :limit="100" :table-props="tableProps" :table-data="tableData" :max-height="300" />
</el-tab-pane> </el-tab-pane>
<el-tab-pane :label="'\u3000当天生产折线图\u3000'" name="graph"> <el-tab-pane :label="'\u3000生产折线图\u3000'" name="graph">
<div style="height: 230px;" v-if="activeLabel == 'graph'" class="graph"> <div style="height: 230px;" v-if="activeLabel == 'graph'" class="graph">
<barChart v-if="tableData && tableData.length > 0" ref="barChart" height="230px" <barChart v-if="tableData && tableData.length > 0" ref="barChart" height="230px"
:bar-data="tableData" /> :bar-data="tableData" />
@@ -59,7 +59,7 @@
<base-table-s ref="lineTodayTable" style="margin-bottom: 16px;" v-if="activeLabelDay == 'table'" <base-table-s ref="lineTodayTable" style="margin-bottom: 16px;" v-if="activeLabelDay == 'table'"
:page="1" :limit="100" :table-props="tableProps" :table-data="tableData2" :max-height="300" /> :page="1" :limit="100" :table-props="tableProps" :table-data="tableData2" :max-height="300" />
</el-tab-pane> </el-tab-pane>
<el-tab-pane :label="'\u3000当天生产折线图\u3000'" name="graph"> <el-tab-pane :label="'\u3000生产折线图\u3000'" name="graph">
<div style="height: 230px;" v-if="activeLabelDay == 'graph'" class="graph"> <div style="height: 230px;" v-if="activeLabelDay == 'graph'" class="graph">
<barChart v-if="tableData2 && tableData2.length > 0" ref="barChart" height="230px" <barChart v-if="tableData2 && tableData2.length > 0" ref="barChart" height="230px"
:bar-data="tableData2" /> :bar-data="tableData2" />
@@ -72,50 +72,30 @@
</div> </div>
</div> </div>
<div class="content-inner" v-if="listQuery.timeType === 3"> <div class="content-inner" v-if="listQuery.timeType === 3">
<!-- 当班数据占1/2剩余高度 -->
<div class="content-card energyOverlimitLog"> <div class="content-card energyOverlimitLog">
<span class="blue-block"></span> <span class="blue-block"></span>
<span class="tip">上一班数据</span> <span class="tip" v-if="listQuery.startTime && listQuery.endTime">
<el-row style="margin-top: 10px;"> <span>{{ reportTypeMap[listQuery.reportType] }}</span>
<el-col class="custom-tabs"> <span>
<el-tabs v-model="activeLabel" :stretch="true" @tab-click="handleTabClick"> {{ parseTime(listQuery.startTime) }} {{
<el-tab-pane :label="'全部数据'" name="table"> parseTime(listQuery.endTime) }}
<base-table-s ref="lineCurrentShiftTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'" </span>
:page="1" :limit="100" :table-props="tableProps" :table-data="tableData" :max-height="300" /> </span>
</el-tab-pane> <span class="tip" v-else>生产数据 </span>
<el-tab-pane :label="'\u3000当天生产折线图\u3000'" name="graph"> <div class="graph">
<div style="height: 230px;" v-if="activeLabel == 'graph'" class="graph"> <base-table-s ref="lineCustomTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'" :page="1"
<barChart v-if="tableData && tableData.length > 0" ref="barChart" height="230px" :limit="100" :table-props="tableProps" :max-height="300" :table-data="tableDataCustom" />
:bar-data="tableData" /> </div>
<div v-else class="no-data-bg"></div>
</div>
</el-tab-pane>
</el-tabs>
</el-col>
</el-row>
</div> </div>
<!-- 当天数据占1/2剩余高度 -->
<div class="content-card energyOverlimitLog"> <div class="content-card energyOverlimitLog">
<span class="blue-block"></span> <span class="blue-block"></span>
<span class="tip">当天数据</span> <span class="tip">生产折线图</span>
<el-row style="margin-top: 10px;"> <div style="width: 100%;height: 100%;" class="graph">
<el-col class="custom-tabs"> <barChart v-if="tableDataCustom && tableDataCustom.length > 0" ref="barChart"
<el-tabs v-model="activeLabelDay" :stretch="true" @tab-click="handleTabClick"> :bar-data="tableDataCustom" />
<el-tab-pane :label="'全部数据'" name="table"> <div v-else class="no-data-bg"></div>
<base-table-s ref="lineTodayTable" style="margin-bottom: 16px;" v-if="activeLabelDay == 'table'" </div>
:page="1" :limit="100" :table-props="tableProps" :table-data="tableData2" :max-height="300" />
</el-tab-pane>
<el-tab-pane :label="'\u3000当天生产折线图\u3000'" name="graph">
<div style="height: 230px;" v-if="activeLabelDay == 'graph'" class="graph">
<barChart v-if="tableData2 && tableData2.length > 0" ref="barChart" height="230px"
:bar-data="tableData2" />
<div v-else class="no-data-bg"></div>
</div>
</el-tab-pane>
</el-tabs>
</el-col>
</el-row>
</div> </div>
</div> </div>
<!-- 3.2 时间维度为自定义时的内容两个平分高度的div --> <!-- 3.2 时间维度为自定义时的内容两个平分高度的div -->
@@ -126,10 +106,10 @@
<span>{{ reportTypeMap[listQuery.reportType] }}</span> <span>{{ reportTypeMap[listQuery.reportType] }}</span>
<span> <span>
{{ parseTime(listQuery.startTime) }} {{ {{ parseTime(listQuery.startTime) }} {{
parseTime(listQuery.endTime) }} parseTime(listQuery.endTime) }}
</span> </span>
</span> </span>
<span class="tip" v-else>生产表格数据 </span> <span class="tip" v-else>生产数据 </span>
<div class="graph"> <div class="graph">
<base-table-s ref="lineCustomTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'" :page="1" <base-table-s ref="lineCustomTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'" :page="1"
:limit="100" :table-props="tableProps" :max-height="300" :table-data="tableDataCustom" /> :limit="100" :table-props="tableProps" :max-height="300" :table-data="tableDataCustom" />
@@ -183,10 +163,10 @@
<span>{{ reportTypeMap[listQuery.reportType] }}</span> <span>{{ reportTypeMap[listQuery.reportType] }}</span>
<span> <span>
{{ parseTime(listQuery.startTime) }} {{ {{ parseTime(listQuery.startTime) }} {{
parseTime(listQuery.endTime) }} parseTime(listQuery.endTime) }}
</span> </span>
</span> </span>
<span class="tip" v-else>生产表格数据 </span> <span class="tip" v-else>生产数据 </span>
<base-table-s ref="productCustomTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'" :page="1" <base-table-s ref="productCustomTable" style="margin-bottom: 16px;" v-if="activeLabel == 'table'" :page="1"
:limit="100" :table-props="productTableProps" :table-data="productTableData" :max-height="300" /> :limit="100" :table-props="productTableProps" :table-data="productTableData" :max-height="300" />
</div> </div>
@@ -199,7 +179,7 @@
<script> <script>
import { parseTime } from '@/filter/code-filter'; import { parseTime } from '@/filter/code-filter';
import { import {
getLineAuto, getPdList, getPdlAutoReportNewSearchNow, getProductAuto, getLineAuto, getPdList, getPdlAutoReportNewSearchNow, getProcessAutoReportLastGroup,
getProcessAutoReportGroup, getProcessAutoReportDay, getProcessAutoReportNew, getPdlAutoReportNewSearchLastGroup getProcessAutoReportGroup, getProcessAutoReportDay, getProcessAutoReportNew, getPdlAutoReportNewSearchLastGroup
} from '@/api/core/monitoring/auto'; } from '@/api/core/monitoring/auto';
import { getFactoryPage } from '@/api/core/base/factory'; import { getFactoryPage } from '@/api/core/base/factory';
@@ -423,7 +403,9 @@ export default {
], ],
product: [ // 按产品监控(不含上一班) product: [ // 按产品监控(不含上一班)
{ id: 1, name: '当天' }, { id: 1, name: '当天' },
{ id: 2, name: '自定义' } { id: 2, name: '自定义' },
{ id: 3, name: '上一班' }
] ]
}, },
formConfig: [ formConfig: [
@@ -527,6 +509,13 @@ export default {
productTableProps() { productTableProps() {
// 当班数据的完整表头(基础列 + 当班动态表头) // 当班数据的完整表头(基础列 + 当班动态表头)
const baseColumns = [ const baseColumns = [
{
prop: 'sizes',
label: '规格',
width: 105,
showOverflowtooltip: true,
fixed: true
},
{ {
prop: 'process', prop: 'process',
label: '产品工艺', label: '产品工艺',
@@ -535,7 +524,7 @@ export default {
{ {
prop: 'processType', prop: 'processType',
label: '产品类型', label: '产品类型',
filter: (val) => (val != 1 ? '面板' : '背板'), filter: (val) => (val === 1 ? '面板' : '背板'),
sortable: true, sortable: true,
fixed: true fixed: true
}, },
@@ -550,6 +539,13 @@ export default {
productTablePropsDay() { productTablePropsDay() {
// 当天数据的完整表头(基础列 + 当天动态表头) // 当天数据的完整表头(基础列 + 当天动态表头)
const baseColumns = [ const baseColumns = [
{
prop: 'sizes',
label: '规格',
width: 105,
showOverflowtooltip: true,
fixed: true
},
{ {
prop: 'process', prop: 'process',
label: '产品工艺', label: '产品工艺',
@@ -601,7 +597,7 @@ export default {
}); });
// 3. 初始化直接调用 按产品监控 的接口 // 3. 初始化直接调用 按产品监控 的接口
this.getProductList(); // this.getProductList();
this.getPdLineList(); this.getPdLineList();
const queryParams = { const queryParams = {
pageNo: 1, pageNo: 1,
@@ -701,7 +697,6 @@ export default {
this.getLastDayDataList(); this.getLastDayDataList();
} else { } else {
this.getProductList();
const timeItemIndex = this.formConfig.findIndex(item => const timeItemIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间') item.label?.includes('刷新时间')
); );
@@ -714,18 +709,84 @@ export default {
} else { } else {
this.formConfig.push(timeLabel); this.formConfig.push(timeLabel);
} }
this.listQuery.timeType = 1; this.listQuery.timeType = 3;
if (this.$refs.searchBarForm) { if (this.$refs.searchBarForm) {
this.$refs.searchBarForm.formInline.timeType = 1; this.$refs.searchBarForm.formInline.timeType = 3;
} }
// 按产品监控:显示产品工艺和类型,隐藏产线,时间维度移除上一班 // 按产品监控:显示产品工艺和类型,隐藏产线,时间维度移除上一班
this.formConfig[0].selectOptions = this.timeTypeOptions.product; // 不含上一班 this.formConfig[0].selectOptions = this.timeTypeOptions.product; // 不含上一班
this.formConfig[3].type = ''; // 隐藏产线 this.formConfig[3].type = ''; // 隐藏产线
this.formConfig[4].type = 'select'; // 显示产品工艺 this.formConfig[4].type = 'select'; // 显示产品工艺
this.formConfig[5].type = 'select'; // 显示产品类型 this.formConfig[5].type = 'select'; // 显示产品类型
this.getProductLastList();
} }
}, },
async getProductLastList() {
console.log('last');
this.listQuery.pageNo = 1;
this.listQuery.pageSize = 10;
this.listQuery.factoryId = this.headFormValue.factoryId || []
this.listQuery.process = this.headFormValue.process ? this.headFormValue.process : [];
this.listQuery.lineId = undefined;
this.listQuery.processType = this.headFormValue.processType ? this.headFormValue.processType : [];
this.listQuery.reportType = this.headFormValue.reportType || undefined;
this.listQuery.timeType = this.headFormValue.timeType ? this.headFormValue.timeType : this.listQuery.timeType;
this.listQuery.searchType = this.headFormValue.searchType || undefined
if (this.listQuery.timeType === 3) {
const resGroup = await getProcessAutoReportLastGroup(this.listQuery);
console.log('resGroup', resGroup);
// 格式化数据lineDetList提取到外层键名加lineId前缀
const formatData = (rawList) => {
if (!Array.isArray(rawList) || rawList.length === 0) {
return [];
}
return rawList.map(item => {
// 解构出 lineDetList 和其他字段rest
const { lineDetList = [], ...rest } = item;
// 遍历 lineDetList 中的每一项,逐个格式化并合并
const formattedLineData = lineDetList.reduce((acc, lineData) => {
// 取当前 lineData 的 lineId 作为前缀(确保存在,否则用空字符串)
const lineIdPrefix = lineData.lineId ? String(lineData.lineId) : '';
// 为当前 lineData 的每个字段添加 lineId 前缀,合并到累加器中
Object.entries(lineData).forEach(([key, value]) => {
const newKey = lineIdPrefix ? `${lineIdPrefix}${key}` : key;
acc[newKey] = value;
});
return acc;
}, {}); // 初始值为空对象
// 合并外层字段和所有格式化后的 lineDetList 字段
return { ...rest, ...formattedLineData };
});
};
// 处理当班和当天数据(分别存储)
this.productTableData = formatData(resGroup.data.list); // 当班数据
console.log(this.productTableData, 'productTableData');
// --------------------------
// 生成当班数据的动态表头
// --------------------------
const groupLineDatas = [];
resGroup.data.list.forEach(item => {
if (item.lineDetList && item.lineDetList.length) {
groupLineDatas.push(...item.lineDetList);
}
});
// 去重当班数据的产线按lineId
const uniqueGroupLines = Array.from(
new Map(groupLineDatas.map(line => [line.lineId, line])).values()
);
// 生成当班数据的表头(一级:产线名,二级:指标)
this.factoryColumns = this.generateLineColumns(uniqueGroupLines);
}
},
// 导出表格 // 导出表格
handleExport() { handleExport() {
// 按产线监控 // 按产线监控
@@ -1043,7 +1104,11 @@ export default {
this.getDataList(); this.getDataList();
} }
} else { } else {
this.getProductList(); if (this.listQuery.timeType === 3) {
this.getProductLastList();
} else {
this.getProductList();
}
} }
break; break;
case 'export': case 'export':
@@ -1076,7 +1141,7 @@ export default {
if (this.activeName === 'productLine') { if (this.activeName === 'productLine') {
this.getDayDataList(); this.getDayDataList();
} else { } else {
this.getProductList(); this.getProductLastList();
} }
break; break;
default: default:
@@ -1132,17 +1197,31 @@ export default {
// 格式化数据lineDetList提取到外层键名加lineId前缀 // 格式化数据lineDetList提取到外层键名加lineId前缀
const formatData = (rawList) => { const formatData = (rawList) => {
// 1. 处理rawList为空/非数组的情况,直接返回空数组
if (!Array.isArray(rawList) || rawList.length === 0) {
return [];
}
return rawList.map(item => { return rawList.map(item => {
// 解构出 lineDetList 和其他字段rest // 防止item为null/undefined的情况默认赋值为空对象
const { lineDetList = [], ...rest } = item; const currentItem = item || {};
// 解构出 lineDetList 和其他字段rest确保lineDetList是数组
const { lineDetList = [], ...rest } = currentItem;
// 2. 处理lineDetList为空/非数组的情况直接返回rest
if (!Array.isArray(lineDetList) || lineDetList.length === 0) {
return { ...rest }; // 浅拷贝,避免原对象引用问题
}
// 遍历 lineDetList 中的每一项,逐个格式化并合并 // 遍历 lineDetList 中的每一项,逐个格式化并合并
const formattedLineData = lineDetList.reduce((acc, lineData) => { const formattedLineData = lineDetList.reduce((acc, lineData) => {
// 防止lineData为null/undefined的情况默认赋值为空对象
const currentLineData = lineData || {};
// 取当前 lineData 的 lineId 作为前缀(确保存在,否则用空字符串) // 取当前 lineData 的 lineId 作为前缀(确保存在,否则用空字符串)
const lineIdPrefix = lineData.lineId ? String(lineData.lineId) : ''; const lineIdPrefix = currentLineData.lineId ? String(currentLineData.lineId) : '';
// 为当前 lineData 的每个字段添加 lineId 前缀,合并到累加器中 // 为当前 lineData 的每个字段添加 lineId 前缀,合并到累加器中
Object.entries(lineData).forEach(([key, value]) => { Object.entries(currentLineData).forEach(([key, value]) => {
const newKey = lineIdPrefix ? `${lineIdPrefix}${key}` : key; const newKey = lineIdPrefix ? `${lineIdPrefix}${key}` : key;
acc[newKey] = value; acc[newKey] = value;
}); });
@@ -1180,6 +1259,9 @@ export default {
// 格式化数据lineDetList提取到外层键名加lineId前缀 // 格式化数据lineDetList提取到外层键名加lineId前缀
const formatData = (rawList) => { const formatData = (rawList) => {
if (!Array.isArray(rawList) || rawList.length === 0) {
return [];
}
return rawList.map(item => { return rawList.map(item => {
// 解构出 lineDetList 和其他字段rest // 解构出 lineDetList 和其他字段rest
const { lineDetList = [], ...rest } = item; const { lineDetList = [], ...rest } = item;
@@ -1336,8 +1418,10 @@ export default {
}, },
// 为当天时调用的接口 // 为当天时调用的接口
getLastDayDataList() { getLastDayDataList() {
getPdlAutoReportNewSearchLastGroup().then((response) => { console.log('this.listQuery', this.listQuery);
this.tableData = response.data.classData.map((item, index) => {
getPdlAutoReportNewSearchLastGroup(this.listQuery).then((response) => {
this.tableDataCustom = response.data.classData.map((item, index) => {
item.originalLossNum = item.original?.lossNum; item.originalLossNum = item.original?.lossNum;
item.originalLossArea = item.original?.lossArea; item.originalLossArea = item.original?.lossArea;
item.edgeLossNum = item.edge?.lossNum; item.edgeLossNum = item.edge?.lossNum;
@@ -1358,7 +1442,7 @@ export default {
}); });
}, },
getDayDataList() { getDayDataList() {
getPdlAutoReportNewSearchNow().then((response) => { getPdlAutoReportNewSearchNow(this.listQuery).then((response) => {
this.tableData = response.data.classData.map((item, index) => { this.tableData = response.data.classData.map((item, index) => {
item.originalLossNum = item.original?.lossNum; item.originalLossNum = item.original?.lossNum;
item.originalLossArea = item.original?.lossArea; item.originalLossArea = item.original?.lossArea;
@@ -1414,6 +1498,45 @@ export default {
handleSearchBarChanged({ param, value }) { handleSearchBarChanged({ param, value }) {
console.log(value, param); console.log(value, param);
if (param === 'timeType') { if (param === 'timeType') {
this.tableData = []
this.tableDataCustom = []
this.tableData2 = []
this.productTableData = []
this.productTableDataDay = []
const resetCommon = () => {
// 重置搜索表单的筛选条件
if (this.$refs.searchBarForm) {
const form = this.$refs.searchBarForm.formInline;
form.timeVal = undefined;
form.timeType = 1;
form.reportType = undefined;
form.searchType = undefined;
form.lineId = undefined;
form.factoryId = undefined;
form.process = undefined;
form.processType = undefined;
}
// 重置查询参数
this.listQuery = {
...this.listQuery, // 保留分页等基础参数
factoryId: undefined,
process: undefined,
lineId: undefined,
processType: undefined,
reportType: undefined,
timeType: 1,
searchType: undefined,
startTime: undefined,
endTime: undefined
};
// 重置表单配置中公共隐藏的项
this.formConfig[1].type = ''; // 隐藏查询类型
this.formConfig[6].type = ''; // 隐藏报表类型
this.formConfig[7].type = ''; // 隐藏时间范围
};
// 3. 执行公共重置
resetCommon();
this.listQuery.timeType = value; this.listQuery.timeType = value;
const timeItemIndex = this.formConfig.findIndex(item => const timeItemIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间') item.label?.includes('刷新时间')

View File

@@ -462,7 +462,7 @@ export default {
this.originData = null; this.originData = null;
this.hasData = true; this.hasData = true;
if (this.$refs.searchBarForm) { if (this.$refs.searchBarForm) {
this.$refs.searchBarForm.form.timeVal = []; // this.$refs.searchBarForm.form.timeVal = [];
} }
}, },

View File

@@ -216,6 +216,7 @@ import {
import { getTree } from '@/api/base/equipment'; import { getTree } from '@/api/base/equipment';
import { getEquipmentTypePage } from '@/api/base/equipmentType'; import { getEquipmentTypePage } from '@/api/base/equipmentType';
import { getEquipmentOverall } from '@/api/base/equipment'; import { getEquipmentOverall } from '@/api/base/equipment';
import { getTenantId } from '@/utils/auth'
// import * as XLSX from 'xlsx'; // import * as XLSX from 'xlsx';
// import FileSaver from 'file-saver'; // import FileSaver from 'file-saver';
@@ -569,7 +570,7 @@ export default {
const token = getAccessToken(); const token = getAccessToken();
const headers = new Headers({ const headers = new Headers({
Authorization: `Bearer ${token}`, Authorization: `Bearer ${token}`,
'tenant-id': store.getters.userId, 'tenant-id': getTenantId(),
'Content-Type': 'text/event-stream', 'Content-Type': 'text/event-stream',
}); });

View File

@@ -135,13 +135,14 @@ export default {
label: '时间范围', label: '时间范围',
dateType: 'datetimerange', dateType: 'datetimerange',
format: 'yyyy-MM-dd HH:mm:ss', format: 'yyyy-MM-dd HH:mm:ss',
// valueFormat: 'timestamp', valueFormat: 'timestamp',
valueFormat: 'yyyy-MM-dd HH:mm:ss', // valueFormat: 'yyyy-MM-dd HH:mm:ss',
rangeSeparator: '-', rangeSeparator: '-',
startPlaceholder: '开始时间', startPlaceholder: '开始时间',
endPlaceholder: '结束时间', endPlaceholder: '结束时间',
param: 'timeVal', param: 'timeVal',
width: 350 width: 350,
defaultSelect: [],
}, },
{ {
type: 'button', type: 'button',
@@ -215,11 +216,55 @@ export default {
// deep: true // deep: true
// }, // },
// }, // },
created() { mounted() {
const { startTimestamp, endTimestamp } = this.getThreeDaysAgoThisTimeToNowTimeStamps();
// 找到时间范围的配置项并赋值对应你代码中的timeVal参数
this.searchBarFormConfig[3].defaultSelect = [startTimestamp, endTimestamp]; // 赋值给日期选择器
this.queryParams.startTime = startTimestamp;
this.queryParams.endTime = endTimestamp;
this.getList(); this.getList();
this.getDict() this.getDict()
}, },
methods: { methods: {
getThreeDaysAgoThisTimeToNowTimeStamps() {
const now = new Date();
// 1. 计算三天前的当前时刻使用setDate直接修改日期保留时分秒等信息
const threeDaysAgoThisTime = new Date(now); // 复制当前日期对象,避免修改原对象
threeDaysAgoThisTime.setDate(threeDaysAgoThisTime.getDate() - 3); // 日期减3天时分秒保持和当前一致
// 2. 获取时间戳(毫秒级和秒级)
// 开始时间戳:三天前的当前时刻
const startTimestamp = threeDaysAgoThisTime.getTime(); // 毫秒级
const startTimestampSec = Math.floor(startTimestamp / 1000); // 秒级
// 结束时间戳:当前时刻
const endTimestamp = now.getTime(); // 毫秒级
const endTimestampSec = Math.floor(endTimestamp / 1000); // 秒级
// 封装日期格式化函数转换为yyyy-MM-dd HH:mm:ss格式
const formatDateTime = (date) => {
const y = date.getFullYear();
// 月份是从0开始的所以要+1补零确保是两位
const m = String(date.getMonth() + 1).padStart(2, '0');
const d = String(date.getDate()).padStart(2, '0');
const h = String(date.getHours()).padStart(2, '0');
const min = String(date.getMinutes()).padStart(2, '0');
const s = String(date.getSeconds()).padStart(2, '0');
return `${y}-${m}-${d} ${h}:${min}:${s}`;
};
// 格式化后的字符串:三天前的当前时刻 和 当前时刻
const startDateTimeStr = formatDateTime(threeDaysAgoThisTime);
const endDateTimeStr = formatDateTime(now);
return {
startTimestamp, // 三天前当前时刻的毫秒级时间戳
endTimestamp, // 当前时刻的毫秒级时间戳
startTimestampSec, // 三天前当前时刻的秒级时间戳
endTimestampSec, // 当前时刻的秒级时间戳
startDateTimeStr, // yyyy-MM-dd HH:mm:ss格式的开始时间字符串
endDateTimeStr // yyyy-MM-dd HH:mm:ss格式的结束时间字符串
};
},
getDict() { getDict() {
getPdList().then(res => { getPdList().then(res => {
this.searchBarFormConfig[1].selectOptions = res.data || []; this.searchBarFormConfig[1].selectOptions = res.data || [];

View File

@@ -150,7 +150,8 @@ export default {
startPlaceholder: '开始时间', startPlaceholder: '开始时间',
endPlaceholder: '结束时间', endPlaceholder: '结束时间',
param: 'timeVal', param: 'timeVal',
width: 350 width: 350,
defaultSelect: [],
}, },
{ {
type: 'button', type: 'button',
@@ -226,11 +227,56 @@ export default {
// deep: true // deep: true
// }, // },
// }, // },
created() { mounted() {
const { startTimestamp, endTimestamp } = this.getThreeDaysAgoThisTimeToNowTimeStamps();
// 找到时间范围的配置项并赋值对应你代码中的timeVal参数
this.searchBarFormConfig[2].defaultSelect = [startTimestamp, endTimestamp]; // 赋值给日期选择器
this.queryParams.startTime = startTimestamp;
this.queryParams.endTime = endTimestamp;
this.getList(); this.getList();
this.getDict() this.getDict()
}, },
methods: { methods: {
getThreeDaysAgoThisTimeToNowTimeStamps() {
const now = new Date();
// 1. 计算三天前的当前时刻使用setDate直接修改日期保留时分秒等信息
const threeDaysAgoThisTime = new Date(now); // 复制当前日期对象,避免修改原对象
threeDaysAgoThisTime.setDate(threeDaysAgoThisTime.getDate() - 3); // 日期减3天时分秒保持和当前一致
// 2. 获取时间戳(毫秒级和秒级)
// 开始时间戳:三天前的当前时刻
const startTimestamp = threeDaysAgoThisTime.getTime(); // 毫秒级
const startTimestampSec = Math.floor(startTimestamp / 1000); // 秒级
// 结束时间戳:当前时刻
const endTimestamp = now.getTime(); // 毫秒级
const endTimestampSec = Math.floor(endTimestamp / 1000); // 秒级
// 封装日期格式化函数转换为yyyy-MM-dd HH:mm:ss格式
const formatDateTime = (date) => {
const y = date.getFullYear();
// 月份是从0开始的所以要+1补零确保是两位
const m = String(date.getMonth() + 1).padStart(2, '0');
const d = String(date.getDate()).padStart(2, '0');
const h = String(date.getHours()).padStart(2, '0');
const min = String(date.getMinutes()).padStart(2, '0');
const s = String(date.getSeconds()).padStart(2, '0');
return `${y}-${m}-${d} ${h}:${min}:${s}`;
};
// 格式化后的字符串:三天前的当前时刻 和 当前时刻
const startDateTimeStr = formatDateTime(threeDaysAgoThisTime);
const endDateTimeStr = formatDateTime(now);
return {
startTimestamp, // 三天前当前时刻的毫秒级时间戳
endTimestamp, // 当前时刻的毫秒级时间戳
startTimestampSec, // 三天前当前时刻的秒级时间戳
endTimestampSec, // 当前时刻的秒级时间戳
startDateTimeStr, // yyyy-MM-dd HH:mm:ss格式的开始时间字符串
endDateTimeStr // yyyy-MM-dd HH:mm:ss格式的结束时间字符串
};
},
getDict() { getDict() {
getPdList().then(res => { getPdList().then(res => {
this.searchBarFormConfig[1].selectOptions = res.data || []; this.searchBarFormConfig[1].selectOptions = res.data || [];

View File

@@ -152,7 +152,8 @@ export default {
startPlaceholder: '开始时间', startPlaceholder: '开始时间',
endPlaceholder: '结束时间', endPlaceholder: '结束时间',
param: 'timeVal', param: 'timeVal',
width: 350 width: 350,
defaultSelect: [],
}, },
{ {
type: 'button', type: 'button',
@@ -225,11 +226,56 @@ export default {
// deep: true // deep: true
// }, // },
// }, // },
created() { mounted() {
const { startTimestamp, endTimestamp } = this.getThreeDaysAgoThisTimeToNowTimeStamps();
// 找到时间范围的配置项并赋值对应你代码中的timeVal参数
this.searchBarFormConfig[2].defaultSelect = [startTimestamp, endTimestamp]; // 赋值给日期选择器
this.queryParams.startTime = startTimestamp;
this.queryParams.endTime = endTimestamp;
this.getList(); this.getList();
this.getDict() this.getDict()
}, },
methods: { methods: {
getThreeDaysAgoThisTimeToNowTimeStamps() {
const now = new Date();
// 1. 计算三天前的当前时刻使用setDate直接修改日期保留时分秒等信息
const threeDaysAgoThisTime = new Date(now); // 复制当前日期对象,避免修改原对象
threeDaysAgoThisTime.setDate(threeDaysAgoThisTime.getDate() - 3); // 日期减3天时分秒保持和当前一致
// 2. 获取时间戳(毫秒级和秒级)
// 开始时间戳:三天前的当前时刻
const startTimestamp = threeDaysAgoThisTime.getTime(); // 毫秒级
const startTimestampSec = Math.floor(startTimestamp / 1000); // 秒级
// 结束时间戳:当前时刻
const endTimestamp = now.getTime(); // 毫秒级
const endTimestampSec = Math.floor(endTimestamp / 1000); // 秒级
// 封装日期格式化函数转换为yyyy-MM-dd HH:mm:ss格式
const formatDateTime = (date) => {
const y = date.getFullYear();
// 月份是从0开始的所以要+1补零确保是两位
const m = String(date.getMonth() + 1).padStart(2, '0');
const d = String(date.getDate()).padStart(2, '0');
const h = String(date.getHours()).padStart(2, '0');
const min = String(date.getMinutes()).padStart(2, '0');
const s = String(date.getSeconds()).padStart(2, '0');
return `${y}-${m}-${d} ${h}:${min}:${s}`;
};
// 格式化后的字符串:三天前的当前时刻 和 当前时刻
const startDateTimeStr = formatDateTime(threeDaysAgoThisTime);
const endDateTimeStr = formatDateTime(now);
return {
startTimestamp, // 三天前当前时刻的毫秒级时间戳
endTimestamp, // 当前时刻的毫秒级时间戳
startTimestampSec, // 三天前当前时刻的秒级时间戳
endTimestampSec, // 当前时刻的秒级时间戳
startDateTimeStr, // yyyy-MM-dd HH:mm:ss格式的开始时间字符串
endDateTimeStr // yyyy-MM-dd HH:mm:ss格式的结束时间字符串
};
},
getDict() { getDict() {
getPdList().then(res => { getPdList().then(res => {
this.searchBarFormConfig[1].selectOptions = res.data || []; this.searchBarFormConfig[1].selectOptions = res.data || [];

17160
yarn.lock

File diff suppressed because it is too large Load Diff