feat: 更新导出Excel接口,新增lineId参数;优化sharpConfirm接口参数处理

This commit is contained in:
Zhao Zhao Shen 2025-07-18 15:44:29 +08:00
parent 5ad5237fb7
commit 120dd1e4e6
3 changed files with 99 additions and 28 deletions

View File

@ -41,9 +41,9 @@ export function getLineList() {
} }
// 导出excel // 导出excel
export function exportExcel(deviceId, inputTime, shift) { export function exportExcel(deviceId, inputTime, shift, lineId) {
return request({ return request({
url: `/Check/Export/Juice?deviceTypeId=${deviceId}&inputTime=${inputTime}&shift=${shift}`, url: `/Check/Export/Juice?deviceTypeId=${deviceId}&inputTime=${inputTime}&shift=${shift}&lineId=${lineId}`,
method: 'get', method: 'get',
responseType: 'arraybuffer' // 关键:设置响应类型为 arraybuffer responseType: 'arraybuffer' // 关键:设置响应类型为 arraybuffer
}); });
@ -52,9 +52,21 @@ export function exportExcel(deviceId, inputTime, shift) {
// 报警相关接口 // 报警相关接口
// 时间点确认点检,传递多个 alarmId // 时间点确认点检,传递多个 alarmId
export function sharpConfirm(alarmIdList, confirmTime, checkUser) { export function sharpConfirm(alarmIdList, confirmTime, checkUser) {
const alarmIdParams = alarmIdList.map(id => `alarmIdList=${id}`).join('&'); const params = new URLSearchParams();
// 添加 alarmId 参数
alarmIdList.forEach(id => params.append('alarmIdList', id));
// 添加其他参数
if (confirmTime) {
params.append('confirmTime', confirmTime);
}
if (checkUser) {
params.append('checkUser', checkUser);
}
return request({ return request({
url: `/Check/sharpConfirm?${alarmIdParams}&checkUser=${checkUser}`, url: `/Check/sharpConfirm?${params.toString()}`,
method: 'post' method: 'post'
}); });
} }

View File

@ -2,7 +2,7 @@ import axios from 'axios';
const service = axios.create({ const service = axios.create({
// baseURL: 'http://192.168.1.199:8080/api', // 办公室测试接口 // baseURL: 'http://192.168.1.199:8080/api', // 办公室测试接口
// baseURL: 'http://39.105.9.124:8090/api', // 家用测试接口 // baseURL: 'http://39.105.9.124:8082/api', // 家用测试接口
baseURL: '/api', baseURL: '/api',
timeout: 5000, // 请求超时时间 timeout: 5000, // 请求超时时间
headers: { headers: {

View File

@ -50,8 +50,8 @@
<span class="fixed-width"></span> <span class="fixed-width"></span>
<span class="fixed-width"></span> <span class="fixed-width"></span>
<span class="fixed-width" v-for="(hour, index) in hours" :key="hour"> <span class="fixed-width" v-for="(hour, index) in hours" :key="hour">
<IxButton :disabled="confirmedHours.includes(hour) || hourCheckStatus[hour] !== null" class="custom-button" @click="handleInspection(hour, index)"> <IxButton :disabled="confirmedHours.includes(hour) || (hourCheckStatus[selectedDeviceTypeId]?.[hour] !== null && hourCheckTime[selectedDeviceTypeId]?.[hour] !== null) || hourCheckValid[selectedDeviceTypeId]?.[hour] === 0" class="custom-button" @click="handleInspection(hour, index)">
{{ hourCheckStatus[hour] !== null ? hourCheckTime[hour] : '确认' }} {{ (hourCheckStatus[selectedDeviceTypeId]?.[hour] !== null && hourCheckTime[selectedDeviceTypeId]?.[hour] !== null) ? hourCheckTime[selectedDeviceTypeId]?.[hour] : '确认' }}
</IxButton> </IxButton>
</span> </span>
</div> </div>
@ -191,13 +191,15 @@ const confirmedHours = ref([]);
const confirmedTimes = ref({}); const confirmedTimes = ref({});
// //
const hourCheckStatus = ref({}); const hourCheckStatus = ref({}); // { [deviceId: string]: { [recordTime: string]: number } }
const hourCheckTime = ref({}); const hourCheckTime = ref({}); // { [deviceId: string]: { [recordTime: string]: string } }
const alarmId = ref({}); // { [deviceId: string]: { [recordTime: string]: number } } const alarmId = ref({}); // { [deviceId: string]: { [recordTime: string]: number } }
const hourCheckValid = ref({}); const hourCheckValid = ref({});
const formatTime = (time) => { const formatTime = (time) => {
if (!time) return null; // null
const date = new Date(time); const date = new Date(time);
if (isNaN(date.getTime())) return null; // null
const hours = date.getHours().toString().padStart(2, '0'); const hours = date.getHours().toString().padStart(2, '0');
const minutes = date.getMinutes().toString().padStart(2, '0'); const minutes = date.getMinutes().toString().padStart(2, '0');
return `${hours}:${minutes}`; return `${hours}:${minutes}`;
@ -211,18 +213,20 @@ const paramsCache = ref({});
// //
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 // ID
const currentAlarmIds = []; const currentAlarmIds = [];
// //
if (hourCheckValid.value[hour] !== 1) { // 0 null/undefined
if (hourCheckValid.value[selectedDeviceTypeId.value]?.[hour] === 0) {
showWarningMessage('存在设备异常,无法执行点检操作!'); showWarningMessage('存在设备异常,无法执行点检操作!');
return; return;
} }
// checkStatus0
// checkStatus0
if (inspectionItems.value.some(item => item.data[hour]?.checkStatus === 0)) { if (inspectionItems.value.some(item => item.data[hour]?.checkStatus === 0)) {
showWarningMessage('存在报警数据未处理,无法执行点检操作!'); showWarningMessage('存在报警数据未处理,无法执行点检操作!');
return; return;
@ -234,14 +238,26 @@ const handleInspection = (hour, index) => {
currentAlarmIds.push(alarmId.value[deviceId][hour]); currentAlarmIds.push(alarmId.value[deviceId][hour]);
} }
}); });
console.log("🚀 ~ handleInspection ~ currentAlarmIds:", currentAlarmIds)
showConfirmMessage('确认要执行点检操作吗?', async () => { showConfirmMessage('确认要执行点检操作吗?', async () => {
await sharpConfirm(currentAlarmIds, 'admin').then(() => { const confirmTime = moment().tz(timezone).format('YYYY-MM-DD HH:mm');
await sharpConfirm(currentAlarmIds, confirmTime, '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; //
hourCheckTime.value[hour] = confirmedTimes.value[selectedItemTime.value]; // //
if (!hourCheckStatus.value[selectedDeviceTypeId.value]) {
hourCheckStatus.value[selectedDeviceTypeId.value] = {};
}
if (!hourCheckTime.value[selectedDeviceTypeId.value]) {
hourCheckTime.value[selectedDeviceTypeId.value] = {};
}
hourCheckStatus.value[selectedDeviceTypeId.value][hour] = 1; //
hourCheckTime.value[selectedDeviceTypeId.value][hour] = confirmedTimes.value[selectedItemTime.value]; //
}).catch((error) => {
console.error('点检确认失败:', error);
showWarningMessage('点检确认失败,请稍后重试');
}); });
}, () => { }, () => {
showWarningMessage('取消点检操作'); showWarningMessage('取消点检操作');
@ -349,7 +365,20 @@ const fetchCurrentValues = async () => {
// //
inspectionItems.value.forEach(item => { inspectionItems.value.forEach(item => {
item.current = formatNumberWithCommas(currentValues?.[item.name]) || '--'; // checkParamId
let currentValue = '--';
for (const [key, value] of Object.entries(currentValues)) {
// checkParamId key
if (item.checkParamId && value !== null) {
//
// 使
if (item.originalName === key) {
currentValue = value;
break;
}
}
}
item.current = formatNumberWithCommas(currentValue) || '--';
}); });
} else { } else {
showWarningMessage('获取当前设备当前值失败!'); showWarningMessage('获取当前设备当前值失败!');
@ -373,41 +402,63 @@ const fetchInspectionData = async () => {
const response = await getInspectionData(deviceTypeId, dateValue, shiftValue); const response = await getInspectionData(deviceTypeId, dateValue, shiftValue);
if (response.data) { if (response.data) {
const inspectionData = response.data; const inspectionData = response.data.filter(record => record.lineId === selectedLineId.value);
const itemsMap = {}; const itemsMap = {};
inspectionData.forEach(record => { inspectionData.forEach(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;
hourCheckStatus.value[recordTime] = record.hourCheckStatus; //
hourCheckTime.value[recordTime] = formatTime(record.hourCheckTime); if (!hourCheckStatus.value[deviceId]) {
hourCheckStatus.value[deviceId] = {};
}
if (!hourCheckTime.value[deviceId]) {
hourCheckTime.value[deviceId] = {};
}
// 使
if (hourCheckStatus.value[deviceId][recordTime] === undefined) {
hourCheckStatus.value[deviceId][recordTime] = record.hourCheckStatus;
}
if (hourCheckTime.value[deviceId][recordTime] === undefined) {
hourCheckTime.value[deviceId][recordTime] = formatTime(record.hourCheckTime);
}
if (!alarmId.value[deviceId]) { if (!alarmId.value[deviceId]) {
alarmId.value[deviceId] = {} alarmId.value[deviceId] = {}
} }
alarmId.value[deviceId][recordTime] = record.alarmId; alarmId.value[deviceId][recordTime] = record.alarmId;
hourCheckValid.value[recordTime] = record.hourCheckValid; //
if (!hourCheckValid.value[deviceId]) {
hourCheckValid.value[deviceId] = {};
}
hourCheckValid.value[deviceId][recordTime] = record.hourCheckValid;
for (const [name, valueObj] of Object.entries(data)) { for (const [name, valueObj] of Object.entries(data)) {
if (valueObj === null || valueObj.valule === null) continue; if (valueObj === null || valueObj.value === null) continue;
// 使 checkParamId
const uniqueKey = valueObj.checkParamId.toString();
// 使 // 使
const paramInfo = paramsCache.value[name] || { projectName: name, referenceValue: 0, unit: '' }; const paramInfo = paramsCache.value[name] || { projectName: name, referenceValue: 0, unit: '' };
if (!itemsMap[name]) { if (!itemsMap[uniqueKey]) {
itemsMap[name] = { itemsMap[uniqueKey] = {
name, name: uniqueKey,
originalName: name, //
label: paramInfo.projectName, // 使 label: paramInfo.projectName, // 使
reference: paramInfo.referenceValue, reference: paramInfo.referenceValue,
current: 0, current: 0,
unit: paramInfo.unit, unit: paramInfo.unit,
checkParamId: valueObj.checkParamId,
data: {} data: {}
}; };
} }
itemsMap[name].data[recordTime] = { itemsMap[uniqueKey].data[recordTime] = {
value: valueObj.value, value: valueObj.value,
checkStatus: valueObj.checkStatus, checkStatus: valueObj.checkStatus,
checkText: valueObj.checkText, checkText: valueObj.checkText,
@ -419,7 +470,6 @@ const fetchInspectionData = async () => {
}); });
inspectionItems.value = Object.values(itemsMap); inspectionItems.value = Object.values(itemsMap);
// //
await fetchCurrentValues(); await fetchCurrentValues();
} else { } else {
@ -510,7 +560,7 @@ const handleExport = () => {
} }
showInfoMessage('导出全部'); showInfoMessage('导出全部');
exportExcel(selectedDeviceTypeId.value, selectedDate.value || currentDate, shift.value) exportExcel(selectedDeviceTypeId.value, selectedDate.value || currentDate, shift.value, selectedLineId.value)
.then((response) => { .then((response) => {
if (response) { if (response) {
// //
@ -683,6 +733,15 @@ onMounted(async () => {
--theme-btn-primary--background--hover: #FFA849; --theme-btn-primary--background--hover: #FFA849;
} }
/* 禁用状态的按钮样式 */
.custom-button[disabled] {
--theme-btn-primary--background: #666666 !important;
--theme-btn-primary--background--hover: #666666 !important;
--theme-btn-primary--color: #999999 !important;
cursor: not-allowed !important;
opacity: 0.6 !important;
}
.drop-down { .drop-down {
width: calc(25% - 1.25rem); width: calc(25% - 1.25rem);
background-color: #23233C; background-color: #23233C;