From 8b9813c901e7b8b311aa84ae3029f71bd67de4cc Mon Sep 17 00:00:00 2001 From: Zhao Zhao Shen Date: Tue, 4 Mar 2025 16:33:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=A0=B7=E5=BC=8F=E4=BF=AE=E6=94=B9=20&?= =?UTF-8?q?=20=E7=82=B9=E6=A3=80=E5=8A=9F=E8=83=BD=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/inspection.js | 14 ++- src/views/Dashboard/index.vue | 8 +- src/views/Inspection/index.vue | 161 +++++++++++++++++++-------------- src/views/layout/vueLayout.vue | 23 ++--- 4 files changed, 116 insertions(+), 90 deletions(-) diff --git a/src/api/inspection.js b/src/api/inspection.js index e9d6ab8..683fe61 100644 --- a/src/api/inspection.js +++ b/src/api/inspection.js @@ -9,9 +9,9 @@ export function getInspectionCurrent(deviceId, inputTime) { } // 获取点检页面整点数值 -export function getInspectionData(deviceId, inputTime) { +export function getInspectionData(deviceId, inputTime, shift) { return request({ - url: `/Check/sharp?deviceId=${deviceId}&inputTime=${inputTime}`, + url: `/Check/sharp?deviceId=${deviceId}&inputTime=${inputTime}&shift=${shift}`, method: 'get' }); } @@ -19,7 +19,15 @@ export function getInspectionData(deviceId, inputTime) { // 获取点检页面参数 export function getCheckParas(deviceId, inputTime) { return request({ - url: `/Check/CheckParas?deviceId=${deviceId}&inputTime=${inputTime}`, + url: `/Check/CheckParas?deviceTypeId=${deviceId}&inputTime=${inputTime}`, + method: 'get' + }); +} + +// 获取设备列表 +export function getDeviceList() { + return request({ + url: '/Check/deviceList', method: 'get' }); } \ No newline at end of file diff --git a/src/views/Dashboard/index.vue b/src/views/Dashboard/index.vue index df30fee..02ea549 100644 --- a/src/views/Dashboard/index.vue +++ b/src/views/Dashboard/index.vue @@ -241,7 +241,7 @@
当前步骤: - 果汁配方 + {{ pulpTank.mixerStep }}
当前液位: @@ -322,7 +322,7 @@ import ProcessGanttChart from '@/components/ProcessGanttChart.vue' const emit = defineEmits(['send-data']); const sendDataToParent = () => { - emit('send-data', 'SIEMENS MIS 1.0 前处理界面'); + emit('send-data', 'SIEMENS MIS 1.0 前处理界面', 'mis-app'); }; // 设置为您期望的时区,比如 "Asia/Shanghai" @@ -815,13 +815,13 @@ onUnmounted(() => { /* 全局样式 */ .dashboard-container { padding: 0 !important; - margin: 0 !important; + margin: 0 -1.5rem 0 0 !important; display: flex; flex-direction: column; align-items: center; background: #000028; height: 100vh; - width: 100%; + width: calc(100% + 1.5rem); overflow: hidden; color: white; font-family: 'Microsoft YaHei', sans-serif; diff --git a/src/views/Inspection/index.vue b/src/views/Inspection/index.vue index 96de89c..b75d104 100644 --- a/src/views/Inspection/index.vue +++ b/src/views/Inspection/index.vue @@ -2,56 +2,55 @@
- + - - - + + + + - 查询 + 查询 导出全部
- 灌注机 - 吹瓶机 - 果汁杀菌 - 果肉杀菌 + + + {{ item.name }} + +
+ +
+ + + + + + 确认 + +
+
+ 点检项目 + 单位 + 参考值 + 当前值 + + {{ hour }} + +
+ - -
- - - - - - - 确认 - -
-
- -
- 点检项目 - 单位 - 参考值 - 当前值 - - {{ hour }} - -
-
@@ -77,7 +76,7 @@ import momentTimezone from 'moment-timezone'; import { ref, computed, getCurrentInstance, onMounted, defineEmits, onUnmounted } from 'vue'; import { IxDatePicker, IxButton, IxDropdownItem, IxEventList, IxEventListItem, IxSelect, IxSelectItem, IxDateInput } from '@siemens/ix-vue'; import InspectionForm from './InspectionForm.vue'; -import { getInspectionCurrent, getInspectionData, getCheckParas } from '@/api/inspection'; +import { getInspectionCurrent, getInspectionData, getCheckParas, getDeviceList } from '@/api/inspection'; const emit = defineEmits(['send-data']); @@ -85,24 +84,26 @@ const emit = defineEmits(['send-data']); const timezone = 'Asia/Shanghai'; // 全局响应式变量 -const globalDeviceId = ref(null); const globalTime = ref(moment().tz(timezone).format('YYYY-MM-DD HH:mm')); const isAutoUpdate = ref(true); // 是否自动更新 -const deviceType = ref(false); const sendDataToParent = () => { - emit('send-data', '点检界面'); + emit('send-data', '点检界面', 'other-app'); }; // 获取当前时间的小时数 const currentHour = new Date().getHours(); // 根据当前时间确定默认班次 -const defaultShift = currentHour >= 7 && currentHour < 19 ? 'day' : 'night'; +const defaultShift = currentHour >= 7 && currentHour < 19 ? '0' : '1'; // 早班为0,晚班为1 // 定义响应式变量 -const shift = ref('day'); // 确保 shift 变量已定义 -const status = ref('1'); // 确保 status 变量已定义 +const shift = ref(defaultShift); // 设置默认班次 +const status = ref('0'); // 确保 status 变量已定义 + +// 设备列表 +const deviceList = ref([]); +const selectedDeviceId = ref(null); const showForm = ref(false); const selectedItemName = ref(''); @@ -121,9 +122,8 @@ const currentDate = formatDate(new Date()); // 计算当前班次的时间段 const hours = computed(() => { const shiftValue = shift.value; - console.log("🚀 ~ hours ~ shiftValue:", shiftValue) const hours = []; - if (shiftValue === 'day') { + if (shiftValue === '0') { for (let i = 7; i <= 18; i++) { hours.push(`${i < 10 ? '0' : ''}${i}:00`); // 白班 07:00-18:00 } @@ -138,10 +138,6 @@ const hours = computed(() => { return hours; }); -const handleShiftClick = (shift) => { - state.value.selectedShift = shift; -}; - // JSON 数据 const data = ref({}); @@ -174,14 +170,44 @@ const toLowerCaseFirstLetter = (str) => { const handleDateChange = (event) => { selectedDate.value = event.target.value; + console.log("🚀 ~ handleDateChange ~ selectedDate.value:", selectedDate.value) }; +const handleShiftChange = (event) => { + shift.value = event.detail; + console.log("🚀 ~ handleShiftChange ~ shift.value:", shift.value) + fetchInspectionData(); + fetchCurrentValues(); +}; + +// 切换设备 +const handleDeviceListChange = (id) => { + selectedDeviceId.value = id; + fetchInspectionData(); + fetchCurrentValues(); +}; + +// 获取设备列表 +const fetchDeviceList = async () => { + try { + const response = await getDeviceList(); + if (response.code === 200) { + deviceList.value = response.data; + selectedDeviceId.value = deviceList.value[2].id; // 默认选中第一个设备 + } + } catch (error) { + console.error('Error fetching device list:', error); + } +}; + +// 获取当前值、参考值、单位等信息 const fetchCurrentValues = async () => { try { - const deviceId = 7; // 根据实际情况设置设备ID - const inputTime = new Date().toISOString(); // 获取当前时间 - const response = await getInspectionCurrent(deviceId, inputTime); - const params = await getCheckParas(deviceId, inputTime); + const deviceId = selectedDeviceId.value; // 根据实际情况设置设备ID + const dateValue = selectedDate.value || currentDate; + // const inputTime = selectedDate.value; //new Date().toISOString(); // 获取当前时间 + const response = await getInspectionCurrent(deviceId, dateValue); + const params = await getCheckParas(deviceId, dateValue); if (response.code === 200) { const currentValues = response.data.data; @@ -192,13 +218,11 @@ const fetchCurrentValues = async () => { if (params.code === 200) { const paramData = params.data; - console.log("🚀 ~ fetchCurrentValues ~ paramData:", paramData) inspectionItems.value.forEach(item => { const param = paramData.find(param => { return toLowerCaseFirstLetter(param.keyname) === item.name; }); - console.log("🚀 ~ fetchCurrentValues ~ param:", param) if (param) { item.label = param.projectDescription; @@ -208,23 +232,20 @@ const fetchCurrentValues = async () => { }); } - console.log("🚀 ~ fetchCurrentValues ~ inspectionItems.value:", inspectionItems.value) } catch (error) { console.error('Error fetching current values:', error); } }; +// 获取点检数据 const fetchInspectionData = async () => { try { - const deviceId = 7; // globalDeviceId // 根据实际情况设置设备ID - const inputTime = new Date().toISOString(); // globalTime; // 获取当前时间 + const deviceId = selectedDeviceId.value; // 根据实际情况设置设备ID + // const inputTime = new Date().toISOString(); // globalTime; // 获取当前时间 const shiftValue = shift.value; const statusValue = status.value; const dateValue = selectedDate.value || currentDate; - console.log("🚀 ~ fetchInspectionData ~ shift:", shiftValue) - console.log("🚀 ~ fetchInspectionData ~ status:", statusValue) - console.log("🚀 ~ fetchInspectionData ~ date:", dateValue) - const response = await getInspectionData(deviceId, inputTime); + const response = await getInspectionData(deviceId, dateValue, shiftValue); if (response.code === 200) { const inspectionData = response.data; const itemsMap = {}; @@ -248,15 +269,21 @@ const fetchInspectionData = async () => { }); inspectionItems.value = Object.values(itemsMap); } - console.log("🚀 ~ fetchInspectionData ~ inspectionItems.value:", inspectionItems.value) } catch (error) { console.error('Error fetching inspection data:', error); } }; +// 查询接口数据 +const handleSearch = () => { + fetchInspectionData(); + fetchCurrentValues(); +}; + let autoUpdateInterval = null; -onMounted(() => { +onMounted(async () => { + await fetchDeviceList(); fetchCurrentValues(); fetchInspectionData(); sendDataToParent(); @@ -278,7 +305,7 @@ onMounted(() => { // 监听 update-history 事件 window.addEventListener('update-history', (event) => { isAutoUpdate.value = false; - globalTime.value = event.detail; + selectedDate.value = event.detail; fetchCurrentValues(); fetchInspectionData(); setupAutoUpdate(); @@ -287,7 +314,7 @@ onMounted(() => { // 监听 reset 事件 window.addEventListener('reset', (event) => { isAutoUpdate.value = true; - globalTime.value = moment().tz(timezone).format('YYYY-MM-DD HH:mm'); + selectedDate.value = moment().tz(timezone).format('YYYY-MM-DD HH:mm'); // fetchData(); // fetchGanttData(); setupAutoUpdate(); @@ -303,7 +330,8 @@ onUnmounted(() => { \ No newline at end of file