quanyawei
2024-11-15 f752f50a484f63fc3786ab1c7ad563f3b17cce77
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<template>
  <div>
    <el-cascader
      v-model="newRegion"
      placeholder="选择省/市/区"
      :options="options"
      clearable
      style="flex:1"
    />
  </div>
</template>
 
<script>
export default {
  data() {
    return {
      form: {
        name: '',
        region: '',
        date1: '',
        date2: '',
        delivery: false,
        type: [],
        resource: '',
        desc: ''
      },
      options: [],
      newRegion: []
    }
  },
  watch: {
    newRegion(n, o) {
      this.$emit('regionCode', n[this.newRegion.length - 1])
    }
  },
  created() {
    this.getRegion()
  },
  methods: {
    getRegion() {
      this.$request({
        url: '/organization/getMapPath',
        method: 'get',
        params: {
          organizationId: this.$store.state.orgId
        }
      })
        .then(res => {
          // console.log('region组件请求getMapPath接口')
          // console.log(res.data)
          const data = res.data
          for (let i = 0; i < data.length; i++) {
            this.options.push({
              value: data[i].provinceCode,
              label: data[i].provinceName
            })
            this.options[i].children = []
            for (let j = 0; j < data[i].cities.length; j++) {
              this.options[i].children.push({
                value: data[i].cities[j].cityCode,
                label: data[i].cities[j].cityName
              })
              this.options[i].children[j].children = []
              for (let k = 0; k < data[i].cities[j].areas.length; k++) {
                this.options[i].children[j].children.push({
                  value: data[i].cities[j].areas[k].areaCode,
                  label: data[i].cities[j].areas[k].areaName
                })
              }
            }
          }
        })
        .catch(err => {
          console.log(err)
        })
    }
  }
}
</script>
 
<style scoped>
.line{
  text-align: center;
}
</style>