This commit is contained in:
姚宇浩 2024-08-20 15:54:19 +08:00
parent 901611527e
commit e34071d948
1 changed files with 68 additions and 30 deletions

View File

@ -154,9 +154,9 @@
</div> </div>
</div> </div>
</div> </div>
<div class="btns"> <div class="btns" v-if="showEdit">
<div class="btnopen" @click="openEdit">编辑</div> <div class="btnopen" @click="openEdit">编辑</div>
<div class="btnsave">保存</div> <div class="btnsave" @click="saveEdit">保存</div>
<div class="btnclose" @click="closeEdit">取消</div> <div class="btnclose" @click="closeEdit">取消</div>
</div> </div>
@ -230,7 +230,7 @@ import http from "@/utils/request.js";
import mapTown from "@/assets/json/ly.json"; import mapTown from "@/assets/json/ly.json";
import { VideoCamera } from "@element-plus/icons-vue"; import { VideoCamera } from "@element-plus/icons-vue";
// import xkz from "@/assets/json/xkz.json"; // import xkz from "@/assets/json/xkz.json";
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";
import j2 from "@/assets/images/map/j2.png"; import j2 from "@/assets/images/map/j2.png";
@ -281,7 +281,11 @@ const cs_un_choose_arr = ref([]); //单点社区其他区块(灰色)
const cs_dd_arr = ref([]); // const cs_dd_arr = ref([]); //
// //
const csqk = ref({}); const csqk = ref({});
// var cssj var cssj;
//id
const changeCsqkId = ref("");
//
const showEdit = ref(false);
// //
const title_choose = ref(""); const title_choose = ref("");
const title_jd = ref(""); const title_jd = ref("");
@ -804,8 +808,8 @@ const initMap = () => {
// //
addJd(); addJd();
}; };
const getCssj = () => { const getCssj = async () => {
http await http
.get("/api/ggfwyth/regionalDivision/getCsRegionalDivision") .get("/api/ggfwyth/regionalDivision/getCsRegionalDivision")
.then((res) => { .then((res) => {
if (res.code == 200) { if (res.code == 200) {
@ -813,9 +817,8 @@ const getCssj = () => {
} }
}); });
}; };
//
var arrJWD = [[[]]]; var arrJWD = [[[]]];
var arr1;
//bd09bd09 //bd09bd09
const bd09 = (x, y) => { const bd09 = (x, y) => {
var ggPoint = new BMapGL.Point(x, y); var ggPoint = new BMapGL.Point(x, y);
@ -823,7 +826,7 @@ const bd09 = (x, y) => {
pointArr.push(ggPoint); pointArr.push(ggPoint);
var convertor = new BMapGL.Convertor(); var convertor = new BMapGL.Convertor();
convertor.translate(pointArr, COORDINATES_BD09_MC, COORDINATES_BD09, (e) => { convertor.translate(pointArr, COORDINATES_BD09_MC, COORDINATES_BD09, (e) => {
arr1 = []; let arr1 = [];
arr1.push(e.points[0].lng); arr1.push(e.points[0].lng);
arr1.push(e.points[0].lat); arr1.push(e.points[0].lat);
console.log("arr1", arr1); console.log("arr1", arr1);
@ -832,28 +835,66 @@ const bd09 = (x, y) => {
}; };
// //
const openEdit = () => { const openEdit = () => {
arrJWD = [[[]]];
cs_choose_arr.value[0].enableEditing(); cs_choose_arr.value[0].enableEditing();
console.log(cs_choose_arr.value[0]); console.log(cs_choose_arr.value[0]);
}; };
// //
const closeEdit = async () => { const saveEdit = async () => {
cs_choose_arr.value[0].disableEditing(); cs_choose_arr.value[0].disableEditing();
console.log(cs_choose_arr.value[0]); console.log(cs_choose_arr.value[0]);
for (const item of cs_choose_arr.value[0].points) { for (const item of cs_choose_arr.value[0].points) {
if (item?.latLng) { if (item?.latLng) {
arr1 = []; let arr1 = [];
arr1.push(item?.latLng.lng); arr1.push(item?.latLng.lng);
arr1.push(item?.latLng.lat); arr1.push(item?.latLng.lat);
arrJWD[0][0].push(arr1); arrJWD[0][0].push(arr1);
} else { } else {
bd09(item.lng, item.lat); bd09(item.lng, item.lat);
//0.1convertor.translate //0.1convertor.translate
await new Promise(resolve => setTimeout(resolve, 100)); await new Promise((resolve) => setTimeout(resolve, 100));
} }
} }
console.log("arrJWD", arrJWD); console.log("arrJWD", arrJWD);
saveDK();
}; };
//
const closeEdit = async () => {
cs_choose_arr.value[0].disableEditing();
cs_choose_arr.value.forEach((item, index) => {
map.removeOverlay(cs_choose_arr.value[index]);
});
addCsChoose();
showEdit.value = false;
};
//
const saveDK = async () => {
await http
.post(
`/api/ggfwyth/regionalDivision/addCsManagerRegionalDivision?id=${
changeCsqkId.value
}&data=${JSON.stringify(arrJWD)}`
)
.then((res) => {
if (res.code == 200) {
ElMessage.success("编辑成功");
}
});
await getCssj();
await loadCs(cfJd.value);
cs_choose_arr.value.forEach((item, index) => {
map.removeOverlay(cs_choose_arr.value[index]);
});
chooseCsList.value.length = 0;
xkzDk.forEach((itemm, indexx) => {
if (itemm.name == cfCs.value) {
chooseCsList.value.push(itemm);
addCsChoose();
}
});
};
// //
const csh = () => { const csh = () => {
clear(); clear();
@ -2526,7 +2567,7 @@ const createCustomOverlayJd2 = (polygon, indexx) => {
//------------------------------ //------------------------------
//--------------------- //---------------------
// //
const loadCs = (name) => { const loadCs = async (name) => {
xkzCenter.length = 0; xkzCenter.length = 0;
xkzDk.length = 0; xkzDk.length = 0;
cssj.forEach((item, index) => { cssj.forEach((item, index) => {
@ -2539,20 +2580,24 @@ const loadCs = (name) => {
for (let w in v.geometry.coordinates) { for (let w in v.geometry.coordinates) {
if (v.geometry.coordinates[w][0].length < 60) continue; if (v.geometry.coordinates[w][0].length < 60) continue;
xkzDk.push({ xkzDk.push({
id: v.id,
name: v.properties.name, name: v.properties.name,
point: v.geometry.coordinates[w], point: v.geometry.coordinates[w],
}); });
} }
xkzCenter.push({ xkzCenter.push({
id: v.id,
name: v.properties.name, name: v.properties.name,
center: v.properties.center, center: v.properties.center,
}); });
} else { } else {
xkzDk.push({ xkzDk.push({
id: v.id,
name: v.properties.name, name: v.properties.name,
point: v.geometry.coordinates[0], point: v.geometry.coordinates[0],
}); });
xkzCenter.push({ xkzCenter.push({
id: v.id,
name: v.properties.name, name: v.properties.name,
center: v.properties.center, center: v.properties.center,
}); });
@ -2654,18 +2699,6 @@ const addCsChoose = () => {
zIndex: 99, zIndex: 99,
}); });
map.addOverlay(cs_choose_arr.value[index]); map.addOverlay(cs_choose_arr.value[index]);
cs_choose_arr.value[index].addEventListener("click", (e) => {
console.log(4444444444, e);
// e.overlay
if (e.overlay && e.overlay.type === "Polygon") {
var vertices = e.overlay.getPath(); //
var coordinates = vertices.map(function (point) {
return { lng: point.lng, lat: point.lat };
});
console.log(coordinates); //
}
});
} }
}); });
}; };
@ -2941,6 +2974,11 @@ const DGcreateCs = (polygon, indexx) => {
}, },
}); });
map.addOverlay(cs_dd_arr.value[indexx]); map.addOverlay(cs_dd_arr.value[indexx]);
cs_dd_arr.value[indexx].addEventListener("click", () => {
console.log(polygon.id);
changeCsqkId.value = polygon.id;
showEdit.value = !showEdit.value;
});
}; };
//(+) //(+)
const DGcreateCs2 = (polygon, indexx) => { const DGcreateCs2 = (polygon, indexx) => {
@ -3061,7 +3099,7 @@ onMounted(async () => {
getData(); getData();
BMAP(); BMAP();
getFwq(); getFwq();
// getCssj(); getCssj();
await getDataBq(); await getDataBq();
loadingss.value = false; loadingss.value = false;
}); });
@ -3633,8 +3671,8 @@ onMounted(async () => {
z-index: 999; z-index: 999;
position: absolute; position: absolute;
color: #ffffff; color: #ffffff;
top: 120px; top: 15%;
left: 600px; right: 30%;
display: flex; display: flex;
cursor: pointer; cursor: pointer;
.btnopen { .btnopen {