Viewer.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. <template>
  2. <AppHeader v-show="!fscChecked" :project="project" :show-adjust="showAdjust" @update="onPointsUpdate" />
  3. <article>
  4. <main>
  5. <div class="split" v-if="source">
  6. <iframe ref="sourceFrame" :src="sourceURL" frameborder="0" @load="onLoadSource"></iframe>
  7. <div class="tools" v-show="!showAdjust && !fscChecked && (dbsChecked || (!target && !bimChecked))">
  8. <div class="item-date">
  9. <calendar name="source" :value="sourceDate" :highlighted="sourceDays" @selected="onSelected" @pick="onPickDate" @prev="onPrevDate" @next="onNextDate"></calendar>
  10. </div>
  11. <div class="item-mode" v-if="source.type == 2">
  12. <div class="iconfont icon-show_roaming" :class="{ active: mode == 0 }" @click="onModeChange(0)"></div>
  13. <div class="iconfont icon-show_plane" :class="{ active: mode == 1 }" @click="onModeChange(1)"></div>
  14. </div>
  15. </div>
  16. <div class="points" v-if="showAdjust">
  17. <div :class="{active:points.p1}">
  18. <i class="iconfont" :class="[points.p1?'icon-positioning01':'icon-positioning02']"></i>
  19. <span>P1</span>
  20. </div>
  21. <div :class="{active:points.p2}">
  22. <i class="iconfont" :class="[points.p2?'icon-positioning01':'icon-positioning02']"></i>
  23. <span>P2</span>
  24. </div>
  25. </div>
  26. </div>
  27. <div class="split" v-if="target">
  28. <iframe ref="targetFrame" :src="targetURL" frameborder="0" @load="onLoadTarget"></iframe>
  29. <div class="tools" v-show="!fscChecked && !bimChecked">
  30. <div class="item-date target">
  31. <calendar name="target" :value="targetDate" :highlighted="targetDays" @selected="onSelected" @pick="onPickDate" @prev="onPrevDate" @next="onNextDate"></calendar>
  32. </div>
  33. </div>
  34. <div class="points" v-if="showAdjust">
  35. <div :class="{active:points.p1}">
  36. <i class="iconfont" :class="[points.p1?'icon-positioning01':'icon-positioning02']"></i>
  37. <span>P1</span>
  38. </div>
  39. <div :class="{active:points.p2}">
  40. <i class="iconfont" :class="[points.p2?'icon-positioning01':'icon-positioning02']"></i>
  41. <span>P2</span>
  42. </div>
  43. </div>
  44. </div>
  45. <div class="model" v-show="!showAdjust">
  46. <div class="bim" :class="{ active: bimChecked }" v-show="!fscChecked">
  47. <div @click="onBimChecked">
  48. <i class="iconfont icon-BIM"></i>
  49. <span>BIM</span>
  50. </div>
  51. </div>
  52. <div class="dbs" :class="{ active: dbsChecked }" @click="onDbsChecked" v-show="!fscChecked">
  53. <i class="iconfont icon-split_screen"></i>
  54. <span>分屏</span>
  55. </div>
  56. <div class="fsc" :class="{ active: fscChecked }" @click="onFscChecked">
  57. <i class="iconfont" :class="[fscChecked ? 'icon-full_screen_selected' : 'icon-full_screen_normal']"></i>
  58. <span>全屏</span>
  59. </div>
  60. </div>
  61. </main>
  62. </article>
  63. </template>
  64. <script setup>
  65. import { ref, onMounted, computed, nextTick } from 'vue'
  66. import { http } from '@/utils/request'
  67. import browser from '@/utils/browser'
  68. import AppHeader from '@/components/header'
  69. import Calendar from '@/components/calendar'
  70. import sync, { loadSourceScene, loadTargetScene } from '@/utils/sync'
  71. // 是否校准模式
  72. const showSplit = ref(browser.urlHasValue('split'))
  73. const showAdjust = ref(browser.urlHasValue('adjust'))
  74. const bimChecked = ref(null)
  75. const dbsChecked = ref(null)
  76. const fscChecked = ref(null)
  77. const datepickName = ref(null)
  78. const sourceFrame = ref(null)
  79. const targetFrame = ref(null)
  80. const mode = ref(0)
  81. const source = ref(null)
  82. const target = ref(null)
  83. const project = ref(null)
  84. const points = ref({p1:false,p2:false})
  85. const scenes = computed(() => {
  86. if (!project.value) {
  87. return []
  88. }
  89. return project.value.sceneList.map(item => {
  90. return {
  91. num: item.num,
  92. type: item.type,
  93. createTime: item.createTime,
  94. }
  95. })
  96. })
  97. const sourceURL = computed(() => {
  98. if (bimChecked.value && !dbsChecked.value) {
  99. return `smart-bim.html?m=${source.value.num}`
  100. }
  101. if (source.value.type < 2) {
  102. // 看看、看见场景
  103. return `smart-kankan.html?m=${source.value.num}&dev`
  104. } else {
  105. // 深时场景
  106. return `smart-laser.html?m=${source.value.num}&dev`
  107. }
  108. })
  109. const targetURL = computed(() => {
  110. if (bimChecked.value) {
  111. return `smart-bim.html?m=${target.value.num}`
  112. }
  113. if (source.value.type < 2) {
  114. // 看看、看见场景
  115. return `smart-kankan.html?m=${target.value.num}&dev`
  116. } else {
  117. // 深时场景
  118. return `smart-laser.html?m=${target.value.num}&dev`
  119. }
  120. })
  121. const sourceDate = computed(() => {
  122. if (source.value) {
  123. console.log(source.value.createTime.toDate())
  124. return source.value.createTime.toDate()
  125. }
  126. })
  127. const targetDate = computed(() => {
  128. if (target.value) {
  129. return target.value.createTime.toDate()
  130. }
  131. })
  132. const sourceDays = computed(() => {
  133. let dates = []
  134. if (datepickName.value == 'source') {
  135. if (dbsChecked.value) {
  136. // 分屏模式
  137. if (bimChecked.value) {
  138. // BIM模式
  139. dates = scenes.value.map(item => item.createTime.toDate())
  140. } else {
  141. // 非BIM模式
  142. dates = scenes.value.filter(item => item.createTime != target.value.createTime).map(item => item.createTime.toDate())
  143. }
  144. } else {
  145. // 非分屏模式
  146. dates = scenes.value.map(item => item.createTime.toDate())
  147. }
  148. }
  149. return {
  150. dates: dates,
  151. }
  152. })
  153. const targetDays = computed(() => {
  154. let dates = []
  155. if (datepickName.value == 'target') {
  156. dates = scenes.value.filter(item => item.createTime != source.value.createTime).map(item => item.createTime.toDate())
  157. }
  158. return {
  159. dates: dates,
  160. }
  161. })
  162. const onLoadSource = () => {
  163. if (bimChecked.value && !dbsChecked.value) {
  164. // BIM单屏模式
  165. return
  166. }
  167. loadSourceScene(sourceFrame, source.value.type < 2 ? 'kankan' : 'laser')
  168. }
  169. const onLoadTarget = () => {
  170. if (bimChecked.value) {
  171. loadTargetScene(targetFrame, 'bim')
  172. } else {
  173. loadTargetScene(targetFrame, target.value.type < 2 ? 'kankan' : 'laser', mode.value)
  174. }
  175. }
  176. const onModeChange = targetMode => {
  177. window.Log('changeMode:'+targetMode, '#3cffff')
  178. if (sync.sourceInst) {
  179. sync.sourceInst.loaded.then(sdk => sdk.scene.changeMode(targetMode))
  180. mode.value = targetMode
  181. }
  182. }
  183. const onPickDate = name => {
  184. datepickName.value = name
  185. }
  186. const onSelected = data => {
  187. if (!data.payload) {
  188. return
  189. }
  190. let { name, payload } = data
  191. let date = payload.format('YYYY-mm-dd')
  192. let dates = (name == 'source' ? sourceDays : targetDays).value.dates.map(item => item.format('YYYY-mm-dd'))
  193. if (dates.indexOf(date) != -1) {
  194. let time = payload.format('YYYY-mm-dd HH:MM')
  195. let find = scenes.value.find(c => c.createTime.indexOf(time) != -1)
  196. if (find) {
  197. if (name == 'source') {
  198. if (find.num != source.value.num) {
  199. source.value = find
  200. }
  201. } else {
  202. if (find.num != target.value.num) {
  203. target.value = find
  204. }
  205. }
  206. }
  207. }
  208. datepickName.value = null
  209. }
  210. const onPrevDate = name => {
  211. let scene = null
  212. if (name == 'source') {
  213. scene = source
  214. } else {
  215. scene = target
  216. }
  217. let index = scenes.value.findIndex(item => item.num == scene.value.num)
  218. if (index == -1) {
  219. return
  220. }
  221. if (--index == -1) {
  222. index = scenes.value.length - 1
  223. }
  224. if (target.value) {
  225. // 分屏模式判断
  226. if (name == 'source') {
  227. if (scenes.value[index].createTime == target.value.createTime) {
  228. index--
  229. }
  230. } else {
  231. if (scenes.value[index].createTime == source.value.createTime) {
  232. index--
  233. }
  234. }
  235. if (index == -1) {
  236. index = scenes.value.length - 1
  237. }
  238. }
  239. scene.value = scenes.value[index]
  240. }
  241. const onNextDate = name => {
  242. let scene = null
  243. if (name == 'source') {
  244. scene = source
  245. } else {
  246. scene = target
  247. }
  248. let index = scenes.value.findIndex(item => item.num == scene.value.num)
  249. if (index == -1) {
  250. return
  251. }
  252. if (++index > scenes.value.length - 1) {
  253. index = 0
  254. }
  255. if (target.value) {
  256. // 分屏模式判断
  257. if (name == 'source') {
  258. if (scenes.value[index].createTime == target.value.createTime) {
  259. index++
  260. }
  261. } else {
  262. if (scenes.value[index].createTime == source.value.createTime) {
  263. index++
  264. }
  265. }
  266. if (index > scenes.value.length - 1) {
  267. index = 0
  268. }
  269. }
  270. scene.value = scenes.value[index]
  271. }
  272. // bim点击
  273. const onBimChecked = () => {
  274. if (bimChecked.value) {
  275. bimChecked.value = false
  276. if (dbsChecked.value) {
  277. // 判断是否分屏状态
  278. let index = scenes.value.findIndex(item => item.num == source.value.num)
  279. if (index == -1) {
  280. return
  281. }
  282. if (++index > scenes.value.length - 1) {
  283. index = 0
  284. }
  285. target.value = scenes.value[index]
  286. }
  287. } else {
  288. bimChecked.value = true
  289. }
  290. }
  291. // 分屏点击
  292. const onDbsChecked = () => {
  293. dbsChecked.value = !dbsChecked.value
  294. if (dbsChecked.value) {
  295. if (bimChecked.value) {
  296. // BIM分屏
  297. source.value = scenes.value[0]
  298. target.value = project.value.bimData
  299. } else {
  300. // 四维看看、激光场景分屏
  301. let index = scenes.value.findIndex(item => item.num == source.value.num)
  302. if (index == -1) {
  303. return
  304. }
  305. if (++index > scenes.value.length - 1) {
  306. index = 0
  307. }
  308. target.value = scenes.value[index]
  309. }
  310. } else {
  311. target.value = null
  312. //targetApp = null
  313. views.clear()
  314. }
  315. }
  316. // 全屏点击
  317. const onFscChecked = () => {
  318. let element = document.documentElement
  319. fscChecked.value = !fscChecked.value
  320. if (fscChecked.value) {
  321. if (element.requestFullscreen) {
  322. element.requestFullscreen()
  323. } else if (element.webkitRequestFullScreen) {
  324. element.webkitRequestFullScreen()
  325. } else if (element.mozRequestFullScreen) {
  326. element.mozRequestFullScreen()
  327. } else if (element.msRequestFullscreen) {
  328. element.msRequestFullscreen()
  329. }
  330. } else {
  331. if (document.exitFullscreen) {
  332. document.exitFullscreen()
  333. } else if (document.webkitCancelFullScreen) {
  334. document.webkitCancelFullScreen()
  335. } else if (document.mozCancelFullScreen) {
  336. document.mozCancelFullScreen()
  337. } else if (document.msExitFullscreen) {
  338. document.msExitFullscreen()
  339. }
  340. }
  341. }
  342. const onPointsUpdate = type =>{
  343. points.value[type] = true
  344. }
  345. onMounted(() => {
  346. const projectId = browser.valueFromUrl('projectId') || 1
  347. http.get(`smart-site/project/info?projectId=${projectId}`)
  348. .then(response => {
  349. if (response.success) {
  350. project.value = response.data
  351. if (project.value.sceneList.length) {
  352. source.value = project.value.sceneList[0]
  353. if (showAdjust.value || showSplit.value) {
  354. onBimChecked()
  355. nextTick(() => onDbsChecked())
  356. }
  357. }
  358. } else {
  359. alert('获取数据失败')
  360. }
  361. })
  362. .catch(() => {
  363. alert('服务器连接失败')
  364. })
  365. })
  366. </script>
  367. <style lang="scss" scoped>
  368. article {
  369. display: flex;
  370. width: 100%;
  371. height: 100%;
  372. overflow: hidden;
  373. }
  374. aside {
  375. width: 160px;
  376. height: 100%;
  377. background-color: rgba(0, 0, 0, 0.8);
  378. h4 {
  379. font-size: 16px;
  380. text-align: center;
  381. }
  382. ul {
  383. margin-top: 20px;
  384. }
  385. li {
  386. margin: 0;
  387. padding: 0;
  388. font-size: 16px;
  389. margin-left: 20px;
  390. cursor: pointer;
  391. &:hover,
  392. &.active {
  393. color: #00c8af;
  394. }
  395. }
  396. }
  397. main {
  398. flex: 1;
  399. width: 100%;
  400. height: 100%;
  401. position: relative;
  402. display: flex;
  403. &.full {
  404. .split {
  405. width: 50%;
  406. }
  407. }
  408. iframe {
  409. position: absolute;
  410. left: 0;
  411. top: 0;
  412. z-index: 1000;
  413. width: 100%;
  414. height: 100%;
  415. }
  416. .split {
  417. margin-left: 2px;
  418. width: 100%;
  419. height: 100%;
  420. overflow: hidden;
  421. position: relative;
  422. &:first-child,
  423. &:last-child {
  424. margin-left: 0;
  425. }
  426. .points {
  427. position: absolute;
  428. left: 50%;
  429. top: 64px;
  430. z-index: 9999;
  431. display: flex;
  432. transform: translateX(-50%);
  433. div {
  434. margin-left: 20px;
  435. width: 70px;
  436. height: 88px;
  437. background: rgba(27, 27, 28, 0.8);
  438. box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25), inset 0px 0px 0px 2px rgba(255, 255, 255, 0.1);
  439. border-radius: 8px 8px 8px 8px;
  440. opacity: 1;
  441. border: 1px solid #000000;
  442. display: flex;
  443. flex-direction: column;
  444. align-items: center;
  445. justify-content: center;
  446. &.active{
  447. color: #0076f6;
  448. }
  449. i {
  450. font-size: 24px;
  451. }
  452. span {
  453. font-size: 16px;
  454. margin-top: 10px;
  455. }
  456. }
  457. }
  458. }
  459. .model {
  460. position: absolute;
  461. left: 50px;
  462. bottom: 40px;
  463. z-index: 1000;
  464. display: flex;
  465. flex-direction: column;
  466. > div {
  467. cursor: pointer;
  468. width: 50px;
  469. height: 50px;
  470. margin-top: 16px;
  471. background: rgba(27, 27, 28, 0.8);
  472. box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);
  473. border-radius: 47px 47px 47px 47px;
  474. border: 1px solid #000000;
  475. display: flex;
  476. flex-direction: column;
  477. align-items: center;
  478. justify-content: center;
  479. &.disable {
  480. opacity: 0.3;
  481. cursor: default;
  482. > div {
  483. pointer-events: none;
  484. }
  485. }
  486. > div {
  487. width: 100%;
  488. height: 100%;
  489. display: flex;
  490. flex-direction: column;
  491. align-items: center;
  492. justify-content: center;
  493. }
  494. &.active {
  495. color: #0076f6;
  496. }
  497. span {
  498. font-size: 12px;
  499. padding-top: 1px;
  500. transform: scale(0.8);
  501. }
  502. }
  503. }
  504. .tools {
  505. position: absolute;
  506. width: 100%;
  507. bottom: 40px;
  508. z-index: 2000;
  509. display: flex;
  510. justify-content: center;
  511. align-items: center;
  512. color: #fff;
  513. pointer-events: none;
  514. > div {
  515. pointer-events: all;
  516. }
  517. .item-mode {
  518. height: 50px;
  519. background: rgba(27, 27, 28, 0.8);
  520. box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);
  521. border-radius: 47px 47px 47px 47px;
  522. border: 1px solid #000000;
  523. display: flex;
  524. justify-content: center;
  525. align-items: center;
  526. margin-left: 10px;
  527. margin-right: 10px;
  528. font-size: 16px;
  529. padding: 0 16px;
  530. div {
  531. cursor: pointer;
  532. font-size: 18px;
  533. }
  534. div:last-child {
  535. margin-left: 20px;
  536. }
  537. div.active {
  538. color: #0076f6;
  539. }
  540. }
  541. }
  542. }
  543. </style>
  544. <style lang="scss">
  545. #app {
  546. background-color: rgba(0, 0, 0, 0.8);
  547. display: flex;
  548. flex-direction: column;
  549. }
  550. .vuejs3-datepicker__calendar {
  551. background: rgba(27, 27, 28, 0.8);
  552. box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);
  553. border-radius: 4px 4px 4px 4px;
  554. opacity: 1;
  555. border: 1px solid #000000;
  556. filter: blur(undefinedpx);
  557. color: #fff;
  558. }
  559. .vuejs3-datepicker__calendar-topbar {
  560. display: none !important;
  561. }
  562. .vuejs3-datepicker__calendar header .up:not(.disabled):hover {
  563. background: rgba(0, 0, 0, 0.3);
  564. color: #fff;
  565. }
  566. .vuejs3-datepicker__calendar header .prev:after {
  567. border-left: 1px solid #fff;
  568. border-bottom: 1px solid #fff;
  569. }
  570. .vuejs3-datepicker__calendar header .prev:not(.disabled):hover {
  571. background: rgba(0, 0, 0, 0.3);
  572. }
  573. .vuejs3-datepicker__calendar header .next:after {
  574. border-top: 1px solid #fff;
  575. border-right: 1px solid #fff;
  576. }
  577. .vuejs3-datepicker__calendar header .next:not(.disabled):hover {
  578. background: rgba(0, 0, 0, 0.3);
  579. }
  580. .highlighted {
  581. background: #4ebde1 !important;
  582. }
  583. .selected {
  584. background: #0076f6 !important;
  585. }
  586. </style>