CockpitVector.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. <template>
  2. <div class="CockpitVectorBox">
  3. <div class="cockpit_vector">
  4. <el-table
  5. :header-cell-style="{
  6. background: 'rgba(10, 25, 38, 0.6)',
  7. color: '#66b1ff',
  8. fontSize: '14px',
  9. fontFamily: 'Microsoft YaHei',
  10. fontWeight: '400',
  11. }"
  12. :data="
  13. store.state.vectorData.filter(
  14. (item) =>
  15. item.name !== 'id' &&
  16. item.name !== 'geom' &&
  17. item.name !== 'type' &&
  18. item.name !== 'create_time' &&
  19. item.name !== 'val1' &&
  20. item.name !== 'val2'
  21. )
  22. "
  23. style="width: 100%"
  24. >
  25. <el-table-column
  26. show-overflow-tooltip="true"
  27. prop="name"
  28. label="属性"
  29. width="90"
  30. >
  31. </el-table-column>
  32. <el-table-column
  33. show-overflow-tooltip="true"
  34. prop="value"
  35. label="属性值"
  36. >
  37. </el-table-column>
  38. </el-table>
  39. <div id="seaTransferCharts" ref="echartsRef"></div>
  40. </div>
  41. </div>
  42. </template>
  43. <script>
  44. //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  45. import { QueryList } from "@/api/cockpitNew";
  46. import * as wellknown from "wellknown";
  47. import * as turf from "@turf/turf";
  48. import * as echarts from "echarts";
  49. import { name } from "file-loader";
  50. let pick_entity = null;
  51. export default {
  52. components: {},
  53. data() {
  54. return {
  55. restaurants: [],
  56. state: "",
  57. timeout: null,
  58. pick_entity: null,
  59. dataid: 0,
  60. tempData: [],
  61. };
  62. },
  63. //监听属性 类似于data概念
  64. computed: {
  65. vectordataid() {
  66. return store.state.vectordataid;
  67. },
  68. },
  69. //监控data中的数据变化
  70. watch: {
  71. vectordataid: {
  72. immediate: true,
  73. handler(newValue) {
  74. this.dataid = newValue;
  75. this.$nextTick(()=>{
  76. this.initChart();
  77. })
  78. },
  79. },
  80. },
  81. //方法集合
  82. methods: {
  83. build_data(geojson) {
  84. geojson.coordinates.forEach((res) => {
  85. const twoDArray = res[0];
  86. const oneDArray = twoDArray.reduce(
  87. (accumulator, currentValue) => accumulator.concat(currentValue),
  88. []
  89. );
  90. pick_entity.entities.add({
  91. polygon: {
  92. // 获取指定属性(positions,holes(图形内需要挖空的区域))
  93. hierarchy: {
  94. positions: Cesium.Cartesian3.fromDegreesArrayHeights(oneDArray),
  95. },
  96. // 边框
  97. outline: true,
  98. // 边框颜色
  99. outlineColor: Cesium.Color.RED,
  100. // 边框尺寸
  101. outlineWidth: 2,
  102. // 填充的颜色,withAlpha透明度
  103. material: Cesium.Color.GREEN.withAlpha(0),
  104. // 是否被提供的材质填充
  105. fill: true,
  106. // 恒定高度
  107. height: 1.1,
  108. // 显示在距相机的距离处的属性,多少区间内是可以显示的
  109. // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(1000, 10000000),
  110. // 是否显示
  111. show: true,
  112. // 顺序,仅当`clampToGround`为true并且支持地形上的折线时才有效。
  113. zIndex: 10,
  114. },
  115. });
  116. // 注意:polygon首尾坐标要一致
  117. var polygon = turf.polygon([twoDArray]);
  118. var centroid = turf.centroid(polygon).geometry.coordinates;
  119. viewer.camera.flyTo({
  120. duration: 1,
  121. destination: Cesium.Cartesian3.fromDegrees(
  122. centroid[0],
  123. centroid[1],
  124. 3000
  125. ),
  126. // destination: {
  127. // x: -6283267.004204832,
  128. // y: 28123682.896774407,
  129. // z: 23709669.98539126
  130. // },
  131. orientation: {
  132. heading: 6.149339593573709,
  133. pitch: -1.539825618847483,
  134. roll: 0,
  135. },
  136. });
  137. });
  138. },
  139. async initChart(params) {
  140. const chartDom = this.$refs.echartsRef;
  141. let myChart = echarts.init(chartDom);
  142. let obj = {
  143. jscType: "jsc_hysyq_yhlx_zbmx_cx",
  144. beginTime: params ? params.beginTime : store.state.cockpit_date[0],
  145. endTime: params ? params.endTime : store.state.cockpit_date[1],
  146. id: params ? params.id : "4602",
  147. val0: this.dataid == 0 ? store.state.vectordataid : this.dataid,
  148. };
  149. let res = await QueryList(obj);
  150. const data = [];
  151. var total = 0;
  152. res.data.forEach((item, index) => {
  153. data.push({
  154. name: item["用海类型"],
  155. value: item["宗海面积(公顷)"],
  156. });
  157. total += Number(item["宗海面积(公顷)"]);
  158. });
  159. const color = [
  160. "#3591FF",
  161. "#2040B8",
  162. "#3EF6D1",
  163. "#0082CE",
  164. "#42DEED",
  165. "#C1CC77",
  166. "#00AB51",
  167. "#31B571",
  168. "#3351E3",
  169. ];
  170. const legendData = data.map((item, index) => {
  171. const tag = index % 6;
  172. return {
  173. name: item.name,
  174. itemStyle: {
  175. color: color[tag] || "",
  176. },
  177. textStyle: {
  178. rich: {
  179. title: {
  180. color: "#CDCEDA",
  181. fontSize: 14,
  182. width: 70,
  183. fontWeight: "bold",
  184. },
  185. p: {
  186. fontSize: 14,
  187. width: 55,
  188. color: "#02D0C5",
  189. shadowColor: "#000",
  190. inactiveColor: "#000",
  191. fontWeight: "bold",
  192. },
  193. },
  194. },
  195. };
  196. });
  197. let option = {
  198. //你的代码
  199. backgroundColor: "transparent",
  200. legend: {
  201. // type: 'scroll',
  202. show: true,
  203. // orient: "vertical",
  204. bottom: 0,
  205. // top: "center",
  206. itemGap: 5,
  207. borderRadius: 5,
  208. itemWidth: 10,
  209. icon: "circle",
  210. // itemHeight: 10,
  211. data: legendData,
  212. formatter: function (name) {
  213. const name1 = name.length > 5 ? `${name.substring(0, 4)}...` : name;
  214. const value = data.filter((item) => item.name === name)[0].value;
  215. // const proportion = data.filter((item) => item.name === name)[0].proportion;
  216. return `{title|${name1}} {p|${value}公顷}`;
  217. },
  218. },
  219. tooltip: {
  220. trigger: "item",
  221. backgroundColor: "rgba(13,5,30,.6)",
  222. borderWidth: 1,
  223. borderColor: "#32A1FF",
  224. padding: 5,
  225. textStyle: {
  226. color: "#fff",
  227. },
  228. formatter: (data) => {
  229. const { name = "", value = "" } = data.data || {};
  230. const name1 =
  231. name.length > 10
  232. ? `${name.substring(0, 10)} <br /> ${name.substring(
  233. 10,
  234. name.length
  235. )}`
  236. : name;
  237. return `${name1} ${value}公顷`;
  238. },
  239. },
  240. title: {
  241. // text: `{a|${total.toFixed(2)}}`+"{b|公顷}",
  242. text: `{a|${total.toFixed(2)}}`,
  243. textStyle: {
  244. rich: {
  245. a: {
  246. color: "#fff",
  247. fontSize: 18,
  248. align: "35%",
  249. },
  250. b: {
  251. fontSize: 14,
  252. color: "#fff",
  253. // fontWeight: "bold",
  254. align: "35%",
  255. },
  256. },
  257. },
  258. x: "35%",
  259. y: "35%",
  260. },
  261. series: [
  262. {
  263. name: "",
  264. type: "pie",
  265. radius: ["40%", "60%"],
  266. center: ["45%", "40%"],
  267. startAngle: 90,
  268. itemStyle: {
  269. shadowBlur: 10,
  270. shadowColor: "rgba(0, 103, 255, 0.2)",
  271. shadowOffsetX: -5,
  272. shadowOffsetY: 5,
  273. color: function (params) {
  274. return color[params.dataIndex % 6];
  275. },
  276. },
  277. label: {
  278. show: false,
  279. },
  280. labelLine: {},
  281. data: data,
  282. },
  283. ],
  284. };
  285. myChart.setOption(option);
  286. },
  287. },
  288. beforeCreate() {}, //生命周期 - 创建之前
  289. created() {}, //生命周期 - 创建完成(可以访问当前this实例)
  290. beforeMount() {}, //生命周期 - 挂载之前
  291. mounted() {
  292. const that = this;
  293. this.$nextTick(() => {
  294. pick_entity = new Cesium.CustomDataSource("pick_entity");
  295. viewer.dataSources.add(pick_entity);
  296. }); //生命周期 - 挂在完成
  297. }, //生命周期 - 挂在完成
  298. beforeUpdate() {}, //生命周期 - 更新之前
  299. updated() {}, //生命周期 - 更新之后
  300. beforeDestroy() {
  301. }, //生命周期 - 销毁之前
  302. destroy() {}, //生命周期 - 销毁完成
  303. activated() {}, //若组件实例是 <KeepAlive> 缓存树的一部分,当组件被插入到 DOM 中时调用。
  304. deactivated() {}, //若组件实例是 <KeepAlive> 缓存树的一部分,当组件从 DOM 中被移除时调用。
  305. };
  306. </script>
  307. <style scoped lang="scss">
  308. .CockpitVectorBox {
  309. // color: #198ec0;
  310. }
  311. .list_vector {
  312. background-image: url("/static/images/ghzc/内容框.png");
  313. width: 20rem;
  314. border-top: 1px solid #ccc;
  315. font-size: 14px;
  316. padding: 1rem;
  317. // border-bottom:1px solid #CCC ;
  318. }
  319. .list_vector:last-child {
  320. border-bottom: 1px solid #ccc;
  321. }
  322. .cockpit_vector {
  323. position: absolute;
  324. top: 6rem;
  325. width: 20rem;
  326. height: 37rem;
  327. overflow: auto;
  328. overflow-x: hidden;
  329. // z-index: -1;
  330. }
  331. /deep/.el-input__inner:focus {
  332. border: 1px solid #1fb1ef;
  333. }
  334. /deep/.el-input__inner {
  335. border: 1px solid #1fb1ef;
  336. background: rgba(0, 80, 111, 0.8);
  337. border-radius: 18px;
  338. height: 30px;
  339. color: white;
  340. line-height: 30px;
  341. // background: #ffffff3b;
  342. }
  343. /deep/.el-input__icon {
  344. line-height: 30px;
  345. border-radius: 0 18px 18px 0;
  346. cursor: pointer;
  347. }
  348. /deep/.el-input__suffix {
  349. background: #1fb1ef;
  350. right: 1px;
  351. padding: 0 5px;
  352. border-radius: 0 18px 18px 0;
  353. opacity: 0.8;
  354. color: #fff;
  355. }
  356. /deep/ .el-autocomplete-suggestion {
  357. margin-top: 8px;
  358. border-radius: 6px;
  359. border: 1px solid #198ec0;
  360. background: rgba(0, 80, 111, 0.6);
  361. color: rgba(25, 142, 192, 1);
  362. .popper__arrow {
  363. top: -8px;
  364. border-bottom-color: rgba(31, 177, 239, 1);
  365. }
  366. .popper__arrow::after {
  367. border-bottom-color: rgba(0, 80, 111, 0.9);
  368. }
  369. .el-autocomplete-suggestion__wrap {
  370. padding: 2px;
  371. }
  372. }
  373. /deep/ .el-autocomplete-suggestion li {
  374. color: #ffffff;
  375. }
  376. /deep/ .el-autocomplete-suggestion li:hover {
  377. background-color: rgba(8, 162, 223, 0.8);
  378. border-radius: 6px;
  379. }
  380. .list_vector_multi {
  381. background-image: url("/static/images/ghzc/内容框.png");
  382. width: 20rem;
  383. border-top: 1px solid #ccc;
  384. font-size: 14px;
  385. padding: 0.5rem 0rem 0.5rem 0rem;
  386. border-left: 1px solid #ccc;
  387. border-right: 1px solid #ccc;
  388. }
  389. .list_vector_multi:last-child {
  390. border-bottom: 1px solid #ccc;
  391. }
  392. /deep/ .el-table tr {
  393. background: rgba(10, 25, 38, 0.5) !important;
  394. }
  395. /deep/ .el-table td.el-table__cell,
  396. .el-table th.el-table__cell.is-leaf {
  397. background: rgba(10, 25, 38, 0.5) !important;
  398. border-bottom: 0px solid #ebeef5;
  399. }
  400. .el-table {
  401. color: #fff;
  402. background: rgba(10, 25, 38, 0.5) !important;
  403. }
  404. /deep/ .el-table__fixed-right::before,
  405. .el-table__fixed::before {
  406. background: rgba(10, 25, 38, 0.9) !important;
  407. }
  408. /deep/ .el-table__fixed-right-patch {
  409. background: rgba(10, 25, 38, 0.9) !important;
  410. }
  411. /deep/ .el-table--border::after,
  412. .el-table--group::after,
  413. .el-table::before {
  414. background: rgba(10, 25, 38, 0) !important;
  415. }
  416. #seaTransferCharts {
  417. width: 100%;
  418. height: 13rem;
  419. background-color: rgba(10, 25, 38, 0.9) !important;
  420. }
  421. </style>