修改人口为0时的错位

This commit is contained in:
姚宇浩 2024-08-06 14:35:37 +08:00
parent 8ef61ca63d
commit 06c8c955b1
1 changed files with 159 additions and 69 deletions

View File

@ -16,7 +16,7 @@
<div
class="content_item2"
v-for="(item, index) in personTotal.slice(0, 1)"
:class="{ choose: item.id == choose.person }"
:class="{ choose: item.age == choose.person }"
@click="buten(item)"
:key="index"
>
@ -76,7 +76,7 @@
<div
class="content_item"
v-for="(item, index) in personTotal.slice(1)"
:class="{ choose: item.id == choose.person }"
:class="{ choose: item.age == choose.person }"
@click="buten(item)"
:key="index"
>
@ -187,7 +187,6 @@ import {
defineProps,
watch,
nextTick,
onActivated,
} from "vue";
import { ElMessage } from "element-plus";
import tools from "@/utils/tools";
@ -195,7 +194,6 @@ import initializeMap from "@/utils/mapInitializer.js";
import http from "@/utils/request.js";
import mapTown from "@/assets/json/ly.json";
// import xkz from "@/assets/json/xkz.json";
import personDetail from "./person/index.vue";
import cssj from "@/assets/json/cssj.json";
import j0 from "@/assets/images/map/j0.png";
import j1 from "@/assets/images/map/j1.png";
@ -224,6 +222,7 @@ import b6 from "@/assets/images/map/b6.png";
import xcbg from "@/assets/images/map/xcbg.png";
import AED from "@/assets/images/map/AED.png";
import Dialog from "./dialog/dialogMapDp.vue";
import personDetail from "./person/index.vue";
//---------------
//
const openD = ref(true);
@ -1105,7 +1104,7 @@ const markera = (e) => {
};
//
const buten = async (item) => {
getData(item.id, item.age);
getData(item.age);
getDatas(cfJd.value, item.age);
};
//
@ -1113,7 +1112,8 @@ const buten2 = async (item) => {
getDataBqs(cfJd.value, cfCs.value, item.id);
};
//
const getData = async (i, e) => {
const getData = async (e) => {
let e1=e;
if (e == "9999") {
e = "";
}
@ -1125,7 +1125,7 @@ const getData = async (i, e) => {
{
id: "9999",
ages: "总人口",
age: "",
age: "9999",
value: "res.data.total",
},
{
@ -1133,7 +1133,7 @@ const getData = async (i, e) => {
name: "近一年死亡",
value: "5650",
ages: "近一年死亡",
age: "1000",
age: "6666",
percent: "",
},
];
@ -1195,8 +1195,8 @@ const getData = async (i, e) => {
} catch (error) {
console.error("Error fetching data:", error);
}
if (i) {
changeRs(i);
if (e1) {
changeRs(e1);
}
};
const getDatas = async (e, i) => {
@ -1211,33 +1211,64 @@ const getDatas = async (e, i) => {
} else if (cfJd.value !== "") {
personTotal.value = [
{
id: "9999",
// id: "9999",
ages: "总人口",
age: "",
age: "9999",
value: "res.data.total",
},
{
id: "6666",
// id: "6666",
name: "近一年死亡",
value: "5650",
ages: "近一年死亡",
age: "1000",
age: "6666",
percent: "",
},
];
let before_age = "";
personTotal.value[0].rksl = res.data.total;
personTotal.value[0].ages = "总人口";
personTotal.value[1].rksl = res.data.swrs;
personTotal.value[1].ages = "近一年死亡";
personTotal.value[1].percent = res.data.swrsPercent;
res.data.age.forEach((item, index) => {
if (index == 0) {
personTotal.value.push({
id: index + 1,
rksl: item.rksl,
age: item.age + "",
ages: item.age + "岁",
percent: item.percent,
});
before_age = item.age;
console.log("执行111", before_age);
} else {
if (item.age - before_age == 1) {
personTotal.value.push({
rksl: item.rksl,
age: item.age + "",
ages: item.age + "岁",
percent: item.percent,
});
before_age = item.age;
} else {
for (let i = 0; i < item.age - before_age - 1; i++) {
++before_age;
personTotal.value.push({
rksl: 0,
age: before_age + "",
ages: before_age + "岁",
percent: 0.0,
});
}
personTotal.value.push({
rksl: item.rksl,
age: item.age + "",
ages: item.age + "岁",
percent: item.percent,
});
before_age = item.age;
}
}
});
}
if (cfJd.value != "") {
@ -1346,17 +1377,18 @@ const getDatas2 = async (e, i, cs) => {
if (res.code == 200) {
personTotal.value = [
{
id: "9999",
// id: "9999",
name: "总人口",
ages: "总人口",
age: "",
age: "9999",
value: "res.data.total",
},
{
id: "6666",
// id: "6666",
name: "近一年死亡",
value: "5650",
ages: "近一年死亡",
age: "1000",
age: "6666",
},
];
personTotal.value[0].rksl = res.data.total;
@ -1364,14 +1396,54 @@ const getDatas2 = async (e, i, cs) => {
personTotal.value[1].rksl = res.data.swrs;
personTotal.value[1].ages = "近一年死亡";
personTotal.value[1].percent = res.data.swrsPercent;
// res.data.age.forEach((item, index) => {
// personTotal.value.push({
// id: index + 1,
// rksl: item.rksl,
// age: item.age + "",
// ages: item.age + "",
// percent: item.percent,
// });
// });
let before_age = "";
res.data.age.forEach((item, index) => {
if (index == 0) {
personTotal.value.push({
id: index + 1,
rksl: item.rksl,
age: item.age + "",
ages: item.age + "岁",
percent: item.percent,
});
before_age = item.age;
console.log("执行111", before_age);
} else {
if (item.age - before_age == 1) {
personTotal.value.push({
rksl: item.rksl,
age: item.age + "",
ages: item.age + "岁",
percent: item.percent,
});
before_age = item.age;
} else {
for (let i = 0; i < item.age - before_age - 1; i++) {
++before_age;
personTotal.value.push({
rksl: 0,
age: before_age + "",
ages: before_age + "岁",
percent: 0.0,
});
}
personTotal.value.push({
rksl: item.rksl,
age: item.age + "",
ages: item.age + "岁",
percent: item.percent,
});
before_age = item.age;
}
}
});
xkzCenter.map((item) => {
item.swrs = 0;
@ -1722,11 +1794,12 @@ const to_jd = (item_name) => {
if (choose.value.person == "9999") {
getDatas(cfJd.value, "");
} else {
if (choose.value.person == 1) {
getDatas(cfJd.value, "0"); //0
} else {
getDatas(cfJd.value, choose.value.person - 1);
}
// if (choose.value.person == 1) {
// getDatas(cfJd.value, "0"); //0
// } else {
// getDatas(cfJd.value, choose.value.person);
// }
getDatas(cfJd.value, choose.value.person);
}
}
// if (title_jd.value == item.name) {
@ -1746,18 +1819,29 @@ const to_jd = (item_name) => {
//
const open_detail = () => {
let age = "";
// if (choose.value.person == "9999") {
// age = "";
// person_detail(age);
// dialogShow.value = true;
// } else if (choose.value.person == "6666") {
// age = "";
// } else if (choose.value.person == 1) {
// age = "0";
// person_detail(age);
// dialogShow.value = true;
// } else {
// age = choose.value.person - 1;
// person_detail(age);
// dialogShow.value = true;
// }
if (choose.value.person == "9999") {
age = "";
person_detail(age);
dialogShow.value = true;
} else if (choose.value.person == "6666") {
age = "";
} else if (choose.value.person == 1) {
age = "0";
person_detail(age);
dialogShow.value = true;
} else {
age = choose.value.person - 1;
age = choose.value.person;
person_detail(age);
dialogShow.value = true;
}
@ -1765,21 +1849,26 @@ const open_detail = () => {
const close = () => {
dialogShow.value = false;
pagination.total = 100;
pagination.currentPage = 1;
};
//
const handlePagination = (current) => {
pagination.currentPage = current;
let age = "";
// if (choose.value.person == "9999") {
// age = "";
// } else if (choose.value.person == "6666") {
// age = "";
// } else if (choose.value.person == 1) {
// age = "0";
// } else {
// age = choose.value.person - 1;
// }
if (choose.value.person == "9999") {
age = "";
} else if (choose.value.person == "6666") {
age = "";
} else if (choose.value.person == 1) {
age = "0";
} else {
age = choose.value.person - 1;
age = choose.value.person;
}
person_detail(age);
};
@ -1796,7 +1885,7 @@ const closeDetail = () => {
openD.value = true;
window.removeEventListener('resize', reset_font2);
};
//
//
const person_detail = (age) => {
http
.get(
@ -2140,11 +2229,13 @@ const addPolygonCounty = () => {
if (choose.value.person == "9999") {
getDatas(cfJd.value, "");
} else {
if (choose.value.person == 1) {
getDatas(cfJd.value, "0"); //0
} else {
getDatas(cfJd.value, choose.value.person - 1);
}
// if (choose.value.person == 1) {
// getDatas(cfJd.value, "0"); //0
// } else {
// getDatas(cfJd.value, choose.value.person - 1);
// }
getDatas(cfJd.value, choose.value.person);
}
}
if (title_jd.value == item.name) {
@ -2415,11 +2506,12 @@ const addPolygonCountyCs = () => {
// getDataBqs(cfJd.value, cfCs.value);
}
//
if (choose.value.person == 1) {
getDatas2(cfJd.value, "0", cfCs.value); //0
} else {
getDatas2(cfJd.value, choose.value.person - 1, cfCs.value);
}
// if (choose.value.person == 1) {
// getDatas2(cfJd.value, "0", cfCs.value); //0
// } else {
// getDatas2(cfJd.value, choose.value.person - 1, cfCs.value);
// }
getDatas2(cfJd.value, choose.value.person, cfCs.value);
// getDatas2(cfJd.value, choose.value.person, cfCs.value);
addCsChoose();
addCsUnChoose();
@ -2513,11 +2605,12 @@ const addCsUnChoose = () => {
// });
// getDataBqs(cfJd.value, cfCs.value);
getDataBq(cfJd.value, cfCs.value);
if (choose.value.person == 1) {
getDatas2(cfJd.value, "0", cfCs.value); //0
} else {
getDatas2(cfJd.value, choose.value.person - 1, cfCs.value);
}
// if (choose.value.person == 1) {
// getDatas2(cfJd.value, "0", cfCs.value); //0
// } else {
// getDatas2(cfJd.value, choose.value.person - 1, cfCs.value);
// }
getDatas2(cfJd.value, choose.value.person, cfCs.value);
// getDatas2(cfJd.value, choose.value.person, cfCs.value);
// if (
// choose.value.person == "cjr" ||
@ -2888,8 +2981,6 @@ const reset_font = () => {
}
};
const reset_font2 = () => {
console.log(111111);
let width = document.documentElement.clientWidth || document.body.clientWidth;
let height =
document.documentElement.clientHeight || document.body.clientHeight;
@ -2899,13 +2990,12 @@ const reset_font2 = () => {
"scale(" + width / 1920 + "," + height / 1080 + ")";
};
onMounted(() => {
// tools.data.set("token", "6b0e380b4a8f46baae4923f83faf670d");
tools.data.set("token", "6b0e380b4a8f46baae4923f83faf670d");
reset_font();
initMap();
getData();
getDataBq();
BMAP();
});
</script>