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