riku
2025-03-07 2592dc279ec82bf3649a4dbe644c6416263a10ef
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<template>
  <el-form-item label="初级产品">
    <el-select
      :loading="loading"
      v-model="index"
      @change="handleChange"
      placeholder="选择AOD数据"
      size="small"
      class="w-150"
    >
      <el-option
        v-for="(s, i) in allGridDataList"
        :key="i"
        :label="timeFormatter(s.dataTime)"
        :value="i"
      />
    </el-select>
  </el-form-item>
</template>
<script setup>
import { ref, onMounted } from 'vue';
import moment from 'moment';
import gridApi from '@/api/gridApi';
import { useFetchData } from '@/composables/fetchData';
 
defineProps({
  modelValue: Object
});
 
const emits = defineEmits(['update:modelValue']);
 
const { loading, fetchData } = useFetchData();
const allGridDataList = ref([]);
const index = ref(null);
 
function fetchAOD(groupId, dataTime) {
  return fetchData(() => {
    return gridApi.fetchGridData(groupId).then((res) => {
      allGridDataList.value = res.data;
      if (res.data.length > 0) {
        index.value = 0;
        handleChange(0);
      } else {
        index.value = null;
        handleChange(null);
      }
    });
  });
}
 
function timeFormatter(value) {
  return moment(value).format('YYYY-MM-DD');
}
 
function handleChange(value) {
  emits(
    'update:modelValue',
    value != null ? allGridDataList.value[value] : null
  );
}
 
// onMounted(() => {
//   fetchAOD();
// });
 
defineExpose({ fetchAOD });
</script>