riku
2023-07-14 023dd7fafa5d1a39d6f62ba88b6c4ec590aa20cd
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
<template>
  <el-select
    v-model="selectedOptions"
    placeholder="网格化记录"
    style="max-width: 150px"
  >
    <el-option
      v-for="s in options"
      :key="s.value"
      :label="s.label"
      :value="s"
    />
  </el-select>
</template>
 
<script>
// 网格化方案记录选项
 
import gridRecordApi from '@/api/gridRecordApi';
 
export default {
  props: {
    // 是否在首选项处添加“全部”选项
    // allOption: {
    //   type: Boolean,
    //   default: true,
    // },
    // 返回结果
    value: Object,
  },
  data() {
    return {
      options: [],
      selectedOptions: {}
    };
  },
  watch: {
    selectedOptions: {
      handler(val) {
        this.$emit('update:value', val);
      },
      deep: true,
    },
  },
  methods: {
    getOptions() {
      gridRecordApi.getGridRecords().then((res) => {
        this.options = res;
        this.selectedOptions = res[0];
      });
    }
  },
  mounted() {
    this.getOptions();
  }
};
</script>