|
|
@@ -184,49 +184,90 @@ const handleBtnActive = async(e) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// const prevClick = async() => {
|
|
|
+// if(currentFrequency.value.split(' ')[1].substring(0,2)=='08'){
|
|
|
+// let previousDay = new Date(currentFrequency.value); // 创建一个表示当前时间的Date对象
|
|
|
+// previousDay.setDate(previousDay.getDate() - 1); // 将日期设置为前一天
|
|
|
+// let year = previousDay.getFullYear();
|
|
|
+// let month = previousDay.getMonth() + 1;
|
|
|
+// let day = previousDay.getDate();
|
|
|
+// currentFrequency.value=`${year}-${month}-${day} 20:30:00`
|
|
|
+// console.log(currentFrequency.value); // 输出前一天日期
|
|
|
+// }else{
|
|
|
+// let now = currentFrequency.value.split(' ')[0]
|
|
|
+// currentFrequency.value=`${now} 08:30:00`
|
|
|
+// }
|
|
|
+// GetMachineDetail()
|
|
|
+// }
|
|
|
const prevClick = async() => {
|
|
|
- if(currentFrequency.value.split(' ')[1].substring(0,2)=='08'){
|
|
|
- let previousDay = new Date(currentFrequency.value); // 创建一个表示当前时间的Date对象
|
|
|
- previousDay.setDate(previousDay.getDate() - 1); // 将日期设置为前一天
|
|
|
- let year = previousDay.getFullYear();
|
|
|
- let month = previousDay.getMonth() + 1;
|
|
|
- let day = previousDay.getDate();
|
|
|
- currentFrequency.value=`${year}-${month}-${day} 20:30:00`
|
|
|
- console.log(currentFrequency.value); // 输出前一天日期
|
|
|
- }else{
|
|
|
- let now = currentFrequency.value.split(' ')[0]
|
|
|
- currentFrequency.value=`${now} 08:30:00`
|
|
|
- }
|
|
|
- GetMachineDetail()
|
|
|
-}
|
|
|
+ if (currentFrequency.value.split(' ')[1].substring(0, 2) === '08') {
|
|
|
+ // 当前是白班,切换到前一天夜班
|
|
|
+ let previousDay = new Date(currentFrequency.value);
|
|
|
+ previousDay.setDate(previousDay.getDate() - 1);
|
|
|
+ currentFrequency.value = `${previousDay.getFullYear()}-${previousDay.getMonth() + 1}-${previousDay.getDate()} 20:30:00`;
|
|
|
+ } else {
|
|
|
+ // 当前是夜班,切换到当天白班
|
|
|
+ let now = currentFrequency.value.split(' ')[0];
|
|
|
+ currentFrequency.value = `${now} 08:30:00`;
|
|
|
+ }
|
|
|
+ await GetMachineDetail(); // 重新获取数据并更新图表
|
|
|
+};
|
|
|
|
|
|
+// const nextClick = async() => {
|
|
|
+// if(currentFrequency.value.split(' ')[1].substring(0,2)=='20'){
|
|
|
+// let nextDay = new Date(currentFrequency.value); // 创建一个表示当前时间的Date对象
|
|
|
+// nextDay.setDate(nextDay.getDate() + 1); // 将日期设置为后一天
|
|
|
+// let year = nextDay.getFullYear();
|
|
|
+// let month = nextDay.getMonth() + 1;
|
|
|
+// let day = nextDay.getDate();
|
|
|
+// currentFrequency.value=`${year}-${month}-${day} 08:30:00`
|
|
|
+// }else{
|
|
|
+// let now = currentFrequency.value.split(' ')[0]
|
|
|
+// currentFrequency.value=`${now} 20:30:00`
|
|
|
+// }
|
|
|
+// GetMachineDetail()
|
|
|
+// }
|
|
|
const nextClick = async() => {
|
|
|
- if(currentFrequency.value.split(' ')[1].substring(0,2)=='20'){
|
|
|
- let nextDay = new Date(currentFrequency.value); // 创建一个表示当前时间的Date对象
|
|
|
- nextDay.setDate(nextDay.getDate() + 1); // 将日期设置为后一天
|
|
|
- let year = nextDay.getFullYear();
|
|
|
- let month = nextDay.getMonth() + 1;
|
|
|
- let day = nextDay.getDate();
|
|
|
- currentFrequency.value=`${year}-${month}-${day} 08:30:00`
|
|
|
- }else{
|
|
|
- let now = currentFrequency.value.split(' ')[0]
|
|
|
- currentFrequency.value=`${now} 20:30:00`
|
|
|
- }
|
|
|
- GetMachineDetail()
|
|
|
-}
|
|
|
+ if (currentFrequency.value.split(' ')[1].substring(0, 2) === '20') {
|
|
|
+ // 当前是夜班,切换到下一天白班
|
|
|
+ let nextDay = new Date(currentFrequency.value);
|
|
|
+ nextDay.setDate(nextDay.getDate() + 1);
|
|
|
+ currentFrequency.value = `${nextDay.getFullYear()}-${nextDay.getMonth() + 1}-${nextDay.getDate()} 08:30:00`;
|
|
|
+ } else {
|
|
|
+ // 当前是白班,切换到当天夜班
|
|
|
+ let now = currentFrequency.value.split(' ')[0];
|
|
|
+ currentFrequency.value = `${now} 20:30:00`;
|
|
|
+ }
|
|
|
+ await GetMachineDetail(); // 重新获取数据并更新图表
|
|
|
+};
|
|
|
|
|
|
|
|
|
const GetMachineDetail = async() => {
|
|
|
timeDifference.value=[0,0,0,0,0,0,0,0]
|
|
|
timeRow.value=[]
|
|
|
timeData.value=[]
|
|
|
- const data = []
|
|
|
- for (let i = 510; i <= 1230; i++) { // 08:30 到 20:30 的分钟数范围
|
|
|
- const hours = Math.floor(i / 60)
|
|
|
- const minutes = i % 60
|
|
|
- const time = (hours < 10 ? '0' + hours : hours) + ':' + (minutes < 10 ? '0' + minutes : minutes)
|
|
|
- data.push([time, 0])
|
|
|
- }
|
|
|
+// 动态生成时间范围(判断当前是白班还是夜班)
|
|
|
+const isDayShift = currentFrequency.value.split(' ')[1].substring(0, 2) === '08';
|
|
|
+ const data = [];
|
|
|
+
|
|
|
+ if (isDayShift) {
|
|
|
+ // 白班:08:30-20:30(510 到 1230 分钟)
|
|
|
+ for (let i = 510; i <= 1230; i++) {
|
|
|
+ const hours = Math.floor(i / 60);
|
|
|
+ const minutes = i % 60;
|
|
|
+ const time = `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;
|
|
|
+ data.push([time, 0]);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 夜班:20:30-08:30(1230 到 510 分钟,跨天)
|
|
|
+ for (let i = 1230; i <= 510 + 1440; i++) { // +1440 表示跨天
|
|
|
+ const totalMinutes = i % 1440; // 确保在 0-1439 分钟范围内
|
|
|
+ const hours = Math.floor(totalMinutes / 60);
|
|
|
+ const minutes = totalMinutes % 60;
|
|
|
+ const time = `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;
|
|
|
+ data.push([time, 0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
const response = await getMachineDetail({machine:props.formData.machine,start:currentFrequency.value});
|
|
|
if (response.code === 0) {
|
|
|
response.data.timeDifference.map(item=>{
|
|
|
@@ -305,6 +346,7 @@ const GetMachineDetail = async() => {
|
|
|
axisLabel: {
|
|
|
interval: 59, // 控制显示的刻度标签间隔,每小时一个
|
|
|
},
|
|
|
+ data: data.map(item => item[0]), // 使用动态生成的 X 轴数据
|
|
|
},
|
|
|
yAxis: {
|
|
|
name: '实时产量',
|
|
|
@@ -350,6 +392,7 @@ const GetMachineDetail = async() => {
|
|
|
axisLabel: {
|
|
|
interval: 59, // 控制显示的刻度标签间隔,每小时一个
|
|
|
},
|
|
|
+ data: data.map(item => item[0]), // 使用动态生成的 X 轴数据
|
|
|
},
|
|
|
yAxis: {
|
|
|
name: '检验时间',
|