forked from drone/command-center-dashboard

chenyao
2025-04-10 858b8f2b41f272855c50d11960bceadc3c62380f
src/views/TaskManage/TaskIntermediateContent/AddTask.vue
@@ -17,14 +17,15 @@
                     v-model="taskData"
                     format="YYYY-MM-DD"
                     value-format="YYYY-MM-DD"
                     :disabled-date="disabledDate"
                  />
               </div>
               <div class="item">任务时间:
                  <!-- <el-time-picker
                  <el-time-picker
                     v-model="searchForm.execute_time_arr"
                     placeholder="选择时间"
                     format="HH:mm"
                     value-format="HH:mm"/> -->
                     value-format="HH:mm"/>
               </div>
               <div class="item">选择航线:
                  <el-select
@@ -113,6 +114,11 @@
});
const isShowAddTask = defineModel('show');
// 禁用当天之前的日期
const disabledDate = (time) => {
  return time.getTime() < Date.now() - 8.64e7; // 86400000 = 24 * 60 * 60 * 1000
};
// 获取航线列表数据
const routeOptions = ref([]);
const getRouteList = async () => {
@@ -191,6 +197,26 @@
    });
    return;
  }
   // 检查任务时间
  if (searchForm.execute_time_arr) {
    const now = new Date();
    const today = now.toDateString();
    const selectedDate = new Date(taskData.value).toDateString();
    if (today === selectedDate) {
      const [hours, minutes] = searchForm.execute_time_arr.split(':');
      const selectedTime = new Date();
      selectedTime.setHours(parseInt(hours), parseInt(minutes));
      if (selectedTime < now) {
        ElMessage({
          message: '任务时间不能小于当前时间',
          type: 'warning'
        });
        return;
      }
    }
  }
   searchForm.begin_time = `${taskData.value} 00:00:00`;
  searchForm.end_time = `${taskData.value} 23:59:59`;