| | |
| | | v-model="taskData" |
| | | format="YYYY-MM-DD" |
| | | value-format="YYYY-MM-DD" |
| | | :disabled-date="disabledDate" |
| | | /> |
| | | </div> |
| | | <div class="item">任务时间: |
| | | <!-- <el-time-picker |
| | | v-model="searchForm.execute_time_arr" |
| | | <el-time-picker |
| | | v-model="timeSlot" |
| | | placeholder="选择时间" |
| | | format="HH:mm" |
| | | value-format="HH:mm"/> --> |
| | | value-format="HH:mm"/> |
| | | </div> |
| | | <div class="item">选择航线: |
| | | <el-select |
| | |
| | | // 添加子组件引用 |
| | | const taskTableRef = ref(null); |
| | | const taskData = ref(''); |
| | | const timeSlot = ref(''); |
| | | const searchForm = reactive({ |
| | | name: '', |
| | | ai_types: [], |
| | |
| | | polygon: [], |
| | | }); |
| | | const isShowAddTask = defineModel('show'); |
| | | |
| | | // 禁用当天之前的日期 |
| | | const disabledDate = (time) => { |
| | | return time.getTime() < Date.now() - 8.64e7; // 86400000 = 24 * 60 * 60 * 1000 |
| | | }; |
| | | |
| | | // 获取航线列表数据 |
| | | const routeOptions = ref([]); |
| | |
| | | }); |
| | | return; |
| | | } |
| | | // 检查任务时间 |
| | | if (timeSlot.value) { |
| | | const now = new Date(); |
| | | const today = now.toDateString(); |
| | | const selectedDate = new Date(taskData.value).toDateString(); |
| | | |
| | | if (today === selectedDate) { |
| | | const [hours, minutes] = timeSlot.value.split(':'); |
| | | const selectedTime = new Date(); |
| | | selectedTime.setHours(parseInt(hours), parseInt(minutes)); |
| | | |
| | | if (selectedTime < now) { |
| | | ElMessage({ |
| | | message: '任务时间不能小于当前时间', |
| | | type: 'warning' |
| | | }); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | if (searchForm.dock_sns.length === 0) { |
| | | ElMessage({ |
| | | message: '请选择机场', |
| | | type: 'warning' |
| | | }); |
| | | return; |
| | | } |
| | | searchForm.begin_time = `${taskData.value} 00:00:00`; |
| | | searchForm.end_time = `${taskData.value} 23:59:59`; |
| | | |
| | | searchForm.execute_time_arr = timeSlot.value ? [timeSlot.value] : []; |
| | | createTask(searchForm).then((res) => { |
| | | if (res.data.code === 0) { |
| | | ElMessage.success('任务创建成功'); |
| | | // 关闭当前窗口,刷新任务管理列表 |
| | | isShowAddTask.value = false; |
| | | // 清除数据 |
| | | cancel(); |
| | | emit('refresh'); |
| | | } |
| | | }); |
| | |
| | | searchForm.file_id = ''; |
| | | searchForm.begin_time = ''; |
| | | searchForm.end_time = ''; |
| | | searchForm.execute_time_arr = ''; |
| | | timeSlot.value = ''; |
| | | searchForm.remark = ''; |
| | | searchForm.dock_sns = []; |
| | | rangDate.value = []; |
| | | waylineId.value = ''; |
| | | wayLineFile.value = ''; |
| | | taskData.value = ''; |
| | | }; |
| | | |
| | | onMounted(() => { |