添加调取stationMap的方法

This commit is contained in:
stt
2025-11-07 16:19:15 +08:00
parent 2631f43623
commit 7d86bbb6c2
4 changed files with 56 additions and 10 deletions

View File

@@ -344,6 +344,7 @@ onMounted(() => {
defineExpose({ defineExpose({
setIcon, setIcon,
init
}); });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@@ -1,6 +1,6 @@
<template> <template>
<!-- 项目管理弹框 --> <!-- 项目管理弹框 -->
<el-dialog v-model="dialogVisible" title="项目管理" width="1600px"> <el-dialog v-model="dialogVisible" title="项目管理" width="1600px" @close="handleDialogClose">
<!-- <el-card class="transparent-card"> --> <!-- <el-card class="transparent-card"> -->
<div style="display: flex; justify-content: space-between"> <div style="display: flex; justify-content: space-between">
<div> <div>
@@ -155,13 +155,14 @@
v-model="ruleForm.substionIds" v-model="ruleForm.substionIds"
placeholder="请选择" placeholder="请选择"
multiple multiple
:teleported="false"
> >
<el-option <el-option
v-for="item in dataList" v-for="item in dataList"
:key="item.id" :key="item.id"
:label="item.name" :label="item.name"
:value="item.id" :value="item.id"
:disabled="item.bindFlag==true" :disabled="item.bindFlag == true && !setDisabled?.includes(item.id)"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
@@ -214,6 +215,7 @@ import { useStore } from "vuex";
const emit = defineEmits<{ const emit = defineEmits<{
(e: "project-change", project: { id: string; name: string }): void; (e: "project-change", project: { id: string; name: string }): void;
(e: "station-map-updated"): void;
}>(); }>();
const store = useStore(); const store = useStore();
@@ -236,6 +238,8 @@ const firstForm = ref({
const dataList = ref([]); //变电站 const dataList = ref([]); //变电站
const setDisabled = ref([]);
const params = reactive({ const params = reactive({
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
@@ -278,6 +282,10 @@ const rules = reactive<FormRules<RuleForm>>({
], ],
}); });
const handleDialogClose = () => {
emit('station-map-updated');
};
const init = () => { const init = () => {
stationMap({ stationMap({
deptId: store.state.deptId, deptId: store.state.deptId,
@@ -343,6 +351,8 @@ const onReset = () => {
const onSubmitadd = () => { const onSubmitadd = () => {
innerVisible.value = true; innerVisible.value = true;
dialogTitle.value = "新增项目"; dialogTitle.value = "新增项目";
init();
setDisabled.value = [];
// Object.assign(ruleForm, {}); 不生效 // Object.assign(ruleForm, {}); 不生效
Object.assign(ruleForm, { Object.assign(ruleForm, {
//生效,但是一个个赋值,麻烦 //生效,但是一个个赋值,麻烦
@@ -362,6 +372,8 @@ const querdata = (e: any) => {};
const editd = (row: any) => { const editd = (row: any) => {
innerVisible.value = true; innerVisible.value = true;
dialogTitle.value = "修改项目"; dialogTitle.value = "修改项目";
init();
setDisabled.value = JSON.parse(JSON.stringify(row.substionIds));
// Object.assign(ruleForm, row); // Object.assign(ruleForm, row);
Object.assign(ruleForm, { Object.assign(ruleForm, {
id: row.id, id: row.id,
@@ -382,6 +394,8 @@ const submitForm = async (formEl: FormInstance | undefined) => {
} else { } else {
getEdit(); getEdit();
} }
init();
emit('station-map-updated');
console.log("submit!"); console.log("submit!");
} else { } else {
console.log("error submit!", fields); console.log("error submit!", fields);
@@ -421,6 +435,7 @@ const getEdit = async () => {
const resetForm = () => { const resetForm = () => {
innerVisible.value = false; innerVisible.value = false;
emit('station-map-updated')
}; };
const onTableSizeChange = (size: number) => { const onTableSizeChange = (size: number) => {
@@ -537,7 +552,6 @@ const activeItem = (item: any) => {
const open = () => { const open = () => {
dialogVisible.value = true; dialogVisible.value = true;
init();
}; };
defineExpose({ defineExpose({
open, open,

View File

@@ -5,6 +5,7 @@
width="100%" width="100%"
height="100%" height="100%"
@pointClick="pointClick" @pointClick="pointClick"
ref="bdMapRef"
></bdMap> ></bdMap>
<!-- 添加加载事件监听 --> <!-- 添加加载事件监听 -->
@@ -19,7 +20,12 @@
:key="keyof" :key="keyof"
@load="onIframeLoad" @load="onIframeLoad"
></iframe> ></iframe>
<el-button v-if="!store.state.showMap" class="backButton" @click="backButton" size="small" :icon="Back" <el-button
v-if="!store.state.showMap"
class="backButton"
@click="backButton"
size="small"
:icon="Back"
>返回</el-button >返回</el-button
> >
</div> </div>
@@ -35,6 +41,8 @@ const props = defineProps<{
project: { id: string; name: string } | null; project: { id: string; name: string } | null;
}>(); }>();
const bdMapRef = ref(null)
const iframeSrc = ref(""); const iframeSrc = ref("");
const keyof = ref(0); const keyof = ref(0);
// 监听 props 变化 // 监听 props 变化
@@ -140,6 +148,18 @@ const backButton = () => {
// window.removeEventListener("message", handleMessage); // window.removeEventListener("message", handleMessage);
}; };
// 监听 station-map-updated 事件并转发给 bdMap 组件
const handleStationMapUpdated = () => {
if (bdMapRef.value && typeof bdMapRef.value.init === 'function') {
bdMapRef.value.init()
}
}
// 暴露方法给父组件调用
defineExpose({
handleStationMapUpdated
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.plan { .plan {

View File

@@ -87,13 +87,14 @@
<Management <Management
ref="createRef" ref="createRef"
@project-change="onProjectChange" @project-change="onProjectChange"
@station-map-updated="handleStationMapUpdated"
></Management> ></Management>
</div> </div>
<div class="body-box"> <div class="body-box">
<!-- 第三行数据 --> <!-- 第三行数据 -->
<div class="content-box"> <div class="content-box">
<dv-border-box-10 :color="color[0]" style="position: relative"> <dv-border-box-10 :color="color[0]" style="position: relative">
<Plan :project="currentProject" /> <Plan :project="currentProject" ref="planRef"/>
<!-- flag 值传递给 SecurityDetail 组件 --> <!-- flag 值传递给 SecurityDetail 组件 -->
<!-- showDetail从SecurityDetail 组件传过来 --> <!-- showDetail从SecurityDetail 组件传过来 -->
<SecurityDetail <SecurityDetail
@@ -235,6 +236,8 @@ const onProjectChange = (project: { id: string; name: string }) => {
currentProject.value = project; currentProject.value = project;
}; };
const planRef = ref() // 添加对 Plan 组件的引用
const smsQueriesRef = ref(); // 短信查询组件引用 const smsQueriesRef = ref(); // 短信查询组件引用
const smsConfigRef = ref(); // 短信查询组件引用 const smsConfigRef = ref(); // 短信查询组件引用
const sendRef = ref(); // 短信查询组件引用 const sendRef = ref(); // 短信查询组件引用
@@ -380,6 +383,14 @@ const createRef = ref();
const openDialog = () => { const openDialog = () => {
createRef.value.open(); createRef.value.open();
}; };
// 处理 Management 组件发出的 station-map-updated 事件
const handleStationMapUpdated = () => {
// 通过 Plan 组件转发给 bdMap
if (planRef.value && typeof planRef.value.handleStationMapUpdated === 'function') {
planRef.value.handleStationMapUpdated()
}
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>