projectInfo.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <ComMapBox ref="ComMapBox" :id="'projectInfo'">
  3. <ComCardBox @close="close()" :styleData="cardStyle">
  4. <div class="widget-projectInfo">
  5. <div class="header">
  6. <div class="name">{{ info.originname }}</div>
  7. <!-- <div class="status">{{ '建设中' }}</div> -->
  8. </div>
  9. <div class="content">
  10. <!-- <div class="content-item">
  11. <div class="name">工程进度:</div>
  12. <div class="value">
  13. <div class="progress-bg"></div>
  14. <div class="progress-value">80%</div>
  15. </div>
  16. </div> -->
  17. <div class="content-item">
  18. <div class="name">工程编码:</div>
  19. <div class="value">{{ info.code }}</div>
  20. </div>
  21. <div class="content-item">
  22. <div class="name">类型:</div>
  23. <div class="value">{{ info.levelname }}</div>
  24. </div>
  25. <div class="content-item">
  26. <div class="name">设计单位:</div>
  27. <div class="value">{{ designUnit }}</div>
  28. </div>
  29. <div class="content-item">
  30. <div class="name">施工单位:</div>
  31. <div class="value">{{ buildUnit }}</div>
  32. </div>
  33. </div>
  34. </div>
  35. </ComCardBox>
  36. </ComMapBox>
  37. </template>
  38. <script lang="ts">
  39. import { mapSearch_api } from '@/api/APIs'
  40. import ComMapBox from '@/views/groupPage/components/ComMapBox.vue'
  41. import ComCardBox from '@/views/groupPage/components/ComCardBox.vue'
  42. import { Vue, Component, Prop, Watch } from 'vue-property-decorator'
  43. const Cesium = (window as any).Cesium
  44. let handler = null
  45. //属性查看
  46. @Component({ name: 'projectInfo', components: { ComMapBox, ComCardBox } })
  47. export default class projectInfo extends Vue {
  48. info: any = {}
  49. position: Array<any> = []
  50. viewer
  51. designUnit: string = ''
  52. buildUnit: string = ''
  53. cardStyle: object = {
  54. '--height': '1.25rem ' /* 240/192 */, //高度
  55. '--width': '1.666667rem ' /* 320/192 */, //宽度
  56. '--borderColor': 'rgba(25, 137, 252, 1)', //边框线颜色
  57. '--backgroundColor': 'rgba(2, 20, 37, 0.45)' //背景颜色
  58. }
  59. mounted() {
  60. this.viewer = (window as any).viewer
  61. this.close() //初始不显示
  62. this.addEntity()
  63. this.addMapEvent()
  64. this.searchInfo()
  65. }
  66. searchInfo() {
  67. const data = { queryText: this.info.originname } //查询条件
  68. mapSearch_api(data).then((res) => {
  69. let dArray = [],
  70. bArray = []
  71. res.result.forEach((item) => {
  72. let buildUnit = item.tjData && item.tjData[0] && item.tjData[0].buildUnit ? item.tjData[0].buildUnit : '无'
  73. let designUnit = item.tjData && item.tjData[1] && item.tjData[1].designUnit ? item.tjData[1].designUnit : '无'
  74. if (!dArray.includes(designUnit)) dArray.push(designUnit)
  75. if (!bArray.includes(buildUnit)) bArray.push(buildUnit)
  76. })
  77. this.designUnit = dArray.join(',')
  78. this.buildUnit = bArray.join(',')
  79. })
  80. }
  81. initInfoPop() {
  82. ;(this.$refs['ComMapBox'] as any).initBox()
  83. ;(this.$refs['ComMapBox'] as any).setPosition(Cesium.Cartesian3.fromDegrees(this.position[0], this.position[1]))
  84. }
  85. addMapEvent() {
  86. const that = this
  87. handler = new Cesium.ScreenSpaceEventHandler(this.viewer.canvas)
  88. handler.setInputAction(
  89. function (movement) {
  90. var pickedObject = this.viewer.scene.pick(movement.position)
  91. // 使用时,最好利用pickPositionSupported判断一下浏览器是否支持模型高度拾取
  92. if (this.viewer.scene.pickPositionSupported && Cesium.defined(pickedObject)) {
  93. if (pickedObject.id._id === 'projectInfo') {
  94. that.initInfoPop()
  95. }
  96. } else {
  97. }
  98. }.bind(this),
  99. Cesium.ScreenSpaceEventType.LEFT_CLICK
  100. )
  101. }
  102. addEntity() {
  103. let viewer = this.viewer
  104. let imgSrc = require('@/views/groupPage/images/地图/工程-管网工程.png')
  105. this.removeEntity()
  106. viewer.entities.add({
  107. id: 'projectInfo',
  108. position: Cesium.Cartesian3.fromDegrees(this.position[0], this.position[1], 0),
  109. billboard: {
  110. image: imgSrc,
  111. width: 45,
  112. height: 45,
  113. heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
  114. eyeOffset: Cesium.Cartesian3.ZERO,
  115. disableDepthTestDistance: 9999999
  116. }
  117. })
  118. var entity = viewer.entities.getById('projectInfo')
  119. viewer.flyTo(entity, {
  120. offset: {
  121. heading: Cesium.Math.toRadians(0.0),
  122. pitch: Cesium.Math.toRadians(-60),
  123. range: 500
  124. }
  125. })
  126. }
  127. removeEntity() {
  128. //清除定位实体
  129. let entitys = this.viewer.entities._entities._array
  130. for (let i = 0; i < entitys.length; i++) {
  131. if (entitys[i].id === 'projectInfo') {
  132. this.viewer.entities.remove(entitys[i])
  133. i--
  134. }
  135. }
  136. }
  137. close() {
  138. ;(this.$refs['ComMapBox'] as any).remove()
  139. }
  140. remove() {
  141. ;(this.$refs['ComMapBox'] as any).remove()
  142. this.removeEntity()
  143. }
  144. beforeDestroy() {
  145. this.close()
  146. }
  147. }
  148. </script>
  149. <style lang='scss' scoped>
  150. .widget-projectInfo {
  151. height: 100%;
  152. width: 90%;
  153. padding: 0.052083rem /* 10/192 */ 0.078125rem /* 15/192 */ 0;
  154. .header {
  155. height: 0.104167rem /* 20/192 */;
  156. display: flex;
  157. justify-content: space-between;
  158. .name {
  159. flex: 1;
  160. overflow: hidden;
  161. text-overflow: ellipsis;
  162. white-space: nowrap;
  163. font-size: 0.083333rem /* 16/192 */;
  164. font-weight: bold;
  165. color: #16c6ea;
  166. }
  167. .status {
  168. flex: 0.3;
  169. background: rgba(3, 153, 228, 1);
  170. border-radius: 2px;
  171. color: #fff;
  172. display: flex;
  173. justify-content: center;
  174. align-items: center;
  175. font-size: 0.072917rem; /* 14/192 */
  176. }
  177. }
  178. .content {
  179. overflow: auto;
  180. height: calc(100% - 25px);
  181. width: 100%;
  182. display: flex;
  183. flex-flow: column;
  184. .content-item {
  185. font-size: 0.072917rem /* 14/192 */;
  186. font-weight: 400;
  187. padding: 0.052083rem /* 10/192 */ 0;
  188. display: flex;
  189. .name {
  190. color: #ffffff;
  191. }
  192. .value {
  193. color: rgba(14, 202, 240, 1);
  194. flex: 1;
  195. white-space: normal;
  196. display: flex;
  197. justify-content: space-between;
  198. align-items: center;
  199. }
  200. .progress-bg {
  201. width: 60%;
  202. height: 0.052083rem /* 10/192 */;
  203. border-radius: 5px;
  204. background: linear-gradient(90deg, #1088f7, #ebe171);
  205. }
  206. .progress-value {
  207. color: rgba(234, 224, 114, 1);
  208. }
  209. }
  210. }
  211. }
  212. </style>