更新
This commit is contained in:
@@ -1,17 +1,74 @@
|
||||
<!--
|
||||
filename: index.vue
|
||||
author: liubin
|
||||
date: 2023-09-04 09:34:52
|
||||
description: 设备异常分析
|
||||
* @Author: zwq
|
||||
* @Date: 2025-06-25 09:53:10
|
||||
* @LastEditors: zwq
|
||||
* @LastEditTime: 2026-04-28 10:59:33
|
||||
* @Description:
|
||||
-->
|
||||
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<!-- 搜索工作栏 -->
|
||||
<SearchBar
|
||||
:formConfigs="searchBarFormConfig"
|
||||
ref="search-bar"
|
||||
@headBtnClick="handleSearchBarBtnClick" />
|
||||
<el-form
|
||||
:inline="true"
|
||||
ref="searchBarForm"
|
||||
:model="queryParams"
|
||||
class="searchBar">
|
||||
<span class="blue-block"></span>
|
||||
<el-form-item label="时间维度">
|
||||
<el-radio-group size="small" v-model="queryParams.radio">
|
||||
<el-radio :label="1">周期报表</el-radio>
|
||||
<el-radio :label="2">累计</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="时间维度">
|
||||
<el-select
|
||||
v-model="queryParams.type"
|
||||
size="small"
|
||||
:disabled="queryParams.radio === 2"
|
||||
placeholder="请选择">
|
||||
<el-option
|
||||
v-for="item in typeoptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="产线/工段">
|
||||
<el-cascader
|
||||
size="small"
|
||||
:options="options"
|
||||
ref="cascaderRef"
|
||||
collapse-tags
|
||||
@change="handleCascaderChange"
|
||||
:props="{
|
||||
value: 'id',
|
||||
label: 'name',
|
||||
checkStrictly: true,
|
||||
multiple: true,
|
||||
emitPath: false,
|
||||
}"></el-cascader>
|
||||
</el-form-item>
|
||||
<el-form-item label="时间范围" prop="recordTime">
|
||||
<el-date-picker
|
||||
size="small"
|
||||
v-model="queryParams.recordTime"
|
||||
type="daterange"
|
||||
format="yyyy-MM-dd"
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
range-separator="-"
|
||||
start-placeholder="开始时间"
|
||||
end-placeholder="结束时间"></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button size="small" type="primary" @click="handleRecordSearch">
|
||||
查询
|
||||
</el-button>
|
||||
<el-button size="small" type="warning" @click="handleExport1">
|
||||
导出
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<!-- 列表 -->
|
||||
<base-table
|
||||
@@ -43,6 +100,14 @@
|
||||
import moment from 'moment';
|
||||
import basicPageMixin from '@/mixins/lb/basicPageMixin';
|
||||
import tableHeightMixin from '@/mixins/lb/tableHeightMixin';
|
||||
import { getGroupPlanTree } from '@/api/group/Schedule';
|
||||
import {
|
||||
exportReportExcel,
|
||||
exportQueryExcel,
|
||||
getReportPage,
|
||||
getQueryPage,
|
||||
} from '@/api/analysis/exception';
|
||||
import { parseTime } from '@/utils/ruoyi';
|
||||
|
||||
export default {
|
||||
name: 'ExceptionAnalysis',
|
||||
@@ -51,21 +116,6 @@ export default {
|
||||
props: {},
|
||||
data() {
|
||||
return {
|
||||
searchBarKeys: ['name', 'code'],
|
||||
// tableBtn: [
|
||||
// this.$auth.hasPermi('base:equipment-group:update')
|
||||
// ? {
|
||||
// type: 'edit',
|
||||
// btnName: '修改',
|
||||
// }
|
||||
// : undefined,
|
||||
// this.$auth.hasPermi('base:equipment-group:delete')
|
||||
// ? {
|
||||
// type: 'delete',
|
||||
// btnName: '删除',
|
||||
// }
|
||||
// : undefined,
|
||||
// ].filter((v) => v),
|
||||
tableBtn: [
|
||||
{
|
||||
type: 'edit',
|
||||
@@ -80,131 +130,147 @@ export default {
|
||||
{ prop: 'lineName', label: '产线' },
|
||||
{ prop: 'sectionName', label: '工段' },
|
||||
{ prop: 'equipmentName', label: '设备' },
|
||||
{ prop: 'createTime', filter: parseTime, label: '日期' },
|
||||
{
|
||||
width: 128,
|
||||
prop: 'actualRunningHours',
|
||||
label: '运行时长(h)',
|
||||
filter: (val) => (val != null ? val.toFixed(2) : '-'),
|
||||
},
|
||||
{ prop: 'downtimeCount', label: '故障次数' },
|
||||
{
|
||||
width: 240,
|
||||
prop: 'mtbf',
|
||||
prop: 'avgDowntimeDuration',
|
||||
label: '平均故障间隔时间[MTBF](h)',
|
||||
filter: (val) => (val != null ? val.toFixed(2) : '-'),
|
||||
},
|
||||
{
|
||||
width: 240,
|
||||
prop: 'mttr',
|
||||
label: '平均维修时间[MTTR](h)',
|
||||
filter: (val) => (val != null ? val.toFixed(2) : '-'),
|
||||
},
|
||||
{ width: 128, prop: 'workTime', label: '工作时长(h)',
|
||||
filter: (val) => (val != null ? val.toFixed(2) : '-'), },
|
||||
{ width: 128, prop: 'downTime', label: '故障时长(h)',
|
||||
filter: (val) => (val != null ? val.toFixed(2) : '-'), },
|
||||
{ prop: 'downCount', label: '故障次数' },
|
||||
],
|
||||
searchBarFormConfig: [
|
||||
{
|
||||
type: 'select',
|
||||
label: '请选择月份',
|
||||
placeholder: '请选择月份',
|
||||
param: 'month',
|
||||
selectOptions: Array(12)
|
||||
.fill(0)
|
||||
.map((v, i) => ({
|
||||
id: i + 1,
|
||||
name: `${i + 1}月`,
|
||||
})),
|
||||
},
|
||||
{
|
||||
__index: 'line',
|
||||
type: 'select',
|
||||
label: '产线',
|
||||
placeholder: '请选择产线',
|
||||
param: 'lineId',
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
btnName: '查询',
|
||||
name: 'search',
|
||||
color: 'primary',
|
||||
filter: (val) => (val != null ? val.toFixed(2) : '-'),
|
||||
},
|
||||
// {
|
||||
// width: 240,
|
||||
// prop: 'mttr',
|
||||
// label: '平均维修时间[MTTR](h)',
|
||||
// filter: (val) => (val != null ? val.toFixed(2) : '-'),
|
||||
// },
|
||||
// {
|
||||
// width: 128,
|
||||
// prop: 'downTime',
|
||||
// label: '故障时长(h)',
|
||||
// filter: (val) => (val != null ? val.toFixed(2) : '-'),
|
||||
// },
|
||||
],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
lineId: null,
|
||||
radio: 1,
|
||||
type: null,
|
||||
factoryId: null,
|
||||
lineId: null,
|
||||
sectionId: null,
|
||||
equId: null,
|
||||
recordTime: null,
|
||||
},
|
||||
typeoptions: [
|
||||
{
|
||||
value: '4',
|
||||
label: '周',
|
||||
},
|
||||
{
|
||||
value: '5',
|
||||
label: '月',
|
||||
},
|
||||
{
|
||||
value: '6',
|
||||
label: '年',
|
||||
},
|
||||
],
|
||||
options: [], // 产线/工段选项
|
||||
};
|
||||
},
|
||||
computed: {},
|
||||
created() {
|
||||
this.fillLineOptions();
|
||||
getGroupPlanTree().then((res) => {
|
||||
this.options = res.data;
|
||||
});
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
async fillLineOptions() {
|
||||
const { data } = await this.$axios({
|
||||
url: '/base/production-line/listAll',
|
||||
method: 'get',
|
||||
handleCascaderChange() {
|
||||
const checkedNodes = this.$refs.cascaderRef.getCheckedNodes();
|
||||
this.queryParams.factoryId = [];
|
||||
this.queryParams.lineId = [];
|
||||
this.queryParams.sectionId = [];
|
||||
this.queryParams.equId = [];
|
||||
checkedNodes.forEach((node) => {
|
||||
if (node.checked) {
|
||||
if (node.level === 1) {
|
||||
this.queryParams.factoryId.push(node.value);
|
||||
} else if (node.level === 2) {
|
||||
this.queryParams.lineId.push(node.value);
|
||||
} else if (node.level === 3) {
|
||||
this.queryParams.sectionId.push(node.value);
|
||||
} else if (node.level === 4) {
|
||||
this.queryParams.equId.push(node.value);
|
||||
}
|
||||
}
|
||||
});
|
||||
const cfg = this.searchBarFormConfig.find(
|
||||
(item) => item.__index == 'line'
|
||||
);
|
||||
this.$set(
|
||||
cfg,
|
||||
'selectOptions',
|
||||
data.map((item) => ({
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
}))
|
||||
);
|
||||
},
|
||||
handleRecordSearch() {
|
||||
if (
|
||||
this.queryParams.recordTime &&
|
||||
this.queryParams.recordTime.length > 0
|
||||
) {
|
||||
this.queryParams.startTime = this.queryParams.recordTime[0];
|
||||
this.queryParams.endTime = this.queryParams.recordTime[1];
|
||||
}
|
||||
this.getList();
|
||||
},
|
||||
|
||||
async getList() {
|
||||
const params = {
|
||||
lineId: this.queryParams.lineId || null,
|
||||
sectionId: this.queryParams.sectionId || null,
|
||||
equipmentId: this.queryParams.equId || null,
|
||||
startTime: this.queryParams.startTime || null,
|
||||
endTime: this.queryParams.endTime || null,
|
||||
type:
|
||||
this.queryParams.radio === 1 ? this.queryParams.type || null : null,
|
||||
};
|
||||
this.loading = true;
|
||||
// 执行查询
|
||||
const { code, data } = await this.$axios({
|
||||
url: '/analysis/equipment-analysis/efficiency',
|
||||
method: 'get',
|
||||
params: {
|
||||
lineId: this.queryParams.lineId || null,
|
||||
recordTime: this.queryParams.recordTime || null,
|
||||
},
|
||||
});
|
||||
const { code, data } = await (this.queryParams.radio === 1
|
||||
? getReportPage(params)
|
||||
: getQueryPage(params));
|
||||
if (code === 0) {
|
||||
this.list = data;
|
||||
} else {
|
||||
this.list.splice(0);
|
||||
}
|
||||
},
|
||||
|
||||
handleSearchBarBtnClick(btn) {
|
||||
switch (btn.btnName) {
|
||||
case 'search':
|
||||
if (btn.month) {
|
||||
this.queryParams.recordTime = [
|
||||
moment()
|
||||
.month(btn.month - 1)
|
||||
.format('YYYY-MM') + '-01 00:00:00',
|
||||
moment().month(btn.month).format('YYYY-MM') + '-01 00:00:00',
|
||||
];
|
||||
} else {
|
||||
this.queryParams.recordTime = null;
|
||||
}
|
||||
this.queryParams.lineId = btn.lineId || null;
|
||||
this.handleQuery();
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
// this.queryParams.pageNo = 1;
|
||||
this.getList();
|
||||
},
|
||||
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm('queryForm');
|
||||
this.handleQuery();
|
||||
handleExport1() {
|
||||
this.handleRecordSearch();
|
||||
// 处理查询参数
|
||||
const params = {
|
||||
lineId: this.queryParams.lineId || null,
|
||||
sectionId: this.queryParams.sectionId || null,
|
||||
equipmentId: this.queryParams.equId || null,
|
||||
startTime: this.queryParams.startTime || null,
|
||||
endTime: this.queryParams.endTime || null,
|
||||
type:
|
||||
this.queryParams.radio === 1 ? this.queryParams.type || null : null,
|
||||
};
|
||||
this.$modal
|
||||
.confirm('是否确认导出所有数据项?')
|
||||
.then(() => {
|
||||
this.exportLoading = true;
|
||||
return this.queryParams.radio === 1
|
||||
? exportReportExcel(params)
|
||||
: exportQueryExcel(params);
|
||||
})
|
||||
.then((response) => {
|
||||
this.$download.excel(response, '报表.xls');
|
||||
this.exportLoading = false;
|
||||
})
|
||||
.catch(() => {});
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user