...
|
...
|
@@ -127,67 +127,75 @@ export default { |
|
|
...mapActions(["fetchAddressProvinces"]),
|
|
|
|
|
|
/* 处理编辑时父组件传递的省市区 */
|
|
|
async parentHandleclick({ areaCode, areaCaption }) {
|
|
|
let returnTitle = this.returnTitle();
|
|
|
|
|
|
if (
|
|
|
areaCode === "" ||
|
|
|
areaCaption === "" ||
|
|
|
areaCode === undefined ||
|
|
|
areaCaption === undefined
|
|
|
) {
|
|
|
async parentHandleclick({ areaCode }) {
|
|
|
if (areaCode === "" || areaCode === undefined || areaCode.length < 8) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (returnTitle !== "") {
|
|
|
//用来判断编辑地址未修改的情况
|
|
|
if (!(areaCaption !== "" && areaCaption.trim().split(" ").length > 1)) {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
let arrList = areaCaption.trim().split(" ");
|
|
|
|
|
|
if (!areaCode) {
|
|
|
areaCode = 0;
|
|
|
}
|
|
|
|
|
|
//省
|
|
|
let provincesCaption = "";
|
|
|
this.province.id = areaCode.substring(0, 2);
|
|
|
this.province.allTitle = arrList[0];
|
|
|
this.province.title = this.titleHandle(arrList[0]);
|
|
|
|
|
|
const provinceResult = await this.fetchAddressProvinces(0);
|
|
|
this.provinces = provinceResult.data;
|
|
|
this.provinces.map(info => {
|
|
|
if (info.id === this.province.id) {
|
|
|
provincesCaption = info.caption;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
this.city.id = areaCode.substring(0, 4);
|
|
|
this.city.allTitle = arrList[1];
|
|
|
this.city.title = this.titleHandle(arrList[1]);
|
|
|
this.province.allTitle = provincesCaption;
|
|
|
this.province.title = this.titleHandle(provincesCaption);
|
|
|
|
|
|
//市
|
|
|
let citysCaption = "";
|
|
|
this.city.id = areaCode.substring(0, 4);
|
|
|
const cityResult = await this.fetchAddressProvinces(
|
|
|
areaCode.substring(0, 2)
|
|
|
);
|
|
|
this.citys = cityResult.data;
|
|
|
this.citys.map(info => {
|
|
|
if (info.id === this.city.id) {
|
|
|
citysCaption = info.caption;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
this.area.id = areaCode.substring(0, 6);
|
|
|
this.area.allTitle = arrList[2];
|
|
|
this.area.title = this.titleHandle(arrList[2]);
|
|
|
this.city.allTitle = citysCaption;
|
|
|
this.city.title = this.titleHandle(citysCaption);
|
|
|
|
|
|
//县
|
|
|
let areasCaption = "";
|
|
|
this.area.id = areaCode.substring(0, 6);
|
|
|
const areaResult = await this.fetchAddressProvinces(
|
|
|
areaCode.substring(0, 4)
|
|
|
);
|
|
|
this.areas = areaResult.data;
|
|
|
|
|
|
this.areas.map(info => {
|
|
|
if (info.id === this.area.id) {
|
|
|
areasCaption = info.caption;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
this.area.allTitle = areasCaption;
|
|
|
this.area.title = this.titleHandle(areasCaption);
|
|
|
|
|
|
//街道
|
|
|
let streetsCaption = "";
|
|
|
this.street.id = areaCode;
|
|
|
this.street.allTitle = arrList[3];
|
|
|
this.street.title = this.titleHandle(arrList[3]);
|
|
|
const result = await this.fetchAddressProvinces(areaCode.substring(0, 6));
|
|
|
this.streets = result.data;
|
|
|
this.streets.map(info => {
|
|
|
if (info.id === this.street.id) {
|
|
|
streetsCaption = info.caption;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
this.street.allTitle = streetsCaption;
|
|
|
this.street.title = this.titleHandle(streetsCaption);
|
|
|
|
|
|
this.street.showList = this.street.titleActive = true;
|
|
|
this.province.showList = this.city.showList = this.area.showList = false;
|
|
|
this.province.titleActive = this.city.titleActive = this.area.titleActive = false;
|
|
|
|
|
|
//根据前6位请求/*街道*/显示列表
|
|
|
const result = await this.fetchAddressProvinces(areaCode.substring(0, 6));
|
|
|
this.streets = result.data;
|
|
|
},
|
|
|
|
|
|
/* 获取地址数据绑定 */
|
...
|
...
|
|