viewer.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <template>
  2. <div v-show="flag">
  3. <datePicker @dateChange="dateChange"></datePicker>
  4. <ser-center></ser-center>
  5. <GKZB ref="gkzb_ref"/>
  6. <BJXM />
  7. <TDSC />
  8. <HYSY ref="hysy_ref" />
  9. <TDSY />
  10. <GDBH ref="gdbh_ref" />
  11. <STXF ref="stxf_ref" />
  12. <WPJG ref="wpjg_ref" />
  13. </div>
  14. </template>
  15. <script>
  16. //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  17. import serCenter from './cockpitNew1/serCenter';
  18. import GKZB from './cockpitNew1/gkzb';
  19. import TDSC from './cockpitNew1/tdsc';
  20. import HYSY from './cockpitNew1/hysy';
  21. import TDSY from './cockpitNew1/tdsy';
  22. import BJXM from './cockpitNew1/bjxm';
  23. import GDBH from './cockpitNew1/gdbh';
  24. import STXF from './cockpitNew1/stxf';
  25. import WPJG from './cockpitNew1/wpjg';
  26. import datePicker from './cockpitNew1/datePicker.vue';
  27. import xzqh from "../../static/data/460200_full.json";
  28. import SerCenter from './cockpitNew1/serCenter.vue';
  29. import { cockpitInfo } from '@/api/cockpit'
  30. export default {
  31. components: { serCenter, GKZB, BJXM, TDSC, HYSY, TDSY, GDBH, STXF, WPJG, datePicker, SerCenter },
  32. data() {
  33. return {
  34. params: {
  35. beginTime: '',
  36. endTime: '',
  37. id: 4602,
  38. },
  39. flag: true,
  40. xzqh_color_click: "rgba(46, 177, 251, 0.6)",
  41. xzqh_color: "rgba(10, 95, 152, 0.5)",
  42. };
  43. },
  44. //监听属性 类似于data概念
  45. computed: {},
  46. //监控data中的数据变化
  47. watch: {},
  48. //方法集合
  49. methods: {
  50. switch() {
  51. this.flag = !this.flag;
  52. },
  53. setDatas() {
  54. this.$refs.gdbh_ref.setData({ id: this.params.id });
  55. this.$refs.stxf_ref.setData({ id: this.params.id });
  56. this.$refs.wpjg_ref.setData(this.params);
  57. },
  58. dateChange(date) {
  59. this.params.beginTime = date[0]
  60. this.params.endTime = date[1]
  61. this.setDatas()
  62. },
  63. async hysyq(address) {
  64. // 选中xzqh查询
  65. let obj = {
  66. beginTime: store.state.cockpit_date[0],
  67. endTime: store.state.cockpit_date[1],
  68. jscType: 'jsc_hysyq_ztsh',
  69. id: address
  70. };
  71. let data = await cockpitInfo(obj);
  72. let obg_text = {
  73. xzqhdm_number: data.data[0].xzqhdm_number,
  74. zhmj: data.data[0].zhmj == undefined ? 0 : data.data[0].zhmj,
  75. }
  76. obg_text.zhmj == null ? 0 : obg_text.zhmj;
  77. store.setCockpitHysyText(obg_text);
  78. // 图表数据
  79. let obj_echart = {
  80. beginTime: store.state.cockpit_date[0],
  81. endTime: store.state.cockpit_date[1],
  82. jscType: 'jsc_hysyq_yelx',
  83. id: address
  84. };
  85. let data_echart = await cockpitInfo(obj_echart);
  86. let obg_echart = {
  87. x: data_echart.data.map(item => item.yhlx_name),
  88. bar: data_echart.data.map(item => item.zhmj)
  89. }
  90. console.log(obg_echart.x.length == 0, "obg_echart.x.length");
  91. obg_echart.x.length == 0 ? obg_echart.x = ['渔业基础设施用海', '开放式养殖用海', '旅游基础设施用海', '浴场用海',
  92. '游乐场用海'] : obg_echart.x = obg_echart.x;
  93. obg_echart.bar.length == 0 ? obg_echart.bar = [0, 0, 0, 0, 0,] : obg_echart.bar = obg_echart.bar;
  94. store.setCockpitHysyEchart(obg_echart);
  95. this.$refs.hysy_ref["getRenKou"]();
  96. // getRenKou();
  97. console.log(address, "address");
  98. },
  99. hysyq_xzqh() {
  100. const that = this;
  101. that.$refs.hysy_ref["label_data"]();
  102. that.$refs.hysy_ref["echart_data"]();
  103. },
  104. async gkzb_xzqh(address) {
  105. let obj = {
  106. // beginTime: store.state.cockpit_date[0],
  107. // endTime: store.state.cockpit_date[1],
  108. jscType: 'jsc_gkzb_ztgu_stbh',
  109. id: address
  110. };
  111. let data = await cockpitInfo(obj);
  112. let obj_yjjbntmj = {
  113. jscType: 'jsc_gdbh_ztgh_nt',
  114. id: address
  115. };
  116. let obj_yjjbntmj_data = await cockpitInfo(obj_yjjbntmj);
  117. // 永久基本农田保护面积
  118. // that.yjjbntmj = obj_yjjbntmj_data.data[0].yjjbntmj;
  119. let obj_kfbjmj = {
  120. jscType: 'jsc_gkzb_ztgh_kfbj',
  121. id: address
  122. };
  123. let obj_kfbjmj_data = await cockpitInfo(obj_kfbjmj);
  124. // // 城市开发边界
  125. // that.kfbjmj = obj_kfbjmj_data.data[0].kfbjmj;
  126. // // 覆盖城镇开发边界
  127. // that.bfb = obj_kfbjmj_data.data[0].bfb * 100;
  128. store.setCockpitGkzb({
  129. mj: data.data[0].mj,// 生态保护红线面积
  130. ly_mj: data.data[0].ly_mj,// 路域生态保护红线
  131. hy_mj: data.data[0].hy_mj,//近海岸面积
  132. yjjbntmj: obj_yjjbntmj_data.data[0].yjjbntmj,// 永久基本农田保护面积
  133. kfbjmj: obj_kfbjmj_data.data[0].kfbjmj,// 城市开发边界
  134. bfb: obj_kfbjmj_data.data[0].bfb * 100,// 覆盖城镇开发边界
  135. });
  136. console.log(store.state.cockpit_gkzb, "sadas");
  137. },
  138. async gkzb() {
  139. const that = this;
  140. that.$refs.gkzb_ref["initData"]();
  141. },
  142. async pick_xzqh() {
  143. const that = this;
  144. const handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
  145. handler.setInputAction(async event => {
  146. let pickObj = viewer.scene.pick(event.position);
  147. var position = viewer.scene.pickPosition(event.position);
  148. if (!position)//点击到地球之外
  149. return false;
  150. var cartographic = Cesium.Cartographic.fromCartesian(position);
  151. let longitude = Cesium.Math.toDegrees(cartographic.longitude);
  152. let latitude = Cesium.Math.toDegrees(cartographic.latitude);
  153. let height = cartographic.height;
  154. let heading = viewer.scene.camera.heading;
  155. let pitch = viewer.scene.camera.pitch;
  156. // that.addSceneFun()
  157. // console.log(longitude, latitude, height);
  158. // if (!pickObj)//未获取实体
  159. // return false;
  160. if (!position) {
  161. position = Cesium.Cartesian3.fromDegrees(0, 0, 0);
  162. }
  163. if (Cesium.defined(pickObj)) {
  164. if (pickObj.id && pickObj.id instanceof Cesium.Entity) {//点击entity
  165. if (pickObj.id.properties.hasProperty('name')) {
  166. const name = pickObj.id.properties.name.getValue();
  167. const address = pickObj.id.properties.adcode.getValue();
  168. const center = pickObj.id.properties.centroid.getValue();
  169. store.state.regional_information={
  170. id:address,
  171. name:name,
  172. }
  173. // 选中状态
  174. pickObj.id.polygon._material.color = Cesium.Color.fromCssColorString(that.xzqh_color_click);
  175. pickObj.id.polygon.extrudedHeight = 850;
  176. // 恢复其他状态
  177. viewer.entities.values.forEach((res) => {
  178. if (res.properties.name._value != name) {
  179. // console.log(res.properties.name._value, "其他的");
  180. // console.log(res);
  181. res.polygon._material.color = Cesium.Color.fromCssColorString(that.xzqh_color)
  182. res.polygon.extrudedHeight = 450;
  183. }
  184. })
  185. that.params.id = address
  186. that.setDatas()
  187. // 驾驶舱海域使用权
  188. that.hysyq(address);
  189. // 驾驶舱土地收储
  190. that.tdsc_xzqh(address);
  191. that.gkzb_xzqh(address);
  192. } else {
  193. }
  194. }
  195. } else {
  196. // 暂时点击周围数据显示三亚市
  197. // 清除所有xzqh状态
  198. viewer.entities.values.forEach((res) => {
  199. // console.log(res.properties.name._value, "其他的");
  200. // console.log(res);
  201. res.polygon._material.color = Cesium.Color.fromCssColorString(that.xzqh_color)
  202. res.polygon.extrudedHeight = 450;
  203. })
  204. // 海域使用
  205. that.hysyq_xzqh();
  206. // 土地收储
  207. that.tdsc();
  208. // 管控指标
  209. that.gkzb();
  210. }
  211. }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
  212. },
  213. tdsc() {
  214. const that = this;
  215. that.store.setCockpitTdsc(true);
  216. },
  217. tdsc_xzqh() {
  218. const that = this;
  219. that.store.setCockpitTdsc(false);
  220. },
  221. init_xzqh() {
  222. const that = this;
  223. xzqh.features.forEach((res) => {
  224. const twoDArray = res.geometry.coordinates[0][0];
  225. const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
  226. console.log();
  227. viewer.entities.add({
  228. position: Cesium.Cartesian3.fromDegrees(res.properties.centroid[0], res.properties.centroid[1], 500),
  229. text: res.properties.name,
  230. label: {
  231. scale: 1.5,
  232. font: "bolder 16px sans-serif",
  233. style: Cesium.LabelStyle.FILL_AND_OUTLINE,
  234. text: res.properties.name,//图标名称
  235. fillColor: Cesium.Color.fromCssColorString("#ffffff"),
  236. pixelOffset: new Cesium.Cartesian2(5, -15),
  237. zIndex: 3,
  238. },
  239. billboard: {
  240. // 图像地址,URI或Canvas的属性
  241. image: "./static/images/overview/htq-f.png",
  242. height: 60,
  243. // 宽度(以像素为单位)
  244. width: 150,
  245. // 相对于坐标的垂直位置
  246. // verticalOrigin: Cesium.VerticalOrigin.CENTER,
  247. // // 相对于坐标的水平位置
  248. // horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
  249. scale: 1.0,
  250. zIndex: 2,
  251. show: true
  252. },
  253. properties: {
  254. 'type': "cockpit",
  255. 'name': res.properties.name,
  256. 'centroid': res.properties.centroid,
  257. 'adcode': res.properties.adcode,
  258. },
  259. polygon: {
  260. zIndex: 1,
  261. hierarchy: {
  262. positions: Cesium.Cartesian3.fromDegreesArray(oneDArray),
  263. },
  264. // outline: false,
  265. material: Cesium.Color.fromCssColorString(that.xzqh_color),
  266. height: 100,
  267. extrudedHeight: 450,
  268. outline: true,
  269. // outlineColor : Cesium.Color.BLACK
  270. outlineColor: Cesium.Color.fromCssColorString('#55A1E3'),
  271. // 设置远近裁条件
  272. distanceDisplayCondition: new Cesium.DistanceDisplayCondition(20000, 9999999999.0),
  273. }
  274. });
  275. })
  276. },
  277. addSceneFun() {
  278. var pitch = viewer.camera.pitch;
  279. //获取当前视角的heading
  280. var heading = viewer.camera.heading;
  281. //获取当前视角的postion(位置)
  282. var position = viewer.camera.position;
  283. var x = position.x;
  284. var y = position.y;
  285. var z = position.z;
  286. var testPitch = pitch;
  287. var testHeading = heading;
  288. // console.log("获取当前视角x,y,z", position.x, position.y, position.z, "pitch", pitch, "heading", heading);
  289. var obj = {
  290. "x": x,
  291. "y": y,
  292. "z": z,
  293. "pitch": pitch,
  294. "heading": heading,
  295. }
  296. console.log(obj, "asd");
  297. }
  298. },
  299. beforeCreate() { }, //生命周期 - 创建之前
  300. created() { }, //生命周期 - 创建完成(可以访问当前this实例)
  301. beforeMount() { }, //生命周期 - 挂载之前
  302. async mounted() {
  303. // let obj = { beginTime: '20230612', endTime: '20230817', jscType: 'jsc_wpjc_yelx', id: '46' };
  304. // let data = await cockpitInfo(obj);
  305. // let obj1 = { beginTime: '20230612', endTime: '20230817', jscType: 'jsc_wpjc_ztsh', id: '46' }
  306. // let data1 = await cockpitInfo(obj1);
  307. // console.log(data, "asda");
  308. // console.log(data1, "asda");
  309. // 三亚行政区划加载
  310. this.$nextTick((res) => {
  311. this.pick_xzqh();
  312. this.init_xzqh()
  313. });
  314. }, //生命周期 - 挂在完成
  315. beforeUpdate() { }, //生命周期 - 更新之前
  316. updated() { }, //生命周期 - 更新之后
  317. beforeDestroy() { }, //生命周期 - 销毁之前
  318. destroy() { },//生命周期 - 销毁完成
  319. activated() { }, //若组件实例是 <KeepAlive> 缓存树的一部分,当组件被插入到 DOM 中时调用。
  320. deactivated() { } //若组件实例是 <KeepAlive> 缓存树的一部分,当组件从 DOM 中被移除时调用。
  321. };
  322. </script>
  323. <style scoped></style>