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