Skip to content

Commit

Permalink
fix: #39
Browse files Browse the repository at this point in the history
  • Loading branch information
dwqs committed Oct 25, 2018
1 parent 1ec93bb commit a0effda
Showing 1 changed file with 33 additions and 13 deletions.
46 changes: 33 additions & 13 deletions components/area-select/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
data: {
type: Object,
required: true
},
isLinkage: {
type: Boolean,
default: false
}
},
Expand Down Expand Up @@ -105,17 +109,17 @@
watch: {
curProvinceCode (val, oldVal) {
this.curProvince = this.provinces[val];
this.provinceChange(val);
this.provinceChange(val, oldVal === val);
},
curCityCode (val, oldVal) {
this.curCity = this.citys[val];
this.cityChange(val);
this.cityChange(val, oldVal === val);
},
curAreaCode (val, oldVal) {
this.curArea = this.areas[val];
this.areaChange(val);
this.areaChange(val, oldVal === val);
},
value (val) {
Expand All @@ -131,7 +135,7 @@
},
methods: {
provinceChange (val) {
provinceChange (val, isEqual) {
if (this.level === 0) {
this.selectChange();
} else if (this.level >= 1) {
Expand All @@ -140,8 +144,10 @@
this.citys = {
[this.curProvinceCode]: this.curProvince
};
this.curCity = this.curProvince;
this.curCityCode = this.curCityCode;
if (this.isLinkage) {
this.curCity = this.curProvince;
this.curCityCode = this.curCityCode;
}
return;
}
Expand All @@ -160,12 +166,19 @@
}
}
this.curCity = curCity;
this.curCityCode = curCityCode;
if (this.isLinkage) {
this.curCity = curCity;
this.curCityCode = curCityCode;
} else if (!isEqual) {
this.curCity = '';
this.curCityCode = '';
this.curArea = '';
this.curAreaCode = '';
}
}
},
cityChange (val) {
cityChange (val, isEqual) {
if (this.level === 1) {
this.selectChange();
} else if (this.level === 2) {
Expand All @@ -175,8 +188,10 @@
this.areas = {
[this.curCityCode]: this.curCity
};
this.curArea = this.curCity;
this.curAreaCode = this.curCityCode;
if (this.isLinkage) {
this.curArea = this.curCity;
this.curAreaCode = this.curCityCode;
}
return;
}
Expand All @@ -195,8 +210,13 @@
}
}
this.curArea = curArea;
this.curAreaCode = curAreaCode;
if (this.isLinkage) {
this.curArea = curArea;
this.curAreaCode = curAreaCode;
} else if (!isEqual) {
this.curArea = '';
this.curAreaCode = '';
}
}
},
Expand Down

0 comments on commit a0effda

Please sign in to comment.