BoxCommonVector.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. <template>
  2. <div class="BoxCommonVector">
  3. <div class="innerContainerVector leftPaneVector">
  4. <h2 class="PangetitleVector">
  5. <span class="pange_textVector">{{ title }}</span>
  6. </h2>
  7. <i class="el-icon-close" @click="close"></i>
  8. <el-input clearable v-model="state" @input="change_witch" class="search" placeholder="请输入内容"></el-input>
  9. <el-table :data="active_dableData" style="width: 100%" height="490" :header-cell-style="{
  10. background: 'rgba(10, 25, 38, 0.6)',
  11. color: '#66b1ff',
  12. fontSize: '14px',
  13. fontFamily: 'Microsoft YaHei',
  14. fontWeight: '400',
  15. }">
  16. <el-table-column show-overflow-tooltip="true" v-for="(index, item) in store.state.cockpit_vector.columns"
  17. :key="index" width="120" :prop="store.state.cockpit_vector.columns[item]"
  18. :label="store.state.cockpit_vector.columns[item]">
  19. </el-table-column>
  20. <el-table-column fixed="right" label="操作" width="90">
  21. <template slot-scope="scope">
  22. <el-button @click="info(scope.row)" type="text" size="small">详情</el-button>
  23. <el-button @click="go(scope.row)" type="text" size="small">定位</el-button>
  24. </template>
  25. </el-table-column>
  26. </el-table>
  27. </div>
  28. </div>
  29. </template>
  30. <script>
  31. import { QueryList } from '@/api/cockpitNew'
  32. import * as tdsy from "@/views/cockpit/js/tdsy";
  33. import * as wellknown from "wellknown";
  34. import * as turf from "@turf/turf";
  35. let pick_entity = null;
  36. export default {
  37. data() {
  38. return {
  39. state: '',
  40. timeout: null,
  41. title: "",
  42. active_dableData: null,
  43. tableData: null,
  44. };
  45. },
  46. methods: {
  47. draw_vector_tdgy_gy_jd(data) {
  48. data.forEach((res) => {
  49. res.type = '国有建设用地完成项目'
  50. if (res.geom) {
  51. res.geom.coordinates.forEach((res_coordinates) => {
  52. let arrayt = [];
  53. if (res_coordinates.length == 1) {
  54. arrayt = res_coordinates[0]
  55. } else {
  56. arrayt = res_coordinates
  57. }
  58. const twoDArray = arrayt;
  59. const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
  60. tdsy.add(res, oneDArray);
  61. })
  62. }
  63. })
  64. },
  65. close() {
  66. store.setViewerFlagb(true);
  67. tdsy.remove();
  68. store.state.vectorData = [];
  69. },
  70. info() { },
  71. switch_show(flag) {
  72. pick_entity.entities.values.forEach((res) => {
  73. res.show = flag;
  74. })
  75. },
  76. build_data(geojson) {
  77. geojson.coordinates.forEach((res) => {
  78. const twoDArray = res[0];
  79. const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
  80. console.log('oneDArray: ', oneDArray);
  81. pick_entity.entities.add({
  82. polygon: {
  83. // 获取指定属性(positions,holes(图形内需要挖空的区域))
  84. hierarchy: {
  85. positions: Cesium.Cartesian3.fromDegreesArrayHeights(oneDArray),
  86. },
  87. // 边框
  88. outline: true,
  89. // 边框颜色
  90. outlineColor: Cesium.Color.RED,
  91. // 边框尺寸
  92. outlineWidth: 10,
  93. // 填充的颜色,withAlpha透明度
  94. material: Cesium.Color.GREEN.withAlpha(0),
  95. // 是否被提供的材质填充
  96. fill: true,
  97. // 恒定高度
  98. height: 1.1,
  99. // 显示在距相机的距离处的属性,多少区间内是可以显示的
  100. // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(1000, 10000000),
  101. // 是否显示
  102. show: true,
  103. // 顺序,仅当`clampToGround`为true并且支持地形上的折线时才有效。
  104. zIndex: 10
  105. }
  106. });
  107. // 注意:polygon首尾坐标要一致
  108. var polygon = turf.polygon([twoDArray]);
  109. var centroid = turf.centroid(polygon).geometry.coordinates;
  110. viewer.camera.flyTo({
  111. duration: 1,
  112. destination: Cesium.Cartesian3.fromDegrees(centroid[0], centroid[1], 3000),
  113. // destination: {
  114. // x: -6283267.004204832,
  115. // y: 28123682.896774407,
  116. // z: 23709669.98539126
  117. // },
  118. orientation: {
  119. heading: 6.149339593573709,
  120. pitch: -1.539825618847483,
  121. roll: 0
  122. },
  123. });
  124. })
  125. },
  126. go(item) {
  127. let arr = [];
  128. const that = this;
  129. pick_entity = new Cesium.CustomDataSource("pick_entity");
  130. viewer.dataSources.add(pick_entity);
  131. Object.keys(item).forEach(key => {
  132. arr.push({
  133. "name": key,
  134. "value": item[key],
  135. });
  136. if (key == 'geom') {
  137. console.log();
  138. let geojson = item[key];
  139. if (geojson.type == 'MultiPolygon') {
  140. this.build_data(geojson);
  141. } else {
  142. const twoDArray = geojson.coordinates[0];
  143. const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
  144. pick_entity.entities.add({
  145. polygon: {
  146. // 获取指定属性(positions,holes(图形内需要挖空的区域))
  147. hierarchy: {
  148. positions: Cesium.Cartesian3.fromDegreesArrayHeights(oneDArray),
  149. },
  150. // 边框
  151. outline: true,
  152. // 边框颜色
  153. outlineColor: Cesium.Color.RED,
  154. // 边框尺寸
  155. outlineWidth: 10,
  156. // 填充的颜色,withAlpha透明度
  157. material: Cesium.Color.GREEN.withAlpha(0),
  158. // 是否被提供的材质填充
  159. fill: true,
  160. // 恒定高度
  161. height: 1.1,
  162. // 显示在距相机的距离处的属性,多少区间内是可以显示的
  163. // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(1000, 10000000),
  164. // 是否显示
  165. show: true,
  166. // 顺序,仅当`clampToGround`为true并且支持地形上的折线时才有效。
  167. zIndex: 10
  168. }
  169. });
  170. // 注意:polygon首尾坐标要一致
  171. var polygon = turf.polygon([geojson.coordinates[0]]);
  172. var centroid = turf.centroid(polygon).geometry.coordinates;
  173. viewer.camera.flyTo({
  174. duration: 1,
  175. destination: Cesium.Cartesian3.fromDegrees(centroid[0], centroid[1], 3000),
  176. // destination: {
  177. // x: -6283267.004204832,
  178. // y: 28123682.896774407,
  179. // z: 23709669.98539126
  180. // },
  181. orientation: {
  182. heading: 6.149339593573709,
  183. pitch: -1.539825618847483,
  184. roll: 0
  185. },
  186. });
  187. }
  188. let flag = true;
  189. let time = setInterval(() => {
  190. flag = !flag
  191. that.switch_show(flag);
  192. }, 500);
  193. setTimeout(() => {
  194. clearInterval(time);
  195. console.log("s");
  196. console.log(pick_entity);
  197. viewer.dataSources.remove(pick_entity);
  198. }, 6000)
  199. }
  200. });
  201. store.state.vectorData = arr
  202. },
  203. change_witch() {
  204. this.get_search(this.state);
  205. },
  206. get_search(word) {
  207. if (word.length == 0) {
  208. this.active_dableData = this.tableData;
  209. } else {
  210. let gy_ju = {
  211. jscType: 'jsc_tdgy_gy_zbmx_cx',
  212. id: '4602',
  213. val0: word,
  214. }
  215. // let bj_sl = {
  216. // beginTime: store.state.cockpit_date[0],
  217. // endTime: store.state.cockpit_date[1],
  218. // jscType: 'jsc_bjxm_csbj_zbmx_cx',
  219. // id: '4602',
  220. // val0: word,
  221. // }
  222. Promise.all([QueryList(gy_ju)]).then((values) => {
  223. this.active_dableData = values[0].data
  224. }).catch((error) => {
  225. console.error(error); // 如果有任何一个 promise 失败,则捕获这个错误
  226. });
  227. }
  228. },
  229. },
  230. computed: {
  231. cockpit_vector() {
  232. return store.state.cockpit_vector;
  233. },
  234. },
  235. watch: {
  236. cockpit_vector(newVal, oldVal) {
  237. console.log('newVal: ', newVal);
  238. this.title = newVal.title
  239. this.active_dableData = newVal.tableData
  240. this.tableData = newVal.tableData
  241. },
  242. active_dableData(newVal, oldVal) {
  243. this.draw_vector_tdgy_gy_jd(newVal);
  244. }
  245. },
  246. mounted() {
  247. const that = this;
  248. this.$nextTick(() => {
  249. pick_entity = new Cesium.CustomDataSource("pick_entity");
  250. viewer.dataSources.add(pick_entity);
  251. });
  252. }
  253. };
  254. </script>
  255. <style lang="scss" scoped>
  256. .BoxCommonVector {
  257. width: 100%;
  258. height: 100%;
  259. position: absolute;
  260. left: -1rem;
  261. top: 0rem;
  262. }
  263. .innerContainerVector {
  264. width: 350px;
  265. height: 600px; //calc(100% - 20px);
  266. position: absolute;
  267. top: 28px;
  268. z-index: 99;
  269. background-image: url("/static/images/ghzc/内容框.png");
  270. background-size: 100% 100%;
  271. border-top-right-radius: 15px;
  272. .search {
  273. // margin: 2rem;
  274. }
  275. /deep/ .el-input {
  276. display: inline-block;
  277. }
  278. /deep/ .el-input__inner {
  279. // background: transparent !important;
  280. color: white !important;
  281. background: rgba(10, 25, 38, 0.5);
  282. border-color: #5ecef09a;
  283. // color: #64daff;
  284. // font-size: 12px;
  285. }
  286. }
  287. .leftPaneVector {
  288. left: 20px;
  289. .el-icon-close {
  290. width: 22px;
  291. height: 22px;
  292. color: #fff !important;
  293. background-color: #335f87;
  294. line-height: 23px;
  295. padding: 0 5px;
  296. border-radius: 4px;
  297. top: -1.9rem !important;
  298. position: relative;
  299. right: -19.5rem;
  300. }
  301. .PangetitleVector {
  302. box-sizing: border-box;
  303. width: 100%;
  304. height: 35px;
  305. background: url("/static/images/overview/titlebox.gif") no-repeat !important;
  306. background-size: 100% 100% !important;
  307. line-height: 35px;
  308. font-size: 14px;
  309. padding-left: 15px;
  310. display: flex;
  311. position: relative;
  312. overflow: hidden;
  313. }
  314. .pange_textVector {
  315. font-size: 14px !important;
  316. font-family: 'HarmonyOS Sans, HarmonyOS Sans';
  317. font-weight: bold;
  318. font-size: 18px;
  319. color: #FFFFFF;
  320. margin-left: 30px;
  321. }
  322. }
  323. /deep/.el-input__inner:focus {
  324. border: 1px solid #1fb1ef;
  325. }
  326. /deep/.el-input__inner {
  327. border: 1px solid rgba(10, 25, 38, 0.5);
  328. background: rgba(10, 25, 38, 0.5);
  329. border-radius: 18px;
  330. height: 30px;
  331. color: white;
  332. line-height: 30px;
  333. // background: #ffffff3b;
  334. }
  335. /deep/.el-input__icon {
  336. line-height: 30px;
  337. border-radius: 0 18px 18px 0;
  338. cursor: pointer;
  339. }
  340. /deep/.el-input__suffix {
  341. background: #1fb1ef;
  342. right: 1px;
  343. padding: 0 5px;
  344. border-radius: 0 18px 18px 0;
  345. opacity: 0.8;
  346. color: #fff;
  347. }
  348. /deep/ .el-autocomplete-suggestion {
  349. margin-top: 8px;
  350. border-radius: 6px;
  351. border: 1px solid #198ec0;
  352. background: rgba(10, 25, 38, 0.9);
  353. color: rgba(25, 142, 192, 1);
  354. .popper__arrow {
  355. top: -8px;
  356. border-bottom-color: rgba(31, 177, 239, 1);
  357. }
  358. .popper__arrow::after {
  359. border-bottom-color: rgba(0, 80, 111, 0.9);
  360. }
  361. .el-autocomplete-suggestion__wrap {
  362. padding: 2px;
  363. }
  364. }
  365. /deep/ .el-autocomplete-suggestion li {
  366. color: #ffffff;
  367. }
  368. /deep/ .el-autocomplete-suggestion li:hover {
  369. background-color: rgba(8, 162, 223, 0.8);
  370. border-radius: 6px;
  371. }
  372. /deep/ .el-table tr {
  373. background: rgba(10, 25, 38, 0.5) !important;
  374. }
  375. /deep/ .el-table td.el-table__cell,
  376. .el-table th.el-table__cell.is-leaf {
  377. background: rgba(10, 25, 38, 0.5) !important;
  378. border-bottom: 0px solid #EBEEF5;
  379. }
  380. .el-table {
  381. color: #fff;
  382. background: rgba(10, 25, 38, 0.5) !important;
  383. }
  384. /deep/ .el-table__fixed-right::before,
  385. .el-table__fixed::before {
  386. background: rgba(10, 25, 38, 0.9) !important;
  387. }
  388. /deep/ .el-table__fixed-right-patch {
  389. background: rgba(10, 25, 38, 0.9) !important;
  390. }
  391. /deep/ .el-table--border::after,
  392. .el-table--group::after,
  393. .el-table::before {
  394. background: rgba(10, 25, 38, 0) !important;
  395. }
  396. </style>