123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- <template>
- <div>
- <n-drawer
- v-model:show="active"
- :width="240"
- placement="right"
- :trap-focus="false"
- :block-scroll="false"
- :show-mask="false"
- :mask-closable="false"
- to="#drawer-target"
- style="--n-body-padding: 0px"
- >
- <n-drawer-content title="线路指引">
- <div class="drawerContent m-5"></div>
- <n-flex justify="center">
- <n-button v-if="!isPanoEditing" type="primary" @click="handleAdd"
- >+ 添加
- </n-button>
- </n-flex>
- <n-list
- hoverable
- clickable
- style="--n-color-modal: none; margin-top: 20px"
- :show-divider="false"
- v-if="!isPanoEditing"
- >
- <n-list-item v-for="(element, index) in dataList" :key="index" style="">
- <n-flex justify="space-between" align="center" :size="0">
- <n-flex align="center">
- <n-icon size="20">
- <WalkSharp />
- </n-icon>
- <template v-if="isShowEditing(index)">
- <n-flex style="flex: 1" align="center">
- <n-input-group>
- <n-input
- v-model:value="element.title"
- maxlength="15"
- style="max-width: 130px"
- />
- <n-button type="primary" @click="currentEditing = NaN">
- 退出
- </n-button>
- </n-input-group>
- </n-flex>
- </template>
- <div v-else @click="handleItem(index)" class="truncate inline-block" style="width: 140px">
- {{ element.title === '新增路线' ? element.title + index : element.title }}
- </div>
- </n-flex>
- <n-dropdown
- @select="(key) => handleSelect(key, index)"
- trigger="hover"
- :options="fullOptions"
- >
- <n-icon :size="20" v-show="!isShowEditing(index)">
- <svg
- xmlns="http://www.w3.org/2000/svg"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- viewBox="0 0 32 32"
- >
- <circle cx="8" cy="16" r="2" fill="currentColor"></circle>
- <circle cx="16" cy="16" r="2" fill="currentColor"></circle>
- <circle cx="24" cy="16" r="2" fill="currentColor"></circle>
- </svg>
- </n-icon>
- </n-dropdown>
- </n-flex>
- </n-list-item>
-
- </n-list>
- <template v-else>
- <n-flex justify="center" align="center" vertical style="flex: 1">
- <n-flex
- justify="start"
- align="start"
- style="min-height: 400px; width: 100%"
- vertical
- >
- <template v-if="dataList[currentPanoEditing].panos.length > 0">
- <n-list
- hoverable
- clickable
- style="--n-color-modal: none; width: 100%"
- :show-divider="false"
- >
- <Sortable
- :list="dataList[currentPanoEditing].panos"
- itemKey="id"
- options="options"
- @end="logEvent"
- >
- <template #item="{ element, index }">
- <!-- v-for="(pano, index) in dataList[currentPanoEditing].panos" -->
- <n-list-item
-
- :key="index"
- >
- <n-flex justify="space-between">
- {{ element.index }}
- <n-icon
- :size="20"
- @click="handlePanoDel(index)"
- :color="'red'"
- >
- <TrashOutline />
- </n-icon>
- </n-flex>
- </n-list-item>
- </template>
- </Sortable>
- </n-list>
- </template>
- <n-flex v-else justify="center" style="width: 100%">
- <span> 暂没数据,请选择线路</span>
- </n-flex>
- </n-flex>
- <n-button
- type="primary"
- @click="handleItemSubmit"
- style="width: 130px"
- >确定并返回列表
- </n-button>
- </n-flex>
- </template>
- </n-drawer-content>
- </n-drawer>
- </div>
- </template>
- <script setup lang="ts">
- import { computed, ref, watch, watchEffect } from 'vue'
- import { sdk, clearScreen, sdk_mounted } from '@/sdk'
- import { onMounted, onUnmounted } from 'vue'
- import { Sortable } from 'sortablejs-vue3'
- import {
- // NRadio,
- // NPopover,
- useDialog,
- useMessage,
- NDropdown,
- NList,
- NListItem,
- NInputGroup
- } from 'naive-ui'
- import { WalkSharp, TrashOutline, EllipsisHorizontal } from '@vicons/ionicons5'
- import { useMainStore } from '@/store'
- const panos = ref([])
- const newDataList = ref<object[]>([])
- const main = useMainStore()
- const currentEditing = ref(NaN)
- const currentPanoEditing = ref()
- const isPanoEditing = ref(false)
- const naviData = computed(() => main.getEditorData.navigation)
- const dataList = ref<
- {
- title: string
- panos: any[]
- }[]
- >([])
- const logEvent = (evt) => {
- const changeData = newDataList.value.splice(evt.oldIndex || 0, 1)
- newDataList.value.splice(evt.newIndex || 0, 0, changeData[0])
- const origin = dataList.value[currentPanoEditing.value]
- origin.panos = newDataList.value
- }
- const handleAdd = () => {
- dataList.value.unshift({
- title: '新增路线',
- panos: []
- })
- panos.value = []
- currentPanoEditing.value = 0
- handleSelect("1",0)
- main.syncNavigation(dataList.value)
- }
- watchEffect(() => {
- if (naviData.value) {
- dataList.value = naviData.value
- }
- })
- onMounted(() => {
-
- })
- onUnmounted(() => {
- sdk_mounted((sdk) => {
- sdk.PanoCheckManager.leave()
- clearScreen(false)
- })
- })
- defineProps<{ msg: string }>()
- const dialog = useDialog()
- const message = useMessage()
- const active = ref(true)
- const fullOptions = ref([
- {
- label: '编辑',
- key: '1'
- },
- {
- label: '删除',
- key: '2'
- }
- ])
- const handleSelect = (key: string, index: number) => {
- // console.log('handleSelect', key)
- switch (key) {
- case '1':
- handleListEdit(index)
- break
- case '2':
- handleListDel(index)
- break
- }
- }
- const handleListEdit = (index: number) => {
- currentPanoEditing.value = index
- isPanoEditing.value = true
- panos.value = dataList.value[index].panos || []
- sdk_mounted((sdk) => {
- sdk.Scene.whenLoaded(() => {
- sdk.PanoCheckManager.enter(dataList.value[index].panos)
- sdk.PanoCheckManager.echo((list: any) => {
- panos.value = list
- })
- clearScreen(true)
- })
- })
- }
- const handleListDel = (index: number) => {
- dataList.value.splice(index, 1)
- }
- const isShowEditing = computed(() => (i: number) => currentEditing.value === i)
- const handleItem = (index: number) => {
- currentEditing.value = index
- }
- const handleItemSubmit = () => {
- isPanoEditing.value = false
- main.syncNavigation(dataList.value)
- sdk_mounted((sdk) => {
- // 重置状态
- sdk.PanoCheckManager.leave()
- clearScreen(false)
- })
- }
- const handlePanoDel = (index: number) => {
- const origin = dataList.value[currentPanoEditing.value].panos
- const panoId = origin[index].id
- origin && origin.splice(index, 1)
- sdk_mounted((sdk) => {
- sdk.Scene.whenLoaded(() => {
- sdk.PanoCheckManager.setPanoChecked(panoId,false)
- })
- })
-
- }
- watch(
- [panos, isPanoEditing],
- () => {
- if (isPanoEditing.value && typeof currentPanoEditing.value === 'number') {
- const origin = dataList.value[currentPanoEditing.value]
- if (origin && panos.value.length > 0) {
- origin.panos = panos.value
- }
- newDataList.value = JSON.parse(JSON.stringify(origin.panos))
- }
- },
- {
- deep: true,
- immediate: true
- }
- )
- </script>
- <style lang="sass" scoped>
- a
- color: #42b983
- label
- margin: 0 0.5em
- font-weight: bold
- code
- background-color: #eee
- padding: 2px 4px
- border-radius: 4px
- color: #304455
- </style>
|