CockpitVector.vue 11 KB

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