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

main
zhufu 2 months ago
parent e630e2302f
commit 929ad54b42

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

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

Loading…
Cancel
Save