123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624 |
- <template>
- <AppHeader v-show="!fscChecked" :project="project" :show-adjust="showAdjust" @update="onPointsUpdate" />
- <article>
- <main>
- <div class="split" v-if="source">
- <iframe ref="sourceFrame" :src="sourceURL" frameborder="0" @load="onLoadSource"></iframe>
- <div class="tools" v-show="!showAdjust && !fscChecked && (dbsChecked || (!target && !bimChecked))">
- <div class="item-date">
- <calendar name="source" :value="sourceDate" :highlighted="sourceDays" @selected="onSelected" @pick="onPickDate" @prev="onPrevDate" @next="onNextDate"></calendar>
- </div>
- <div class="item-mode" v-if="source.type == 2">
- <div class="iconfont icon-show_roaming" :class="{ active: mode == 0 }" @click="onModeChange(0)"></div>
- <div class="iconfont icon-show_plane" :class="{ active: mode == 1 }" @click="onModeChange(1)"></div>
- </div>
- </div>
- <div class="points" v-if="showAdjust">
- <div :class="{active:points.p1}">
- <i class="iconfont" :class="[points.p1?'icon-positioning01':'icon-positioning02']"></i>
- <span>P1</span>
- </div>
- <div :class="{active:points.p2}">
- <i class="iconfont" :class="[points.p2?'icon-positioning01':'icon-positioning02']"></i>
- <span>P2</span>
- </div>
- </div>
- </div>
- <div class="split" v-if="target">
- <iframe ref="targetFrame" :src="targetURL" frameborder="0" @load="onLoadTarget"></iframe>
- <div class="tools" v-show="!fscChecked && !bimChecked">
- <div class="item-date target">
- <calendar name="target" :value="targetDate" :highlighted="targetDays" @selected="onSelected" @pick="onPickDate" @prev="onPrevDate" @next="onNextDate"></calendar>
- </div>
- </div>
- <div class="points" v-if="showAdjust">
- <div :class="{active:points.p1}">
- <i class="iconfont" :class="[points.p1?'icon-positioning01':'icon-positioning02']"></i>
- <span>P1</span>
- </div>
- <div :class="{active:points.p2}">
- <i class="iconfont" :class="[points.p2?'icon-positioning01':'icon-positioning02']"></i>
- <span>P2</span>
- </div>
- </div>
- </div>
- <div class="model" v-show="!showAdjust">
- <div class="bim" :class="{ active: bimChecked }" v-show="!fscChecked">
- <div @click="onBimChecked">
- <i class="iconfont icon-BIM"></i>
- <span>BIM</span>
- </div>
- </div>
- <div class="dbs" :class="{ active: dbsChecked }" @click="onDbsChecked" v-show="!fscChecked">
- <i class="iconfont icon-split_screen"></i>
- <span>分屏</span>
- </div>
- <div class="fsc" :class="{ active: fscChecked }" @click="onFscChecked">
- <i class="iconfont" :class="[fscChecked ? 'icon-full_screen_selected' : 'icon-full_screen_normal']"></i>
- <span>全屏</span>
- </div>
- </div>
- </main>
- </article>
- </template>
- <script setup>
- import { ref, onMounted, computed, nextTick } from 'vue'
- import { http } from '@/utils/request'
- import browser from '@/utils/browser'
- import AppHeader from '@/components/header'
- import Calendar from '@/components/calendar'
- import sync, { loadSourceScene, loadTargetScene } from '@/utils/sync'
- // 是否校准模式
- const showSplit = ref(browser.urlHasValue('split'))
- const showAdjust = ref(browser.urlHasValue('adjust'))
- const bimChecked = ref(null)
- const dbsChecked = ref(null)
- const fscChecked = ref(null)
- const datepickName = ref(null)
- const sourceFrame = ref(null)
- const targetFrame = ref(null)
- const mode = ref(0)
- const source = ref(null)
- const target = ref(null)
- const project = ref(null)
- const points = ref({p1:false,p2:false})
- const scenes = computed(() => {
- if (!project.value) {
- return []
- }
- return project.value.sceneList.map(item => {
- return {
- num: item.num,
- type: item.type,
- createTime: item.createTime,
- }
- })
- })
- const sourceURL = computed(() => {
- if (bimChecked.value && !dbsChecked.value) {
- return `smart-bim.html?m=${source.value.num}`
- }
- if (source.value.type < 2) {
- // 看看、看见场景
- return `smart-kankan.html?m=${source.value.num}&dev`
- } else {
- // 深时场景
- return `smart-laser.html?m=${source.value.num}&dev`
- }
- })
- const targetURL = computed(() => {
- if (bimChecked.value) {
- return `smart-bim.html?m=${target.value.num}`
- }
- if (source.value.type < 2) {
- // 看看、看见场景
- return `smart-kankan.html?m=${target.value.num}&dev`
- } else {
- // 深时场景
- return `smart-laser.html?m=${target.value.num}&dev`
- }
- })
- const sourceDate = computed(() => {
- if (source.value) {
- console.log(source.value.createTime.toDate())
- return source.value.createTime.toDate()
- }
- })
- const targetDate = computed(() => {
- if (target.value) {
- return target.value.createTime.toDate()
- }
- })
- const sourceDays = computed(() => {
- let dates = []
- if (datepickName.value == 'source') {
- if (dbsChecked.value) {
- // 分屏模式
- if (bimChecked.value) {
- // BIM模式
- dates = scenes.value.map(item => item.createTime.toDate())
- } else {
- // 非BIM模式
- dates = scenes.value.filter(item => item.createTime != target.value.createTime).map(item => item.createTime.toDate())
- }
- } else {
- // 非分屏模式
- dates = scenes.value.map(item => item.createTime.toDate())
- }
- }
- return {
- dates: dates,
- }
- })
- const targetDays = computed(() => {
- let dates = []
- if (datepickName.value == 'target') {
- dates = scenes.value.filter(item => item.createTime != source.value.createTime).map(item => item.createTime.toDate())
- }
- return {
- dates: dates,
- }
- })
- const onLoadSource = () => {
- if (bimChecked.value && !dbsChecked.value) {
- // BIM单屏模式
- return
- }
- loadSourceScene(sourceFrame, source.value.type < 2 ? 'kankan' : 'laser')
- }
- const onLoadTarget = () => {
- if (bimChecked.value) {
- loadTargetScene(targetFrame, 'bim')
- } else {
- loadTargetScene(targetFrame, target.value.type < 2 ? 'kankan' : 'laser', mode.value)
- }
- }
- const onModeChange = targetMode => {
- window.Log('changeMode:'+targetMode, '#3cffff')
- if (sync.sourceInst) {
- sync.sourceInst.loaded.then(sdk => sdk.scene.changeMode(targetMode))
- mode.value = targetMode
- }
- }
- const onPickDate = name => {
- datepickName.value = name
- }
- const onSelected = data => {
- if (!data.payload) {
- return
- }
- let { name, payload } = data
- let date = payload.format('YYYY-mm-dd')
- let dates = (name == 'source' ? sourceDays : targetDays).value.dates.map(item => item.format('YYYY-mm-dd'))
- if (dates.indexOf(date) != -1) {
- let time = payload.format('YYYY-mm-dd HH:MM')
- let find = scenes.value.find(c => c.createTime.indexOf(time) != -1)
- if (find) {
- if (name == 'source') {
- if (find.num != source.value.num) {
- source.value = find
- }
- } else {
- if (find.num != target.value.num) {
- target.value = find
- }
- }
- }
- }
- datepickName.value = null
- }
- const onPrevDate = name => {
- let scene = null
- if (name == 'source') {
- scene = source
- } else {
- scene = target
- }
- let index = scenes.value.findIndex(item => item.num == scene.value.num)
- if (index == -1) {
- return
- }
- if (--index == -1) {
- index = scenes.value.length - 1
- }
- if (target.value) {
- // 分屏模式判断
- if (name == 'source') {
- if (scenes.value[index].createTime == target.value.createTime) {
- index--
- }
- } else {
- if (scenes.value[index].createTime == source.value.createTime) {
- index--
- }
- }
- if (index == -1) {
- index = scenes.value.length - 1
- }
- }
- scene.value = scenes.value[index]
- }
- const onNextDate = name => {
- let scene = null
- if (name == 'source') {
- scene = source
- } else {
- scene = target
- }
- let index = scenes.value.findIndex(item => item.num == scene.value.num)
- if (index == -1) {
- return
- }
- if (++index > scenes.value.length - 1) {
- index = 0
- }
- if (target.value) {
- // 分屏模式判断
- if (name == 'source') {
- if (scenes.value[index].createTime == target.value.createTime) {
- index++
- }
- } else {
- if (scenes.value[index].createTime == source.value.createTime) {
- index++
- }
- }
- if (index > scenes.value.length - 1) {
- index = 0
- }
- }
- scene.value = scenes.value[index]
- }
- // bim点击
- const onBimChecked = () => {
- if (bimChecked.value) {
- bimChecked.value = false
- if (dbsChecked.value) {
- // 判断是否分屏状态
- let index = scenes.value.findIndex(item => item.num == source.value.num)
- if (index == -1) {
- return
- }
- if (++index > scenes.value.length - 1) {
- index = 0
- }
- target.value = scenes.value[index]
- }
- } else {
- bimChecked.value = true
- }
- }
- // 分屏点击
- const onDbsChecked = () => {
- dbsChecked.value = !dbsChecked.value
- if (dbsChecked.value) {
- if (bimChecked.value) {
- // BIM分屏
- source.value = scenes.value[0]
- target.value = project.value.bimData
- } else {
- // 四维看看、激光场景分屏
- let index = scenes.value.findIndex(item => item.num == source.value.num)
- if (index == -1) {
- return
- }
- if (++index > scenes.value.length - 1) {
- index = 0
- }
- target.value = scenes.value[index]
- }
- } else {
- target.value = null
- //targetApp = null
- views.clear()
- }
- }
- // 全屏点击
- const onFscChecked = () => {
- let element = document.documentElement
- fscChecked.value = !fscChecked.value
- if (fscChecked.value) {
- if (element.requestFullscreen) {
- element.requestFullscreen()
- } else if (element.webkitRequestFullScreen) {
- element.webkitRequestFullScreen()
- } else if (element.mozRequestFullScreen) {
- element.mozRequestFullScreen()
- } else if (element.msRequestFullscreen) {
- element.msRequestFullscreen()
- }
- } else {
- if (document.exitFullscreen) {
- document.exitFullscreen()
- } else if (document.webkitCancelFullScreen) {
- document.webkitCancelFullScreen()
- } else if (document.mozCancelFullScreen) {
- document.mozCancelFullScreen()
- } else if (document.msExitFullscreen) {
- document.msExitFullscreen()
- }
- }
- }
- const onPointsUpdate = type =>{
- points.value[type] = true
- }
- onMounted(() => {
- const projectId = browser.valueFromUrl('projectId') || 1
- http.get(`smart-site/project/info?projectId=${projectId}`)
- .then(response => {
- if (response.success) {
- project.value = response.data
- if (project.value.sceneList.length) {
- source.value = project.value.sceneList[0]
- if (showAdjust.value || showSplit.value) {
- onBimChecked()
- nextTick(() => onDbsChecked())
- }
- }
- } else {
- alert('获取数据失败')
- }
- })
- .catch(() => {
- alert('服务器连接失败')
- })
- })
- </script>
- <style lang="scss" scoped>
- article {
- display: flex;
- width: 100%;
- height: 100%;
- overflow: hidden;
- }
- aside {
- width: 160px;
- height: 100%;
- background-color: rgba(0, 0, 0, 0.8);
- h4 {
- font-size: 16px;
- text-align: center;
- }
- ul {
- margin-top: 20px;
- }
- li {
- margin: 0;
- padding: 0;
- font-size: 16px;
- margin-left: 20px;
- cursor: pointer;
- &:hover,
- &.active {
- color: #00c8af;
- }
- }
- }
- main {
- flex: 1;
- width: 100%;
- height: 100%;
- position: relative;
- display: flex;
- &.full {
- .split {
- width: 50%;
- }
- }
- iframe {
- position: absolute;
- left: 0;
- top: 0;
- z-index: 1000;
- width: 100%;
- height: 100%;
- }
- .split {
- margin-left: 2px;
- width: 100%;
- height: 100%;
- overflow: hidden;
- position: relative;
- &:first-child,
- &:last-child {
- margin-left: 0;
- }
- .points {
- position: absolute;
- left: 50%;
- top: 64px;
- z-index: 9999;
- display: flex;
- transform: translateX(-50%);
- div {
- margin-left: 20px;
- width: 70px;
- height: 88px;
- background: rgba(27, 27, 28, 0.8);
- box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25), inset 0px 0px 0px 2px rgba(255, 255, 255, 0.1);
- border-radius: 8px 8px 8px 8px;
- opacity: 1;
- border: 1px solid #000000;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- &.active{
- color: #0076f6;
- }
- i {
- font-size: 24px;
- }
- span {
- font-size: 16px;
- margin-top: 10px;
- }
- }
- }
- }
- .model {
- position: absolute;
- left: 50px;
- bottom: 40px;
- z-index: 1000;
- display: flex;
- flex-direction: column;
- > div {
- cursor: pointer;
- width: 50px;
- height: 50px;
- margin-top: 16px;
- background: rgba(27, 27, 28, 0.8);
- box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);
- border-radius: 47px 47px 47px 47px;
- border: 1px solid #000000;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- &.disable {
- opacity: 0.3;
- cursor: default;
- > div {
- pointer-events: none;
- }
- }
- > div {
- width: 100%;
- height: 100%;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- }
- &.active {
- color: #0076f6;
- }
- span {
- font-size: 12px;
- padding-top: 1px;
- transform: scale(0.8);
- }
- }
- }
- .tools {
- position: absolute;
- width: 100%;
- bottom: 40px;
- z-index: 2000;
- display: flex;
- justify-content: center;
- align-items: center;
- color: #fff;
- pointer-events: none;
- > div {
- pointer-events: all;
- }
- .item-mode {
- height: 50px;
- background: rgba(27, 27, 28, 0.8);
- box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);
- border-radius: 47px 47px 47px 47px;
- border: 1px solid #000000;
- display: flex;
- justify-content: center;
- align-items: center;
- margin-left: 10px;
- margin-right: 10px;
- font-size: 16px;
- padding: 0 16px;
- div {
- cursor: pointer;
- font-size: 18px;
- }
- div:last-child {
- margin-left: 20px;
- }
- div.active {
- color: #0076f6;
- }
- }
- }
- }
- </style>
- <style lang="scss">
- #app {
- background-color: rgba(0, 0, 0, 0.8);
- display: flex;
- flex-direction: column;
- }
- .vuejs3-datepicker__calendar {
- background: rgba(27, 27, 28, 0.8);
- box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);
- border-radius: 4px 4px 4px 4px;
- opacity: 1;
- border: 1px solid #000000;
- filter: blur(undefinedpx);
- color: #fff;
- }
- .vuejs3-datepicker__calendar-topbar {
- display: none !important;
- }
- .vuejs3-datepicker__calendar header .up:not(.disabled):hover {
- background: rgba(0, 0, 0, 0.3);
- color: #fff;
- }
- .vuejs3-datepicker__calendar header .prev:after {
- border-left: 1px solid #fff;
- border-bottom: 1px solid #fff;
- }
- .vuejs3-datepicker__calendar header .prev:not(.disabled):hover {
- background: rgba(0, 0, 0, 0.3);
- }
- .vuejs3-datepicker__calendar header .next:after {
- border-top: 1px solid #fff;
- border-right: 1px solid #fff;
- }
- .vuejs3-datepicker__calendar header .next:not(.disabled):hover {
- background: rgba(0, 0, 0, 0.3);
- }
- .highlighted {
- background: #4ebde1 !important;
- }
- .selected {
- background: #0076f6 !important;
- }
- </style>
|