operationModels.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. <template>
  2. <div id="distribution" class="distribution-index">
  3. <div :id="'previewBim'+_uid" class="previewBim"></div>
  4. <div id="distribution-drap" class="distribution-drap" v-show="drapShow" @mousedown="dragStart"
  5. @touchstart="dragStart">
  6. <div class="distribution-drap-title">
  7. <div id="title" class="distribution-drap-title-content">{{detail.title}}</div>
  8. <i id="close" class="el-icon-circle-close" @click="drapShow = false"></i>
  9. </div>
  10. <div class="distribution-drap-content">
  11. <organization v-if="type === 'organizationDetail'" :detail="detail" @clickName="clickName">
  12. </organization>
  13. <house v-else-if="type === 'roomDetail'" :detail="detail"></house>
  14. </div>
  15. <div class="image-box" v-if="detail.imageBox">
  16. <el-carousel trigger="click" height="130px">
  17. <el-carousel-item v-for="item in detail.imageBox" :key="item.id">
  18. <img :src="item.url" :alt="item.url" />
  19. </el-carousel-item>
  20. </el-carousel>
  21. </div>
  22. <div style="padding: 5px;" v-else></div>
  23. </div>
  24. <el-dialog :close-on-click-modal="false" :title="noticeBoardType === '1' ? '企业看板':'设备看板'"
  25. :visible.sync="modelVisible" width="1100px" :append-to-body="true">
  26. <notice-board v-if="modelVisible" :type="noticeBoardType" :detailId="detail.id"></notice-board>
  27. </el-dialog>
  28. </div>
  29. </template>
  30. <script>
  31. import {
  32. getIntegrateViewToken,
  33. } from '@/httpApi/bim'
  34. import {
  35. getHouseListByPage
  36. } from '@/httpApi/space'
  37. import {
  38. getOrganizationListByPage
  39. } from '@/httpApi/business'
  40. import bimView from '@/uitls/controls'
  41. import noticeBoard from '@/components/work/common/noticeBoard'
  42. import organization from '@/components/work/bim/modelDetail/organization'
  43. import house from '@/components/work/bim/modelDetail/house'
  44. export default {
  45. props: ['target'],
  46. data() {
  47. return {
  48. bimViewer: null,
  49. noticeBoardType: '1',
  50. modelVisible: false,
  51. drapShow: false,
  52. detail: {},
  53. roomList: [],
  54. organizationObj: {},
  55. type: '',
  56. item: {}
  57. }
  58. },
  59. created() {
  60. this.item = this.target;
  61. },
  62. mounted() {
  63. let width = document.getElementById('distribution').clientWidth;
  64. document.getElementById('distribution-drap').style.left = (width - 330) + 'px';
  65. document.getElementById('distribution-drap').style.top = '30px';
  66. getOrganizationListByPage({
  67. currPage: 1,
  68. pageSize: 100,
  69. organizationId: this.$store.getters.organization.id,
  70. projectId: this.$store.getters.project.id
  71. }).then(res => {
  72. if (res.state) {
  73. let list = res.data.dataList,
  74. obj = {};
  75. for (let i = 0; i < list.length; i++) {
  76. if (list[i].roomIds) {
  77. let roomIds = list[i].roomIds.split(',');
  78. for (let k = 0; k < roomIds.length; k++) {
  79. obj[roomIds[k]] = list[i];
  80. }
  81. }
  82. }
  83. this.organizationObj = obj;
  84. this.init();
  85. }
  86. })
  87. },
  88. beforeDestroy() {
  89. if (this.bimViewer) this.bimViewer.destroy();
  90. },
  91. components: {
  92. noticeBoard,
  93. organization,
  94. house
  95. },
  96. methods: {
  97. clickName(noticeBoardType) {
  98. this.modelVisible = true;
  99. this.noticeBoardType = noticeBoardType;
  100. },
  101. init(type) {
  102. if (type != '1') this.$loading();
  103. let postData = {
  104. currPage: 1,
  105. pageSize: 100,
  106. projectItemTargetId: this.item.id
  107. }
  108. getHouseListByPage(postData).then(res => {
  109. if (res.state) {
  110. this.roomList = res.data.dataList.filter(node => node.dataValue).map(node => {
  111. let nodes = JSON.parse(node.dataValue);
  112. nodes['name'] = node.roomNumber;
  113. nodes['id'] = node.roomNumber;
  114. nodes['data'] = node;
  115. return nodes;
  116. });
  117. if (type == '1') {
  118. this.initFloor();
  119. this.setFloor();
  120. } else {
  121. getIntegrateViewToken(this.item.bimIntegrateId).then(this.successFunc);
  122. }
  123. } else {
  124. this.$loading.close();
  125. }
  126. })
  127. },
  128. changeTarget(data) {
  129. this.clearFloor();
  130. this.item = data;
  131. this.init('1');
  132. },
  133. successFunc(res) {
  134. if (res.state) {
  135. this.bimViewer = new bimView({
  136. dom: document.getElementById('previewBim' + this._uid),
  137. viewToken: res.data,
  138. renderSuccess: () => {
  139. this.$loading.close();
  140. if (this.item.bimIntegrateId === '3102248339366592') this.modelRenderSuccess();
  141. this.initFloor();
  142. this.setFloor();
  143. }
  144. })
  145. } else {
  146. this.$loading.close();
  147. }
  148. },
  149. modelRenderSuccess() {
  150. this.bimViewer.hideComponentsByObjectData([{
  151. categoryId: "-2000038",
  152. levelName: "标高 1"
  153. }])
  154. this.bimViewer.overrideComponentsColorByObjectData([{
  155. family: "楼板",
  156. levelName: "标高 1"
  157. }], "#cecece")
  158. this.bimViewer.overrideComponentsColorByObjectData([{
  159. family: "基本墙",
  160. levelName: "标高 1"
  161. }], "#afa6ab");
  162. },
  163. initFloor() {
  164. for (var i = 0; i < this.roomList.length; i++) {
  165. this.bimViewer.insertRooms({
  166. id: this.roomList[i].roomId,
  167. boundary: {
  168. "outer": this.roomList[i].boundary
  169. },
  170. height: this.roomList[i].height,
  171. roomColor: this.returnRGBA(this.roomList[i].roomColor)
  172. })
  173. }
  174. },
  175. clearFloor() { //清除房间
  176. let ids = this.roomList.filter(node => node.name).map(node => node.roomId);
  177. let arr1 = ids.map(id => 'room' + id);
  178. let arr2 = ids.map(id => 'floor' + id);
  179. this.bimViewer.clearDrawable(arr1.concat(arr2));
  180. this.bimViewer.clearAllRooms();
  181. },
  182. dragStart(evt) {
  183. let oEvent = evt || event; //获取事件对象,这个是兼容写法
  184. if (oEvent.target.id !== 'title') return;
  185. let div = document.getElementById('distribution-drap');
  186. let disX = oEvent.clientX - parseInt(div.style.left || 0);
  187. let disY = oEvent.clientY - parseInt(div.style.top || 0);
  188. div.style.left = oEvent.clientX - disX + 'px';
  189. div.style.top = oEvent.clientY - disY + 'px';
  190. document.onmousemove = function(evt) { //实时改变目标元素obox的位置
  191. let oEvent = evt || event;
  192. div.style.left = oEvent.clientX - disX + 'px';
  193. div.style.top = oEvent.clientY - disY + 'px';
  194. }
  195. //停止拖动
  196. document.onmouseup = function() {
  197. document.onmousemove = null;
  198. document.onmouseup = null;
  199. }
  200. },
  201. showDrap(type, data) {
  202. this.type = type;
  203. this.detail = data;
  204. this.drapShow = true;
  205. },
  206. setFloor() { //设置房间
  207. for (var i = 0; i < this.roomList.length; i++) {
  208. let boundary = this.roomList[i].boundary;
  209. let arrX = boundary.map(node => node.x);
  210. let arrY = boundary.map(node => node.y);
  211. let maxX = Math.max(...arrX);
  212. let minX = Math.min(...arrX);
  213. let maxY = Math.max(...arrY);
  214. let minY = Math.min(...arrY);
  215. let x = (maxX - minX) / 2 + minX;
  216. let y = (maxY - minY) / 2 + minY;
  217. if (this.roomList[i].name) {
  218. let house = this.roomList[i].data;
  219. house['title'] = this.roomList[i].name;
  220. house['imageBox'] = house.picture ? JSON.parse(house.picture) : [];
  221. this.bimViewer.addDrawable({
  222. position: {
  223. x: x,
  224. y: y,
  225. z: boundary[0].z + this.roomList[i].height
  226. },
  227. offsetX: -30,
  228. offsetY: 5,
  229. html: ` <div class="floor-name">${this.roomList[i].name}</div>`,
  230. id: 'floor' + this.roomList[i].roomId
  231. }, data => {
  232. this.showDrap('roomDetail', house);
  233. })
  234. }
  235. if (this.organizationObj[this.roomList[i].roomId]) {
  236. let organization = this.organizationObj[this.roomList[i].roomId];
  237. organization['title'] = this.roomList[i].name;
  238. this.bimViewer.addDrawable({
  239. position: {
  240. x: x,
  241. y: y,
  242. z: boundary[0].z + this.roomList[i].height
  243. },
  244. offsetX: -75,
  245. offsetY: -40,
  246. html: ` <div class="tips-4"><div class="name">${organization.name}</div><i class="iconfont huifont-sanjiaojiantou-xia"></i></div>`,
  247. id: 'room' + this.roomList[i].roomId,
  248. visibleDistance: parseInt(this.roomList[i].distance)
  249. }, data => {
  250. this.showDrap('organizationDetail', organization);
  251. })
  252. }
  253. }
  254. },
  255. open(type) {
  256. this.type = type;
  257. this.modelVisible = true;
  258. },
  259. returnRGBA(color) {
  260. let [r, g, b, a] = color.match(/\d+(\.\d+)?/g).map(Number);
  261. return {
  262. r,
  263. g,
  264. b,
  265. a
  266. }
  267. },
  268. }
  269. }
  270. </script>
  271. <style lang="scss">
  272. .distribution-index {
  273. width: 100%;
  274. height: 100%;
  275. display: flex;
  276. flex-direction: column;
  277. position: relative;
  278. overflow: hidden;
  279. background: $--box-background;
  280. .video-toggle {
  281. position: fixed;
  282. width: 700px;
  283. height: 500px;
  284. background: #000;
  285. left: 50%;
  286. top: 50%;
  287. transform: translate(-50%, -50%);
  288. display: flex;
  289. flex-direction: column;
  290. z-index: 999;
  291. .chart-title {
  292. display: flex;
  293. justify-content: space-between;
  294. width: 100%;
  295. background-size: contain;
  296. position: relative;
  297. background-color: $--background;
  298. padding-left: 15px;
  299. align-items: center;
  300. .el-icon-close {
  301. padding: 8px;
  302. font-size: 24px;
  303. cursor: pointer;
  304. }
  305. }
  306. .chart-title:before {
  307. content: "";
  308. position: absolute;
  309. height: 2px;
  310. left: 0px;
  311. right: 0;
  312. border-bottom: 2px solid;
  313. -o-border-image: linear-gradient(315deg, rgba(167, 208, 255, 0), rgba(110, 163, 255, .3)) 2 2;
  314. border-image: linear-gradient(315deg, rgba(167, 208, 255, 0), rgba(110, 163, 255, .3)) 2 2;
  315. bottom: .5px;
  316. }
  317. .video-toggle-box {
  318. flex: 1;
  319. height: 0;
  320. display: flex;
  321. align-items: center;
  322. padding: 20px;
  323. box-sizing: border-box;
  324. }
  325. video {
  326. max-height: 100%;
  327. }
  328. }
  329. .tips-4 {
  330. cursor: pointer;
  331. }
  332. .floor-name {
  333. cursor: pointer;
  334. width: 60px;
  335. text-align: center;
  336. color: #fff;
  337. }
  338. .left-button {
  339. position: absolute;
  340. z-index: 998;
  341. display: flex;
  342. justify-content: center;
  343. left: 0;
  344. bottom: 30px;
  345. width: 100%;
  346. }
  347. .menu-item {
  348. width: 100px;
  349. height: 32px;
  350. font-size: 16px;
  351. color: #AAB5C7;
  352. line-height: 30px;
  353. letter-spacing: 2px;
  354. text-align: center;
  355. background-image: url(../../../assets/image/common/tab.png);
  356. background-size: 100% 100%;
  357. margin: 0 15px;
  358. cursor: pointer;
  359. }
  360. .menu-item.active,
  361. .menu-item:hover {
  362. color: #fff;
  363. background-image: url(../../../assets/image/common/tab_active.png);
  364. }
  365. .previewBim {
  366. flex: 1;
  367. height: 0;
  368. }
  369. .distribution-drap {
  370. position: absolute;
  371. top: 30px;
  372. right: 30px;
  373. background: $--color-background;
  374. width: 300px;
  375. border-radius: 8px;
  376. z-index: 998;
  377. right: 30px;
  378. top: 30px;
  379. .distribution-drap-title {
  380. height: 40px;
  381. display: flex;
  382. align-items: center;
  383. .distribution-drap-title-content {
  384. flex: 1;
  385. width: 0;
  386. font-weight: 500;
  387. cursor: move;
  388. padding-left: 10px;
  389. }
  390. .el-icon-circle-close {
  391. font-size: 20px;
  392. cursor: pointer;
  393. padding-right: 10px;
  394. }
  395. }
  396. .user-list {
  397. padding: 0 10px 0px 10px;
  398. font-size: 13px;
  399. .user-item {
  400. display: flex;
  401. margin-bottom: 2px;
  402. .user-key {
  403. width: 84px;
  404. }
  405. .user-value {
  406. flex: 1;
  407. width: 0;
  408. margin-left: 2px;
  409. overflow: hidden;
  410. white-space: nowrap;
  411. text-overflow: ellipsis;
  412. }
  413. }
  414. .user-item>div {
  415. background: #232A37;
  416. line-height: 34px;
  417. padding: 0 16px;
  418. }
  419. .user-item:last-child {
  420. margin-bottom: 0;
  421. }
  422. }
  423. .image-box {
  424. width: 100%;
  425. height: 150px;
  426. padding: 10px;
  427. box-sizing: border-box;
  428. position: relative;
  429. img {
  430. width: 100%;
  431. height: 100%;
  432. object-fit: cover;
  433. user-select: none;
  434. -webkit-user-drag: none;
  435. }
  436. .video-mask {
  437. position: absolute;
  438. top: 0;
  439. left: 0;
  440. right: 0;
  441. bottom: 0;
  442. background: rgba(0, 0, 0, 0.5);
  443. z-index: 2;
  444. display: flex;
  445. justify-content: center;
  446. align-items: center;
  447. opacity: 0;
  448. transition: 300ms;
  449. cursor: pointer;
  450. i {
  451. font-size: 24px;
  452. }
  453. }
  454. }
  455. .image-box:hover {
  456. .video-mask {
  457. opacity: 1;
  458. }
  459. }
  460. }
  461. .walk-box {
  462. position: absolute;
  463. bottom: 30px;
  464. left: 50%;
  465. margin-left: -80px;
  466. display: flex;
  467. align-items: center;
  468. z-index: 998;
  469. .walk-box-item {
  470. width: 80px;
  471. height: 80px;
  472. border-radius: 80px;
  473. background: #232A37;
  474. text-align: center;
  475. line-height: 80px;
  476. cursor: pointer;
  477. margin-right: 20px;
  478. &:hover {
  479. opacity: 0.7;
  480. }
  481. }
  482. .iconfont {
  483. font-size: 36px;
  484. }
  485. }
  486. // .bf-house,
  487. // .bf-tree-toolbar {
  488. // display: none;
  489. // }
  490. }
  491. </style>