|
@@ -13,7 +13,7 @@
|
|
|
<el-option v-for="(item, index) in locationOptions.list" :key="index" :label="item.title"
|
|
<el-option v-for="(item, index) in locationOptions.list" :key="index" :label="item.title"
|
|
|
:value="{ value: item.point, item }">
|
|
:value="{ value: item.point, item }">
|
|
|
<span>{{ item.title }}</span>
|
|
<span>{{ item.title }}</span>
|
|
|
- <span class="sub-title">{{ item.province }}{{ item.city }}{{ item.district }}</span>
|
|
|
|
|
|
|
+ <span class="sub-title">{{ item.province }}{{ item.city }}{{ item.district || '' }}</span>
|
|
|
</el-option>
|
|
</el-option>
|
|
|
</el-select>
|
|
</el-select>
|
|
|
</div>
|
|
</div>
|
|
@@ -130,7 +130,7 @@ import customHeader from "@/components/customHeader.vue";
|
|
|
import IndexMap from "./map/index.js";
|
|
import IndexMap from "./map/index.js";
|
|
|
import { useRoute, useRouter } from "vue-router";
|
|
import { useRoute, useRouter } from "vue-router";
|
|
|
import { mapLocation } from "./map/index.js";
|
|
import { mapLocation } from "./map/index.js";
|
|
|
-import { onMounted, ref, reactive, watch, onActivated, nextTick } from "vue";
|
|
|
|
|
|
|
+import { onMounted, ref, reactive, watch, onActivated, nextTick,onDeactivated } from "vue";
|
|
|
import { useStore } from "vuex";
|
|
import { useStore } from "vuex";
|
|
|
import { convertPointToArray } from "@/utils/index";
|
|
import { convertPointToArray } from "@/utils/index";
|
|
|
import { ElMessage } from "element-plus";
|
|
import { ElMessage } from "element-plus";
|
|
@@ -275,9 +275,10 @@ onMounted(() => {
|
|
|
const polygonArr = ref(null);
|
|
const polygonArr = ref(null);
|
|
|
const paramsType = ref(null);
|
|
const paramsType = ref(null);
|
|
|
onActivated(() => {
|
|
onActivated(() => {
|
|
|
|
|
+ const centerPointVal = sessionStorage.getItem('centerPoint') ? JSON.parse(sessionStorage.getItem('centerPoint')) : null;
|
|
|
paramsType.value = route.query.type;
|
|
paramsType.value = route.query.type;
|
|
|
|
|
|
|
|
- centerPoint.value = store.state.home.miniUserLocationPoint;
|
|
|
|
|
|
|
+ centerPoint.value = centerPointVal || store.state.home.miniUserLocationPoint;
|
|
|
const arr = convertPointToArray(centerPoint.value);
|
|
const arr = convertPointToArray(centerPoint.value);
|
|
|
getLocationName(`${arr[1]},${arr[0]}`);
|
|
getLocationName(`${arr[1]},${arr[0]}`);
|
|
|
// 仅在携带 isReload 标记、且不是编辑/小程序回流场景时,认为是一次全新创建,重置表单和地块,
|
|
// 仅在携带 isReload 标记、且不是编辑/小程序回流场景时,认为是一次全新创建,重置表单和地块,
|
|
@@ -315,6 +316,10 @@ onActivated(() => {
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+onDeactivated(() => {
|
|
|
|
|
+ sessionStorage.setItem('centerPoint', JSON.stringify(centerPoint.value));
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
// 处理地图更新的逻辑
|
|
// 处理地图更新的逻辑
|
|
|
function handleMapUpdate() {
|
|
function handleMapUpdate() {
|
|
|
if (route.query.isReload) {
|
|
if (route.query.isReload) {
|
|
@@ -436,9 +441,9 @@ const handleSearchRes = (v) => {
|
|
|
indexMap.setMapPosition(coordinateArray);
|
|
indexMap.setMapPosition(coordinateArray);
|
|
|
centerPoint.value = `POINT (${coordinateArray[0]} ${coordinateArray[1]})`;
|
|
centerPoint.value = `POINT (${coordinateArray[0]} ${coordinateArray[1]})`;
|
|
|
ruleForm.address = v.item?.title || v.item?.address;
|
|
ruleForm.address = v.item?.title || v.item?.address;
|
|
|
- pointAddress.value = v.item?.province + v.item?.city + v.item?.district;
|
|
|
|
|
|
|
+ pointAddress.value = v.item?.province + v.item?.city + (v.item?.district || '');
|
|
|
// 更新farmCity以便后续更新农场名称
|
|
// 更新farmCity以便后续更新农场名称
|
|
|
- farmCity.value = v.item?.city + v.item?.district || "";
|
|
|
|
|
|
|
+ farmCity.value = v.item?.city + (v.item?.district || "");
|
|
|
// 地址修改后,如果满足条件则自动更新农场名称
|
|
// 地址修改后,如果满足条件则自动更新农场名称
|
|
|
updateFarmNameIfNeeded();
|
|
updateFarmNameIfNeeded();
|
|
|
getSpecieList();
|
|
getSpecieList();
|
|
@@ -691,7 +696,7 @@ function getLocationName(location) {
|
|
|
const add = result.formatted_addresses?.recommend ? result.formatted_addresses.recommend : result.address + "";
|
|
const add = result.formatted_addresses?.recommend ? result.formatted_addresses.recommend : result.address + "";
|
|
|
ruleForm.address = add;
|
|
ruleForm.address = add;
|
|
|
pointAddress.value = result.address;
|
|
pointAddress.value = result.address;
|
|
|
- farmCity.value = result.address_component?.city + result.address_component?.district || "";
|
|
|
|
|
|
|
+ farmCity.value = result.address_component?.city + (result.address_component?.district || "");
|
|
|
// 地址修改后,如果满足条件则自动更新农场名称
|
|
// 地址修改后,如果满足条件则自动更新农场名称
|
|
|
updateFarmNameIfNeeded();
|
|
updateFarmNameIfNeeded();
|
|
|
});
|
|
});
|
|
@@ -915,7 +920,7 @@ function populateEditData() {
|
|
|
if (editData.district) {
|
|
if (editData.district) {
|
|
|
try {
|
|
try {
|
|
|
const districtInfo = JSON.parse(editData.district);
|
|
const districtInfo = JSON.parse(editData.district);
|
|
|
- pointAddress.value = districtInfo.province + districtInfo.city + districtInfo.district;
|
|
|
|
|
|
|
+ pointAddress.value = districtInfo.province + districtInfo.city + (districtInfo?.district || '');
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
|
console.warn("解析地址信息失败:", e);
|
|
console.warn("解析地址信息失败:", e);
|
|
|
}
|
|
}
|