Compare commits

..

7 Commits

Author SHA1 Message Date
‘937886381’
51e1ef8501 修改 2026-06-11 15:31:25 +08:00
‘937886381’
35fb0d8bfb Merge branch 'projects/line-new' into projects/line-new-zhp 2025-12-24 16:35:44 +08:00
‘937886381’
0c52306cc6 修改 2025-12-24 16:34:37 +08:00
a5fba28ff7 Merge pull request 'projects/line-new-zhp' (#468) from projects/line-new-zhp into projects/line-new
Reviewed-on: #468
2025-12-23 08:53:19 +08:00
‘937886381’
1f8b994218 Merge branch 'projects/line-new' into projects/line-new-zhp 2025-12-23 08:49:07 +08:00
‘937886381’
ccfa73f3bc xiugai 2025-12-23 08:46:44 +08:00
‘937886381’
89ff79bfd7 修改 2025-12-23 08:35:46 +08:00
12 changed files with 2276 additions and 598 deletions

BIN
dist.zip

Binary file not shown.

View File

@@ -0,0 +1,25 @@
import request from '@/utils/request'
export function getEquipmentAlarmLogPage(query) {
return request({
url: '/monitoring/equipment-param-alarm-log/page',
method: 'get',
params: query,
});
}
export function getEqList(query) {
return request({
url: '/base/equipment/listByLine',
method: 'get',
params: query,
});
}
export function getLineList(query) {
return request({
url: '/base/production-line/listAll',
method: 'get',
// params: query,
});
}

View File

@@ -88,7 +88,32 @@ export default {
};
},
created() {},
methods: {
methods: {
dataFormSubmit() {
this.$refs["dataForm"].validate((valid) => {
if (!valid) {
return false;
}
// 修改的提交
if (this.dataForm.id) {
this.urlOptions.updateURL(this.dataForm).then(response => {
this.$modal.msgSuccess("修改成功");
this.visible = false;
this.$emit("refreshDataList");
});
return;
}
// 添加的提交
this.urlOptions.createURL(this.dataForm).then(response => {
if (response.code === 1001033 || response.code === 1001034) {
return this.$modal.msgError(response.msg);
}
this.$modal.msgSuccess("新增成功");
this.visible = false;
this.$emit("refreshDataList");
});
});
},
},
};
</script>

View File

@@ -152,7 +152,30 @@ export default {
.label;
}
});
},
},
dataFormSubmit() {
this.$refs["dataForm"].validate((valid) => {
if (!valid) {
return false;
}
// 修改的提交
if (this.dataForm.id) {
this.urlOptions.updateURL(this.dataForm).then(response => {
this.$modal.msgSuccess("修改成功");
this.visible = false;
this.$emit("refreshDataList");
});
return;
}
// 添加的提交
this.urlOptions.createURL(this.dataForm).then(response => {
// console.log('response',);
this.$modal.msgSuccess("新增成功");
this.visible = false;
this.$emit("refreshDataList");
});
});
},
},
};
</script>

View File

@@ -64,7 +64,7 @@
<script>
import eqDetail from './eq-detail';
import { parseTime } from '../../mixins/code-filter';
import { getPdList } from '@/api/core/monitoring/auto';
import { getPLlistByFactory } from '@/api/core/monitoring/auto';
import { getNewCTNow, getNewCTCharts } from '@/api/core/analysis/index';
import { getFactoryPage } from '@/api/core/base/factory';
// import codeFilter from '../../mixins/code-filter'
@@ -134,7 +134,9 @@ export default {
type: 'select',
label: '工厂',
selectOptions: [],
param: 'factoryId',
param: 'factoryId',
collapseTags: true,
multiple: true,
onchange: true,
},
{
@@ -233,9 +235,9 @@ export default {
return exportTableOut;
},
getPdLineList() {
getPdList().then((res) => {
this.formConfig[1].selectOptions = res.data || [];
});
// getPLlistByFactory().then((res) => {
// this.formConfig[1].selectOptions = res.data || [];
// });
const params = {
pageSize: 100,
pageNo: 1,
@@ -275,7 +277,7 @@ export default {
handleSearchBarChanged({ param, value }) {
this.listQuery.lineId = [];
this.$refs.searchBarForm.formInline.lineId = undefined;
getPdList(value).then((res) => {
getPLlistByFactory({ factoryIds: this.$refs.searchBarForm.formInline.factoryId }).then((res) => {
this.formConfig[1].selectOptions = res.data || [];
});
},

View File

@@ -190,175 +190,6 @@ import barChart from './BarChart.vue';
import ButtonNav from '@/components/ButtonNav';
import { listData } from '@/api/system/dict/data';
// 表格列配置
const tableProps = [
{
prop: 'factoryName',
label: '工厂',
fixed: true
},
{
prop: 'lineName',
label: '产线',
fixed: true
},
{
prop: 'sizes',
label: '规格',
width: 105,
showOverflowtooltip: true,
fixed: true
},
{
prop: 'process',
label: '产品工艺',
fixed: true
},
{
prop: 'inputN',
label: '投入',
align: 'center',
children: [
{ prop: 'inputNum', label: '投入数量/片' },
{
prop: 'inputArea',
label: '投入面积/m²',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
prop: 'outputN',
label: '产出',
align: 'center',
children: [
{ prop: 'outputNum', label: '产出数量/片' },
{
prop: 'outputArea',
label: '产出面积/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
prop: 'lossN',
label: '不良',
align: 'center',
children: [
{ prop: 'lossNum', label: '不良数量/片' },
{
prop: 'lossArea',
label: '不良面积/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
prop: 'lossRatio',
label: '不良率/%',
filter: (val) => (val != null ? val.toFixed(2) : '-')
},
{
prop: 'outputRatio',
label: '投入产出率/%',
filter: (val) => (val != null ? val.toFixed(2) : '-')
},
{
prop: 'processingRatio',
label: '加工成品率/%',
filter: (val) => (val != null ? val.toFixed(2) : '-')
},
{
label: '不良详情',
align: 'center',
children: [
{
label: '原片',
align: 'center',
children: [
{ prop: 'originalLossNum', label: '原片不良/片' },
{
prop: 'originalLossArea',
label: '原片不良/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
label: '磨边',
align: 'center',
children: [
{ prop: 'edgeLossNum', label: '磨边不良/片' },
{
prop: 'edgeLossArea',
label: '磨边不良/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
label: '打孔',
align: 'center',
children: [
{ prop: 'drillLossNum', label: '打孔不良/片' },
{
prop: 'drillLossArea',
label: '打孔不良/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
label: '镀膜',
align: 'center',
children: [
{ prop: 'coatingLossNum', label: '镀膜不良/片' },
{
prop: 'coatingLossArea',
label: '镀膜不良/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
label: '丝印',
align: 'center',
children: [
{ prop: 'silkLossNum', label: '丝印不良/片' },
{
prop: 'silkLossArea',
label: '丝印不良/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
label: '钢化',
align: 'center',
children: [
{ prop: 'temperingLossNum', label: '钢化不良/片' },
{
prop: 'temperingLossArea',
label: '钢化不良/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
label: '包装',
align: 'center',
children: [
{ prop: 'packingLossNum', label: '包装不良/片' },
{
prop: 'packingLossArea',
label: '包装不良/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
}
]
}
];
export default {
components: { barChart, ButtonNav, baseTableS },
@@ -372,6 +203,7 @@ export default {
total: 1,
timeType: 1 // 1-当天2-自定义
},
isPeriodicReport:false,
reportTypeMap: {
1: '日报',
2: '周报',
@@ -383,7 +215,6 @@ export default {
fileName: '',
headFormValue:{},
dataListLoading: false,
tableProps,
factoryColumns: [],
factoryColumnsDay: [],
activeName: 'product',
@@ -511,6 +342,184 @@ export default {
};
},
computed: {
tableProps() {
const props = [
{
prop: 'factoryName',
label: '工厂',
fixed: true
},
{
prop: 'lineName',
label: '产线',
fixed: true
},
{
prop: 'sizes',
label: '规格',
width: 105,
showOverflowtooltip: true,
fixed: true
},
{
prop: 'process',
label: '产品工艺',
fixed: true
},
(this.isPeriodicReport ? {
prop: 'reportDate',
label: '日期',
fixed: true,
width: 120
} : ''),
{
prop: 'inputN',
label: '投入',
align: 'center',
children: [
{ prop: 'inputNum', label: '投入数量/片' },
{
prop: 'inputArea',
label: '投入面积/m²',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
prop: 'outputN',
label: '产出',
align: 'center',
children: [
{ prop: 'outputNum', label: '产出数量/片' },
{
prop: 'outputArea',
label: '产出面积/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
prop: 'lossN',
label: '不良',
align: 'center',
children: [
{ prop: 'lossNum', label: '不良数量/片' },
{
prop: 'lossArea',
label: '不良面积/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
prop: 'lossRatio',
label: '不良率/%',
filter: (val) => (val != null ? val.toFixed(2) : '-')
},
{
prop: 'outputRatio',
label: '投入产出率/%',
filter: (val) => (val != null ? val.toFixed(2) : '-')
},
{
prop: 'processingRatio',
label: '加工成品率/%',
filter: (val) => (val != null ? val.toFixed(2) : '-')
},
{
label: '不良详情',
align: 'center',
children: [
{
label: '原片',
align: 'center',
children: [
{ prop: 'originalLossNum', label: '原片不良/片' },
{
prop: 'originalLossArea',
label: '原片不良/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
label: '磨边',
align: 'center',
children: [
{ prop: 'edgeLossNum', label: '磨边不良/片' },
{
prop: 'edgeLossArea',
label: '磨边不良/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
label: '打孔',
align: 'center',
children: [
{ prop: 'drillLossNum', label: '打孔不良/片' },
{
prop: 'drillLossArea',
label: '打孔不良/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
label: '镀膜',
align: 'center',
children: [
{ prop: 'coatingLossNum', label: '镀膜不良/片' },
{
prop: 'coatingLossArea',
label: '镀膜不良/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
label: '丝印',
align: 'center',
children: [
{ prop: 'silkLossNum', label: '丝印不良/片' },
{
prop: 'silkLossArea',
label: '丝印不良/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
label: '钢化',
align: 'center',
children: [
{ prop: 'temperingLossNum', label: '钢化不良/片' },
{
prop: 'temperingLossArea',
label: '钢化不良/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
label: '包装',
align: 'center',
children: [
{ prop: 'packingLossNum', label: '包装不良/片' },
{
prop: 'packingLossArea',
label: '包装不良/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
}
]
}
];
return props
},
productTableProps() {
// 当班数据的完整表头(基础列 + 当班动态表头)
const baseColumns = [
@@ -530,14 +539,20 @@ export default {
prop: 'processType',
label: '产品类型',
filter: (val) => (val === 1 ? '面板' : '背板'),
fixed: true,
sortable: true,
fixed: true
},
{
prop: 'factoryName',
label: '工厂',
fixed: true
}
},
(this.isPeriodicReport ? {
prop: 'reportDate',
label: '日期',
fixed: true,
width: 120
} : ''),
];
return [...baseColumns, ...this.factoryColumns];
},
@@ -559,7 +574,7 @@ export default {
{
prop: 'processType',
label: '产品类型',
filter: (val) => (val === 1 ? '面板' : '背板'),
filter: (val) => (val != 1 ? '面板' : '背板'),
sortable: true,
fixed: true
},
@@ -567,7 +582,13 @@ export default {
prop: 'factoryName',
label: '工厂',
fixed: true
}
},
(this.isPeriodicReport ? {
prop: 'reportDate',
label: '日期',
fixed: true,
width: 120
} : ''),
];
return [...baseColumns, ...this.factoryColumnsDay];
}
@@ -704,94 +725,157 @@ export default {
}
},
// 导出表格
handleExport() {
// 导出表格改为async方法支持await调用
async handleExport() {
// 按产线监控
if (this.activeName === 'productLine') {
if (this.listQuery.timeType === 1) {
// 产线-当天:导出当班 + 当天两个表格(自定义汇总文件名)
this.exportMultipleTables([
await this.exportMultipleTables([
{ ref: 'lineCurrentShiftTable', name: '产线监控_当班数据' },
{ ref: 'lineTodayTable', name: '产线监控_当天数据' }
], '产线监控_当班及当天数据汇总'); // 传入自定义汇总文件名
} else if (this.listQuery.timeType === 1) {
// 产线-当天:导出当班 + 当天两个表格(自定义汇总文件名)
this.exportMultipleTables([
{ ref: 'lineCurrentShiftTable', name: '产线监控_上一班数据' },
{ ref: 'lineTodayTable', name: '产线监控_当天数据' }
], '产线监控_当班及当天数据汇总'); // 传入自定义汇总文件名
} else if (this.listQuery.timeType === 3) {
// 修复:注释错误,原为“产线-当天”,实际是“产线-上一班”
// 产线-上一班:导出单个表格
await this.exportSingleTable('lineCustomTable', '产线监控_上一班时间数据');
} else {
// 产线-自定义:导出一个表格(自定义文件名)
this.exportSingleTable('lineCustomTable', '产线监控_自定义时间数据');
await this.exportSingleTable('lineCustomTable', '产线监控_自定义时间数据');
}
}
// 按产品监控
else {
if (this.listQuery.timeType === 1) {
// 产品-当天:导出当班 + 当天两个表格(自定义汇总文件名)
this.exportMultipleTables([
await this.exportMultipleTables([
{ ref: 'productCurrentShiftTable', name: '产品监控_当班数据' },
{ ref: 'productTodayTable', name: '产品监控_当天数据' }
{ ref: 'productCurrentShiftTable', name: '产品监控_当天数据' }
], '产品监控_当班及当天数据汇总'); // 传入自定义汇总文件名
} else if (this.listQuery.timeType === 3) {
// 修复:注释错误,原为“产线-当天”,实际是“产品-上一班”
// 产品-上一班:导出单个表格
await this.exportSingleTable('productCustomTable', '产品监控_上一班时间数据');
} else {
// 产品-自定义:导出一个表格(自定义文件名)
this.exportSingleTable('productCustomTable', '产品监控_自定义时间数据');
await this.exportSingleTable('productCustomTable', '产品监控_自定义时间数据');
}
}
},
// 导出单个表格(保持原有逻辑,文件名由调用方传入,已区分不同场景
exportSingleTable(refName, fileName) {
const table = this.getTableDom(refName);
if (!table) return;
// 导出单个表格(改为async方法使用await获取DOM
async exportSingleTable(refName, fileName) {
try {
// 关键修复使用await等待getTableDom返回DOM元素而非Promise
const table = await this.getTableDom(refName);
if (!table) {
this.$message.warning(`无法导出:${refName}表格DOM获取失败`);
return;
}
const clonedTable = table.cloneNode(true);
this.adjustTableForExport(clonedTable);
// 确认table是原生DOM元素后再调用cloneNode
if (!(table instanceof HTMLElement)) {
this.$message.error(`无法导出:${refName}表格不是合法的DOM元素`);
return;
}
const workbook = XLSX.utils.table_to_book(clonedTable);
const fullName = `${fileName}_${this.formatDate()}.xlsx`;
XLSX.writeFile(workbook, fullName);
},
// 导出多个表格(新增自定义汇总文件名参数,适配不同选项卡)
exportMultipleTables(tables, customSummaryName) {
const workbook = XLSX.utils.book_new();
let hasValidTable = false;
tables.forEach(({ ref, name }) => {
const table = this.getTableDom(ref);
if (!table) return;
hasValidTable = true;
const clonedTable = table.cloneNode(true);
this.adjustTableForExport(clonedTable);
const worksheet = XLSX.utils.table_to_sheet(clonedTable);
XLSX.utils.book_append_sheet(workbook, worksheet, name);
});
if (!hasValidTable) {
this.$message.warning('未找到有效表格数据');
return;
const workbook = XLSX.utils.table_to_book(clonedTable);
const fullName = `${fileName}_${this.formatDate()}.xlsx`;
XLSX.writeFile(workbook, fullName);
} catch (error) {
this.$message.error(`导出表格失败:${error.message}`);
console.error('单个表格导出错误:', error);
}
// 动态生成汇总文件名:自定义名称 + 日期
const fullName = `${customSummaryName}_${this.formatDate()}.xlsx`;
XLSX.writeFile(workbook, fullName);
},
// 辅助方法获取表格DOM元素包含表头
getTableDom(refName) {
const tableComponent = this.$refs[refName];
if (!tableComponent) {
this.$message.warning(`未找到${refName}表格`);
return null;
// 导出多个表格改为async方法使用await获取DOM
async exportMultipleTables(tables, customSummaryName) {
try {
const workbook = XLSX.utils.book_new();
let hasValidTable = false;
// 遍历表格配置使用await获取每个表格的DOM
for (const { ref, name } of tables) { // 改用for...of循环支持await
const table = await this.getTableDom(ref);
if (!table) {
this.$message.warning(`${ref}表格DOM获取失败跳过该表格`);
continue;
}
// 确认table是原生DOM元素
if (!(table instanceof HTMLElement)) {
this.$message.warning(`${ref}表格不是合法的DOM元素跳过该表格`);
continue;
}
hasValidTable = true;
const clonedTable = table.cloneNode(true);
this.adjustTableForExport(clonedTable);
const worksheet = XLSX.utils.table_to_sheet(clonedTable);
XLSX.utils.book_append_sheet(workbook, worksheet, name);
}
if (!hasValidTable) {
this.$message.warning('未找到有效表格数据,导出失败');
return;
}
// 动态生成汇总文件名:自定义名称 + 日期
const fullName = `${customSummaryName}_${this.formatDate()}.xlsx`;
XLSX.writeFile(workbook, fullName);
} catch (error) {
this.$message.error(`导出多个表格失败:${error.message}`);
console.error('多个表格导出错误:', error);
}
// 获取完整表格容器(包含表头和表体)
},
/**
* 获取表格DOM元素支持异步重试
* @param {string} refName - 表格的ref名称
* @param {number} retryCount - 当前重试次数(内部使用,外部调用无需传参)
* @returns {Promise<HTMLElement|null>} 表格DOM元素Promise
*/
async getTableDom(refName, retryCount = 0) {
// 1. 配置常量,便于维护
const maxRetry = 5; // 最大重试次数
const retryDelay = 300; // 每次重试延迟时间(ms)
// 2. 设置激活标签,确保重试时也能执行该逻辑
this.activeLabel = 'table';
this.activeLabelDay = 'table';
// 若需调试,可保留日志
// console.log(`[getTableDom-${refName}] activeLabel:`, this.activeLabel, 'activeLabelDay:', this.activeLabelDay);
// 3. 获取表格组件
const tableComponent = this.$refs[refName];
// 4. 表格组件不存在时,处理重试逻辑
if (!tableComponent) {
// 达到最大重试次数,返回失败
if (retryCount >= maxRetry) {
this.$message.warning(`未找到${refName}表格,已达到最大重试次数(${maxRetry}次)`);
return null;
}
// 未达到最大重试次数,延迟后重试
this.$message.warning(`未找到${refName}表格,将进行第${retryCount + 1}次重试...`);
await new Promise(resolve => setTimeout(resolve, retryDelay));
// 递归调用并返回结果
return this.getTableDom(refName, retryCount + 1);
}
// 5. 获取完整表格容器(包含表头和表体)
const tableContainer = tableComponent.$el.querySelector('.el-table');
if (!tableContainer) {
this.$message.warning(`${refName}表格数据为空`);
this.$message.warning(`${refName}表格容器不存在(可能表格数据为空`);
return null;
}
// 6. 成功获取表格DOM返回结果
return tableContainer;
},
@@ -856,7 +940,7 @@ export default {
if (mainTable && allHeaderRows.length > 0) {
const newThead = document.createElement('thead');
// 按层级添加表头行
allHeaderRows.forEach(cells => {
allHeaderRows.forEach((cells, rowIndex) => {
const newTr = document.createElement('tr');
cells.forEach(cell => {
// 复制单元格避免DOM残留引用问题
@@ -867,6 +951,18 @@ export default {
});
// 将新表头插入主表体最前面
mainTable.insertBefore(newThead, mainTable.firstChild);
// ================ 新增:修改第一列表头为“序号” ================
// 找到第一层级的第一个表头单元格(<th>
const firstHeaderCell = newThead.querySelector('tr:first-child th:first-child');
if (firstHeaderCell) {
// 清空原有内容,设置为“序号”
firstHeaderCell.innerHTML = ''; // 清空原有内容(包括子元素)
firstHeaderCell.textContent = '序号'; // 设置纯文本“序号”(更稳定)
// 可选:添加样式(如居中,根据需求调整)
// firstHeaderCell.style.textAlign = 'center';
}
// =============================================================
}
// 7. 合并固定列数据到主表体仅处理tbody数据
@@ -897,6 +993,23 @@ export default {
}
});
}
// ================ 可选优化为tbody第一列添加序号数字 ================
// 如果表格体的第一列原本无数据可补充1、2、3...的序号
if (mainTable) {
const tbodyRows = mainTable.querySelectorAll('tbody tr');
tbodyRows.forEach((row, index) => {
const firstTd = row.querySelector('td:first-child');
if (firstTd) {
// 清空原有内容设置为序号index+1因为索引从0开始
firstTd.innerHTML = '';
firstTd.textContent = index + 1;
// 可选:居中显示
// firstTd.style.textAlign = 'center';
}
});
}
// =============================================================
},
// 辅助方法:格式化日期(用于文件名)
@@ -1082,8 +1195,11 @@ export default {
pageSize: 100,
pageNo: 1,
total: 0,
timeType: this.activeName === 'productLine' ? 3 : 1,
timeType: 3,
};
this.formConfig[1].type = '';
this.formConfig[6].type = '';
this.formConfig[7].type = '';
// 重置后默认是当天,添加刷新时间
const resetTimeIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间')
@@ -1151,6 +1267,9 @@ export default {
this.listQuery.timeType = this.headFormValue.timeType ? this.headFormValue.timeType : this.listQuery.timeType;
this.listQuery.searchType = this.headFormValue.searchType || undefined
if (this.listQuery.timeType === 2) {
if (!this.listQuery.startTime && !this.listQuery.endTime) {
return this.$modal.msgError('请选择时间');
}
const resGroup = await getProcessAutoReportNew(this.listQuery);
console.log('resGroup', resGroup);
@@ -1517,6 +1636,7 @@ export default {
// 搜索栏下拉选择变化
handleSearchBarChanged({ param, value }) {
if (param === 'timeType') {
this.isPeriodicReport = false
this.tableData2 = []
this.tableDataCustom = []
this.tableData = []
@@ -1584,15 +1704,59 @@ export default {
}
} else if (param === 'searchType') {
this.isPeriodicReport = value === 2;
if (this.$refs.searchBarForm && this.$refs.searchBarForm.formInline) {
const formInline = this.$refs.searchBarForm.formInline;
formInline.reportType = ''
// 精准判断只有字段存在时才置为undefined不存在则不处理
if ('timeVal' in formInline) {
formInline.timeVal = undefined;
}
if ('timeValWeek' in formInline) {
formInline.timeValWeek = undefined;
}
if ('timeValMonth' in formInline) {
formInline.timeValMonth = undefined;
}
if ('timeValYear' in formInline) {
formInline.timeValYear = undefined;
}
}
// const formInline = this.$refs.searchBarForm.formInline;
this.listQuery.startTime = undefined
this.listQuery.endTime = undefined
console.log(this.listQuery,'list');
if (value === 1) {
// 统计数据:显示时间范围,隐藏报表类型
this.formConfig[7].type = 'datePicker';
this.formConfig[7] = {
type: 'datePicker',
label: '时间范围',
dateType: 'datetimerange',
format: 'yyyy-MM-dd HH:mm:ss',
valueFormat: 'timestamp',
rangeSeparator: '-',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间',
param: 'timeVal',
width: 350
};
this.formConfig[6].type = '';
this.$refs.searchBarForm.formInline.timeVal = undefined;
} else {
// 周期性报表:显示报表类型,隐藏时间范围
this.formConfig[6].type = 'select';
this.formConfig[7].type = 'datePicker';
this.formConfig[7] = {
type: 'datePicker',
label: '时间范围',
dateType: 'datetimerange',
format: 'yyyy-MM-dd HH:mm:ss',
valueFormat: 'timestamp',
rangeSeparator: '-',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间',
param: 'timeVal',
width: 350
};
}
} else if (param === 'reportType') {
if (this.$refs.searchBarForm && this.$refs.searchBarForm.formInline) {

View File

@@ -190,176 +190,6 @@ import barChart from './BarChart.vue';
import ButtonNav from '@/components/ButtonNav';
import { listData } from '@/api/system/dict/data';
// 表格列配置
const tableProps = [
{
prop: 'factoryName',
label: '工厂',
fixed: true
},
{
prop: 'lineName',
label: '产线',
fixed: true
},
{
prop: 'sizes',
label: '规格',
width: 105,
showOverflowtooltip: true,
fixed: true
},
{
prop: 'process',
label: '产品工艺',
fixed: true
},
{
prop: 'inputN',
label: '投入',
align: 'center',
children: [
{ prop: 'inputNum', label: '投入数量/片' },
{
prop: 'inputArea',
label: '投入面积/m²',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
prop: 'outputN',
label: '产出',
align: 'center',
children: [
{ prop: 'outputNum', label: '产出数量/片' },
{
prop: 'outputArea',
label: '产出面积/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
prop: 'lossN',
label: '不良',
align: 'center',
children: [
{ prop: 'lossNum', label: '不良数量/片' },
{
prop: 'lossArea',
label: '不良面积/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
prop: 'lossRatio',
label: '不良率/%',
filter: (val) => (val != null ? val.toFixed(2) : '-')
},
{
prop: 'outputRatio',
label: '投入产出率/%',
filter: (val) => (val != null ? val.toFixed(2) : '-')
},
{
prop: 'processingRatio',
label: '加工成品率/%',
filter: (val) => (val != null ? val.toFixed(2) : '-')
},
{
label: '不良详情',
align: 'center',
children: [
{
label: '原片',
align: 'center',
children: [
{ prop: 'originalLossNum', label: '原片不良/片' },
{
prop: 'originalLossArea',
label: '原片不良/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
label: '磨边',
align: 'center',
children: [
{ prop: 'edgeLossNum', label: '磨边不良/片' },
{
prop: 'edgeLossArea',
label: '磨边不良/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
label: '打孔',
align: 'center',
children: [
{ prop: 'drillLossNum', label: '打孔不良/片' },
{
prop: 'drillLossArea',
label: '打孔不良/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
label: '镀膜',
align: 'center',
children: [
{ prop: 'coatingLossNum', label: '镀膜不良/片' },
{
prop: 'coatingLossArea',
label: '镀膜不良/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
label: '丝印',
align: 'center',
children: [
{ prop: 'silkLossNum', label: '丝印不良/片' },
{
prop: 'silkLossArea',
label: '丝印不良/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
label: '钢化',
align: 'center',
children: [
{ prop: 'temperingLossNum', label: '钢化不良/片' },
{
prop: 'temperingLossArea',
label: '钢化不良/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
label: '包装',
align: 'center',
children: [
{ prop: 'packingLossNum', label: '包装不良/片' },
{
prop: 'packingLossArea',
label: '包装不良/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
}
]
}
];
export default {
components: { barChart, ButtonNav, baseTableS },
data() {
@@ -382,13 +212,13 @@ export default {
activeLabelDay: 'table', // 当天数据tab
fileName: '',
dataListLoading: false,
tableProps,
factoryColumns: [],
factoryColumnsDay: [],
activeName: 'product',
headFormValue:{},
tableBtn: [],
showData: [],
isPeriodicReport:false,
tableData: [],
tableData2: [], // 示例数据,实际从接口获取
productTableData: [],
@@ -506,6 +336,184 @@ export default {
};
},
computed: {
tableProps() {
const props = [
{
prop: 'factoryName',
label: '工厂',
fixed: true
},
{
prop: 'lineName',
label: '产线',
fixed: true
},
{
prop: 'sizes',
label: '规格',
width: 105,
showOverflowtooltip: true,
fixed: true
},
{
prop: 'process',
label: '产品工艺',
fixed: true
},
(this.isPeriodicReport ? {
prop: 'reportDate',
label: '日期',
fixed: true,
width: 120
} : ''),
{
prop: 'inputN',
label: '投入',
align: 'center',
children: [
{ prop: 'inputNum', label: '投入数量/片' },
{
prop: 'inputArea',
label: '投入面积/m²',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
prop: 'outputN',
label: '产出',
align: 'center',
children: [
{ prop: 'outputNum', label: '产出数量/片' },
{
prop: 'outputArea',
label: '产出面积/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
prop: 'lossN',
label: '不良',
align: 'center',
children: [
{ prop: 'lossNum', label: '不良数量/片' },
{
prop: 'lossArea',
label: '不良面积/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
prop: 'lossRatio',
label: '不良率/%',
filter: (val) => (val != null ? val.toFixed(2) : '-')
},
{
prop: 'outputRatio',
label: '投入产出率/%',
filter: (val) => (val != null ? val.toFixed(2) : '-')
},
{
prop: 'processingRatio',
label: '加工成品率/%',
filter: (val) => (val != null ? val.toFixed(2) : '-')
},
{
label: '不良详情',
align: 'center',
children: [
{
label: '原片',
align: 'center',
children: [
{ prop: 'originalLossNum', label: '原片不良/片' },
{
prop: 'originalLossArea',
label: '原片不良/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
label: '磨边',
align: 'center',
children: [
{ prop: 'edgeLossNum', label: '磨边不良/片' },
{
prop: 'edgeLossArea',
label: '磨边不良/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
label: '打孔',
align: 'center',
children: [
{ prop: 'drillLossNum', label: '打孔不良/片' },
{
prop: 'drillLossArea',
label: '打孔不良/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
label: '镀膜',
align: 'center',
children: [
{ prop: 'coatingLossNum', label: '镀膜不良/片' },
{
prop: 'coatingLossArea',
label: '镀膜不良/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
label: '丝印',
align: 'center',
children: [
{ prop: 'silkLossNum', label: '丝印不良/片' },
{
prop: 'silkLossArea',
label: '丝印不良/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
label: '钢化',
align: 'center',
children: [
{ prop: 'temperingLossNum', label: '钢化不良/片' },
{
prop: 'temperingLossArea',
label: '钢化不良/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
},
{
label: '包装',
align: 'center',
children: [
{ prop: 'packingLossNum', label: '包装不良/片' },
{
prop: 'packingLossArea',
label: '包装不良/㎡',
filter: (val) => (val != null ? val.toFixed(2) : '-')
}
]
}
]
}
];
return props
},
productTableProps() {
// 当班数据的完整表头(基础列 + 当班动态表头)
const baseColumns = [
@@ -532,7 +540,13 @@ export default {
prop: 'factoryName',
label: '工厂',
fixed: true
}
},
(this.isPeriodicReport ? {
prop: 'reportDate',
label: '日期',
fixed: true,
width: 120
} : ''),
];
return [...baseColumns, ...this.factoryColumns];
},
@@ -562,7 +576,13 @@ export default {
prop: 'factoryName',
label: '工厂',
fixed: true
}
},
(this.isPeriodicReport ? {
prop: 'reportDate',
label: '日期',
fixed: true,
width: 120
} : ''),
];
return [...baseColumns, ...this.factoryColumnsDay];
}
@@ -787,97 +807,159 @@ export default {
}
},
// 导出表格
handleExport() {
// 导出表格改为async方法支持await调用
async handleExport() {
// 按产线监控
if (this.activeName === 'productLine') {
if (this.listQuery.timeType === 1) {
// 产线-当天:导出当班 + 当天两个表格(自定义汇总文件名)
this.exportMultipleTables([
await this.exportMultipleTables([
{ ref: 'lineCurrentShiftTable', name: '产线监控_当班数据' },
{ ref: 'lineTodayTable', name: '产线监控_当天数据' }
], '产线监控_当班及当天数据汇总'); // 传入自定义汇总文件名
} else if (this.listQuery.timeType === 1) {
// 产线-当天:导出当班 + 当天两个表格(自定义汇总文件名)
this.exportMultipleTables([
{ ref: 'lineCurrentShiftTable', name: '产线监控_上一班数据' },
{ ref: 'lineTodayTable', name: '产线监控_当天数据' }
], '产线监控_当班及当天数据汇总'); // 传入自定义汇总文件名
} else if (this.listQuery.timeType === 3) {
// 修复:注释错误,原为“产线-当天”,实际是“产线-上一班”
// 产线-上一班:导出单个表格
await this.exportSingleTable('lineCustomTable', '产线监控_上一班时间数据');
} else {
// 产线-自定义:导出一个表格(自定义文件名)
this.exportSingleTable('lineCustomTable', '产线监控_自定义时间数据');
await this.exportSingleTable('lineCustomTable', '产线监控_自定义时间数据');
}
}
// 按产品监控
else {
if (this.listQuery.timeType === 1) {
// 产品-当天:导出当班 + 当天两个表格(自定义汇总文件名)
this.exportMultipleTables([
await this.exportMultipleTables([
{ ref: 'productCurrentShiftTable', name: '产品监控_当班数据' },
{ ref: 'productTodayTable', name: '产品监控_当天数据' }
{ ref: 'productCurrentShiftTable', name: '产品监控_当天数据' }
], '产品监控_当班及当天数据汇总'); // 传入自定义汇总文件名
} else if (this.listQuery.timeType === 3) {
// 修复:注释错误,原为“产线-当天”,实际是“产品-上一班”
// 产品-上一班:导出单个表格
await this.exportSingleTable('productCustomTable', '产品监控_上一班时间数据');
} else {
// 产品-自定义:导出一个表格(自定义文件名)
this.exportSingleTable('productCustomTable', '产品监控_自定义时间数据');
await this.exportSingleTable('productCustomTable', '产品监控_自定义时间数据');
}
}
},
// 导出单个表格(保持原有逻辑,文件名由调用方传入,已区分不同场景
exportSingleTable(refName, fileName) {
const table = this.getTableDom(refName);
if (!table) return;
// 导出单个表格(改为async方法使用await获取DOM
async exportSingleTable(refName, fileName) {
try {
// 关键修复使用await等待getTableDom返回DOM元素而非Promise
const table = await this.getTableDom(refName);
if (!table) {
this.$message.warning(`无法导出:${refName}表格DOM获取失败`);
return;
}
const clonedTable = table.cloneNode(true);
this.adjustTableForExport(clonedTable);
// 确认table是原生DOM元素后再调用cloneNode
if (!(table instanceof HTMLElement)) {
this.$message.error(`无法导出:${refName}表格不是合法的DOM元素`);
return;
}
const workbook = XLSX.utils.table_to_book(clonedTable);
const fullName = `${fileName}_${this.formatDate()}.xlsx`;
XLSX.writeFile(workbook, fullName);
},
// 导出多个表格(新增自定义汇总文件名参数,适配不同选项卡)
exportMultipleTables(tables, customSummaryName) {
const workbook = XLSX.utils.book_new();
let hasValidTable = false;
tables.forEach(({ ref, name }) => {
const table = this.getTableDom(ref);
if (!table) return;
hasValidTable = true;
const clonedTable = table.cloneNode(true);
this.adjustTableForExport(clonedTable);
const worksheet = XLSX.utils.table_to_sheet(clonedTable);
XLSX.utils.book_append_sheet(workbook, worksheet, name);
});
if (!hasValidTable) {
this.$message.warning('未找到有效表格数据');
return;
const workbook = XLSX.utils.table_to_book(clonedTable);
const fullName = `${fileName}_${this.formatDate()}.xlsx`;
XLSX.writeFile(workbook, fullName);
} catch (error) {
this.$message.error(`导出表格失败:${error.message}`);
console.error('单个表格导出错误:', error);
}
// 动态生成汇总文件名:自定义名称 + 日期
const fullName = `${customSummaryName}_${this.formatDate()}.xlsx`;
XLSX.writeFile(workbook, fullName);
},
// 辅助方法获取表格DOM元素包含表头
getTableDom(refName) {
const tableComponent = this.$refs[refName];
if (!tableComponent) {
this.$message.warning(`未找到${refName}表格`);
return null;
// 导出多个表格改为async方法使用await获取DOM
async exportMultipleTables(tables, customSummaryName) {
try {
const workbook = XLSX.utils.book_new();
let hasValidTable = false;
// 遍历表格配置使用await获取每个表格的DOM
for (const { ref, name } of tables) { // 改用for...of循环支持await
const table = await this.getTableDom(ref);
if (!table) {
this.$message.warning(`${ref}表格DOM获取失败跳过该表格`);
continue;
}
// 确认table是原生DOM元素
if (!(table instanceof HTMLElement)) {
this.$message.warning(`${ref}表格不是合法的DOM元素跳过该表格`);
continue;
}
hasValidTable = true;
const clonedTable = table.cloneNode(true);
this.adjustTableForExport(clonedTable);
const worksheet = XLSX.utils.table_to_sheet(clonedTable);
XLSX.utils.book_append_sheet(workbook, worksheet, name);
}
if (!hasValidTable) {
this.$message.warning('未找到有效表格数据,导出失败');
return;
}
// 动态生成汇总文件名:自定义名称 + 日期
const fullName = `${customSummaryName}_${this.formatDate()}.xlsx`;
XLSX.writeFile(workbook, fullName);
} catch (error) {
this.$message.error(`导出多个表格失败:${error.message}`);
console.error('多个表格导出错误:', error);
}
// 获取完整表格容器(包含表头和表体)
},
/**
* 获取表格DOM元素支持异步重试
* @param {string} refName - 表格的ref名称
* @param {number} retryCount - 当前重试次数(内部使用,外部调用无需传参)
* @returns {Promise<HTMLElement|null>} 表格DOM元素Promise
*/
async getTableDom(refName, retryCount = 0) {
// 1. 配置常量,便于维护
const maxRetry = 5; // 最大重试次数
const retryDelay = 300; // 每次重试延迟时间(ms)
// 2. 设置激活标签,确保重试时也能执行该逻辑
this.activeLabel = 'table';
this.activeLabelDay = 'table';
// 若需调试,可保留日志
// console.log(`[getTableDom-${refName}] activeLabel:`, this.activeLabel, 'activeLabelDay:', this.activeLabelDay);
// 3. 获取表格组件
const tableComponent = this.$refs[refName];
// 4. 表格组件不存在时,处理重试逻辑
if (!tableComponent) {
// 达到最大重试次数,返回失败
if (retryCount >= maxRetry) {
this.$message.warning(`未找到${refName}表格,已达到最大重试次数(${maxRetry}次)`);
return null;
}
// 未达到最大重试次数,延迟后重试
this.$message.warning(`未找到${refName}表格,将进行第${retryCount + 1}次重试...`);
await new Promise(resolve => setTimeout(resolve, retryDelay));
// 递归调用并返回结果
return this.getTableDom(refName, retryCount + 1);
}
// 5. 获取完整表格容器(包含表头和表体)
const tableContainer = tableComponent.$el.querySelector('.el-table');
if (!tableContainer) {
this.$message.warning(`${refName}表格数据为空`);
this.$message.warning(`${refName}表格容器不存在(可能表格数据为空`);
return null;
}
// 6. 成功获取表格DOM返回结果
return tableContainer;
},
// 重点修复:调整表格结构(解决表头重复问题)
adjustTableForExport(tableContainer) {
// 1. 移除空表格提示和分页等无关元素
@@ -939,7 +1021,7 @@ export default {
if (mainTable && allHeaderRows.length > 0) {
const newThead = document.createElement('thead');
// 按层级添加表头行
allHeaderRows.forEach(cells => {
allHeaderRows.forEach((cells, rowIndex) => {
const newTr = document.createElement('tr');
cells.forEach(cell => {
// 复制单元格避免DOM残留引用问题
@@ -950,6 +1032,18 @@ export default {
});
// 将新表头插入主表体最前面
mainTable.insertBefore(newThead, mainTable.firstChild);
// ================ 新增:修改第一列表头为“序号” ================
// 找到第一层级的第一个表头单元格(<th>
const firstHeaderCell = newThead.querySelector('tr:first-child th:first-child');
if (firstHeaderCell) {
// 清空原有内容,设置为“序号”
firstHeaderCell.innerHTML = ''; // 清空原有内容(包括子元素)
firstHeaderCell.textContent = '序号'; // 设置纯文本“序号”(更稳定)
// 可选:添加样式(如居中,根据需求调整)
// firstHeaderCell.style.textAlign = 'center';
}
// =============================================================
}
// 7. 合并固定列数据到主表体仅处理tbody数据
@@ -980,6 +1074,23 @@ export default {
}
});
}
// ================ 可选优化为tbody第一列添加序号数字 ================
// 如果表格体的第一列原本无数据可补充1、2、3...的序号
if (mainTable) {
const tbodyRows = mainTable.querySelectorAll('tbody tr');
tbodyRows.forEach((row, index) => {
const firstTd = row.querySelector('td:first-child');
if (firstTd) {
// 清空原有内容设置为序号index+1因为索引从0开始
firstTd.innerHTML = '';
firstTd.textContent = index + 1;
// 可选:居中显示
// firstTd.style.textAlign = 'center';
}
});
}
// =============================================================
},
// 辅助方法:格式化日期(用于文件名)
@@ -1003,7 +1114,45 @@ export default {
this.formConfig[2].selectOptions = res.data.list || [];
});
},
getWeekTimeRange(date) {
const targetDate = new Date(date);
const day = targetDate.getDay() || 7; // 周日转为7
const year = targetDate.getFullYear();
const month = targetDate.getMonth();
const dateNum = targetDate.getDate();
// 本周一 00:00:00
const startDate = new Date(year, month, dateNum - day + 1);
startDate.setHours(0, 0, 0, 0);
// 本周日 23:59:59
const endDate = new Date(year, month, dateNum - day + 7);
endDate.setHours(23, 59, 59, 999);
return {
startTime: startDate.getTime(),
endTime: endDate.getTime()
};
},
// 辅助函数获取本年的开始和结束时间戳1月1日00:00:00 到 12月31日23:59:59
getYearTimeRange(date) {
const targetDate = new Date(date);
const year = targetDate.getFullYear();
// 本年1月1日 00:00:00
const startDate = new Date(year, 0, 1);
startDate.setHours(0, 0, 0, 0);
// 本年12月31日 23:59:59
const endDate = new Date(year, 11, 31);
endDate.setHours(23, 59, 59, 999);
return {
startTime: startDate.getTime(),
endTime: endDate.getTime()
};
},
// 搜索/导出按钮点击
buttonClick(val) {
this.headFormValue = val
@@ -1116,7 +1265,7 @@ export default {
break;
case 'reset':
this.$refs.searchBarForm.resetForm();
this.$refs.searchBarForm.formInline.timeType = 1;
this.$refs.searchBarForm.formInline.timeType = 3;
this.formConfig[0].selectOptions = this.activeName === 'product'
? this.timeTypeOptions.productLine
: this.timeTypeOptions.product;
@@ -1124,8 +1273,11 @@ export default {
pageSize: 100,
pageNo: 1,
total: 0,
timeType: this.activeName === 'productLine' ? 3 : 1,
timeType: 3,
};
this.formConfig[1].type = '';
this.formConfig[6].type = '';
this.formConfig[7].type = '';
const resetTimeIndex = this.formConfig.findIndex(item =>
item.label?.includes('刷新时间')
);
@@ -1192,6 +1344,9 @@ export default {
this.listQuery.timeType = this.headFormValue.timeType ? this.headFormValue.timeType : this.listQuery.timeType;
this.listQuery.searchType = this.headFormValue.searchType || undefined
if (this.listQuery.timeType === 2) {
if (!this.listQuery.startTime && !this.listQuery.endTime) {
return this.$modal.msgError('请选择时间');
}
const resGroup = await getProcessAutoReportNew(this.listQuery);
console.log('resGroup', resGroup);
@@ -1498,6 +1653,7 @@ export default {
handleSearchBarChanged({ param, value }) {
console.log(value, param);
if (param === 'timeType') {
this.isPeriodicReport = false
this.tableData = []
this.tableDataCustom = []
this.tableData2 = []
@@ -1566,15 +1722,60 @@ export default {
this.formConfig[7].type = '';
}
} else if (param === 'searchType') {
this.isPeriodicReport = value === 2;
console.log('this.isPeriodicReport ', this.isPeriodicReport);
if (this.$refs.searchBarForm && this.$refs.searchBarForm.formInline) {
const formInline = this.$refs.searchBarForm.formInline;
formInline.reportType = ''
// 精准判断只有字段存在时才置为undefined不存在则不处理
if ('timeVal' in formInline) {
formInline.timeVal = undefined;
}
if ('timeValWeek' in formInline) {
formInline.timeValWeek = undefined;
}
if ('timeValMonth' in formInline) {
formInline.timeValMonth = undefined;
}
if ('timeValYear' in formInline) {
formInline.timeValYear = undefined;
}
}
// const formInline = this.$refs.searchBarForm.formInline;
this.listQuery.startTime = undefined
this.listQuery.endTime = undefined
console.log(this.listQuery, 'list');
if (value === 1) {
// 统计数据:显示时间范围,隐藏报表类型
this.formConfig[7].type = 'datePicker';
this.formConfig[7] = {
type: 'datePicker',
label: '时间范围',
dateType: 'datetimerange',
format: 'yyyy-MM-dd HH:mm:ss',
valueFormat: 'timestamp',
rangeSeparator: '-',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间',
param: 'timeVal',
width: 350
};
this.formConfig[6].type = '';
this.$refs.searchBarForm.formInline.timeVal = undefined;
} else {
// 周期性报表:显示报表类型,隐藏时间范围
this.formConfig[6].type = 'select';
this.formConfig[7].type = 'datePicker';
this.formConfig[7] = {
type: 'datePicker',
label: '时间范围',
dateType: 'datetimerange',
format: 'yyyy-MM-dd HH:mm:ss',
valueFormat: 'timestamp',
rangeSeparator: '-',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间',
param: 'timeVal',
width: 350
};
}
} else if (param === 'reportType') {
if (this.$refs.searchBarForm && this.$refs.searchBarForm.formInline) {

View File

@@ -0,0 +1,321 @@
<template>
<div class="app-container">
<!-- 搜索工作栏 -->
<SearchBar :formConfigs="searchBarFormConfig" ref="search-bar" @headBtnClick="handleSearchBarBtnClick"
@select-changed="handleSearchBarItemChange" />
<!-- 列表 -->
<base-table :table-props="tableProps" :page="queryParams.pageNo" :limit="queryParams.pageSize" :table-data="list"
@emitFun="handleEmitFun">
<!-- <method-btn
v-if="tableBtn.length"
slot="handleBtn"
:width="120"
label="操作"
:method-list="tableBtn"
@clickBtn="handleTableBtnClick" /> -->
</base-table>
<!-- 分页组件 -->
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
@pagination="getList" />
<!-- 对话框(添加 / 修改) -->
<!-- <base-dialog
:dialogTitle="title"
:dialogVisible="open"
width="500px"
@close="cancel"
@cancel="cancel"
@confirm="submitForm">
<DialogForm v-if="open" ref="form" :dataForm="form" :rows="rows" />
</base-dialog> -->
</div>
</template>
<script>
import {
getEquipmentAlarmLogPage,
getEqList,
getLineList
} from '@/api/monitoring/eqParamAlarmLog';
import Editor from '@/components/Editor';
import moment from 'moment';
import basicPageMixin from '@/mixins/lb/basicPageMixin';
// import { getFactoryPage } from '@/api/core/base/factory';
export default {
name: 'EquipmentAlarmLog',
components: {
Editor,
},
mixins: [basicPageMixin],
data() {
return {
searchBarKeys: ['checkTime'],
// optionArrUrl: [getFactoryPage,getEqList],
tableBtn: [
this.$auth.hasPermi('base:equipment-alarm-log:update')
? {
type: 'edit',
btnName: '修改',
}
: undefined,
this.$auth.hasPermi('base:equipment-alarm-log:delete')
? {
type: 'delete',
btnName: '删除',
}
: undefined,
].filter((v) => v),
tableProps: [
{
prop: 'factoryName',
label: '工厂',
},
{ prop: 'lineName', label: '产线' },
{ prop: 'equipmentName', label: '设备名称' },
{ prop: 'paramName', label: '参数名称' },
{ prop: 'paramLimit', label: '参数范围' },
{
prop: 'alarmType', label: '报警类型',
filter: (val) => (val === 1 ? '高于上限' : val === 2 ?'低于下限' : '否'),
},
// {
// // width: 90,
// prop: 'alarmGrade',
// label: '报警级别',
// filter: publicFormatter(this.DICT_TYPE.EQU_ALARM_LEVEL),
// },
{
prop: 'createTime',
label: '报警时间',
width: 180,
filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
},
{ prop: 'alarmContent', label: '报警内容' },
// {
// _action: 'equipment-group-show-alert',
// label: '报警',
// ,
// subcomponent: {
// props: ['injectData'],
// render: function (h) {
// const _this = this;
// return h(
// 'el-button',
// {
// props: { type: 'text', size: 'mini' },
// on: {
// click: function () {
// console.log('inejctdata', _this.injectData);
// _this.$emit('emitData', {
// action: _this.injectData._action,
// // value: _this.injectData.id,
// value: _this.injectData,
// });
// },
// },
// },
// '查看报警'
// );
// },
// },
// },
],
searchBarFormConfig: [
{
type: 'select',
label: '产线',
selectOptions: [],
param: 'lineId',
onchange: true,
filterable: true,
},
{
type: 'select',
label: '设备名称',
selectOptions: [],
param: 'equipmentId',
filterable: true,
// onchange: true,
},
{
type: 'datePicker',
label: '时间段',
dateType: 'daterange', // datetimerange
// format: 'yyyy-MM-dd HH:mm:ss',
format: 'yyyy-MM-dd',
valueFormat: 'yyyy-MM-dd HH:mm:ss',
rangeSeparator: '-',
startPlaceholder: '开始日期',
endPlaceholder: '结束日期',
defaultTime: ['00:00:00', '23:59:59'],
param: 'createTime',
// width: 350,
},
{
type: 'button',
btnName: '查询',
name: 'search',
color: 'primary',
},
],
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNo: 1,
pageSize: 20,
factoryId: undefined,
createTime: [],
},
// 表单参数
form: {},
// 表单校验
rules: {},
};
},
created() {
this.getArr();
this.getList();
},
methods: {
async getArr() {
const params = {
page: 1,
limit: 500,
};
getLineList().then((response) => {
this.searchBarFormConfig[0].selectOptions = response.data
});
// const list = await getEqList();
// this.searchBarFormConfig[1].selectOptions = list.data.map((eq) => ({
// name: eq.name,
// id: eq.id,
// }))
// this.optionArrUrl.forEach((item, index) => {
// item(params).then((response) => {
// this.searchBarFormConfig[index].selectOptions = response.data;
// });
// });
},
/** 重写 basicPageMixin 里的 handleSearchBarBtnClick */
handleSearchBarBtnClick(btn) {
// 仅查询一种情况
this.queryParams.lineId = btn.lineId;
this.queryParams.equipmentId = btn.equipmentId;
this.queryParams.createTime = btn.createTime;
this.handleQuery();
},
/** 查询列表 */
getList() {
this.loading = true;
// 执行查询
getEquipmentAlarmLogPage(this.queryParams).then((response) => {
this.list = response.data.list;
this.total = response.data.total;
this.loading = false;
});
},
/** 取消按钮 */
cancel() {
this.open = false;
this.reset();
},
/** 表单重置 */
reset() {
this.form = {
id: undefined,
alarmId: undefined,
alarmContent: undefined,
alarmValue: undefined,
alarmEquipmentId: undefined,
remark: undefined,
};
this.resetForm('form');
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNo = 1;
this.getList();
},
// /** 重置按钮操作 */
// resetQuery() {
// this.resetForm('queryForm');
// this.handleQuery();
// },
// /** 新增按钮操作 */
// handleAdd() {
// this.reset();
// this.open = true;
// this.title = '添加设备报警日志';
// },
async handleSearchBarItemChange({ param, value: id }) {
if (param == 'lineId') {
if (id == '') {
// 清除设备选框里的选项
this.searchBarFormConfig[1].selectOptions = [];
return;
}
const list = await getEqList({
id
});
this.searchBarFormConfig[1].selectOptions = list.data.map((eq) => ({
name: eq.name,
id: eq.id,
}));
}
},
/** 修改按钮操作 */
// handleUpdate(row) {
// this.reset();
// const id = row.id;
// getEquipmentAlarmLog(id).then((response) => {
// this.form = response.data;
// this.open = true;
// this.title = '修改设备报警日志';
// });
// },
// /** 提交按钮 */
// submitForm() {
// this.$refs['form'].validate((valid) => {
// if (!valid) {
// return;
// }
// // 修改的提交
// if (this.form.id != null) {
// updateEquipmentAlarmLog(this.form).then((response) => {
// this.$modal.msgSuccess('修改成功');
// this.open = false;
// this.getList();
// });
// return;
// }
// // 添加的提交
// createEquipmentAlarmLog(this.form).then((response) => {
// this.$modal.msgSuccess('新增成功');
// this.open = false;
// this.getList();
// });
// });
// },
/** 删除按钮操作 */
// handleDelete(row) {
// const id = row.id;
// this.$modal
// .confirm('是否确认删除设备报警日志编号为"' + id + '"的数据项?')
// .then(function () {
// return deleteEquipmentAlarmLog(id);
// })
// .then(() => {
// this.getList();
// this.$modal.msgSuccess('删除成功');
// })
// .catch(() => {});
// },
/** 导出按钮操作 */
},
};
</script>

View File

@@ -0,0 +1,301 @@
<template>
<div class="app-container">
<!-- 搜索工作栏 -->
<SearchBar
:formConfigs="searchBarFormConfig"
ref="search-bar"
@headBtnClick="handleSearchBarBtnClick"
@select-changed="handleSearchBarItemChange" />
<!-- 列表 -->
<base-table
:table-props="tableProps"
:page="queryParams.pageNo"
:limit="queryParams.pageSize"
:table-data="list"
@emitFun="handleEmitFun">
<method-btn
v-if="tableBtn.length"
slot="handleBtn"
label="操作"
:width="120"
:method-list="tableBtn"
@clickBtn="handleTableBtnClick" />
</base-table>
<!-- 分页组件 -->
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize"
@pagination="getList" />
<!-- 对话框(添加 / 修改) -->
<!-- <base-dialog
:dialogTitle="title"
:dialogVisible="open"
width="500px"
@close="cancel"
@cancel="cancel"
@confirm="submitForm">
<DialogForm v-if="open" ref="form" :dataForm="form" :rows="rows" />
</base-dialog> -->
</div>
</template>
<script>
import moment from 'moment';
import basicPageMixin from '@/mixins/lb/basicPageMixin';
import { publicFormatter } from '@/utils/dict';
import { getPdList } from '@/api/core/monitoring/auto';
import { getProductionLinePage } from '@/api/core/base/productionLine';
import { getFactoryPage } from '@/api/core/base/factory';
export default {
name: 'EquipmentStatusAndParams',
mixins: [basicPageMixin],
data() {
return {
searchBarKeys: ['equipmentId', 'productionLineId'],
optionArrUrl: [getFactoryPage, getProductionLinePage],
tableBtn: [
this.$auth.hasPermi('base:equipment-alarm-log:update')
? {
type: 'edit',
btnName: '修改',
}
: undefined,
this.$auth.hasPermi('base:equipment-alarm-log:delete')
? {
type: 'delete',
btnName: '删除',
}
: undefined,
].filter((v) => v),
tableProps: [
{
prop: 'factoryName',
label: '工厂',
},
{
prop: 'lineName',
label: '产线名',
},
{
prop: 'workshopName',
label: '工段名',
showOverflowtooltip: true,
},
{
width: 200,
prop: 'equipmentName',
label: '设备名称',
},
{
width: 150,
showOverflowtooltip: true,
prop: 'equipmentCode',
label: '设备编码',
},
{ width: 128, prop: 'inQuantity', label: '投入数[片]' },
{ width: 128, prop: 'outQuantity', label: '产出数[片]' },
{
width: 128,
prop: 'run',
label: '是否运行',
filter: (val) => (val != null ? (val ? '是' : '否') : '-'),
},
{
width: 128,
prop: 'status',
label: '状态',
filter: (val) =>
val != null ? ['正常', '计划停机', '故障'][val] : '-',
},
// {
// width: 128,
// prop: 'error',
// label: '是否故障',
// filter: (val) => (val != null ? (val ? '是' : '否') : '-'),
// },
// {
// prop: 'quantityRecordTime',
// label: '生产量记录时间',
// width: 180,
// filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
// },
// {
// prop: 'statusRecordTime',
// label: '状态记录时间',
// width: 180,
// filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
// },
{
_action: 'params-monitor',
label: '操作',
width: 56,
subcomponent: {
props: ['injectData'],
render: function (h) {
const _this = this;
return h(
'el-button',
{
class: 'iconfont icon-detail',
props: { type: 'text' },
on: {
click: function () {
_this.$emit('emitData', {
action: _this.injectData._action,
// value: _this.injectData.id,
value: _this.injectData,
});
},
},
}
// '查看详情'
);
},
},
},
],
searchBarFormConfig: [
{
type: 'select',
label: '工厂',
selectOptions: [],
param: 'factoryId',
onchange: true,
},
{
type: 'select',
label: '产线',
onchange: true,
placeholder: '请选择产线',
selectOptions: [],
param: 'productionLineId',
},
{
type: 'select',
label: '设备',
placeholder: '请选择设备',
param: 'equipmentId',
selectOptions: [],
},
{
type: 'button',
btnName: '查询',
name: 'search',
color: 'primary',
},
],
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNo: 1,
pageSize: 10,
factoryId: null,
productionLineId: [],
equipmentId: null,
},
total: 0,
// 表单参数
form: {},
// 表单校验
rules: {},
};
},
created() {
this.getArr();
this.getList();
},
methods: {
getArr() {
const params = {
page: 1,
limit: 500,
};
this.optionArrUrl.forEach((item, index) => {
item(params).then((response) => {
this.searchBarFormConfig[index].selectOptions = response.data.list;
});
});
},
/** 根据产线获取设备 */
async getEquipmentList(id) {
const { data } = await this.$axios({
url: '/base/equipment/listByLine',
method: 'get',
params: { id },
});
return data;
},
/** 监听 search bar 的产线下拉框改变 */
async handleSearchBarItemChange({ param, value: id }) {
if (param == 'productionLineId') {
if (id == '') {
// 清除设备选框里的选项
this.searchBarFormConfig[2].selectOptions = [];
return;
}
const list = await this.getEquipmentList(id);
this.searchBarFormConfig[2].selectOptions = list.map((eq) => ({
name: eq.name,
id: eq.id,
}));
} else if (param == 'factoryId') {
// 清除设备选框里的选项
this.searchBarFormConfig[2].selectOptions = [];
this.queryParams.equipmentId = undefined;
this.queryParams.productionLineId = [];
this.$refs['search-bar'].formInline.equipmentId = undefined;
this.$refs['search-bar'].formInline.productionLineId = undefined;
getPdList(id).then((res) => {
this.searchBarFormConfig[1].selectOptions = res.data || [];
});
}
},
handleSearchBarBtnClick(btn) {
const { equipmentId, productionLineId,factoryId } = btn;
if (equipmentId) this.queryParams.equipmentId = equipmentId;
else this.queryParams.equipmentId = null;
if (productionLineId)
this.queryParams.productionLineId = [productionLineId];
else this.queryParams.productionLineId = [];
this.queryParams.factoryId = factoryId || null;
this.getList();
},
/** 查询列表 */
async getList() {
this.loading = true;
const { data } = await this.$axios({
url: '/monitoring/equipment-monitor/realtime-page',
method: 'POST',
data: this.queryParams,
});
this.list = data.list;
this.total = data.total;
},
handleEmitFun({ action, value }) {
if (action == 'params-monitor') {
const { equipmentId, equipmentName, equipmentCode } = value;
this.$router.push({
name: 'equipmentFullParams',
params: {
equipmentId,
equipmentCode,
equipmentName,
},
});
}
},
},
};
</script>

View File

@@ -0,0 +1,400 @@
<!--
filename: dialogForm.vue
author: liubin
date: 2023-09-11 15:55:13
description: DialogForm for qualityInspectionRecord only
-->
<template>
<el-dialog :title="title" :append-to-body="true" :visible.sync="dialogVisible" width="60%" :before-close="handleClose">
<div>
<!-- 保留ref="search-bar"用于获取组件实例 -->
<SearchBar :formConfigs="searchBarFormConfig" ref="search-bar" @headBtnClick="handleSearchBarBtnClick" />
<!-- 统一使用ref关联DOM避免id选择器混乱 -->
<div ref="coreLineChart" style="width: 95%; height: 400px;"></div>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="dialogVisible = false"> </el-button>
</span>
</el-dialog>
</template>
<script>
// 引入echarts确保项目已安装npm install echarts --save
import * as echarts from 'echarts'; // 统一引入方式兼容新版ECharts
export default {
name: 'DialogForm',
model: {
prop: 'dataForm',
event: 'update',
},
emits: ['update'],
components: {},
props: {
dataForm: {
type: Object,
default: () => ({}),
},
eqId: {
type: [String, Number],
default: () => '',
}
},
data() {
return {
searchBarFormConfig: [
{
type: 'datePicker',
label: '时间段',
dateType: 'daterange',
format: 'yyyy-MM-dd',
valueFormat: 'timestamp', // 毫秒级时间戳格式
rangeSeparator: '-',
startPlaceholder: '开始日期',
endPlaceholder: '结束日期',
defaultTime: ['00:00:00', '23:59:59'],
defaultSelect: [],
param: 'createTime', // 日期选择器的参数名,用于赋值
},
{
type: 'button',
btnName: '查询',
name: 'search',
color: 'primary',
},
],
title:'趋势图',
dialogVisible: false,
listQuery: {
equId: undefined,
paramId: undefined,
plcName: undefined,
plcParamName: undefined,
startTime: undefined,
endTime: undefined
},
list: [],
myChart: null, // ECharts实例
resizeHandler: null // 缓存resize事件处理函数方便销毁
};
},
mounted() {
// 初始化图表确保DOM渲染完成
this.$nextTick(() => {
this.initChart(); // 调用正确的初始化方法
});
},
beforeDestroy() {
// 1. 移除resize事件监听防止内存泄漏
if (this.resizeHandler && window.removeEventListener) {
window.removeEventListener('resize', this.resizeHandler);
}
// 2. 销毁ECharts实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
},
methods: {
// 核心方法获取最近30天时间段毫秒级时间戳
getLast30DaysTimeRange() {
const today = new Date();
// 起始时间30天前 00:00:00.000
const startDate = new Date(today);
startDate.setDate(today.getDate() - 30);
startDate.setHours(0, 0, 0, 0);
const startTimeStamp = startDate.getTime();
// 结束时间:昨天 23:59:59.000
const endDate = new Date(today);
endDate.setDate(today.getDate() - 1);
endDate.setHours(23, 59, 59, 0);
const endTimeStamp = endDate.getTime();
return {
startTime: startTimeStamp,
endTime: endTimeStamp,
timeRangeArr: [startTimeStamp, endTimeStamp] // 关键数组格式直接适配daterange
};
},
// 弹窗关闭回调
handleClose(done) {
this.dialogVisible = false;
done();
},
// 搜索栏按钮点击事件
handleSearchBarBtnClick(btn) {
const { createTime } = btn;
// 解析日期选择器的时间戳数组
if (createTime && Array.isArray(createTime) && createTime.length === 2) {
this.listQuery.startTime = createTime[0];
this.listQuery.endTime = createTime[1];
}
this.getList();
},
// 初始化弹窗
init(data) {
this.dialogVisible = true;
console.log('d', data);
this.listQuery = {
equId: data.equipmentId,
paramId: data.paramId,
plcName: data.plcName,
plcParamNam: data.plcParamNam,
startTime: undefined,
endTime: undefined
};
this.title = (data.equipmentName ? data.equipmentName : '') + (data.paramName ? data.paramName : '') + '趋势图'
// 1. 获取30天时间段的时间戳数组
const { startTime, endTime, timeRangeArr } = this.getLast30DaysTimeRange();
this.listQuery.startTime = startTime
this.listQuery.endTime = endTime
// 2. 给日期选择器赋值
this.$nextTick(() => {
this.searchBarFormConfig[0].defaultSelect = timeRangeArr;
});
// 若图表未初始化重新初始化弹窗打开后DOM可能重新渲染
if (!this.myChart) {
this.initChart();
}
this.getList();
},
// 获取数据
async getList() {
try {
const { data } = await this.$axios({
url: '/monitoring/equipment-monitor/paramMonitorDet',
method: 'post',
data: {
startTime: this.listQuery.startTime,
endTime: this.listQuery.endTime,
...this.listQuery
},
});
let xData = []
let maxData = []
let minData = []
let pData = []
data.paramValue.forEach(ele => {
xData.push(ele.time)
maxData.push(ele.paramMax)
minData.push(ele.paramMin)
pData.push(ele.paramMean)
});
this.updateChart(xData, maxData, minData, pData)
} catch (error) {
console.error('获取数据失败:', error);
}
},
// 统一初始化图表修复核心创建ECharts实例 + 绑定resize事件
initChart() {
// 1. 通过ref获取DOM容器避免id选择器冲突
const chartDom = this.$refs.coreLineChart;
if (!chartDom) {
console.error('图表容器未找到!');
return;
}
// 2. 销毁已有实例,避免重复创建
if (this.myChart) {
this.myChart.dispose();
}
// 3. 创建ECharts实例
this.myChart = echarts.init(chartDom);
// 4. 初始化空配置,防止图表报错
this.myChart.setOption({
xAxis: { type: 'category', data: [] },
yAxis: { type: 'value' },
series: []
});
// 5. 绑定resize事件仅绑定一次缓存处理函数
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize(); // 图表自适应窗口大小
}
};
window.addEventListener('resize', this.resizeHandler);
},
// 更新折线图(全部实现渐变样式)
updateChart(xData, maxData, minData, pData) {
// 容错:若实例未初始化,先初始化
if (!this.myChart) {
this.initChart();
if (!this.myChart) return;
}
const option = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
label: {
backgroundColor: '#6a7985'
}
}
},
grid: {
top: 30,
bottom: 120,
right: 20,
left: 40
},
xAxis: [
{
type: 'category',
boundaryGap: true,
axisTick: { show: false },
axisLine: {
show: true,
lineStyle: { color: 'rgba(0, 0, 0, 0.15)' }
},
axisLabel: {
color: 'rgba(0, 0, 0, 0.45)',
fontSize: 12,
interval: 0,
padding: [5, 0, 0, 0],
rotate: 60, // 正确配置文字旋转45度
},
data: xData
}
],
yAxis: {
type: 'value',
nameTextStyle: {
color: 'rgba(0, 0, 0, 0.45)',
fontSize: 12,
align: 'right'
},
scale: true,
splitNumber: 4,
axisTick: { show: false },
axisLabel: {
color: 'rgba(0, 0, 0, 0.45)',
fontSize: 12,
formatter: '{value}'
},
splitLine: { lineStyle: { color: 'rgba(0, 0, 0, 0.15)' } },
axisLine: { show: true, lineStyle: { color: 'rgba(0, 0, 0, 0.15)' } }
},
series: [
// 1. 平均值折线图(渐变样式)
// 2. 最大值折线图(渐变样式)
{
name: '最大值',
type: 'line',
lineStyle: {
color: 'rgba(75, 157, 255, 1)',
width: 2
},
itemStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: 'rgba(130, 204, 255, 1)' },
{ offset: 1, color: 'rgba(75, 157, 255, 1)' }
]),
borderColor: 'rgba(75, 157, 255, 1)',
borderWidth: 2,
radius: 4
},
areaStyle: {
opacity: 0.3,
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: 'rgba(130, 204, 255, 0.8)' },
{ offset: 1, color: 'rgba(75, 157, 255, 0.1)' }
])
},
symbol: 'circle',
symbolSize: 6,
data: maxData || []
},
{
name: '平均值',
type: 'line',
lineStyle: {
color: 'rgba(118, 218, 190, 1)',
width: 2
},
itemStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: 'rgba(174, 239, 224, 1)' },
{ offset: 1, color: 'rgba(118, 218, 190, 1)' }
]),
borderColor: 'rgba(118, 218, 190, 1)',
borderWidth: 2,
radius: 4
},
// areaStyle: {
// opacity: 0.3,
// color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
// { offset: 0, color: 'rgba(174, 239, 224, 0.8)' },
// { offset: 1, color: 'rgba(118, 218, 190, 0.1)' }
// ])
// },
symbol: 'circle',
symbolSize: 6,
data: pData || []
},
// 3. 最小值折线图(渐变样式)
{
name: '最小值',
type: 'line',
lineStyle: {
color: 'rgba(249, 164, 74, 1)',
width: 2
},
itemStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: 'rgba(253, 209, 129, 1)' },
{ offset: 1, color: 'rgba(249, 164, 74, 1)' }
]),
borderColor: 'rgba(249, 164, 74, 1)',
borderWidth: 2,
radius: 4
},
areaStyle: {
opacity: 0.3,
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: 'rgba(253, 209, 129, 0.8)' },
{ offset: 1, color: 'rgba(249, 164, 74, 0.1)' }
])
},
symbol: 'circle',
symbolSize: 6,
data: minData || []
}
]
};
// 更新图表配置,清空原有数据
this.myChart.setOption(option, true);
},
cancel() {
this.dialogVisible = false;
}
},
};
</script>
<style scoped lang="scss">
.el-date-editor,
.el-select {
width: 100%;
}
</style>

View File

@@ -0,0 +1,215 @@
<!--
filename: dialogForm.vue
author: liubin
date: 2023-09-11 15:55:13
description: DialogForm for qualityInspectionRecord only
-->
<template>
<div>
<base-table :table-props="tableProps" :page="queryParams.pageNo" :limit="queryParams.pageSize" :table-data="list">
<method-btn v-if="tableBtn.length" slot="handleBtn" label="操作" :width="120" :method-list="tableBtn"
@clickBtn="handleTableBtnClick" />
</base-table>
<chart v-if="open" ref="visRef" />
</div>
</template>
<script>
import chart from './chart.vue';
export default {
name: 'DialogForm',
model: {
prop: 'dataForm',
event: 'update',
},
emits: ['update'],
components: { chart },
props: {
dataForm: {
type: Object,
default: () => ({}),
},
eqId: {
type: [String, Number],
default: () => '',
}
},
data() {
return {
open: false,
tableBtn: [{
type: 'chart',
btnName: '趋势图',
}
// this.$auth.hasPermi('base:equipment-alarm-log:delete')
// ? {
// type: 'delete',
// btnName: '删除',
// }
// : undefined,
].filter((v) => v),
tableProps: [
{
prop: 'paramName',
label: '参数名',
},
// {
// prop: 'lineName',
// label: '产线名',
// },
// {
// prop: 'workshopName',
// label: '工段名',
// showOverflowtooltip: true,
// },
{
// width: 200,
prop: 'paramValue',
label: '参数值',
},
{
// width: 200,
prop: 'paramLimit',
label: '参数范围',
},
],
list: [],
queryParams: {
pageNo: 1,
pageSize: 100,
},
};
},
mounted() {
// Promise.all([this.getProductLineList(), this.getInspectionDetList()]).then(
// () => {
// this.formLoading = false;
// }
// );
},
watch: {
// 'innerDataForm.productionLineId': {
// handler: async function (plId) {
// if (plId) await this.getWorksectionList(plId);
// },
// immediate: true,
// },
eqId: {
handler: function (value) {
console.log(value, '11111');
// this.innerDataForm = Object.assign({}, dataForm);
// if (dataForm.productionLineId)
this.getList();
},
immediate: true,
},
},
methods: {
submitForm() {
this.open = false;
},
cancel() {
this.open = false;
// this.reset();
},
handleTableBtnClick({ data, type }) {
if (type === 'chart') {
console.log(data,);
this.open = true
this.$nextTick(() => {
this.$refs.visRef.init(data)
})
}
},
/** 模拟透传 ref */
// validate(cb) {
// return this.$refs.form.validate(cb);
// },
// resetFields(args) {
// return this.$refs.form.resetFields(args);
// },
async getList() {
this.loading = true;
const { data } = await this.$axios({
url: '/monitoring/equipment-monitor/paramMonitor',
method: 'get',
params: {
id: this.eqId
},
});
console.log('data', data);
this.list = data
// this.total = data.total;
},
// handleInspectionDetChange(value) {
// const { id, content } = this.cacheInspectionDetList.find(
// (item) => item.id == value
// );
// this.innerDataForm.inspectionDetId = id;
// this.innerDataForm.inspectionDetContent = content;
// this.$emit('update', this.innerDataForm);
// },
// async handleProductlineChange(id) {
// // await this.getWorksectionList(id);
// this.innerDataForm.sectionId = null;
// this.$emit('update', this.innerDataForm);
// },
// // getCode
// async getCode(url) {
// const response = await this.$axios(url);
// return response.data;
// },
// // 获取产线列表
// async getProductLineList() {
// const response = await this.$axios('/base/production-line/listAll');
// this.productionLineList = response.data.map((item) => ({
// label: item.name,
// value: item.id,
// }));
// },
// // 获取检测内容列表
// async getInspectionDetList() {
// const response = await this.$axios(
// '/base/quality-inspection-det/listAll'
// );
// this.cacheInspectionDetList = response.data;
// this.inspectionDetList = response.data.map((item) => ({
// label: item.content,
// value: item.id,
// }));
// },
// // 获取工段列表
// async getWorksectionList(plId) {
// const response = await this.$axios(
// '/base/workshop-section/listByParentId',
// {
// params: {
// id: plId,
// },
// }
// );
// this.sectionList = response.data.map((item) => ({
// label: item.name,
// value: item.id,
// }));
// },
},
};
</script>
<style scoped lang="scss">
.el-date-editor,
.el-select {
width: 100%;
}
</style>

View File

@@ -1,38 +1,25 @@
<template>
<div class="app-container">
<!-- 搜索工作栏 -->
<SearchBar
:formConfigs="searchBarFormConfig"
ref="search-bar"
@headBtnClick="handleSearchBarBtnClick"
@select-changed="handleSearchBarItemChange" />
<div class="app-container">
<!-- 搜索工作栏 -->
<SearchBar :formConfigs="searchBarFormConfig" ref="search-bar" @headBtnClick="handleSearchBarBtnClick"
@select-changed="handleSearchBarItemChange" />
<!-- 列表 -->
<base-table
:table-props="tableProps"
:page="queryParams.pageNo"
:limit="queryParams.pageSize"
:table-data="list"
@emitFun="handleEmitFun">
<method-btn
v-if="tableBtn.length"
slot="handleBtn"
label="操作"
:width="120"
:method-list="tableBtn"
@clickBtn="handleTableBtnClick" />
</base-table>
<!-- 列表 -->
<base-table :table-props="tableProps" :page="queryParams.pageNo" :limit="queryParams.pageSize" :table-data="list"
@emitFun="handleEmitFun">
<!-- <method-btn v-if="tableBtn.length" slot="handleBtn" label="操作" :width="120" :method-list="tableBtn"
@clickBtn="handleTableBtnClick" /> -->
</base-table>
<!-- 分页组件 -->
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize"
@pagination="getList" />
<!-- 对话框(添加 / 修改) -->
<!-- <base-dialog
<!-- 分页组件 -->
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
@pagination="getList" />
<base-dialog :dialogTitle="title" :dialogVisible="open" width="50%" @close="cancel" @cancel="cancel"
@confirm="submitForm">
<DialogForm v-if="open" ref="form" v-model="form" :eqId="eqId" />
</base-dialog>
<!-- 对话框(添加 / 修改) -->
<!-- <base-dialog
:dialogTitle="title"
:dialogVisible="open"
width="500px"
@@ -41,7 +28,7 @@
@confirm="submitForm">
<DialogForm v-if="open" ref="form" :dataForm="form" :rows="rows" />
</base-dialog> -->
</div>
</div>
</template>
<script>
@@ -51,91 +38,87 @@ import { publicFormatter } from '@/utils/dict';
import { getPdList } from '@/api/core/monitoring/auto';
import { getProductionLinePage } from '@/api/core/base/productionLine';
import { getFactoryPage } from '@/api/core/base/factory';
import DialogForm from './dialogForm.vue';
export default {
name: 'EquipmentStatusAndParams',
name: 'EquipmentStatusAndParams',
components: {
DialogForm
},
mixins: [basicPageMixin],
data() {
return {
searchBarKeys: ['equipmentId', 'productionLineId'],
optionArrUrl: [getFactoryPage, getProductionLinePage],
tableBtn: [
this.$auth.hasPermi('base:equipment-alarm-log:update')
? {
type: 'edit',
btnName: '修改',
}
: undefined,
this.$auth.hasPermi('base:equipment-alarm-log:delete')
? {
type: 'delete',
btnName: '删除',
}
: undefined,
].filter((v) => v),
return {
eqId:undefined,
// searchBarKeys: ['equipmentId', 'productionLineId'],
optionArrUrl: [ getProductionLinePage],
// tableBtn: [
// this.$auth.hasPermi('base:equipment-alarm-log:update')
// ? {
// type: 'edit',
// btnName: '修改',
// }
// : undefined,
// this.$auth.hasPermi('base:equipment-alarm-log:delete')
// ? {
// type: 'delete',
// btnName: '删除',
// }
// : undefined,
// ].filter((v) => v),
tableProps: [
{
prop: 'factoryName',
label: '工厂',
},
{
prop: 'lineName',
label: '产线名',
},
{
prop: 'workshopName',
label: '工段名',
showOverflowtooltip: true,
},
{
width: 200,
// width: 200,
prop: 'equipmentName',
label: '设备名称',
},
{
width: 150,
// width: 150,
showOverflowtooltip: true,
prop: 'equipmentCode',
label: '设备编码',
},
{ width: 128, prop: 'inQuantity', label: '投入数[片]' },
{ width: 128, prop: 'outQuantity', label: '产出数[片]' },
{
// width: 128,
prop: 'inQuantity', label: '投入数(片)'
},
{
// width: 128,
prop: 'outQuantity', label: '产出数(片)'
},
{
width: 128,
// width: 128,
prop: 'run',
label: '是否运行',
filter: (val) => (val != null ? (val ? '是' : '否') : '-'),
},
{
width: 128,
// width: 128,
prop: 'status',
label: '状态',
filter: (val) =>
val != null ? ['正常', '计划停机', '故障'][val] : '-',
},
// {
// width: 128,
// prop: 'error',
// label: '是否故障',
// filter: (val) => (val != null ? (val ? '是' : '否') : '-'),
// },
// {
// prop: 'quantityRecordTime',
// label: '生产量记录时间',
// width: 180,
// filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
// },
// {
// prop: 'statusRecordTime',
// label: '状态记录时间',
// width: 180,
// filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
// },
{
width: 128,
prop: 'error',
label: '是否故障',
filter: (val) => (val != null ? (val ? '是' : '否') : '-'),
},
{
prop: 'quantityRecordTime',
label: '生产量记录时间',
width: 180,
filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
},
{
prop: 'statusRecordTime',
label: '状态记录时间',
width: 180,
filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
},
{
_action: 'params-monitor',
label: '操作',
width: 56,
label: '参数监控',
width: 100,
subcomponent: {
props: ['injectData'],
render: function (h) {
@@ -162,13 +145,13 @@ export default {
},
],
searchBarFormConfig: [
{
type: 'select',
label: '工厂',
selectOptions: [],
param: 'factoryId',
onchange: true,
},
// {
// type: 'select',
// label: '工厂',
// selectOptions: [],
// param: 'factoryId',
// onchange: true,
// },
{
type: 'select',
label: '产线',
@@ -192,7 +175,8 @@ export default {
},
],
// 是否显示弹出层
open: false,
open: false,
title:'',
// 查询参数
queryParams: {
pageNo: 1,
@@ -239,25 +223,26 @@ export default {
if (param == 'productionLineId') {
if (id == '') {
// 清除设备选框里的选项
this.searchBarFormConfig[2].selectOptions = [];
this.searchBarFormConfig[1].selectOptions = [];
return;
}
const list = await this.getEquipmentList(id);
this.searchBarFormConfig[2].selectOptions = list.map((eq) => ({
this.searchBarFormConfig[1].selectOptions = list.map((eq) => ({
name: eq.name,
id: eq.id,
}));
} else if (param == 'factoryId') {
// 清除设备选框里的选项
this.searchBarFormConfig[2].selectOptions = [];
this.queryParams.equipmentId = undefined;
this.queryParams.productionLineId = [];
this.$refs['search-bar'].formInline.equipmentId = undefined;
this.$refs['search-bar'].formInline.productionLineId = undefined;
getPdList(id).then((res) => {
this.searchBarFormConfig[1].selectOptions = res.data || [];
});
}
}
// else if (param == 'factoryId') {
// // 清除设备选框里的选项
// this.searchBarFormConfig[2].selectOptions = [];
// this.queryParams.equipmentId = undefined;
// this.queryParams.productionLineId = [];
// this.$refs['search-bar'].formInline.equipmentId = undefined;
// this.$refs['search-bar'].formInline.productionLineId = undefined;
// getPdList(id).then((res) => {
// this.searchBarFormConfig[1].selectOptions = res.data || [];
// });
// }
},
handleSearchBarBtnClick(btn) {
@@ -281,19 +266,35 @@ export default {
});
this.list = data.list;
this.total = data.total;
},
},
handleShow(value) {
// this.reset();
this.open = true;
this.eqId =value.equipmentId
this.title = value.factoryName + '/' + value.lineName + '/' + value.equipmentName;
},
/** 提交按钮 */
submitForm() {
this.open = false;
},
cancel() {
this.open = false;
// this.reset();
},
handleEmitFun({ action, value }) {
if (action == 'params-monitor') {
const { equipmentId, equipmentName, equipmentCode } = value;
this.$router.push({
name: 'equipmentFullParams',
params: {
equipmentId,
equipmentCode,
equipmentName,
},
});
if (action == 'params-monitor') {
console.log('value', value);
const { equipmentId, equipmentName, factoryName, lineName } = value;
this.handleShow(value)
// this.$router.push({
// name: 'equipmentFullParams',
// params: {
// equipmentId,
// equipmentCode,
// equipmentName,
// },
// });
}
},
},