|
@@ -152,7 +152,7 @@ let alarmLayer = null;
|
|
|
let staticMapLayers = null;
|
|
let staticMapLayers = null;
|
|
|
let staticMapPointLayers = null;
|
|
let staticMapPointLayers = null;
|
|
|
let distributionLayer = null;
|
|
let distributionLayer = null;
|
|
|
-const areaVal = ref(["3"]);
|
|
|
|
|
|
|
+const areaVal = ref([]);
|
|
|
const mapRef = ref(null);
|
|
const mapRef = ref(null);
|
|
|
const showDetail = ref(false);
|
|
const showDetail = ref(false);
|
|
|
const treeRef = ref(null);
|
|
const treeRef = ref(null);
|
|
@@ -437,14 +437,20 @@ onMounted(async () => {
|
|
|
eventBus.off("chat:showMapLayer", handleMapLayer);
|
|
eventBus.off("chat:showMapLayer", handleMapLayer);
|
|
|
eventBus.on("chat:showMapLayer", handleMapLayer);
|
|
eventBus.on("chat:showMapLayer", handleMapLayer);
|
|
|
|
|
|
|
|
- getRegionCropAreaYield();
|
|
|
|
|
|
|
+ // 注意:getRegionCropAreaYield 会在省级列表加载完成后自动调用(在 lazyLoad 中)
|
|
|
|
|
+ // 如果 areaVal 已经有值,则立即调用
|
|
|
|
|
+ if (areaVal.value && areaVal.value.length > 0) {
|
|
|
|
|
+ getRegionCropAreaYield(areaVal.value[areaVal.value.length - 1]);
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-const getRegionCropAreaYield = async () => {
|
|
|
|
|
|
|
+const getRegionCropAreaYield = async (adminCode) => {
|
|
|
|
|
+ const code = adminCode || (areaVal.value && areaVal.value.length > 0 ? areaVal.value[areaVal.value.length - 1] : '156440000');
|
|
|
|
|
+
|
|
|
const res = await VE_API.warning.fetchRegionCropAreaYield({
|
|
const res = await VE_API.warning.fetchRegionCropAreaYield({
|
|
|
- adminCode: 156440000,
|
|
|
|
|
- year:'',
|
|
|
|
|
- quarter:'',
|
|
|
|
|
|
|
+ adminCode: code,
|
|
|
|
|
+ year: '',
|
|
|
|
|
+ quarter: '',
|
|
|
});
|
|
});
|
|
|
if (res.code === 0 && res.data) {
|
|
if (res.code === 0 && res.data) {
|
|
|
// 更新区域作物数据
|
|
// 更新区域作物数据
|
|
@@ -684,11 +690,17 @@ const props1 = {
|
|
|
VE_API.species.provinceList().then((res) => {
|
|
VE_API.species.provinceList().then((res) => {
|
|
|
if (res.code === 0 && res.data) {
|
|
if (res.code === 0 && res.data) {
|
|
|
const nodes = res.data.map((item) => ({
|
|
const nodes = res.data.map((item) => ({
|
|
|
- value: item.provCode || item.code || item.id,
|
|
|
|
|
|
|
+ value: item.provCode || item.code, // 使用code,不使用id
|
|
|
label: item.provName || item.name,
|
|
label: item.provName || item.name,
|
|
|
leaf: false, // 省级不是叶子节点
|
|
leaf: false, // 省级不是叶子节点
|
|
|
}));
|
|
}));
|
|
|
- areaVal.value = nodes[0].value;
|
|
|
|
|
|
|
+ if (nodes.length > 0) {
|
|
|
|
|
+ // 设置第一个省的code
|
|
|
|
|
+ const firstProvinceCode = nodes[0].value;
|
|
|
|
|
+ areaVal.value = [firstProvinceCode];
|
|
|
|
|
+ // 使用第一个省的code初始化数据
|
|
|
|
|
+ getRegionCropAreaYield(firstProvinceCode);
|
|
|
|
|
+ }
|
|
|
resolve(nodes);
|
|
resolve(nodes);
|
|
|
} else {
|
|
} else {
|
|
|
resolve([]);
|
|
resolve([]);
|
|
@@ -702,7 +714,7 @@ const props1 = {
|
|
|
VE_API.species.cityList({ provCode }).then((res) => {
|
|
VE_API.species.cityList({ provCode }).then((res) => {
|
|
|
if (res.code === 0 && res.data) {
|
|
if (res.code === 0 && res.data) {
|
|
|
const nodes = res.data.map((item) => ({
|
|
const nodes = res.data.map((item) => ({
|
|
|
- value: item.cityCode || item.code || item.id,
|
|
|
|
|
|
|
+ value: item.cityCode || item.code,
|
|
|
label: item.cityName || item.name,
|
|
label: item.cityName || item.name,
|
|
|
leaf: false, // 市级不是叶子节点
|
|
leaf: false, // 市级不是叶子节点
|
|
|
}));
|
|
}));
|
|
@@ -719,7 +731,7 @@ const props1 = {
|
|
|
VE_API.species.districtList({ cityCode }).then((res) => {
|
|
VE_API.species.districtList({ cityCode }).then((res) => {
|
|
|
if (res.code === 0 && res.data) {
|
|
if (res.code === 0 && res.data) {
|
|
|
const nodes = res.data.map((item) => ({
|
|
const nodes = res.data.map((item) => ({
|
|
|
- value: item.districtCode || item.code || item.id,
|
|
|
|
|
|
|
+ value: item.districtCode || item.code,
|
|
|
label: item.districtName || item.name,
|
|
label: item.districtName || item.name,
|
|
|
leaf: true, // 区级是叶子节点
|
|
leaf: true, // 区级是叶子节点
|
|
|
}));
|
|
}));
|
|
@@ -738,10 +750,12 @@ const props1 = {
|
|
|
|
|
|
|
|
const toggleArea = (v) => {
|
|
const toggleArea = (v) => {
|
|
|
activeBoxName.value = null;
|
|
activeBoxName.value = null;
|
|
|
- // const val = v[v.length - 1];
|
|
|
|
|
- // if (val === "3" || val === "3186") {
|
|
|
|
|
- // eventBus.emit("warningHome:toggleArea", val);
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ // 获取选中的最后一个值(即最终的code)
|
|
|
|
|
+ const selectedCode = v && v.length > 0 ? v[v.length - 1] : null;
|
|
|
|
|
+ if (selectedCode) {
|
|
|
|
|
+ // 调用接口更新区域作物数据
|
|
|
|
|
+ getRegionCropAreaYield(selectedCode);
|
|
|
|
|
+ }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const activeBoxName = ref(null);
|
|
const activeBoxName = ref(null);
|