无人机管理后台前端(已迁走)
xiaoxiao
2025-06-10 4cf0b6d70e50ee02611e2c6d844b6133f1383241
src/views/dataCenter/components/searchData.vue
@@ -111,10 +111,10 @@
import dayjs from 'dayjs';
import { useStore } from 'vuex';
import { getRegionTreeAll, getDeviceRegion, deptsByAreaCode } from '@/api/job/task';
const store = useStore();
const userAreaCode = computed(() => store.getters.userInfo.detail.areaCode);
const selectedAreaCode = computed(() => store.state.user.selectedAreaCode);
const emit = defineEmits(['search']);
const treeProps = {
  label: 'name',
  value: 'id',
@@ -172,7 +172,21 @@
let deptData = ref([]);
// 从单机巢任务传参值
const signDevice_sn = ref('');
const handleDateChange = () => {};
// 日期限制
const handleDateChange = val => {
  if (val && val.length === 2) {
    const start = dayjs(val[0]);
    const end = dayjs(val[1]);
    const diff = end.diff(start, 'day');
    if (diff > 31) {
      ElMessage.warning('日期范围不能超过31天');
      dateRange.value = [];
      return;
    }
  }
  handleSearch();
};
// 部门下得机巢
const requestDockInfo = () => {
  getRegionTreeAll({ parentCode: userAreaCode.value }).then(res => {
@@ -207,9 +221,32 @@
  });
};
// 搜索
const handleSearch = () => {};
const handleSearch = () => {
  if (!dateRange.value) {
    dateRange.value = [];
  }
  let params = {
    ...searchForm,
    start_date: dateRange.value.length
      ? dayjs(dateRange?.value[0]).startOf('day').format(timeFormat)
      : null,
    end_date: dateRange.value.length
      ? dayjs(dateRange?.value[1]).endOf('day').format(timeFormat)
      : null,
  };
  console.log('searchForm', params);
  // 调用父组件方法
  emit('search', params);
};
// 重置
const handleReset = () => {};
const handleReset = () => {
  dateRange.value = [];
  Object.keys(searchForm).forEach(key => {
    searchForm[key] = '';
  });
  handleNodeClick({ id: userAreaCode.value });
  handleSearch();
};
onMounted(() => {
  requestDockInfo();
});