张卓
2022-09-29 4ef1c909df36c48f7f040e9ec408fc15e6745e71
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
<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() {
    const runAsync = new Promise((resolve, reject) => {
      this.$request({
        url: '/organization/getMapPath',
        method: 'get',
        params: {
          organizationId: this.$store.state.orgId
        }
      })
        .then(res => {
          const data = res.data
          for (let i = 0; i < data.length; i++) {
            this.options.push({
              value: data[i].provinceCode,
              label: data[i].provinceName
            })
          }
          resolve()
        })
        .catch(err => {
          console.log('请求Region失败')
          console.log(err)
        })
    })
 
    //获取省code
    runAsync.then(() => {
      this.newRegion = Number(
        this.$store.state.regionCode.toString().substr(0, 2) + '0000'
      )
    })
  }
}
</script>
 
<style scoped>
.line {
  text-align: center;
}
</style>