{"version":3,"file":"index.19c5553e.mjs","sources":["../../../../components/selectProv/index.vue"],"sourcesContent":["<template>\r\n  <div class=\"flex\">\r\n    <el-select v-model=\"provinceCode\" class=\"mgr10\" :style=\"{width: width + 'px'}\" placeholder=\"省\" @change=\"changeProvince(provinceCode)\">\r\n      <el-option\r\n        v-for=\"(item, index) in provinceList\"\r\n        :key=\"index\"\r\n        :label=\"item.regionName\"\r\n        :value=\"item.regionName\"\r\n      />\r\n    </el-select>\r\n    <div></div>\r\n    <el-select v-model=\"cityCode\" class=\"mgr10\" :style=\"{width: width + 'px'}\" placeholder=\"市\" @change=\"changeCity(cityCode)\">\r\n      <el-option\r\n        v-for=\"(item, index) in cityList\"\r\n        :key=\"index\"\r\n        :label=\"item.regionName\"\r\n        :value=\"item.regionName\"\r\n      />\r\n    </el-select>\r\n    <div></div>\r\n    <!-- <el-select v-model=\"areaCode\" :style=\"{width: width + 'px'}\" placeholder=\"区\" @change=\"changeArea(areaCode)\">\r\n      <el-option\r\n        v-for=\"item in areaList\"\r\n        :key=\"item.code\"\r\n        :label=\"item.value\"\r\n        :value=\"item.value\"\r\n      />\r\n    </el-select> -->\r\n  </div>\r\n</template>\r\n\r\n<script>\r\nimport { regionList } from '@/api/event.js'\r\nexport default {\r\n  props: {\r\n    dataCode: {\r\n      type: Object,\r\n      default: () => {}\r\n    },\r\n    width: {\r\n      type: Number,\r\n      default: 220\r\n    }\r\n  },\r\n  data() {\r\n    return {\r\n      provinceList: [],\r\n      cityList: [],\r\n      areaList: [],\r\n      province: '',\r\n      city: '',\r\n      area: '',\r\n      provinceCode: '',\r\n      cityCode: '',\r\n      areaCode: ''\r\n    }\r\n  },\r\n  watch: {\r\n    dataCode(val) {\r\n      this.rebackData()\r\n    }\r\n  },\r\n  created() {\r\n    this.getProvince()\r\n  },\r\n  mounted() {\r\n    if (this.dataCode.provinceCode) {\r\n      this.rebackData()\r\n    }\r\n  },\r\n  methods: {\r\n    // 省份\r\n    getProvince() {\r\n      regionList({ level: 1, parentId: 1 }).then(res => {\r\n        this.provinceList = res\r\n      })\r\n    },\r\n    // 区\r\n    getRegion(name) {\r\n      const that = this\r\n      this.provinceList.map((item, index) => {\r\n        if (item.regionName === name) {\r\n          regionList({ level: 2, parentId: item.id }).then(res => {\r\n            that.cityList = res\r\n          })\r\n          return\r\n        }\r\n      })\r\n    },\r\n    // 地址回填\r\n    rebackData() {\r\n      this.changeProvince(this.dataCode.provinceCode)\r\n      this.changeCity(this.dataCode.cityCode)\r\n      // this.changeArea(this.dataCode.areaCode)\r\n    },\r\n    changeProvince(provinceCode) {\r\n      this.provinceCode = provinceCode\r\n      this.cityCode = ''\r\n      this.areaCode = ''\r\n      this.getRegion(provinceCode)\r\n      this.confirm()\r\n    },\r\n    changeCity(cityCode) {\r\n      this.cityCode = cityCode\r\n      this.areaCode = ''\r\n      // this.cityList.forEach((item) => {\r\n      //   if (item.regionName === cityCode) {\r\n      //     this.city = item.regionName\r\n      //     this.areaList = item.children\r\n      //     return\r\n      //   }\r\n      // })\r\n      this.confirm()\r\n    },\r\n    changeArea(areaCode) {\r\n      this.areaCode = areaCode\r\n      this.areaList.forEach((item) => {\r\n        if (item.code === areaCode) {\r\n          this.area = item.value\r\n          return\r\n        }\r\n      })\r\n      this.confirm()\r\n      // this.$emit('getLocationCode', {\r\n      //   province: this.province,\r\n      //   provinceCode: this.provinceCode,\r\n      //   city: this.city,\r\n      //   cityCode: this.cityCode,\r\n      //   area: this.area,\r\n      //   areaCode: this.areaCode\r\n      // })\r\n    },\r\n    confirm() {\r\n      this.$emit('getLocationCode', {\r\n        province: this.province,\r\n        provinceCode: this.provinceCode,\r\n        city: this.city,\r\n        cityCode: this.cityCode,\r\n        area: this.area,\r\n        areaCode: this.areaCode\r\n      })\r\n    }\r\n  }\r\n}\r\n\r\n</script>\r\n"],"names":["_sfc_main","props","dataCode","width","data","provinceList","city","area","provinceCode","watch","this","rebackData","created","getProvince","mounted","methods","regionList","level","parentId","then","res","getRegion","name","map","item","index","that","cityList","changeCity","cityCode","areaCode","changeArea","areaList","forEach","value","confirm","_hoisted_1","class","_openBlock","_createElementBlock","style","_normalizeStyle","$props","placeholder","_Fragment","_renderList","$data","key"],"mappings":"wHAiCA,MAAAA,EAAA,CACEC,MAAA,CACEC,SAAA,6BAIAC,MAAA,2BAKFC,KAAA,KACE,CACEC,aAAA,uCAIAC,KAAA,GACAC,KAAA,GACAC,aAAA,6BAKJC,MAAA,aAEIC,KAAAC,YACF,GAEFC,UACEF,KAAAG,eAEFC,UACEJ,KAAAR,SAAAM,cACEE,KAAAC,cAGJI,QAAA,eAGIC,EAAA,CAAAC,MAAA,EAAAC,SAAA,IAAAC,MAAAC,IACEV,KAAAL,aAAAe,CAAA,KAIJC,UAAAC,gBAEEZ,KAAAL,aAAAkB,KAAA,CAAAC,EAAAC,4DAGMC,EAAAC,SAAAP,CAAA,GAGJ,kEAMFV,KAAAkB,WAAAlB,KAAAR,SAAA2B,iDAKAnB,KAAAmB,SAAA,GACAnB,KAAAoB,SAAA,qCAIFF,WAAAC,GACEnB,KAAAmB,SAAAA,EACAnB,KAAAoB,SAAA,mBAUFC,WAAAD,GACEpB,KAAAoB,SAAAA,EACApB,KAAAsB,SAAAC,SAAAT,iBAEId,KAAAH,KAAAiB,EAAAU,MAEF,oBAYJC,+DAGI3B,aAAAE,KAAAF,aACAF,KAAAI,KAAAJ,4BAEAC,KAAAG,KAAAH,KACAuB,SAAApB,KAAAoB,UAEJ,IA5IGM,EAAA,CAAAC,MAAA,6IAAL,OAAAC,IAAAC,EAAA,MAAAH,EAAA,uFACoCC,MAAA,QAAeG,MAAAC,EAAA,CAAAtC,MAAAuC,EAAAvC,MAAA,OAA8BwC,YAAA,iFAC7EL,GAAA,GAAAC,EAAAK,EAAA,KAAAC,EAAAC,EAAAzC,cAAA,CAAAmB,EAAAC,cAEGsB,IAAAtB,8LAMyBY,MAAA,QAAeG,MAAAC,EAAA,CAAAtC,MAAAuC,EAAAvC,MAAA,OAA8BwC,YAAA,yEACzEL,GAAA,GAAAC,EAAAK,EAAA,KAAAC,EAAAC,EAAAnB,UAAA,CAAAH,EAAAC,cAEGsB,IAAAtB"}