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