Authored by 张文文

地址编辑逻辑修改

... ... @@ -255,8 +255,7 @@ export default {
this.isShowProvince = true;
this.$refs.addressAct.parentHandleclick({
areaCode: this.model.area_code,
areaCaption: this.model.area
areaCode: this.model.area_code
});
},
popHidden() {
... ... @@ -299,7 +298,7 @@ export default {
this.model.consignee = item.consignee;
this.model.address_id = item.address_id;
this.model.mobile = item.mobile;
this.model.area_code = item.area_code;
this.model.area_code = item.area_code || item.areaCode;
this.model.area = item.area;
this.model.address = item.address;
this.model.tag_code = item.tag_code;
... ...
... ... @@ -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;
},
/* 获取地址数据绑定 */
... ...