|
@@ -92,6 +92,7 @@
|
|
prop: "addressTemp",
|
|
prop: "addressTemp",
|
|
labelWidth: 120,
|
|
labelWidth: 120,
|
|
type: 'map',
|
|
type: 'map',
|
|
|
|
+ // component: 'avueMap',
|
|
hide: true,
|
|
hide: true,
|
|
rules: [{
|
|
rules: [{
|
|
required: true,
|
|
required: true,
|
|
@@ -192,13 +193,24 @@
|
|
ids.push(ele.id);
|
|
ids.push(ele.id);
|
|
});
|
|
});
|
|
return ids.join(",");
|
|
return ids.join(",");
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ created() {
|
|
|
|
+ this.option.column[1].change = function (column) {
|
|
|
|
+ if (column.value.length > 0) {
|
|
|
|
+ let value = column.value;
|
|
|
|
+ this.getAddress(value[0], value[1], (result) => {
|
|
|
|
+ column.value[2] = result;
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }.bind(this);
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
rowSave(row, done, loading) {
|
|
rowSave(row, done, loading) {
|
|
row.longitude = row.addressTemp[0];
|
|
row.longitude = row.addressTemp[0];
|
|
row.latitude = row.addressTemp[1];
|
|
row.latitude = row.addressTemp[1];
|
|
- row.address = row.addressTemp[2];
|
|
|
|
|
|
+ row.address = this.address;
|
|
console.log(row)
|
|
console.log(row)
|
|
add(row).then(() => {
|
|
add(row).then(() => {
|
|
this.onLoad(this.page);
|
|
this.onLoad(this.page);
|
|
@@ -215,7 +227,7 @@
|
|
rowUpdate(row, index, done, loading) {
|
|
rowUpdate(row, index, done, loading) {
|
|
row.longitude = row.addressTemp[0];
|
|
row.longitude = row.addressTemp[0];
|
|
row.latitude = row.addressTemp[1];
|
|
row.latitude = row.addressTemp[1];
|
|
- row.address = row.addressTemp[2];
|
|
|
|
|
|
+ row.address = this.address;
|
|
update(row).then(() => {
|
|
update(row).then(() => {
|
|
this.onLoad(this.page);
|
|
this.onLoad(this.page);
|
|
this.$message({
|
|
this.$message({
|
|
@@ -271,6 +283,11 @@
|
|
if (["edit", "view"].includes(type)) {
|
|
if (["edit", "view"].includes(type)) {
|
|
getDetail(this.form.id).then(res => {
|
|
getDetail(this.form.id).then(res => {
|
|
this.form = res.data.data;
|
|
this.form = res.data.data;
|
|
|
|
+ let addressTemp = [];
|
|
|
|
+ addressTemp.push(this.form.longitude)
|
|
|
|
+ addressTemp.push(this.form.latitude)
|
|
|
|
+ addressTemp.push(this.form.address)
|
|
|
|
+ this.form.addressTemp = addressTemp;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
done();
|
|
done();
|
|
@@ -339,6 +356,24 @@
|
|
});
|
|
});
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
+ getAddress (r, p, callback) {
|
|
|
|
+ new window.AMap.service("AMap.Geocoder", () => {
|
|
|
|
+ //回调函数
|
|
|
|
+ let geocoder = new window.AMap.Geocoder({});
|
|
|
|
+ geocoder.getAddress([r, p], (status, result) => {
|
|
|
|
+ if (status === "complete" && result.info === "OK") {
|
|
|
|
+ var address = result.regeocode.formattedAddress;
|
|
|
|
+ this.address = address;
|
|
|
|
+ callback(address);
|
|
|
|
+ } else {
|
|
|
|
+ this.$message({
|
|
|
|
+ type: "error",
|
|
|
|
+ message: "高德地图调用失败!"
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|