Blame view

src/components/fee/parkingAreaSelect2.vue 1.2 KB
b25b036d   wuxw   v1.9 优化日期
1
  <template>
2e0fd29c   wuxw   开发报修
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
    <el-select
      v-model="value"
      filterable
      remote
      :remote-method="remoteMethod"
      :loading="loading"
      :placeholder="$t('parkingAreaSelect2.parkingLotPlaceholder')"
      style="width:100%"
      @change="handleChange"
    >
      <el-option
        v-for="item in options"
        :key="item.paId"
        :label="item.num"
        :value="item.paId"
      />
    </el-select>
  </template>
  
  <script>
  import { listParkingAreas } from '@/api/fee/carCreateFeeApi'
  
  export default {
    name: 'ParkingAreaSelect2',
    props: {
      value: {
        type: String,
        default: ''
      }
    },
    data() {
      return {
        options: [],
        loading: false
      }
    },
    methods: {
      async remoteMethod(query) {
        if (query) {
          this.loading = true
          try {
            const res = await listParkingAreas({
              num: query,
              page: 1,
              row: 50
            })
            this.options = res.parkingAreas || []
          } catch (error) {
            console.error('获取停车场失败:', error)
          } finally {
            this.loading = false
          }
        } else {
          this.options = []
        }
      },
      handleChange(value) {
        this.$emit('change', value)
      }
    }
  }
  </script>