PropertiesView.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <transition
  3. appear
  4. name="animate__animated animate__move"
  5. enter-active-class="animate__flipInX"
  6. leave-active-class="animate__flipOutX"
  7. >
  8. <div class="widget-PropertiesView" ref="widget-PropertiesView">
  9. <div class="wrap">
  10. <el-cascader
  11. ref="PropertiesView"
  12. v-model="selectValue"
  13. :options="options"
  14. :props="{ expandTrigger: 'hover' }"
  15. clearable
  16. size="small"
  17. placeholder="属性查看"
  18. popper-class="widget-PropertiesView-el-cascader-dropDown"
  19. ></el-cascader>
  20. </div>
  21. </div>
  22. </transition>
  23. </template>
  24. <script lang="ts">
  25. import { Vue, Component, Prop, Watch } from 'vue-property-decorator'
  26. import PipeUnitInfo from '@/views/groupPage/districtPageModules/pipeUnitInfo/index.vue'
  27. import artifactsInfo from '@/views/groupPage/districtPageModules/customTools/infoComponents/artifactsInfo.vue'
  28. import { createTooltip } from '@/views/groupPage/util'
  29. import { getLatAndLon } from '@/views/groupPage/util'
  30. const Cesium = (window as any).Cesium
  31. //属性查看
  32. @Component({ name: 'PropertiesView' })
  33. export default class PropertiesView extends Vue {
  34. toolTip = null
  35. tooltipHandler = null
  36. componentInfo = null
  37. pipeInfo = null
  38. options = [
  39. {
  40. value: 'bjck',
  41. label: '部件查看',
  42. children: [
  43. {
  44. value: 'point',
  45. label: '点选'
  46. },
  47. {
  48. value: 'rect',
  49. label: '框选'
  50. }
  51. ]
  52. },
  53. {
  54. value: 'component',
  55. label: '构件查看'
  56. }
  57. ]
  58. selectValue = []
  59. viewer
  60. get isInitViewer() {
  61. return this.$store.state.bigScreen.isInitViewer
  62. }
  63. get propertiesViewValue() {
  64. return this.$store.state.bigScreen.propertiesViewValue
  65. }
  66. @Watch('isInitViewer')
  67. onChangeViewMethod() {
  68. this.viewer = (window as any).viewer
  69. }
  70. @Watch('propertiesViewValue')
  71. onChangeValueMethod(val) {
  72. this.selectValue = val
  73. }
  74. @Watch('selectValue')
  75. onChangeMethod(val) {
  76. if (!val) return
  77. this.$store.state.bigScreen.propertiesViewValue = val
  78. const type = [...val]
  79. this.destroyLastOperation()
  80. if (type.includes('point')) {
  81. this.pipeUnitInfo('point')
  82. }
  83. if (type.includes('rect')) {
  84. this.pipeUnitInfo('rect')
  85. }
  86. if (type.includes('component')) {
  87. this.activeViewComponent()
  88. }
  89. }
  90. mounted() {
  91. let target = this.$refs['widget-PropertiesView'] as any
  92. target.style.setProperty('--right', '2.34375rem')
  93. }
  94. pipeUnitInfo(type) {
  95. const pipeInfoConstructor = Vue.extend(PipeUnitInfo)
  96. this.pipeInfo = new pipeInfoConstructor({
  97. data: {
  98. pickType: type,
  99. isInteractive: true,
  100. locateUnit: null
  101. },
  102. store: this.$store
  103. }).$mount()
  104. }
  105. //构件查看激活
  106. activeViewComponent() {
  107. const that = this
  108. this.toolTip = createTooltip(document.querySelector('#' + this.$store.state.bigScreen.mapContainerId))
  109. const handler = new Cesium.ScreenSpaceEventHandler(this.viewer.canvas)
  110. this.tooltipHandler = handler
  111. // 设置要在输入事件上执行的功能,官方文档查询ScreenSpaceEventType可以看到所有的cesium鼠标事件
  112. handler.setInputAction((movement) => {
  113. var pickedObject = this.viewer.scene.pick(movement.position)
  114. const coordinate = getLatAndLon(this.viewer, movement)
  115. const position = Cesium.Cartesian3.fromDegrees(coordinate.longitude, coordinate.latitude, coordinate.altitude)
  116. if (this.viewer.scene.pickPositionSupported && Cesium.defined(pickedObject)) {
  117. const info = {
  118. name: pickedObject.primitive._name
  119. }
  120. this.showInfoPanel(position, info)
  121. }
  122. }, Cesium.ScreenSpaceEventType.LEFT_CLICK)
  123. handler.setInputAction((movement) => {
  124. this.toolTip.showAt(movement.endPosition, '<p>鼠标左键选择构件进行查看,右键单击取消</p>')
  125. }, Cesium.ScreenSpaceEventType.MOUSE_MOVE)
  126. handler.setInputAction(() => {
  127. this.clearPickEvent()
  128. this.selectValue = []
  129. }, Cesium.ScreenSpaceEventType.RIGHT_CLICK)
  130. }
  131. //显示构件信息
  132. showInfoPanel(position, info) {
  133. const artifactsInfoConstructor = Vue.extend(artifactsInfo)
  134. const that = this
  135. this.componentInfo = new artifactsInfoConstructor({
  136. data: {
  137. position,
  138. info
  139. },
  140. store: this.$store
  141. }).$mount()
  142. }
  143. //清除事件
  144. clearPickEvent() {
  145. if (this.componentInfo) {
  146. this.componentInfo.close()
  147. }
  148. if (this.toolTip) {
  149. this.toolTip.remove()
  150. this.toolTip = null
  151. }
  152. if (this.tooltipHandler && !this.tooltipHandler.isDestroyed()) {
  153. this.tooltipHandler.destroy()
  154. this.tooltipHandler = null
  155. }
  156. }
  157. destroyLastOperation() {
  158. if (this.pipeInfo) {
  159. this.pipeInfo.reset()
  160. }
  161. this.clearPickEvent()
  162. }
  163. }
  164. </script>
  165. <style lang="scss" scoped>
  166. .animate__flipInX,
  167. .animate__flipOutX {
  168. animation-duration: 3s; //动画持续时间
  169. animation-delay: 0s; //动画延迟时间
  170. }
  171. .widget-PropertiesView {
  172. $size10: 0.052083rem /* 10/192 */;
  173. $size20: 0.104167rem /* 20/192 */;
  174. z-index: 2;
  175. //position
  176. top: 0.505208rem /* 97/192 */;
  177. margin-right: var(--right); //2.34375rem /* 450/192 */;
  178. position: absolute;
  179. right: 0;
  180. //size
  181. //background
  182. background-color: rgba(20, 24, 47, 0.5);
  183. color: #eee;
  184. box-shadow: 0 0 20px rgba(1, 9, 20, 1);
  185. //font
  186. font-family: Source Han Sans CN;
  187. .wrap {
  188. display: flex;
  189. flex-flow: column;
  190. align-items: flex-end;
  191. width: 0.625rem /* 120/192 */;
  192. & ::placeholder {
  193. color: rgba(43, 167, 255, 1);
  194. }
  195. /deep/ .el-cascader {
  196. $background: rgba(7, 48, 80, 0.9);
  197. .el-input__inner {
  198. color: rgba(43, 167, 255, 1);
  199. border: none;
  200. background-color: $background;
  201. }
  202. .el-icon-arrow-down:before {
  203. content: '';
  204. display: block;
  205. // 定义元素宽高
  206. margin-top: 0.041667rem /* 8/192 */;
  207. width: 0.130208rem /* 25/192 */;
  208. height: 0.078125rem /* 15/192 */;
  209. background: url('~@/views/groupPage/images/三角上.png') no-repeat center center;
  210. background-size: 100% 100%;
  211. transform: rotate(180deg);
  212. }
  213. }
  214. // .icon {
  215. // width: 0.520833rem /* 100/192 */;
  216. // height: 0.177083rem /* 34/192 */;
  217. // background: rgba(3, 109, 190, 0.4);
  218. // border-radius: 2px;
  219. // display: flex;
  220. // justify-content: center;
  221. // align-items: center;
  222. // cursor: pointer;
  223. // font-size: 0.072917rem /* 14/192 */;
  224. // font-weight: 500;
  225. // color: #2ba7ff;
  226. // .iconImg {
  227. // width: 0.104167rem /* 20/192 */;
  228. // height: 0.083333rem /* 16/192 */;
  229. // }
  230. // .upImg {
  231. // background: url('~@/views/groupPage/images/三角上.png');
  232. // }
  233. // .downImg {
  234. // background: url('~@/views/groupPage/images/三角下.png');
  235. // }
  236. // }
  237. }
  238. }
  239. </style>
  240. <style lang="scss">
  241. .widget-PropertiesView-el-cascader-dropDown {
  242. background: rgba(2, 60, 93, 0.64);
  243. border-color: #023c5d;
  244. & ::placeholder {
  245. color: rgba(43, 167, 255, 1);
  246. }
  247. .el-cascader-menu {
  248. color: #eee;
  249. border-right: solid 1px rgba(64, 158, 255, 0.24);
  250. }
  251. .el-cascader-menu:last-child {
  252. border-right: none;
  253. }
  254. .el-cascader-node:hover {
  255. background-color: rgba(43, 167, 255, 0.2);
  256. }
  257. .popper__arrow {
  258. border-bottom-color: rgba(43, 167, 255, 0.2) !important;
  259. }
  260. .popper__arrow::after {
  261. border-bottom-color: rgba(43, 167, 255, 0.2) !important;
  262. }
  263. }
  264. </style>