项目首页进入后默认选中第一条数据

main
zhufu 2 months ago
parent e630e2302f
commit 929ad54b42

@ -32,7 +32,7 @@
<script setup lang="ts">
import AddProject from './AddProject/index.vue'
import { ref, defineProps, onMounted, createVNode } from "vue"
import { ref, defineProps, onMounted, createVNode, watch } from "vue"
import { GetWorkspaceList, GetWorkSpaceById, DeleteWorkspace } from '@/api/demo/projecthome'
import { message, Modal } from 'ant-design-vue'
import { ExclamationCircleOutlined } from '@ant-design/icons-vue'
@ -42,17 +42,24 @@ onMounted(() => {
getProjectList()
})
const props = defineProps(['map', 'activeProject', 'airPort'])
const props = defineProps(['map', 'activeProject', 'airPort', 'connect'])
const emits = defineEmits(['update:activeProject'])
const addModal = ref(false)
const modalType = ref('')
const projectList = ref([])
const updateProject = ref({})
const lastSubscriptUrl = ref('')
const getList = ref(false)
const addProject = () => {
modalType.value = 'insert'
addModal.value = true
}
watch(() => [getList.value, props.connect], (value) => {
const check = value.every(item => item === true)
if(check){
selectProject(projectList.value[0])
}
})
const selectProject = (item) => {
if(props.activeProject != item.Id){
props.airPort.latitude = null
@ -74,6 +81,10 @@ const selectProject = (item) => {
const getProjectList = () => {
GetWorkspaceList().then(res => {
projectList.value = res
if(res.length > 0){
emits('update:activeProject',res[0].Id)
getList.value = true
}
})
}
const editProject = (item) => {

@ -5,7 +5,7 @@
</div>
<div ref="leftComponentRef" style="position: absolute;top: 0px;left: 0px;">
<!-- 项目列表 -->
<ProjectList :map="map" v-model:activeProject="activeProject" :airPort="airPort"/>
<ProjectList :map="map" v-model:activeProject="activeProject" :airPort="airPort" :connect="connect"/>
<!-- 基本信息 -->
<Info />
</div>
@ -46,6 +46,7 @@ const DESIGN_HEIGHT = 962
const leftComponentRef = ref<HTMLElement | null>(null)
const rightComponentRef = ref<HTMLElement | null>(null)
const map = ref()
const connect = ref(false)
const clickAirPort = () => {
sessionStorage.setItem('homeToFlightId', activeProject.value);
@ -68,6 +69,7 @@ function updateScale() {
}
}
const connectionCallback = () => {
connect.value = true
getClient().on('message', (topic, msg) => {
if (topic.endsWith("osd")) {
const rs = JSON.parse(msg)

Loading…
Cancel
Save