|
|
@@ -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: '提示',
|