HD_wangm 2 месяцев назад
Родитель
Сommit
866d55ea80

+ 84 - 21
pages/order/detail/restartIndex.uvue

@@ -31,6 +31,14 @@
 					    <text class="info-label">下发时间</text>
 					    <text class="info-value">{{ assignTime ?? '' }}</text>
 					</view>
+					<view class="info-item" v-if="realStartTime != ''">
+					    <text class="info-label">开始时间</text>
+					    <text class="info-value">{{ realStartTime ?? '' }}</text>
+					</view>
+					<view class="info-item" v-if="realStartTime != ''">
+					    <text class="info-label">结束时间</text>
+					    <text class="info-value">{{ realEndTime ?? '' }}</text>
+					</view>
 					<view class="info-item" v-if="orderType == '1'">
 					    <text class="info-label">发生时间</text>
 					    <text class="info-value">{{ occurTime ?? '' }}</text>
@@ -136,6 +144,8 @@
 	const assignTime = ref<string>('')
 	const occurTime = ref<string>('')
 	const pauseTime = ref<string>('')
+	const realStartTime = ref<string>('')
+	const realEndTime = ref<string>('')
 
 	const showshutdownTimePicker = ref<boolean>(false)
 
@@ -234,24 +244,26 @@
 			return
 		}
 
-		// 添加时间验证逻辑
-		const restartTimeDate = new Date(restartTime.value);
-		const currentDate = new Date(); // 获取当前时间
-
-		// 验证复运时间不能大于当前时间
-		if (restartTimeDate > currentDate) {
+		// 添加时间验证逻辑(统一用时间戳对比,避免格式问题)
+		const restartTimeStamp = new Date(restartTime.value).getTime(); // 恢复运行时间戳
+		const currentTimeStamp = new Date().getTime(); // 当前时间戳
+		const realStartTimeStamp = realStartTime.value != '' ? new Date(realStartTime.value).getTime() : 0; // 开工时间戳
+		const realEndTimeStamp = realEndTime.value != '' ? new Date(realEndTime.value).getTime() : 0; // 收工时间戳
+	
+		// 验证1:恢复运行时间不能大于当前时间
+		if (restartTimeStamp > currentTimeStamp) {
 			uni.showToast({
 				title: '恢复运行时间不能大于当前时间',
 				icon: 'none'
 			});
 			return;
 		}
-
+	
 		if (orderType.value == '1') {
-			// 维修工单restartTime不能小于occurTime
+			// 维修工单:恢复运行时间不能小于发生时间
 			if (occurTime.value != '') {
-				const occurTimeDate = new Date(occurTime.value);
-				if (restartTimeDate < occurTimeDate) {
+				const occurTimeStamp = new Date(occurTime.value).getTime();
+				if (restartTimeStamp < occurTimeStamp) {
 					uni.showToast({
 						title: '恢复运行时间不能早于发生时间',
 						icon: 'none'
@@ -259,11 +271,34 @@
 					return;
 				}
 			}
+			
+			// 2. 开工时间不为空时,恢复运行时间不能小于开工时间
+			if (realStartTimeStamp > 0) { // 开工时间戳>0表示非空且有效
+				if (restartTimeStamp < realStartTimeStamp) {
+					uni.showToast({
+						title: '恢复运行时间不能早于开始时间',
+						icon: 'none'
+					});
+					return;
+				}
+			}
+				
+			// 3. 收工时间不为空时,恢复运行时间不能大于收工时间
+			if (realEndTimeStamp > 0) { // 收工时间戳>0表示非空且有效
+				if (restartTimeStamp > realEndTimeStamp) {
+					uni.showToast({
+						title: '恢复运行时间不能晚于结束时间',
+						icon: 'none'
+					});
+					return;
+				}
+			}
 		} else if (orderType.value == '2') {
-			// 维保工单restartTime不能小于pauseTime
+			// 维保工单校验逻辑
+			// 1. 恢复运行时间不能小于停机时间(原有逻辑,改为时间戳对比)
 			if (pauseTime.value != '') {
-				const pauseTimeDate = new Date(pauseTime.value);
-				if (restartTimeDate < pauseTimeDate) {
+				const pauseTimeStamp = new Date(pauseTime.value).getTime();
+				if (restartTimeStamp < pauseTimeStamp) {
 					uni.showToast({
 						title: '恢复运行时间不能早于停机时间',
 						icon: 'none'
@@ -271,6 +306,28 @@
 					return;
 				}
 			}
+	
+			// 2. 开工时间不为空时,恢复运行时间不能小于开工时间
+			if (realStartTimeStamp > 0) { // 开工时间戳>0表示非空且有效
+				if (restartTimeStamp < realStartTimeStamp) {
+					uni.showToast({
+						title: '恢复运行时间不能早于开始时间',
+						icon: 'none'
+					});
+					return;
+				}
+			}
+	
+			// 3. 收工时间不为空时,恢复运行时间不能大于收工时间
+			if (realEndTimeStamp > 0) { // 收工时间戳>0表示非空且有效
+				if (restartTimeStamp > realEndTimeStamp) {
+					uni.showToast({
+						title: '恢复运行时间不能晚于结束时间',
+						icon: 'none'
+					});
+					return;
+				}
+			}
 		}
 
 		if (orderType.value == '1' && lostPower.value.trim() === '') {
@@ -280,15 +337,19 @@
 			})
 			return
 		}
-		// 验证损失电量必须大于0
-		const lostPowerNum = parseFloat(lostPower.value);
-		if (isNaN(lostPowerNum) || lostPowerNum <= 0) {
-			uni.showToast({
-				title: '损失电量必须大于0',
-				icon: 'none'
-			})
-			return
+		
+		if(lostPower.value.trim() != '') {
+			// 验证损失电量必须大于0
+			const lostPowerNum = parseFloat(lostPower.value);
+			if (isNaN(lostPowerNum) || lostPowerNum <= 0) {
+				uni.showToast({
+					title: '损失电量必须大于0',
+					icon: 'none'
+				})
+				return
+			}
 		}
+		
 		if (isDealing.value || hasDealed.value) return // 双重保险
 		isDealing.value = true
 		try {
@@ -392,6 +453,8 @@
 				assignTime.value = (data['assignTime'] as string | null) ?? ''
 				occurTime.value = (data['occurTime'] as string | null) ?? ''
 				pauseTime.value = (data['pauseTime'] as string | null) ?? ''
+				realStartTime.value = (data['realStartTime'] as string | null) ?? ''
+				realEndTime.value = (data['realEndTime'] as string | null) ?? ''
 				if(orderType == 2 && pauseTime.value == '') {
 					uni.showModal({
 					  title: '提示',

+ 29 - 0
pages/order/detail/shutdownIndex.uvue

@@ -31,6 +31,10 @@
 					    <text class="info-label">下发时间</text>
 					    <text class="info-value">{{ assignTime ?? '' }}</text>
 					</view>
+					<view class="info-item" v-if="realStartTime != ''">
+					    <text class="info-label">开始时间</text>
+					    <text class="info-value">{{ realStartTime ?? '' }}</text>
+					</view>
                 </view>
             </view>
 			<view class="info-section">
@@ -109,6 +113,7 @@
 	const brand = ref<string>('')
 	const model = ref<string>('')
 	const assignTime = ref<string>('')
+	const realStartTime = ref<string>('')
 
 	const showshutdownTimePicker = ref<boolean>(false)
 	
@@ -170,6 +175,29 @@
 			})
 			return
 		}
+		// 2. 时间格式转换(兼容字符串/Date类型,统一转为时间戳对比)
+		const pauseTimeStamp = new Date(pauseTime.value).getTime();
+		const currentTimeStamp = new Date().getTime(); // 当前系统时间戳
+		// 处理realStartTime(开工打卡时间),空值时为0
+		const realStartTimeStamp = realStartTime.value != '' ? new Date(realStartTime.value).getTime() : 0;
+		// 3. 校验1:停机时间不能大于当前时间
+		if (pauseTimeStamp > currentTimeStamp) {
+			uni.showToast({
+				title: '停机时间不能晚于当前时间',
+				icon: 'none'
+			})
+			return
+		}
+	
+		// 4. 校验2:realStartTime不为空时,停机时间不能小于开工时间
+		if (realStartTimeStamp > 0 && pauseTimeStamp < realStartTimeStamp) {
+			uni.showToast({
+				title: '停机时间不能早于开始时间',
+				icon: 'none'
+			})
+			return
+		}
+		
 		if (isDealing.value || hasDealed.value) return // 双重保险
 		isDealing.value = true
 		try {
@@ -269,6 +297,7 @@
 				brand.value = (data['brand'] as string | null) ?? ''
 				model.value = (data['model'] as string | null) ?? ''
 				assignTime.value = (data['assignTime'] as string | null) ?? ''
+				realStartTime.value = (data['realStartTime'] as string | null) ?? ''
 
             } else {
                 const msg = resultObj['msg'] as string | null

+ 86 - 7
pages/order/detail/wbFinalize.uvue

@@ -39,6 +39,14 @@
 					    <text class="info-label">接单时间</text>
 					    <text class="info-value">{{ acceptTime ?? '' }}</text>
 					</view>
+					<view class="info-item" v-if="pauseTime != ''">
+					    <text class="info-label">停机时间</text>
+					    <text class="info-value">{{ pauseTime ?? '' }}</text>
+					</view>
+					<view class="info-item" v-if="restartTime != ''">
+					    <text class="info-label">复运时间</text>
+					    <text class="info-value">{{ restartTime ?? '' }}</text>
+					</view>
                 </view>
             </view>
             <!-- 结单表单 -->
@@ -1074,14 +1082,85 @@
             });
             return false;
         }
+		
+		// 统一转换为时间戳(避免格式问题,对比更精准)
+		const realStartTimeStamp = new Date(realStartTime.value).getTime();
+		const currentTimeStamp = new Date().getTime(); // 当前时间戳
+		const realEndTimeStamp = new Date(realEndTime.value).getTime(); // 结束时间戳
+		
+		
+		// 校验1:开始时间不能大于当前时间
+		if (realStartTimeStamp > currentTimeStamp) {
+			uni.showToast({
+				title: '开始时间不能大于当前时间',
+				icon: 'none'
+			});
+			return false;
+		}
+	
+		// 校验2:开始时间不能大于结束时间(优化原有逻辑,用时间戳更稳定)
+		if (realStartTimeStamp >= realEndTimeStamp) {
+			uni.showToast({
+				title: '开始时间不能大于结束时间',
+				icon: 'none'
+			});
+			return false;
+		}
+	
+		// 校验3:开始时间不能大于停机时间(pauseTime非空时校验)
+		if (pauseTime.value != '' && pauseTime.value.trim() !== '') {
+			const pauseTimeStamp = new Date(pauseTime.value).getTime();
+			if (realStartTimeStamp > pauseTimeStamp) {
+				uni.showToast({
+					title: '开始时间不能大于停机时间',
+					icon: 'none'
+				});
+				return false;
+			}
+			
+			if (realEndTimeStamp < pauseTimeStamp) {
+				uni.showToast({
+					title: '结束时间不能小于停机时间',
+					icon: 'none'
+				});
+				return false;
+			}
+			
+		}
+	
+		// 校验4:开始时间不能大于恢复运行时间(restartTime非空时校验)
+		if (restartTime.value != '' && restartTime.value.trim() !== '') {
+			const restartTimeStamp = new Date(restartTime.value).getTime();
+			if (realStartTimeStamp > restartTimeStamp) {
+				uni.showToast({
+					title: '开始时间不能大于复运时间',
+					icon: 'none'
+				});
+				return false;
+			}
+		}
+		
+		// 1. 结束时间不能大于当前时间
+		if (realEndTimeStamp > currentTimeStamp) {
+			uni.showToast({
+				title: '结束时间不能大于当前时间',
+				icon: 'none'
+			});
+			return false;
+		}
+	
+		// 2. 结束时间不能小于恢复运行时间(restartTime/复运时间非空时校验)
+		if (restartTime.value != '' && restartTime.value.trim() !== '') {
+			const restartTimeStamp = new Date(restartTime.value).getTime();
+			if (realEndTimeStamp < restartTimeStamp) {
+				uni.showToast({
+					title: '结束时间不能小于复运时间',
+					icon: 'none'
+				});
+				return false;
+			}
+		}
 
-        if (new Date(realEndTime.value) <= new Date(realStartTime.value)) {
-            uni.showToast({
-                title: '结束时间必须大于开始时间',
-                icon: 'none'
-            });
-            return false;
-        }
 
 		if (teamLeaderName.value == '') {
 		    uni.showToast({

+ 86 - 8
pages/order/detail/wxFinalize.uvue

@@ -51,6 +51,14 @@
 					    <text class="info-label">故障描述</text>
 					    <text class="info-value">{{ faultDesc ?? '-' }}</text>
 					</view>
+					<view class="info-item" v-if="pauseTime != ''">
+					    <text class="info-label">发生时间</text>
+					    <text class="info-value">{{ pauseTime ?? '' }}</text>
+					</view>
+					<view class="info-item" v-if="restartTime != ''">
+					    <text class="info-label">复运时间</text>
+					    <text class="info-value">{{ restartTime ?? '' }}</text>
+					</view>
                 </view>
             </view>
             <!-- 结单表单 -->
@@ -1210,14 +1218,84 @@
             });
             return false;
         }
-
-        if (new Date(realEndTime.value) <= new Date(realStartTime.value)) {
-            uni.showToast({
-                title: '结束时间必须大于开始时间',
-                icon: 'none'
-            });
-            return false;
-        }
+		
+		// 统一转换为时间戳(避免格式问题,对比更精准)
+		const realStartTimeStamp = new Date(realStartTime.value).getTime();
+		const currentTimeStamp = new Date().getTime(); // 当前时间戳
+		const realEndTimeStamp = new Date(realEndTime.value).getTime(); // 结束时间戳
+		
+		// 校验1:开始时间不能大于当前时间
+		if (realStartTimeStamp > currentTimeStamp) {
+			uni.showToast({
+				title: '开始时间不能大于当前时间',
+				icon: 'none'
+			});
+			return false;
+		}
+			
+		// 校验2:开始时间不能大于结束时间(优化原有逻辑,用时间戳更稳定)
+		if (realStartTimeStamp >= realEndTimeStamp) {
+			uni.showToast({
+				title: '开始时间不能大于结束时间',
+				icon: 'none'
+			});
+			return false;
+		}
+			
+		// 校验3:开始时间不能大于发生时间(pauseTime非空时校验)
+		if (pauseTime.value != '' && pauseTime.value.trim() !== '') {
+			const pauseTimeStamp = new Date(pauseTime.value).getTime();
+			if (realStartTimeStamp < pauseTimeStamp) {
+				uni.showToast({
+					title: '开始时间不能小于发生时间',
+					icon: 'none'
+				});
+				return false;
+			}
+			
+			if (realEndTimeStamp < pauseTimeStamp) {
+				uni.showToast({
+					title: '结束时间不能小于发生时间',
+					icon: 'none'
+				});
+				return false;
+			}
+			
+		}
+			
+		// 校验4:开始时间不能大于恢复运行时间(restartTime非空时校验)
+		if (restartTime.value != '' && restartTime.value.trim() !== '') {
+			const restartTimeStamp = new Date(restartTime.value).getTime();
+			if (realStartTimeStamp > restartTimeStamp) {
+				uni.showToast({
+					title: '开始时间不能大于复运时间',
+					icon: 'none'
+				});
+				return false;
+			}
+		}
+		
+		// 1. 结束时间不能大于当前时间
+		if (realEndTimeStamp > currentTimeStamp) {
+			uni.showToast({
+				title: '结束时间不能大于当前时间',
+				icon: 'none'
+			});
+			return false;
+		}
+			
+		// 2. 结束时间不能小于恢复运行时间(restartTime/复运时间非空时校验)
+		if (restartTime.value != '' && restartTime.value.trim() !== '') {
+			const restartTimeStamp = new Date(restartTime.value).getTime();
+			if (realEndTimeStamp < restartTimeStamp) {
+				uni.showToast({
+					title: '结束时间不能小于复运时间',
+					icon: 'none'
+				});
+				return false;
+			}
+		}
+		
 
 		if (teamLeaderName.value == '') {
 		    uni.showToast({