fix: 修改点检确认
This commit is contained in:
parent
0ca3e6ddfb
commit
89163ce339
|
@ -42,10 +42,11 @@ export function exportExcel(deviceId, inputTime, shift) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 报警相关接口
|
// 报警相关接口
|
||||||
// 时间点确认点检,不传时间,默认当前时间
|
// 时间点确认点检,传递多个 alarmId
|
||||||
export function sharpConfirm(alarmId, confirmTime, checkUser) {
|
export function sharpConfirm(alarmIdList, confirmTime, checkUser) {
|
||||||
|
const alarmIdParams = alarmIdList.map(id => `alarmIdList=${id}`).join('&');
|
||||||
return request({
|
return request({
|
||||||
url: `/Check/sharpConfirm?alarmId=${alarmId}&checkUser=${checkUser}`,
|
url: `/Check/sharpConfirm?${alarmIdParams}&checkUser=${checkUser}`,
|
||||||
method: 'post'
|
method: 'post'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -58,3 +59,11 @@ export function alarmReasonConfirm(data) {
|
||||||
data
|
data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询某一报警信息
|
||||||
|
export function getAlarmReason(alarmId, checkParamId) {
|
||||||
|
return request({
|
||||||
|
url: `Check/GetAlarmReason?alarmId=${alarmId}&checkParamId=${checkParamId}`,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
|
@ -915,10 +915,10 @@ let autoUpdateInterval = null;
|
||||||
|
|
||||||
// 生命周期钩子
|
// 生命周期钩子
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
await fetchStatusColors(); // 调用获取颜色状态数据的函数
|
||||||
await fetchData();
|
await fetchData();
|
||||||
fetchGanttData();
|
fetchGanttData();
|
||||||
fetchStopReason();
|
fetchStopReason();
|
||||||
await fetchStatusColors(); // 调用获取颜色状态数据的函数
|
|
||||||
sendDataToParent();
|
sendDataToParent();
|
||||||
|
|
||||||
const setupAutoUpdate = () => {
|
const setupAutoUpdate = () => {
|
||||||
|
|
|
@ -29,13 +29,17 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, defineProps, defineEmits, onMounted } from 'vue';
|
import { ref, defineProps, defineEmits, onMounted } from 'vue';
|
||||||
import { IxButton, IxChip } from '@siemens/ix-vue';
|
import { IxButton, IxChip } from '@siemens/ix-vue';
|
||||||
|
import { getAlarmReason } from '@/api/inspection';
|
||||||
import moment from 'moment-timezone';
|
import moment from 'moment-timezone';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
itemName: String,
|
itemName: String,
|
||||||
itemTime: String,
|
itemTime: String,
|
||||||
timezone: String,
|
timezone: String,
|
||||||
currentStatus: String,
|
currentAlarmInfo: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({})
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const reason = ref('');
|
const reason = ref('');
|
||||||
|
@ -56,9 +60,11 @@ const handleSubmit = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if(props.currentStatus === '已处理') {
|
if (props.currentAlarmInfo.currentStatus === '已处理') {
|
||||||
// 数据库读取当前的处理信息
|
// 数据库读取当前的处理信息
|
||||||
reason.value = '已处理';
|
getAlarmReason(props.currentAlarmInfo.currentAlarmId, props.currentAlarmInfo.currentCheckParamId).then((res) => {
|
||||||
|
reason.value = res.data.check_text;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -79,17 +85,20 @@ onMounted(() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-validation-example {
|
.form-validation-example {
|
||||||
background-color:#23233C;
|
background-color: #23233C;
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
border-radius: 0.5rem;
|
border-radius: 0.5rem;
|
||||||
width: 25rem; /* 设置表单宽度 */
|
width: 25rem;
|
||||||
|
/* 设置表单宽度 */
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
border: 0.0625rem solid white; /* 增加白色边框 */
|
border: 0.0625rem solid white;
|
||||||
|
/* 增加白色边框 */
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-header h5 {
|
.form-header h5 {
|
||||||
color: #9898A8; /* 修改颜色 */
|
color: #9898A8;
|
||||||
|
/* 修改颜色 */
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-body {
|
.form-body {
|
||||||
|
@ -118,32 +127,43 @@ onMounted(() => {
|
||||||
.form-header h5,
|
.form-header h5,
|
||||||
.form-body p,
|
.form-body p,
|
||||||
.form-body label {
|
.form-body label {
|
||||||
color: #9898A8; /* 修改颜色 */
|
color: #9898A8;
|
||||||
text-align: left; /* 文字靠左对齐 */
|
/* 修改颜色 */
|
||||||
font-size: 0.7rem; /* 字体大小为9px */
|
text-align: left;
|
||||||
|
/* 文字靠左对齐 */
|
||||||
|
font-size: 0.7rem;
|
||||||
|
/* 字体大小为9px */
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-header p {
|
.form-header p {
|
||||||
text-align: left; /* 文字靠左对齐 */
|
text-align: left;
|
||||||
font-size: 0.875rem; /* 字体大小为12px */
|
/* 文字靠左对齐 */
|
||||||
|
font-size: 0.875rem;
|
||||||
|
/* 字体大小为12px */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.item-chip-container {
|
.item-chip-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.03125rem; /* 0.5px */
|
gap: 0.03125rem;
|
||||||
height: 100%; /* 确保容器高度 */
|
/* 0.5px */
|
||||||
|
height: 100%;
|
||||||
|
/* 确保容器高度 */
|
||||||
}
|
}
|
||||||
|
|
||||||
.item-chip-container p {
|
.item-chip-container p {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center; /* 上下居中 */
|
align-items: center;
|
||||||
margin: 0; /* 移除默认外边距 */
|
/* 上下居中 */
|
||||||
line-height: 1; /* 确保行高 */
|
margin: 0;
|
||||||
|
/* 移除默认外边距 */
|
||||||
|
line-height: 1;
|
||||||
|
/* 确保行高 */
|
||||||
}
|
}
|
||||||
|
|
||||||
.chip {
|
.chip {
|
||||||
font-size: 0.7rem; /* 字体大小为9px */
|
font-size: 0.7rem;
|
||||||
|
/* 字体大小为9px */
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- 点检表单 -->
|
<!-- 点检表单 -->
|
||||||
<InspectionForm v-if="showForm" :itemName="selectedItemName" :itemTime="selectedItemTime" :timezone="timezone" :currentStatus="currentStatus" @close="showForm = false" @submit="(currentTime, reason) => handleFormSubmit(selectedItemIndex, reason)" />
|
<InspectionForm v-if="showForm" :itemName="selectedItemName" :itemTime="selectedItemTime" :timezone="timezone" :currentAlarmInfo="currentAlarmInfo" @close="showForm = false" @submit="(currentTime, reason) => handleFormSubmit(selectedItemIndex, reason)" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -126,6 +126,8 @@ const selectedItemName = ref('');
|
||||||
const selectedItemTime = ref('');
|
const selectedItemTime = ref('');
|
||||||
const selectedItemIndex = ref(null);
|
const selectedItemIndex = ref(null);
|
||||||
|
|
||||||
|
const currentDeviceId = ref(null);
|
||||||
|
|
||||||
const selectedDate = ref(null);
|
const selectedDate = ref(null);
|
||||||
|
|
||||||
const formatDate = (date) => {
|
const formatDate = (date) => {
|
||||||
|
@ -135,7 +137,12 @@ const formatDate = (date) => {
|
||||||
const day = d.getDate().toString().padStart(2, '0');
|
const day = d.getDate().toString().padStart(2, '0');
|
||||||
return `${year}/${month}/${day}`;
|
return `${year}/${month}/${day}`;
|
||||||
};
|
};
|
||||||
const currentStatus = ref('');
|
|
||||||
|
const currentAlarmInfo = ref({
|
||||||
|
currentStatus: '',
|
||||||
|
currentAlarmId: '',
|
||||||
|
currentCheckParamId: '',
|
||||||
|
});
|
||||||
|
|
||||||
const currentDate = formatDate(new Date());
|
const currentDate = formatDate(new Date());
|
||||||
|
|
||||||
|
@ -178,28 +185,35 @@ const formatTime = (time) => {
|
||||||
return `${hours}:${minutes}`;
|
return `${hours}:${minutes}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 点检按钮点击事件 handleAlarmConfirm
|
// 点检按钮点击事件
|
||||||
const handleInspection = (hour, index) => {
|
const handleInspection = (hour, index) => {
|
||||||
selectedItemName.value = inspectionItems.value[index].label;
|
selectedItemName.value = inspectionItems.value[index].label;
|
||||||
selectedItemTime.value = hour;
|
selectedItemTime.value = hour;
|
||||||
selectedItemIndex.value = index; // 保存当前索引
|
selectedItemIndex.value = index; // 保存当前索引
|
||||||
|
// 获取当前时间点所有设备报警ID
|
||||||
|
const currentAlarmIds = [];
|
||||||
|
|
||||||
// 校验是否已经确认异常数据
|
// 校验是否已经确认异常数据
|
||||||
if (hourCheckValid.value[hour] !== 1) {
|
if (hourCheckValid.value[hour] !== 1) {
|
||||||
console.log("🚀 ~ handleInspection ~ hourCheckValid.value[hour]:", hourCheckValid.value[hour])
|
|
||||||
showWarningMessage('存在设备异常,无法执行点检操作!');
|
showWarningMessage('存在设备异常,无法执行点检操作!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("🚀 ~ handleInspection ~ inspectionItems.value:", inspectionItems.value)
|
|
||||||
// 校验这个时刻这一列有咩有报警未处理的数据,也就是checkStatus为0的数据
|
// 校验这个时刻这一列有咩有报警未处理的数据,也就是checkStatus为0的数据
|
||||||
if (inspectionItems.value.some(item => item.data[hour]?.checkStatus === 0)) {
|
if (inspectionItems.value.some(item => item.data[hour]?.checkStatus === 0)) {
|
||||||
showWarningMessage('存在报警数据未处理,无法执行点检操作!');
|
showWarningMessage('存在报警数据未处理,无法执行点检操作!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 遍历所有设备收集报警ID和状态
|
||||||
|
Object.keys(alarmId.value).forEach(deviceId => {
|
||||||
|
if (alarmId.value[deviceId]?.[hour]) {
|
||||||
|
currentAlarmIds.push(alarmId.value[deviceId][hour]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
console.log("🚀 ~ handleInspection ~ currentAlarmIds:", currentAlarmIds)
|
||||||
|
|
||||||
showConfirmMessage('确认要执行点检操作吗?', async () => {
|
showConfirmMessage('确认要执行点检操作吗?', async () => {
|
||||||
await sharpConfirm(alarmId.value[hour], 'admin').then(() => {
|
await sharpConfirm(currentAlarmIds, 'admin').then(() => {
|
||||||
confirmedHours.value.push(selectedItemTime.value);
|
confirmedHours.value.push(selectedItemTime.value);
|
||||||
confirmedTimes.value[selectedItemTime.value] = moment().tz(timezone).format('HH:mm');
|
confirmedTimes.value[selectedItemTime.value] = moment().tz(timezone).format('HH:mm');
|
||||||
hourCheckStatus.value[hour] = 1; // 更新点检状态
|
hourCheckStatus.value[hour] = 1; // 更新点检状态
|
||||||
|
@ -215,15 +229,24 @@ const handleAlarmInspection = (hour, index, status) => {
|
||||||
selectedItemName.value = inspectionItems.value[index].label;
|
selectedItemName.value = inspectionItems.value[index].label;
|
||||||
selectedItemTime.value = hour;
|
selectedItemTime.value = hour;
|
||||||
selectedItemIndex.value = index; // 确保在这里设置 selectedItemIndex
|
selectedItemIndex.value = index; // 确保在这里设置 selectedItemIndex
|
||||||
currentStatus.value = status === 0 ? '未处理' : '已处理';
|
|
||||||
|
// 从数据项中获取实际设备ID
|
||||||
|
currentDeviceId.value = inspectionItems.value[index].data[hour]?.deviceId;
|
||||||
|
|
||||||
|
currentAlarmInfo.value = {
|
||||||
|
currentStatus : status === 0 ? '未处理' : '已处理',
|
||||||
|
currentAlarmId: alarmId.value[currentDeviceId.value]?.[selectedItemTime.value],
|
||||||
|
currentCheckParamId: inspectionItems.value[index].data[hour]?.checkParamId
|
||||||
|
}
|
||||||
|
|
||||||
showForm.value = true;
|
showForm.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 点检表单提交事件
|
// 点检表单提交事件
|
||||||
const handleFormSubmit = async (index, reason) => {
|
const handleFormSubmit = async (index, reason) => {
|
||||||
await alarmReasonConfirm({
|
await alarmReasonConfirm({
|
||||||
alarmId: alarmId.value[selectedItemTime.value],
|
alarmId: currentAlarmInfo.value.currentAlarmId, // alarmId.value[selectedItemTime.value],
|
||||||
checkParamId: inspectionItems.value[index].data[selectedItemTime.value].checkParamId,
|
checkParamId: currentAlarmInfo.value.currentCheckParamId,//inspectionItems.value[index].data[selectedItemTime.value]checkParamId,
|
||||||
alarmReason: reason,
|
alarmReason: reason,
|
||||||
checkUser: 'admin'
|
checkUser: 'admin'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
|
@ -343,7 +366,6 @@ const fetchInspectionData = async () => {
|
||||||
const inspectionData = response.data;
|
const inspectionData = response.data;
|
||||||
const itemsMap = {};
|
const itemsMap = {};
|
||||||
inspectionData.forEach(record => {
|
inspectionData.forEach(record => {
|
||||||
console.log("🚀 ~ fetchInspectionData ~ record:", record)
|
|
||||||
const recordTime = record.recordTime;
|
const recordTime = record.recordTime;
|
||||||
const data = record.data;
|
const data = record.data;
|
||||||
const deviceId = record.deviceId;
|
const deviceId = record.deviceId;
|
||||||
|
@ -374,7 +396,8 @@ const fetchInspectionData = async () => {
|
||||||
checkStatus: valueObj.checkStatus,
|
checkStatus: valueObj.checkStatus,
|
||||||
checkText: valueObj.checkText,
|
checkText: valueObj.checkText,
|
||||||
checkParamId: valueObj.checkParamId,
|
checkParamId: valueObj.checkParamId,
|
||||||
checkUser: valueObj.checkUser
|
checkUser: valueObj.checkUser,
|
||||||
|
deviceId: record.deviceId,
|
||||||
// hourCheckStatus: valueObj.hourCheckStatus,
|
// hourCheckStatus: valueObj.hourCheckStatus,
|
||||||
// hourCheckTime: valueObj.hourCheckTime
|
// hourCheckTime: valueObj.hourCheckTime
|
||||||
};
|
};
|
||||||
|
@ -390,14 +413,17 @@ const fetchInspectionData = async () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
// 查询接口数据
|
// 查询接口数据
|
||||||
const handleSearch = () => {
|
const handleSearch = async () => {
|
||||||
fetchInspectionData();
|
try {
|
||||||
fetchCurrentValues();
|
await Promise.all([fetchInspectionData(), fetchCurrentValues()]);
|
||||||
|
// showInfoMessage('数据刷新成功');
|
||||||
|
} catch (error) {
|
||||||
|
showWarningMessage('数据刷新失败');
|
||||||
|
console.error('Error refreshing data:', error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleExport = () => {
|
const handleExport = () => {
|
||||||
console.log("🚀 ~ handleExport ~ inspectionItems.value.some(item => Object.values(item.data).some(data => data.checkStatus === 0)):", inspectionItems.value.some(item => Object.values(item.data).some(data => data.checkStatus === 0)))
|
|
||||||
|
|
||||||
// 增加一个判断,判断当前的数据中inspectionItems.value中是否有报警数据,如果有则提示不允许导出
|
// 增加一个判断,判断当前的数据中inspectionItems.value中是否有报警数据,如果有则提示不允许导出
|
||||||
if (inspectionItems.value.some(item => Object.values(item.data).some(data => data.checkStatus === 0))) {
|
if (inspectionItems.value.some(item => Object.values(item.data).some(data => data.checkStatus === 0))) {
|
||||||
showWarningMessage('请先处理报警数据,再进行导出!');
|
showWarningMessage('请先处理报警数据,再进行导出!');
|
||||||
|
@ -438,8 +464,7 @@ const getDeviceNameById = (id) => {
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await fetchDeviceList();
|
await fetchDeviceList();
|
||||||
fetchCurrentValues();
|
await handleSearch();
|
||||||
fetchInspectionData();
|
|
||||||
sendDataToParent();
|
sendDataToParent();
|
||||||
|
|
||||||
// const setupAutoUpdate = () => {
|
// const setupAutoUpdate = () => {
|
||||||
|
|
Loading…
Reference in New Issue