viewer1.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <div v-show="flag">
  3. <datePicker @dateChange="dateChange"></datePicker>
  4. <ser-center></ser-center>
  5. <JSYD />
  6. <TDSC />
  7. <HYSY ref="hysy_ref" />
  8. <TDSY />
  9. <GDBH ref="gdbh_ref"/>
  10. <STXF ref="stxf_ref"/>
  11. <WPJG ref="wpjg_ref"/>
  12. </div>
  13. </template>
  14. <script>
  15. //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  16. import serCenter from './cockpitNew1/serCenter';
  17. import JSYD from './cockpitNew1/jsyd';
  18. import TDSC from './cockpitNew1/tdsc';
  19. import HYSY from './cockpitNew1/hysy';
  20. import TDSY from './cockpitNew1/tdsy';
  21. import GDBH from './cockpitNew1/gdbh';
  22. import STXF from './cockpitNew1/stxf';
  23. import WPJG from './cockpitNew1/wpjg';
  24. import datePicker from './cockpitNew1/datePicker.vue';
  25. import xzqh from "../../static/data/460200_full.json";
  26. import SerCenter from './cockpitNew1/serCenter.vue';
  27. import { cockpitInfo } from '@/api/cockpit'
  28. export default {
  29. components: { serCenter, JSYD, TDSC, HYSY, TDSY, GDBH, STXF, WPJG, datePicker, SerCenter },
  30. data() {
  31. return {
  32. flag: true,
  33. xzqh_color_click: "rgba(46, 177, 251, 0.6)",
  34. xzqh_color: "rgba(10, 95, 152, 0.5)",
  35. };
  36. },
  37. //监听属性 类似于data概念
  38. computed: {},
  39. //监控data中的数据变化
  40. watch: {},
  41. //方法集合
  42. methods: {
  43. switch() {
  44. console.log("switch", "asdasd");
  45. this.flag = !this.flag;
  46. },
  47. dateChange(date) {
  48. let params = { beginTime: date[0], endTime: date[1] };
  49. this.$refs.gdbh_ref.setData(params);
  50. this.$refs.stxf_ref.setData(params);
  51. this.$refs.wpjg_ref.setData(params);
  52. },
  53. async hysyq(address) {
  54. // 选中xzqh查询
  55. let obj = {
  56. beginTime: '20240101',
  57. endTime: '20240501',
  58. jscType: 'jsc_hysyq_ztsh',
  59. id: address
  60. };
  61. let data = await cockpitInfo(obj);
  62. let obg_text = {
  63. xzqhdm_number: data.data[0].xzqhdm_number,
  64. zhmj: data.data[0].zhmj,
  65. }
  66. console.log(obg_text, "obg_echart");
  67. store.setCockpitHysyText(obg_text);
  68. // 图表数据
  69. let obj_echart = {
  70. beginTime: '20240101',
  71. endTime: '20240501',
  72. jscType: 'jsc_hysyq_yelx',
  73. id: address
  74. };
  75. let data_echart = await cockpitInfo(obj_echart);
  76. let obg_echart = {
  77. x: data_echart.data.map(item => item.yhlx_name),
  78. bar: data_echart.data.map(item => item.zhmj)
  79. }
  80. store.setCockpitHysyEchart(obg_echart);
  81. this.$refs.hysy_ref["getRenKou"]();
  82. // getRenKou();
  83. console.log(address, "address");
  84. },
  85. async pick_xzqh() {
  86. const that = this;
  87. const handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
  88. handler.setInputAction(async event => {
  89. let pickObj = viewer.scene.pick(event.position);
  90. var position = viewer.scene.pickPosition(event.position);
  91. if (!position)//点击到地球之外
  92. return false;
  93. var cartographic = Cesium.Cartographic.fromCartesian(position);
  94. let longitude = Cesium.Math.toDegrees(cartographic.longitude);
  95. let latitude = Cesium.Math.toDegrees(cartographic.latitude);
  96. let height = cartographic.height;
  97. let heading = viewer.scene.camera.heading;
  98. let pitch = viewer.scene.camera.pitch;
  99. if (!pickObj)//未获取实体
  100. return false;
  101. // console.log(longitude, latitude, height);
  102. if (!pickObj) {
  103. return false;
  104. }
  105. if (!position) {
  106. position = Cesium.Cartesian3.fromDegrees(0, 0, 0);
  107. }
  108. if (Cesium.defined(pickObj)) {
  109. if (pickObj.id && pickObj.id instanceof Cesium.Entity) {//点击entity
  110. if (pickObj.id.properties.hasProperty('name')) {
  111. const name = pickObj.id.properties.name.getValue();
  112. const address = pickObj.id.properties.adcode.getValue();
  113. const center = pickObj.id.properties.centroid.getValue();
  114. // 选中状态
  115. pickObj.id.polygon._material.color = Cesium.Color.fromCssColorString(that.xzqh_color_click);
  116. pickObj.id.polygon.extrudedHeight = 850;
  117. // 恢复其他状态
  118. viewer.entities.values.forEach((res) => {
  119. if (res.properties.name._value != name) {
  120. // console.log(res.properties.name._value, "其他的");
  121. // console.log(res);
  122. res.polygon._material.color = Cesium.Color.fromCssColorString(that.xzqh_color)
  123. res.polygon.extrudedHeight = 450;
  124. }
  125. })
  126. // 驾驶舱海域使用权
  127. that.hysyq(address);
  128. } else {
  129. }
  130. }
  131. } else {
  132. }
  133. }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
  134. },
  135. init_xzqh() {
  136. const that = this;
  137. xzqh.features.forEach((res) => {
  138. const twoDArray = res.geometry.coordinates[0][0];
  139. const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
  140. console.log();
  141. viewer.entities.add({
  142. position: Cesium.Cartesian3.fromDegrees(res.properties.centroid[0], res.properties.centroid[1], 500),
  143. text: res.properties.name,
  144. label: {
  145. scale: 1.5,
  146. font: "bolder 16px sans-serif",
  147. style: Cesium.LabelStyle.FILL_AND_OUTLINE,
  148. text: res.properties.name,//图标名称
  149. fillColor: Cesium.Color.fromCssColorString("#ffffff"),
  150. pixelOffset: new Cesium.Cartesian2(5, -15),
  151. zIndex: 3,
  152. },
  153. billboard: {
  154. // 图像地址,URI或Canvas的属性
  155. image: "./static/images/overview/htq-f.png",
  156. height: 60,
  157. // 宽度(以像素为单位)
  158. width: 150,
  159. // 相对于坐标的垂直位置
  160. // verticalOrigin: Cesium.VerticalOrigin.CENTER,
  161. // // 相对于坐标的水平位置
  162. // horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
  163. scale: 1.0,
  164. zIndex: 2,
  165. show: true
  166. },
  167. properties: {
  168. 'type': "cockpit",
  169. 'name': res.properties.name,
  170. 'centroid': res.properties.centroid,
  171. 'adcode': res.properties.adcode,
  172. },
  173. polygon: {
  174. zIndex: 1,
  175. hierarchy: {
  176. positions: Cesium.Cartesian3.fromDegreesArray(oneDArray),
  177. },
  178. outline: false,
  179. material: Cesium.Color.fromCssColorString(that.xzqh_color),
  180. height: 100,
  181. extrudedHeight: 450,
  182. }
  183. });
  184. })
  185. }
  186. },
  187. beforeCreate() { }, //生命周期 - 创建之前
  188. created() { }, //生命周期 - 创建完成(可以访问当前this实例)
  189. beforeMount() { }, //生命周期 - 挂载之前
  190. async mounted() {
  191. // let obj = { beginTime: '20230612', endTime: '20230817', jscType: 'jsc_wpjc_yelx', id: '46' };
  192. // let data = await cockpitInfo(obj);
  193. // let obj1 = { beginTime: '20230612', endTime: '20230817', jscType: 'jsc_wpjc_ztsh', id: '46' }
  194. // let data1 = await cockpitInfo(obj1);
  195. // console.log(data, "asda");
  196. // console.log(data1, "asda");
  197. // 三亚行政区划加载
  198. this.$nextTick((res) => {
  199. this.pick_xzqh();
  200. this.init_xzqh()
  201. });
  202. }, //生命周期 - 挂在完成
  203. beforeUpdate() { }, //生命周期 - 更新之前
  204. updated() { }, //生命周期 - 更新之后
  205. beforeDestroy() { }, //生命周期 - 销毁之前
  206. destroy() { },//生命周期 - 销毁完成
  207. activated() { }, //若组件实例是 <KeepAlive> 缓存树的一部分,当组件被插入到 DOM 中时调用。
  208. deactivated() { } //若组件实例是 <KeepAlive> 缓存树的一部分,当组件从 DOM 中被移除时调用。
  209. };
  210. </script>
  211. <style scoped></style>