forked from drone/command-center-dashboard

chenyao
2025-04-10 858b8f2b41f272855c50d11960bceadc3c62380f
feat: 增加任务时间段和当天判断
3 files modified
59 ■■■■■ changed files
src/api/home/task.js 12 ●●●● patch | view | raw | blame | history
src/views/TaskManage/TaskIntermediateContent/AddTask.vue 30 ●●●●● patch | view | raw | blame | history
src/views/TaskManage/TaskIntermediateContent/TaskTable.vue 17 ●●●● patch | view | raw | blame | history
src/api/home/task.js
@@ -86,17 +86,11 @@
}
// 获取可飞行机巢列表
export const getFlyingNestBy = (data) => {
export const getFlyingNestBy = (data,page) => {
    return request({
        url: `/drone-device-core/manage/api/v1/devices/getFlyingNestBy?current=${data.page}&size=${data.limit}`,
        url: `/drone-device-core/manage/api/v1/devices/getFlyingNestBy?current=${page.page}&size=${page.size}`,
        method: 'post',
        data: {
            wayline_id: data.wayline_id,
            type: data.type,
            latitude: data.latitude,
            longitude: data.longitude,
            polygon: data.polygon
        },
        data: data,
    })
}
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`;
    
src/views/TaskManage/TaskIntermediateContent/TaskTable.vue
@@ -11,8 +11,8 @@
    </el-table>
    <div class="pagination">
      <el-pagination
        v-model:current-page="pageParams.page"
        v-model:page-size="pageParams.limit"
        v-model:current-page="pagingParams.page"
        v-model:page-size="pagingParams.size"
        :page-sizes="[10, 20, 30]"
        layout="total, sizes, prev, pager, next"
        :total="total"
@@ -54,36 +54,37 @@
  longitude: props.singlePoint.longitude,
  latitude: props.singlePoint.latitude,
  polygon: [],
});
let pagingParams = ref({
  page: 1,
  limit: 10
  size: 10
});
// 获取可用机巢列表数据
const total = ref(0);
const tableData = ref([]);
const getNestList = async () => {
    tableData.value = [];
  // console.log(pageParams.value,'草草草草')
  const res = await getFlyingNestBy(pageParams.value);
  const res = await getFlyingNestBy(pageParams.value, pagingParams.value);
  if (res.data.code === 0) {
    tableData.value = res.data.data;
  }
};
// 分页大小改变
const handleSizeChange = (val) => {
  pageParams.value.limit = val;
  pagingParams.value.size = val;
  getNestList();
};
// 页码改变
const handleCurrentChange = (val) => {
  pageParams.value.page = val;
  pagingParams.value.page = val;
  getNestList();
};
// 刷新数据
const refreshData = () => {
  tableData.value = [];
  pageParams.value.page = 1;
  pagingParams.value.page = 1;
  getNestList();
};