fix(生产模块-设备故障履历): 优化设备异常历史记录查询功能

- 移除设备编码的必填要求
- 将班次和异常代码选择器改为多选
- 在选择器中添加描述信息
- 优化异常代码组的加载逻辑
- 调整表格中的班次和异常代码选择器
- 更新查询参数和结果处理方式
This commit is contained in:
关博 2025-06-10 19:22:27 +08:00
parent 9471957326
commit bb9400b2fa
2 changed files with 49 additions and 63 deletions

View File

@ -16,7 +16,7 @@
<el-row :gutter="24">
<!-- 设备编码 -->
<el-col :span="6">
<el-form-item label="设备编码:" required prop="resrce">
<el-form-item label="设备编码:" prop="resrce">
<el-input placeHolder="设备编码+" v-model="formObj.resrce" clearable>
<i slot="suffix" class="el-input__icon el-icon-copy-document" @click.stop="openDialog('resrce')"/>
</el-input>
@ -25,18 +25,16 @@
<!-- 班次 -->
<el-col :span="6">
<el-form-item label="班次:" prop="shift">
<el-select v-model="formObj.shift" clearable>
<el-option v-for="item in shiftList" :key="item.userWorkShift" :label="item.userWorkShift"
:value="item.userWorkShift"/>
<el-select v-model="formObj.shiftList" multiple clearable>
<el-option v-for="item in shiftList" :key="item.userWorkShift" :label="`${item.userWorkShift} - ${item.description}`" :value="item.userWorkShift"/>
</el-select>
</el-form-item>
</el-col>
<!-- 异常代码 -->
<el-col :span="6">
<el-form-item label="异常代码:" prop="abnCode">
<el-select v-model="formObj.abnCode" clearable>
<el-option v-for="item in abnCodeSearchList" :key="item.reasonCode" :label="item.reasonCode"
:value="item.reasonCode"/>
<el-select v-model="formObj.abnCodeList" multiple clearable>
<el-option v-for="item in abnCodeSearchList" :key="item.reasonCode" :label="`${item.reasonCode} - ${item.description}`" :value="item.reasonCode"/>
</el-select>
</el-form-item>
</el-col>
@ -102,23 +100,21 @@
<el-table-column align="center" prop="shift" label="班次">
<template #default="scope">
<el-select v-model="scope.row.shift" clearable @change="handleShiftChange(scope.$index)">
<el-option v-for="item in shiftList" :key="item.userWorkShift" :label="item.userWorkShift"
:value="item.userWorkShift"/>
<el-option v-for="item in shiftList" :key="item.userWorkShift" :label="`${item.userWorkShift} - ${item.description}`" :value="item.userWorkShift"/>
</el-select>
</template>
</el-table-column>
<el-table-column align="center" prop="abnCodeGroup" label="异常代码组">
<template #default="scope">
<el-select v-model="scope.row.abnCodeGroup" clearable @change="handleAbnCodeGroupChange(scope.$index)">
<el-option v-for="item in abnCodeGroupList" :key="item.value" :label="item.label" :value="item.value"/>
<el-option v-for="item in abnCodeGroupList" :key="item.value" :label="`${item.value} - ${item.label}`" :value="item.value"/>
</el-select>
</template>
</el-table-column>
<el-table-column align="center" prop="abnCode" label="异常代码" min-width="140">
<template #default="scope">
<el-select v-model="scope.row.abnCode" clearable @change="handleAbnCodeChange(scope.$index)">
<el-option v-for="item in scope.row.abnCodeFilterList" :key="item.reasonCode" :label="item.reasonCode"
:value="item.reasonCode"/>
<el-option v-for="item in scope.row.abnCodeFilterList" :key="item.reasonCode" :label="`${item.reasonCode} - ${item.description}`" :value="item.reasonCode"/>
</el-select>
</template>
</el-table-column>
@ -204,7 +200,8 @@ export default {
name: getStore({name: 'userInfo'}).name,
fabNo: '', // 作业规则获取车间
resrceDialogObj: {...resrceInitDialogObj}, // 设备
shiftList: [], // 班组状态(字典)
shiftList: [], // 班组状态
reasonCodeCategoryList: [], // 异常代码类别(字典)
abnCodeGroupList: [], // 异常代码组(选择)
abnCodeGroupStringList: [], // 异常代码组(字符串)
abnCodeList: [], // 异常代码
@ -220,9 +217,6 @@ export default {
size: 20
},
formRules: {
resrce: [
{required: true, message: '请选择设备', trigger: ['change','blur']}
],
timeRange: [
{required: true, message: '请选择时间范围', trigger: 'change'}
],
@ -260,7 +254,7 @@ export default {
// 获取作业规则
let activityId = this.$route.query.ACTIVITY_ID
showLoading()
listByActivityId(activityId).then((response) => {
listByActivityId(activityId).then(async (response) => {
hideLoading();
if (response.data.code !== 0) {
return this.$message.error(response.data.msg)
@ -278,13 +272,17 @@ export default {
me.abnCodeSearchList = res.data.data;
})
// 获取异常代码
// 获取异常代码组
const codes = reasonCodeCategory.split(';');
// 转换为包含value和label的对象数组
me.abnCodeGroupList = codes.map(code => ({
value: code.trim(),
label: code.trim()
}));
// 过滤掉空字符串
const filteredCodes = codes.filter(code => code.trim() !== '');
// 获取字典数据
const reasonCodeCategoryList = await this.getDataDictionary("reason_code_category");
this.abnCodeGroupList = reasonCodeCategoryList.filter(item =>
filteredCodes.includes(item.value)
);
} else if (optionList[i].optionName === 'GET_RESOURCE') {
let equipmentCode = optionList[i].optionValue;
me.resrceStringList = equipmentCode.split(";")
@ -376,40 +374,12 @@ export default {
this.selectObjs = objs.map(obj => obj.rowIndex);
this.multiple = !objs.length;
},
// 移除选定项
// doRemoveSelected() {
// // 检查是否有选中的行
// if (this.selectObjs.length === 0) {
// this.$message.warning('请先选择要移除的项');
// return;
// }
//
// this.$confirm('是否确认移除选中行', {
// confirmButtonText: '确认',
// cancelButtonText: '取消',
// type: 'warning'
// }).then(() => {
// // 使用 item.id 进行匹配(而不是 handle)
// this.equipmentAbnHistoryList = this.equipmentAbnHistoryList.filter(
// item => !this.selectObjs.includes(item.id)
// );
//
// // 重置多选状态
// this.selectObjs = [];
// this.multiple = true;
// }).catch(() => {
// // 用户点击取消时不做任何操作
// console.log('用户取消删除');
// });
// },
// 移除选定项
doRemoveSelected() {
if (this.selectObjs.length === 0) {
this.$message.warning('请先选择要移除的项');
return;
}
this.$confirm('是否确认移除选中行', {
confirmButtonText: '确认',
cancelButtonText: '取消',
@ -617,8 +587,6 @@ export default {
}
},
// 弹出框通用选择
dialogSelected(row, type) {
switch (type) {
@ -638,15 +606,25 @@ export default {
}
},
// 获取数据字典
getDataDictionary(dictType, list) {
fetchDictList({
// 获取数据字典(返回Promise)
getDataDictionary(dictType) {
return fetchDictList({
current: "1",
size: "1000",
dictType: dictType,
}).then((response) => {
this[list] = response.data.data.records
return response.data.data.records; // 直接返回 records 数组
});
},
// getDataDictionary(dictType, listKey) {
// return fetchDictList({
// current: "1",
// size: "1000",
// dictType: dictType,
// }).then((response) => {
// this[listKey] = response.data.data.records;
// });
// },
// 页面大小改变
handleSizeChange(val) {
@ -666,18 +644,15 @@ export default {
if (flag) {
me.page.current = 1;
}
if (!me.formObj.resrce) {
return me.$message.error("请选择设备");
}
if (!me.formObj.timeRange) {
return me.$message.error("请选择生产日期");
}
let obj = {
site: me.site,
equipmentCode: me.formObj.resrce,
shift: me.formObj.shift,
shiftList: me.formObj.shiftList,
creatorName: me.formObj.creatorName,
abnCode: me.formObj.abnCode,
abnCodeList: me.formObj.abnCodeList,
startTimeStr: formatterDate(me.formObj.timeRange[0], 'yyyy-MM-dd hh:mm:ss'),
endTimeStr: formatterDate(me.formObj.timeRange[1], 'yyyy-MM-dd hh:mm:ss'),
};
@ -694,6 +669,17 @@ export default {
return false;
}
me.equipmentAbnHistoryList = response.data.data.records;
me.equipmentAbnHistoryList = response.data.data.records.map(record => {
// 根据当前 record.abnCodeGroup 过滤出对应的 abnCodeFilterList
const filteredList = me.abnCodeSearchList.filter(
item => item.category === record.abnCodeGroup
);
// 返回新对象,带上过滤后的集合
return {
...record,
abnCodeFilterList: filteredList
};
});
me.page.total = response.data.data.total;
me.page.current = response.data.data.current;
}).catch(() => {

View File

@ -20,9 +20,9 @@ export const resrceInitDialogObj= {
export const initFormObj = {
resrce: "",
resrceDesc: "",
shift: "",
shiftList: [],
creator: "",
abnCode: "",
abnCodeList: [],
startTime: "",
endTime: "",
timeRange: "",