调整外部数据更新后插件内自动同步相关
This commit is contained in:
Vendored
+2
-2
File diff suppressed because one or more lines are too long
+33
-26
@@ -115,12 +115,7 @@ export default {
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.defaultAddr = JSON.parse(JSON.stringify(this.value));
|
||||
this.created = true;
|
||||
this.checkProvince();
|
||||
this.checkCity();
|
||||
this.checkArea();
|
||||
this.created = false;
|
||||
this.init();
|
||||
},
|
||||
// computed: {
|
||||
// defaultAddr: {
|
||||
@@ -146,13 +141,7 @@ export default {
|
||||
// },
|
||||
mounted() {
|
||||
this.$watch("value", (res) => {
|
||||
console.log(11);
|
||||
this.defaultAddr = JSON.parse(JSON.stringify(this.value));
|
||||
this.created = true;
|
||||
this.checkProvince();
|
||||
this.checkCity();
|
||||
this.checkArea();
|
||||
this.created = false;
|
||||
this.init();
|
||||
});
|
||||
},
|
||||
// 不知道是哪里姿势不对用了此方法就一直无法获取父主键传过来的v-model
|
||||
@@ -180,6 +169,21 @@ export default {
|
||||
// },
|
||||
watch: {},
|
||||
methods: {
|
||||
init() {
|
||||
let newAddress = JSON.stringify(this.value);
|
||||
let oldAddress = JSON.stringify(this.defaultAddr);
|
||||
console.log(newAddress.toString(), oldAddress.toString());
|
||||
|
||||
if (newAddress.toString() != oldAddress.toString()) {
|
||||
this.defaultAddr = JSON.parse(newAddress);
|
||||
console.log(1111);
|
||||
this.checkProvince();
|
||||
this.checkCity();
|
||||
this.checkArea();
|
||||
|
||||
this.$emit("input", this.defaultAddr);
|
||||
}
|
||||
},
|
||||
// 选择省
|
||||
checkProvince() {
|
||||
this.provinceJson.forEach((element) => {
|
||||
@@ -193,12 +197,13 @@ export default {
|
||||
|
||||
this.defaultAddr.province_code = element.code;
|
||||
this.defaultAddr.province = element.name;
|
||||
|
||||
if (!this.created) {
|
||||
this.$emit("input", this.defaultAddr);
|
||||
this.defaultAddr.city_code = "";
|
||||
this.defaultAddr.area_code = "";
|
||||
}
|
||||
this.defaultAddr.city_code = "";
|
||||
this.defaultAddr.area_code = "";
|
||||
// if (!this.created) {
|
||||
// this.$emit("input", this.defaultAddr);
|
||||
// this.defaultAddr.city_code = "";
|
||||
// this.defaultAddr.area_code = "";
|
||||
// }
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -214,10 +219,12 @@ export default {
|
||||
|
||||
this.defaultAddr.city_code = element.code;
|
||||
this.defaultAddr.city = element.name;
|
||||
if (!this.created) {
|
||||
this.$emit("input", this.defaultAddr);
|
||||
this.defaultAddr.area_code = "";
|
||||
}
|
||||
this.defaultAddr.area_code = "";
|
||||
|
||||
// if (!this.created) {
|
||||
// this.$emit("input", this.defaultAddr);
|
||||
// this.defaultAddr.area_code = "";
|
||||
// }
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -232,9 +239,9 @@ export default {
|
||||
) {
|
||||
this.defaultAddr.area_code = element.code;
|
||||
this.defaultAddr.area = element.name;
|
||||
if (!this.created) {
|
||||
this.$emit("input", this.defaultAddr);
|
||||
}
|
||||
// if (!this.created) {
|
||||
// this.$emit("input", this.defaultAddr);
|
||||
// }
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user