123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- <!--
- * @LastEditors: wangcc
- -->
- <template>
- <div class="pickerAddr u-flex">
- <div class="select-wrap select-province" @click="provinceClick">
- 省:
- <el-select v-model="selectProvince.name" placeholder="请选择" disabled>
- <!-- <el-option
- v-for="item in vuexCityList"
- :key="item.areaCode"
- :label="item.areaName"
- :value="{value:item.areaCode,label:item.areaName,areaId:item.areaId}"
- ></el-option>-->
- </el-select>
- </div>
- <div class="select-wrap">
- 市:
- <el-select v-model="selectCity" placeholder="请选择" @change="cityChange($event,'city')">
- <el-option
- v-for="item in vuexCityList"
- :key="item.areaCode"
- :label="item.areaName"
- :value="{value:item.areaCode,label:item.areaName,areaId:item.areaId}"
- ></el-option>
- </el-select>
- </div>
- <div class="select-wrap">
- 县:
- <el-select v-model="selectDistrict" placeholder="请选择" @change="cityChange($event,'district')">
- <el-option
- v-for="item in vuexDistrictList"
- :key="item.areaCode"
- :label="item.areaName"
- :value="{value:item.areaCode,label:item.areaName,areaId:item.areaId}"
- ></el-option>
- </el-select>
- </div>
- <div class="select-wrap">
- 乡:
- <el-select v-model="selectStreet" placeholder="请选择" @change="cityChange($event,'street')">
- <el-option
- v-for="item in vuexStreetList"
- :key="item.areaCode"
- :label="item.areaName"
- :value="{value:item.areaCode,label:item.areaName,areaId:item.areaId}"
- ></el-option>
- </el-select>
- </div>
- </div>
- </template>
- <script>
- import { mapMutations, mapState, mapGetters } from 'vuex';
- export default {
-
-
-
-
-
- name: '',
- components: {},
- data() {
- return {
- selectProvince: {
- parentId: '520000',
- name: '贵州省',
- mapLevel: 'province'
- },
- selectCity: {},
- selectDistrict: {},
- selectStreet: {},
- value: '',
- parentId: '520000',
- name: '',
- areaId: ''
- };
- },
- watch: {
- '$store.state.addr.selectCity'(val) {
- this.selectCity = val;
- },
- '$store.state.addr.selectDistrict'(val) {
- this.selectDistrict = val;
- },
- '$store.state.addr.selectStreet'(val) {
- this.selectStreet = val;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- },
- computed: {
-
- ...mapGetters(['vuexCityList', 'vuexDistrictList', 'vuexStreetList'])
- },
- created() {
- this.$store.dispatch('searchArea', {
- parentId: this.parentId,
- name: this.name,
- mapLevel: 'province'
- });
- },
- mounted() {},
- methods: {
- ...mapMutations([
- 'changeSelectCity',
- 'changeSelectDistrict',
- 'changeSelectStreet',
- 'changeSelectProject'
- ]),
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- cityChange(val, level) {
- if (level == 'city') {
- this.changeSelectCity({
- value: val.value,
- label: val.label,
- areaId: val.areaId,
- prop: '1'
- });
- } else if (level == 'district') {
- this.changeSelectDistrict({
- value: val.value,
- label: val.label,
- areaId: val.areaId,
- prop: '1'
- });
- } else if (level == 'street') {
- this.changeSelectStreet({
- value: val.value,
- label: val.label,
- areaId: val.areaId,
- prop: '1'
- });
- }
- this.parentId = val.value.substring(0, 6);
- this.name = level;
- this.$store.dispatch('searchArea', {
- parentId: this.parentId,
- name: val.label,
- mapLevel: level
- });
- },
- provinceClick() {
-
- this.$store.dispatch('searchArea', {
- ...this.selectProvince
- });
- this.changeSelectCity({});
- this.changeSelectDistrict({});
- this.changeSelectStreet({});
- this.changeSelectProject({});
- }
- }
- };
- </script>
- <style lang='scss' scoped>
- .pickerAddr {
- font-size: 18px;
- color: var(--main-color);
- text-align: right;
- margin-bottom: 1vh;
- .select-wrap:not(:last-of-type) {
- margin-right: 10px;
- }
- .select-province {
- position: relative;
- &::after {
- content: '';
- width: 100%;
- height: 100%;
- position: absolute;
- left: 0;
- top: 0;
- background: transparent;
- cursor: pointer;
- }
- }
- .select-province.select-wrap {
- /deep/ .el-input__inner {
- cursor: pointer;
- }
- }
- .el-select {
- width: 8vw;
- /deep/ .el-input__inner {
- font-size: 18px;
-
-
- color: var(--main-color);
- background: linear-gradient(
- 180deg,
- rgba(0, 250, 253, 0.3) 0%,
- rgba(0, 250, 253, 0) 54%,
- rgba(0, 250, 253, 0.3) 100%
- );
- border-radius: 0px 0px 0px 0px;
- opacity: 0.9;
- border: 1px solid rgba(0, 250, 253, 0.3);
- &::-webkit-input-placeholder {
- color: var(--main-color);
- }
- &:hover {
- border-color: var(--main-color);
- }
- }
- /deep/ .el-input__icon {
- color: var(--main-color);
- }
- }
- }
- @media only screen and (max-width: 1200px) {
- .pickerAddr {
- font-size: 16px;
- .el-select {
- /deep/ .el-input__inner {
- font-size: 16px;
- }
- }
- }
- }
- </style>
|